Files
zeekayandGitHub 728fc1bd79 wallet: PQAccount + ML-DSA-65 HD derivation + SLH-DSA-192 recovery (#2)
* wallet: PQAccount + ML-DSA-65 HD derivation + SLH-DSA-192 recovery

ML-DSA-65 native wallet accounts with 48-byte SHAKE256-384 AccountID
derived via cSHAKE-256 domain separation. KMAC/cSHAKE child seeds use
"LUX/WALLET/{IDENTITY,TX,SESSION,RECOVERY}/V1" customization strings.
HD path: m/44'/9000'/<chain>'/0'/<role>'/<account>', mirroring the F35
hardening landed in genesis/pkg/genesis/keys.go.

Recovery accounts use SLH-DSA-SHAKE-192s (FIPS 205, NIST Cat 3) for
stateless cold-key recovery on a separate hardened branch
m/44'/9000'/<chain>'/2'/<account>' so a leaked wallet branch cannot
derive recovery keys.

Keystore at rest: Argon2id (RFC 9106) → AES-256-GCM with AAD bound to
(scheme, role, chain, path). Private keys never persisted in plaintext.

WalletSchemeID/RecoverySchemeID declared locally (consensus/config has
not committed its WalletSchemeID byte yet); byte values match the raw
ML-DSA block (0x40..) so wire compatibility is preserved when the
consensus type lands.

AccountID KAT cross-checked against @noble/hashes/sha3-addons cshake256
(JS) — Go and TS implementations produce identical 48-byte AccountIDs
for the canonical test vector.

37 unit tests in wallet/account/, 7 in wallet/ (PQWallet facade).
Patch-bump.

* wallet/account: drop unused branchClassical constant

staticcheck U1000 catches it. The comment on branchPQ already
documents that branches 1' (secp256k1) and 2' (recovery) live in
sibling derivations, so the unused constant is dead documentation.

Patch-bump.

* sdk/wallet/account: use luxfi/crypto/pq/mldsa/mldsa65 wrapper

Switches PQAccount ML-DSA-65 key derivation, signing, and verification
from the upstream cloudflare/circl entry points to the luxfi/crypto
wrapper exposed at github.com/luxfi/crypto/pq/mldsa/mldsa65 (v1.18.4
adds the canonical NewKeyFromSeed/[]byte entry point we want).

  - NewKeyFromSeed accepts []byte (any length) and internally cSHAKEs
    to the 32-byte ξ FIPS 204 §5.1 consumes. The wallet already pre-
    domain-separates by role through cSHAKE before handing the seed
    off; the wrapper's per-parameter-set "LUX/FIPS204/MLDSA65/seed"
    customization compounds with the wallet role customization without
    overlap.
  - Sign returns ([]byte, error) directly — replaces the SignTo(...)
    out-parameter form.
  - go.mod: bump luxfi/crypto v1.18.3 → v1.18.4.

Tests rebound to the luxfi/crypto package; sizes (PublicKeySize,
PrivateKeySize, SignatureSize) are re-exported aliases so existing
KAT and roundtrip tests continue to verify byte-identical values.
All 37 wallet/account tests pass under GOWORK=off.

* sdk/wallet/account: gofmt — unstuck CI lint job

Pure gofmt -w pass on four files flagged by golangci-lint in the
previous PR run. Doc-comment list indentation only — no code changes,
all tests green.

  - wallet/account/cshake.go
  - wallet/account/keystore.go
  - wallet/account/scheme.go
  - wallet/account/sign_tx_test.go

* sdk/wallet/keychain: hybrid AND-verifies (closes F112)

Adds VerifyHybridSecp256k1MLDSA and VerifyHybridSecp256k1SLHDSA — the
AND-verifying hybrid signature verifiers that close red-team F112.

Previously the hybrid signature format produced by PQSigner.Sign
(length-prefixed classical || PQ concatenation) had no verifier in
this package, leaving every consumer to interpret it. The implicit
"either half verifies" OR semantics is as strong as the WEAKER of the
two halves (ECDSA in the production hybrids) — a forged hybrid
carrying a valid ECDSA half plus random "PQ" bytes would pass any OR
verifier.

The new verifiers require BOTH halves to verify under their respective
public keys. Failure on either half returns a typed sentinel
(ErrHybridSigClassicalFailed / ErrHybridSigPQFailed) without short-
circuiting on the classical refusal — both halves are checked before
the AND result is computed so timing-side channels do not leak which
half failed.

SplitHybridSignature is exported so callers can dispatch verification
through their own keying setup without re-implementing the wire-format
parsing.

Adds 9 regression tests:
  - happy-path AND accepts (MLDSA + SLHDSA)
  - tampered classical → ErrHybridSigClassicalFailed
  - tampered PQ → ErrHybridSigPQFailed
  - ECDSA-valid || random PQ bytes → ErrHybridSigPQFailed (the
    canonical F112 attack)
  - wrong message → either-half-fail
  - truncated blob → ErrHybridSigTruncated
  - wire-format round-trip

Closes red-team F112.
2026-05-29 22:10:41 -07:00
..