PQC Software
Pure-JS post-quantum cryptography wrapper around the vendored @noble/post-quantum bundle (lib/vendor/noble-post-quantum.cjs). Ships the FIPS-203 ML-KEM family, FIPS-204 ML-DSA family, and FIPS-205 SLH-DSA family (both SHAKE and SHA-2 hash variants) as first-class accessors on b.pqcSoftware.*.
Defaults pin to the highest category-5 parameter set per family: DEFAULT_KEM = ML-KEM-1024, DEFAULT_LATTICE_SIG = ML-DSA-87, DEFAULT_HASH_SIG = SLH-DSA-SHAKE-256f. Ciphertexts are FIPS-203 conformant in both directions — output produced by Node's WebCrypto ML-KEM-1024 (used by b.crypto.encrypt and b.middleware.apiEncrypt) decapsulates here, and vice versa, making this the reference-implementation path for interop tests against Node WebCrypto or a hardware HSM.
Each KEM exposes keygen() / encapsulate() / decapsulate(); each signature object exposes keygen() / sign() / verify() — both shapes match the upstream @noble/post-quantum API directly, so the module is also re-bundlable into a browser build that ships b.middleware.apiEncrypt.client.
The vendored bundle is a build artifact. In deployments that stripped lib/vendor/, isAvailable() returns false and every accessor returns a stub that throws PqcError on call — operators in that posture fall back to Node WebCrypto via b.crypto.encrypt / b.crypto.decrypt.
b.pqcSoftware.isAvailable() #
Returns true when the vendored @noble/post-quantum bundle loaded successfully and its KEM / signature objects are wired into the accessors. Returns false when lib/vendor/noble-post-quantum.cjs is missing or threw at require time — every accessor in that posture returns a stub whose primitive calls throw PqcError.
var b = require("blamejs");
if (b.pqcSoftware.isAvailable()) {
var ss = b.pqcSoftware.DEFAULT_KEM.keygen();
ss.publicKey.length;
// → 1568 (ML-KEM-1024 public key, FIPS 203 §8 |pk| = 1568)
}
b.pqcSoftware.listAlgorithms() #
Returns the names of every PQC algorithm exposed on the b.pqcSoftware surface — the three ML-KEM parameter sets, the three ML-DSA parameter sets, and six SLH-DSA parameter sets (three SHAKE + three SHA-2). Returns an empty array when the vendored bundle is unavailable.
var b = require("blamejs");
var names = b.pqcSoftware.listAlgorithms();
names.indexOf("ml_kem_1024") >= 0;
// → true (when the vendored bundle is present)
b.pqcSoftware.runKnownAnswerTest() #
Round-trips ML-KEM-1024 against itself with a self-generated keypair: keygen → encapsulate → decapsulate, then a constant-time compare of the two shared secrets. This is a self- consistency gate, not the FIPS 203 Appendix A KAT vectors (those ~800 KB of test data are intentionally not vendored). The check fails fast at boot if the vendored bundle is broken, rather than mid-request when an envelope decrypt aborts.
Returns { ok, reason?, sharedSecretLength? }. ok: true means keygen / encapsulate / decapsulate cycled cleanly and the two shared secrets are byte-identical (32 bytes per FIPS 203 §1).
var b = require("blamejs");
var result = b.pqcSoftware.runKnownAnswerTest();
result.ok;
// → true (or { ok: false, reason: "" } when broken)
Last updated 2026-08-08T16:39:49.652Z by seeder.