> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x402layer.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Post-quantum crypto

> ML-KEM-768, hybrid encryption, ML-DSA-65 and SLH-DSA as pay-per-call processors, plus free client snippets that keep your keys on your machine.

Four first-party processors for the NIST post-quantum standards. Pay per call over x402 with USDC on
Base or Solana. No account needed.

| Processor | What it does | Standard | Price |
| - | - | - | - |
| `pq-kem` | ML-KEM-768 keygen, encapsulate, decapsulate | FIPS 203 | \$0.003 |
| `pq-hybrid` | Hybrid public-key encryption: X25519 + ML-KEM-768 (X-Wing), HKDF-SHA256, AES-256-GCM | FIPS 203, IETF X-Wing draft | \$0.003 |
| `pq-ml-dsa` | ML-DSA-65 keygen, sign, verify | FIPS 204 | \$0.003 |
| `pq-slh-dsa` | SLH-DSA-SHA2-128s (default) or -128f keygen, sign, verify | FIPS 205 | \$0.005 |

Endpoint: `POST https://processors.x402compute.cc/processors/<slug>/run` with `{"input": {"op": "..."}}`.
Every processor answers `{"op": "info"}` with its formats.

## What is post-quantum, exactly

* **Key exchange** (`pq-kem`, and the key agreement inside `pq-hybrid`) uses ML-KEM-768. This is what
  protects against "harvest now, decrypt later": data recorded today cannot be opened later by a quantum computer.
* **`pq-hybrid` is hybrid.** The X-Wing combiner mixes the X25519 and ML-KEM-768 secrets, so your data
  stays secret unless both are broken.
* **AES-256-GCM** is symmetric. A quantum computer does not meaningfully weaken 256-bit keys.
* **Signatures.** ML-DSA-65 is lattice-based. SLH-DSA relies only on hash functions, which makes it the
  conservative choice for long-lived identity, release and archive keys.

## What we keep

These processors log nothing. The platform option `privacy.ephemeral_io` is set on all four:

* the run input (keys, messages, plaintext) is erased in the same write that ends the run;
* the result is kept about 10 minutes so you can collect it (a lost reply stays recoverable), then erased;
* the setting cannot be switched off later.

Your input and output do pass through our platform while the run executes. If a private key must never
leave your machine, use the client snippets below: they do every operation locally, for free.

## Examples

```bash theme={null}
# Generate a hybrid key pair (or do it locally with the snippet)
curl -X POST https://processors.x402compute.cc/processors/pq-hybrid/run \
  -H 'content-type: application/json' -d '{"input":{"op":"keygen"}}'
# -> 402 with the price; pay with any x402 client, then:
# {"op":"keygen","public_key":"...","secret_key":"...","secret_key_format":"seed","warning":"..."}

# Encrypt to someone's public key
{"input":{"op":"encrypt","public_key":"<base64>","plaintext":"hello","aad":"doc-42"}}
# -> {"format":"sglpq-hybrid-v1","envelope":"<base64>"}

# Verify an ML-DSA-65 signature (public data only)
{"input":{"op":"verify","public_key":"<base64>","signature":"<base64>","message":"pay 5 USDC","context":"app-v1"}}
# -> {"valid":true}
```

## Formats

| Algorithm | Private key | Public key | Other |
| - | - | - | - |
| ML-KEM-768 | 64-byte seed (2400-byte expanded accepted) | 1184 bytes | ciphertext 1088, shared secret 32 |
| X-Wing | 32-byte seed | 1216 bytes | |
| ML-DSA-65 | 32-byte seed (4032-byte expanded accepted) | 1952 bytes | signature 3309 |
| SLH-DSA-SHA2-128s / 128f | 64 bytes | 32 bytes | signature 7856 / 17088 |

All binary values are base64. Messages and plaintext are sent as UTF-8 `message` / `plaintext`, or as
bytes in `message_b64` / `plaintext_b64`, up to 64 KiB per call. Seed-form keys are what
`pyca/cryptography` exports, so keys move between the processors, Python and JavaScript unchanged.

### Envelope `sglpq-hybrid-v1`

```
envelope = "SGLPQ" 0x01 0x01 || X-Wing ciphertext (1120) || nonce (12) || AES-GCM ciphertext || tag (16)
key      = HKDF-SHA256(X-Wing shared secret, salt = empty,
                       info = "sglpq-hybrid-v1 X-Wing HKDF-SHA256 AES-256-GCM key")
aad      = header || X-Wing ciphertext || nonce || your aad
```

## Client snippets (free, local)

* **JavaScript** (`@noble/post-quantum`): Node 20+, browsers, Deno, Bun, Workers.
  [pq-client.mjs](https://github.com/ivaavimusic/docs/blob/main/examples/pq-crypto/pq-client.mjs)
* **Python** (`cryptography >= 46`): ML-KEM, ML-DSA, X-Wing and the envelope.
  [pq\_client.py](https://github.com/ivaavimusic/docs/blob/main/examples/pq-crypto/pq_client.py).
  SLH-DSA is not in `pyca/cryptography`; verify with `pq-slh-dsa` or locally with liboqs-python.

## How it is tested

Against the official NIST ACVP test vectors (FIPS 203, 204, 205) and the X-Wing draft's vectors, through
our own wrappers, plus byte-for-byte interop between the processors, the JS snippet and the Python snippet.

## Library and limits

The processors use `@noble/post-quantum` 0.7.1, a maintained, widely used pure JavaScript library. Its
authors state it has been self-audited (April 2026) but not yet independently audited, and pure
JavaScript does not promise constant-time execution. Keep long-term private keys client-side.

Check whether a website already uses post-quantum key exchange with the free
[post-quantum TLS checker](https://www.singularitylayer.cc/post-quantum-tls-checker).

## Check your own code

In Studio chat, ask **"make my app quantum-safe"** with your GitHub connected. It reads the repository
(read only), lists the cryptography it uses, marks what recorded traffic or data could be decrypted later,
and writes a step-by-step migration plan. \$0.50 from credits, shown on a confirm card and charged only if
the scan completes. It is a pattern scan: it finds crypto your code names and can miss what is hidden in
configuration.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.