Files
zeekay ca0bf6b303 precompile: seven packages to 96-99%, from lanes killed before they could commit
slhdsa 97.9 · mlkem 97.4 · mldsa 96.8 · xwing 96.2 · bls12381 97.2 ·
kzg4844 97.8 · v3 98.7. All build, vet and gofmt clean, all green under
-count=1, and preserved here rather than lost to a session limit.

v3's lane did report before it died: 78.1% to 98.7%, 70 of 70 mutations caught,
four of which survived a first pass and needed tests written. The two that
matter are rounding: burn rounding principal UP, and fee growth rounding UP,
neither of which any behaviour test could see -- a Q128.128 off-by-one is
2^-128 of a token and floors to zero through every payout path, so it took an
exact-value assertion. It also found that a full drain of a pool with
overlapping positions REVERTS rather than paying out, because deposits round
down once per position while payouts round down once per step over combined
liquidity, and floor(a+b) >= floor(a)+floor(b). Custody holds; not one unbacked
wei leaves. Liveness, not theft.

The other six carry no report -- their lanes were killed mid-run. Build, vet,
gofmt and the suite are all I can vouch for.
2026-08-28 13:27:00 -07:00
..

ML-KEM Precompile

Post-quantum key encapsulation mechanism precompile implementing FIPS 203 (ML-KEM).

Address

0x0200000000000000000000000000000000000007

Specification

See LP-4318: ML-KEM Post-Quantum Key Encapsulation

Operations

Encapsulate (0x01)

Generate a shared secret and ciphertext from a public key.

Input:

Offset Size Description
0 1 Operation (0x01)
1 1 Mode (0x00=512, 0x01=768, 0x02=1024)
2 varies Public key

Output:

Offset Size Description
0 varies Ciphertext
varies 32 Shared secret

Decapsulate (0x02)

Recover the shared secret from a ciphertext using a private key.

Input:

Offset Size Description
0 1 Operation (0x02)
1 1 Mode (0x00=512, 0x01=768, 0x02=1024)
2 varies Private key
varies varies Ciphertext

Output:

Offset Size Description
0 32 Shared secret

Key Sizes

Mode Public Key Private Key Ciphertext Shared Secret
ML-KEM-512 800 1632 768 32
ML-KEM-768 1184 2400 1088 32
ML-KEM-1024 1568 3168 1568 32

Gas Costs

Operation ML-KEM-512 ML-KEM-768 ML-KEM-1024
Encapsulate 50,000 75,000 100,000
Decapsulate 60,000 90,000 120,000

Security Levels

  • ML-KEM-512: 128-bit security (NIST Level 1)
  • ML-KEM-768: 192-bit security (NIST Level 3) - Recommended
  • ML-KEM-1024: 256-bit security (NIST Level 5)

Usage Example (Solidity)

import {MLKEMCaller} from "./IMLKEM.sol";

contract QuantumSecureExchange {
    using MLKEMCaller for *;

    function establishSecret(bytes calldata recipientPubKey)
        external view
        returns (bytes memory ciphertext, bytes32 sharedSecret)
    {
        return MLKEMCaller.encapsulate768(recipientPubKey);
    }

    function recoverSecret(
        bytes calldata privateKey,
        bytes calldata ciphertext
    ) external view returns (bytes32 sharedSecret) {
        return MLKEMCaller.decapsulate768(privateKey, ciphertext);
    }
}

References