Abstract
This ERC defines how a post quantum account proves a signature over off chain typed data. The typed data is hashed exactly as EIP-712 defines, the signer produces a post quantum signature of that hash, and a verifier checks it through the ERC-1271 isValidSignature interface by calling the verification precompile for the named scheme. The signature carries a scheme byte, so one verification path covers the module lattice and the hash based families and any scheme a later precompile adds.
Motivation
Off chain typed data signing under EIP-712 is how a wallet proves a user's intent to a contract without a transaction. Order books, permits, delegations, votes and session grants all rest on it, and they recover the signer with an elliptic curve recovery that a quantum computer breaks. The on chain path for a post quantum account is advancing, but the off chain path has none, so a post quantum account cannot sign a permit or an order that the rest of the ecosystem accepts.
ERC-1271 already lets a contract account answer whether a signature over a hash is valid. What is missing is a standard way for a post quantum account to answer that question, so that a dapp verifies a post quantum signature over EIP-712 typed data through the same interface it already uses for contract accounts, without knowing which post quantum scheme the account holds.
Specification
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 and RFC 8174.
Typed data hash
The hash signed is the 32 byte EIP-712 hash keccak256(0x1901 ++ domainSeparator ++ hashStruct(message)), computed exactly as EIP-712 defines. This ERC does not change the domain separator or the struct hashing.
Signature
The signature over the typed data hash is the byte string scheme ++ signature. The scheme is a scheme byte that names a post quantum signature scheme, and the signature is exactly the fixed signature size for that scheme. A verifier MUST reject a signature whose length is not one byte more than the fixed signature size for its scheme byte.
Verification
A post quantum account verifies a typed data hash through the ERC-1271 interface.
function isValidSignature(bytes32 hash, bytes calldata signature) external view returns (bytes4 magicValue);The account MUST verify signature over hash as follows.
- Read
schemeandpublicKeyfrom the account credential, the scheme byte and the post quantum public key the account verifies against. - Read
sigSchemeas the first byte andrawSignatureas the remaining bytes ofsignature. IfsigSchemeis not equal toscheme, or the length ofrawSignatureis not the fixed signature size forscheme, the account MUST treat the signature as invalid. - Call the precompile registered for
schemewith the inputpublicKey ++ rawSignature ++ hash, wherehashis the 32 byte typed data hash. - Return the ERC-1271 magic value
0x1626ba7ewhen the precompile returns the 32 byte word one, and return0xffffffffotherwise.
An account MUST NOT revert when the signature is invalid, so that a verifier distinguishes an invalid signature from a failed call.
Rationale
Why reuse EIP-712 and ERC-1271
The hash is left exactly as EIP-712 defines so that a tool that builds typed data today builds the same bytes for a post quantum signer, and only the signing and the verification change. The answer is returned through ERC-1271 so that a dapp that already calls isValidSignature for contract accounts verifies a post quantum account the same way, with no new call to learn. The change is confined to the signature encoding and the verifier, which is the smallest surface that makes post quantum off chain signing work.
Why the scheme byte
The scheme byte makes the signature self describing and names a scheme the same way the on chain path does, so the two paths share one registry. A verifier dispatches on the named scheme rather than on the length of a field, which keeps the standard crypto agile as schemes are added or retired.
Why not a new recovery
An elliptic curve signature recovers the signer from the signature, which a post quantum scheme does not do. The account already holds the public key as its credential, so the verifier checks the signature against the stored key rather than recovering an address. This is why the verification lives on the account through ERC-1271 rather than in a standalone recovery function.
Backwards Compatibility
The typed data hash is unchanged from EIP-712, and the interface is the existing ERC-1271 isValidSignature, so a dapp needs no change to verify a post quantum account. A verifier that expects a 65 byte elliptic curve signature will reject a post quantum signature on length, which is the correct outcome, and a dapp adds post quantum support by routing verification through ERC-1271 rather than through elliptic curve recovery.
Reference Implementation
A reference account verifies an EIP-712 hash through isValidSignature by decoding the scheme and the signature, calling the precompile for the scheme and returning the ERC-1271 magic value. The reference contract and the typed data test vectors for each registered scheme are published with this proposal, and the vectors are cross checked against independent implementations of ML-DSA and SLH-DSA.
Security Considerations
The hash binds a domain separator that includes the chain id and the verifying contract as EIP-712 defines, so a post quantum typed data signature cannot be replayed on another chain or against another contract when the domain is set correctly. An application MUST set the domain and MUST include a nonce in the struct where a signature must not be replayed within a domain.
A verifier MUST read the account credential at verification time rather than trust a key carried in the signature, so that a rotated credential takes effect at once. The account MUST return the failure value rather than revert on a bad signature, so that a verifier distinguishes an invalid signature from a reverting call and so that an off chain check completes. A post quantum signature is large, so a verifier that accepts one as calldata MUST account for its size.
Copyright
Copyright and related rights waived via CC0.
