Files
zeekay cf34e276b0 initial: PQAuth library + IPQVerify interface + Foundry tests
Canonical Solidity helpers for the Lux EVM's native post-quantum
precompiles. One source of truth for L1 contract authors who need to
authenticate post-quantum signers.

PQAuth wraps:
  0x012201  ML-KEM-768           (FIPS 203, key encapsulation)
  0x012202  ML-DSA verify        (FIPS 204, signatures: 44/65/87)
  0x012203  SLH-DSA verify       (FIPS 205, hash-based)
  0x012204  Corona threshold   (lattice threshold verify)
  0x002221  X-Wing hybrid KEM    (X25519 + ML-KEM-768)

API:
  verifyMLDSA44/65/87(pubkey, msgDigest, sig) -> bool
  verifySLHDSA       (pubkey, msgDigest, sig) -> bool
  verifyPermit       (pubkey, msgDigest, sig)  reverts on invalid

The msgDigest is 32 bytes, precomputed off-chain as
TupleHash256(parts, 32, "LUX_PQ_PERMIT_V1") per NIST SP 800-185 §5.
We refuse to implement TupleHash256/cSHAKE256 in Solidity: the EVM
lacks the primitive and emulation costs ~200k gas with high risk of
subtle field-framing bugs. Reference Go implementation:
luxfi/consensus/protocol/auth/hash.go.

Gas comparison vs ETHDILITHIUM (LGPL-3.0, vendored ML-DSA in YUL):
  ETHDILITHIUM verify:      ~8,100,000 gas
  PQAuth.verifyMLDSA65:        100,320 gas (100k base + 320 for 32-byte digest)
  => ~80x cheaper. Do not vendor or re-implement ML-DSA in user code.

IPQVerify.verifyZAuthProof reverts: reserved for the F102/F103 tx-type
0x05 path (separate multi-week project, Option B in the strict-PQ
rollout plan).

Tests (10 passing under forge):
  test_VerifyMLDSA65_ValidSignature_ReturnsTrue
  test_VerifyMLDSA65_InvalidSignature_ReturnsFalse
  test_VerifyMLDSA65_WrongPubkeyLength_Reverts
  test_VerifyMLDSA65_WrongSignatureLength_Reverts
  test_VerifyPermit_ValidSignature_NoRevert
  test_VerifyPermit_InvalidSignature_Reverts
  test_VerifySLHDSA_ValidSignature_ReturnsTrue
  test_VerifySLHDSA_InvalidSignature_ReturnsFalse
  test_VerifyZAuthProof_Reverts
  test_CanonicalAddresses

Stack: Foundry, solc 0.8.27, evm_version=cancun.
2026-05-10 21:39:29 -07:00
..