JOSE JWE (experimental, ML-KEM)

JSON Web Encryption (RFC 7516) with ML-KEM-1024 key encapsulation and XChaCha20-Poly1305 AEAD content encryption. Lives under b.jose.jwe.experimental because the JOSE PQC IANA codepoint registration (draft-ietf-jose-pqc-kem-05) hasn't finalized — the namespace name is the contract: codepoints may change between minors without the framework's stable surface being affected.

When the JOSE WG closes the draft and IANA registers final codepoints, the same primitives graduate to b.jose.jwe (or a stable equivalent) with explicit deprecation of the experimental namespace and a one-minor migration window per the framework's stable-upgrade-policy rule.

Compact serialization only — no JSON serialization variant (saves wire-format complexity at this experimental tier; operators that need JWE-JSON wait for the stable surface).

b.jose.jwe.experimental.encrypt(plaintext, recipientPublicKeyPem, opts?) #

experimental0.10.10
{
  typ:           string,        // optional JWE "typ" header
  contentType:   string,        // optional JWE "cty" header
  audit:         boolean,        // default true; emit audit event on encrypt
}

Encrypt a payload under the recipient's ML-KEM-1024 public key. Returns the JWE compact serialization

.... (base64url segments) per RFC 7516 §3.1 with experimental PQC codepoints.

Header includes { alg: "ML-KEM-1024", enc: "XC20P", typ: "JWE", "x-blamejs-experimental": true } — operators that scrape JWE envelopes can refuse the experimental marker until the codepoint stabilises.

var pair = b.crypto.generateEncryptionKeyPair();
var jwe = b.jose.jwe.experimental.encrypt("hello", pair.mlkem.publicKey);
typeof jwe; // → "string" (compact form)

b.jose.jwe.experimental.decrypt(compact, recipientPrivateKeyPem, opts?) #

experimental0.10.10
{
  audit:         boolean,        // default true
}

Decrypt a compact-serialization JWE produced by the experimental encrypt path. Returns the plaintext Buffer. Refuses on alg / enc mismatch, missing experimental marker, or any cryptographic verify failure. Never throws on adversarial input — typed JoseJweExperimentalError with a coded refusal.

var plaintext = b.jose.jwe.experimental.decrypt(jwe, pair.mlkem.privateKey);
plaintext.toString("utf8"); // → "hello"

Last updated 2026-08-08T16:39:49.652Z by seeder.