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

29 lines
700 B
TOML

# Lux contracts โ€” Foundry config.
#
# Single source of truth for the canonical Solidity helpers that the
# Lux EVM (geth/evm/coreth) exposes to L1 contract authors. These are
# thin wrappers around the native precompiles in luxfi/precompile.
[profile.default]
src = "src"
test = "test"
out = "out"
libs = ["lib"]
solc = "0.8.27"
optimizer = true
optimizer_runs = 200
via_ir = false
# evm_version pinned to cancun โ€” same baseline the Lux EVM advertises.
evm_version = "cancun"
# Forbid implicit address-literal-to-uint coercion that older OpenZeppelin
# style allows.
extra_output = ["storageLayout", "metadata"]
[fmt]
line_length = 120
tab_width = 4
bracket_spacing = true
int_types = "long"