0009. Audited classical cryptography libraries and EIP-712

Design document, published from the repository at docs/adr/0009-classical-cryptography-libraries.md.

  • Status: Accepted
  • Date: 2026-11-13
  • Amends: ADR-0007

Context

FEAT-03 (QuantLayer Identity) must verify wallet ownership (EIP-712, secp256k1 recovery, Keccak-256), verify Ed25519/ES256K signatures for proof of possession and authorization, derive identifiers with SHA-256, and generate unpredictable nonces. ADR-0007 deferred all cryptographic implementation.

Decision

  1. No hand-written primitives. Hashing, curve arithmetic and signature verification come from @noble/hashes and @noble/curves (v2): audited, dependency-free, constant-time-oriented, and the same code that underpins viem and ethers.
  2. They are used in exactly two packages:
    • @quantlayer-protocol/crypto-classical — implements the @quantlayer-protocol/crypto ports: SHA-256 / Keccak-256 HashFunctions, a verify-only Ed25519/ES256K SignatureVerifier, secp256k1 public-key recovery, and a CSPRNG RandomSource. It exposes no signing API.
    • @quantlayer-protocol/evm — EIP-55, CAIP-10 eip155 accounts, EIP-712 typed-data hashing and an EIP-712/EIP-1271 AccountOwnershipVerifier. It uses crypto-classical for primitives; its EIP-712 encoder is protocol encoding verified against the specification's own test vectors.
  3. Strict verification parameters: Ed25519 with RFC 8032 strict decoding (no ZIP-215 leniency); ECDSA with low-S enforced (EIP-2) everywhere; exact public-key and signature lengths.
  4. Post-quantum algorithms remain behind the SignatureVerifier port, to be provided by rust/quantlayer-pqc via WASM (ADR-0007 unchanged for PQC). Unknown algorithms fail closed with UNSUPPORTED_ALGORITHM.
  5. Layering: crypto-classical → {shared, core, crypto}; evm → {shared, core, crypto, crypto-classical, identity} (an adapter depends on the domain port it implements).

Consequences

  • Real signatures are verified in tests against published vectors (RFC 8032, FIPS 180, EIP-55, EIP-712).
  • Adding a classical algorithm means extending crypto-classical only.
  • Library upgrades are security-relevant changes and must be reviewed as such.