FrodoKEM-976-SHAKE key encapsulation mechanism wrapper class
FrodoKEM976SHAKE
High-level wrapper for FrodoKEM-976-SHAKE KEM operations. Provides secure key generation, encapsulation, and decapsulation with automatic memory management.
Memory Management:
const kem = await createFrodoKEM976SHAKE();// Generate keypairconst { publicKey, secretKey } = kem.generateKeyPair();// Encapsulateconst { ciphertext, sharedSecret } = kem.encapsulate(publicKey);// Decapsulateconst recoveredSecret = kem.decapsulate(ciphertext, secretKey);// Cleanupkem.destroy(); Copy
const kem = await createFrodoKEM976SHAKE();// Generate keypairconst { publicKey, secretKey } = kem.generateKeyPair();// Encapsulateconst { ciphertext, sharedSecret } = kem.encapsulate(publicKey);// Decapsulateconst recoveredSecret = kem.decapsulate(ciphertext, secretKey);// Cleanupkem.destroy();
Get algorithm information
Algorithm metadata
console.log(kem.info.name); // 'FrodoKEM-976-SHAKE'console.log(kem.info.securityLevel); // 3console.log(kem.info.keySize); // { publicKey: 15632, secretKey: 31296, ciphertext: 15744, sharedSecret: 24 } Copy
console.log(kem.info.name); // 'FrodoKEM-976-SHAKE'console.log(kem.info.securityLevel); // 3console.log(kem.info.keySize); // { publicKey: 15632, secretKey: 31296, ciphertext: 15744, sharedSecret: 24 }
Generate a new FrodoKEM-976-SHAKE keypair
If instance is destroyed
If key generation fails
const { publicKey, secretKey } = kem.generateKeyPair();console.log('Public key:', publicKey.length); // 15632 bytesconsole.log('Secret key:', secretKey.length); // 31296 bytes Copy
const { publicKey, secretKey } = kem.generateKeyPair();console.log('Public key:', publicKey.length); // 15632 bytesconsole.log('Secret key:', secretKey.length); // 31296 bytes
Encapsulate a shared secret using a public key
Public key (15632 bytes)
If public key size is invalid
If encapsulation fails
const { ciphertext, sharedSecret } = kem.encapsulate(publicKey);console.log('Ciphertext:', ciphertext.length); // 15744 bytesconsole.log('Shared secret:', sharedSecret.length); // 24 bytes Copy
const { ciphertext, sharedSecret } = kem.encapsulate(publicKey);console.log('Ciphertext:', ciphertext.length); // 15744 bytesconsole.log('Shared secret:', sharedSecret.length); // 24 bytes
Decapsulate a shared secret using a secret key
Ciphertext (15744 bytes)
Secret key (31296 bytes)
Shared secret (24 bytes)
If ciphertext or secret key size is invalid
If decapsulation fails
const sharedSecret = kem.decapsulate(ciphertext, secretKey);console.log('Recovered secret:', sharedSecret.length); // 24 bytes Copy
const sharedSecret = kem.decapsulate(ciphertext, secretKey);console.log('Recovered secret:', sharedSecret.length); // 24 bytes
Free WASM resources
Releases all WASM memory associated with this instance. The instance cannot be used after calling destroy().
kem.destroy();// kem is now unusable Copy
kem.destroy();// kem is now unusable
FrodoKEM-976-SHAKE key encapsulation mechanism wrapper class
FrodoKEM976SHAKE
Description
High-level wrapper for FrodoKEM-976-SHAKE KEM operations. Provides secure key generation, encapsulation, and decapsulation with automatic memory management.
Memory Management:
Example