FrodoKEM-1344-SHAKE key encapsulation mechanism wrapper class
FrodoKEM1344SHAKE
High-level wrapper for FrodoKEM-1344-SHAKE KEM operations. Provides secure key generation, encapsulation, and decapsulation with automatic memory management.
Memory Management:
const kem = await createFrodoKEM1344SHAKE();// Generate keypairconst { publicKey, secretKey } = kem.generateKeyPair();// Encapsulateconst { ciphertext, sharedSecret } = kem.encapsulate(publicKey);// Decapsulateconst recoveredSecret = kem.decapsulate(ciphertext, secretKey);// Cleanupkem.destroy(); Copy
const kem = await createFrodoKEM1344SHAKE();// 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-1344-SHAKE'console.log(kem.info.securityLevel); // 5console.log(kem.info.keySize); // { publicKey: 21520, secretKey: 43088, ciphertext: 21632, sharedSecret: 32 } Copy
console.log(kem.info.name); // 'FrodoKEM-1344-SHAKE'console.log(kem.info.securityLevel); // 5console.log(kem.info.keySize); // { publicKey: 21520, secretKey: 43088, ciphertext: 21632, sharedSecret: 32 }
Generate a new FrodoKEM-1344-SHAKE keypair
If instance is destroyed
If key generation fails
const { publicKey, secretKey } = kem.generateKeyPair();console.log('Public key:', publicKey.length); // 21520 bytesconsole.log('Secret key:', secretKey.length); // 43088 bytes Copy
const { publicKey, secretKey } = kem.generateKeyPair();console.log('Public key:', publicKey.length); // 21520 bytesconsole.log('Secret key:', secretKey.length); // 43088 bytes
Encapsulate a shared secret using a public key
Public key (21520 bytes)
If public key size is invalid
If encapsulation fails
const { ciphertext, sharedSecret } = kem.encapsulate(publicKey);console.log('Ciphertext:', ciphertext.length); // 21632 bytesconsole.log('Shared secret:', sharedSecret.length); // 32 bytes Copy
const { ciphertext, sharedSecret } = kem.encapsulate(publicKey);console.log('Ciphertext:', ciphertext.length); // 21632 bytesconsole.log('Shared secret:', sharedSecret.length); // 32 bytes
Decapsulate a shared secret using a secret key
Ciphertext (21632 bytes)
Secret key (43088 bytes)
Shared secret (32 bytes)
If ciphertext or secret key size is invalid
If decapsulation fails
const sharedSecret = kem.decapsulate(ciphertext, secretKey);console.log('Recovered secret:', sharedSecret.length); // 32 bytes Copy
const sharedSecret = kem.decapsulate(ciphertext, secretKey);console.log('Recovered secret:', sharedSecret.length); // 32 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-1344-SHAKE key encapsulation mechanism wrapper class
FrodoKEM1344SHAKE
Description
High-level wrapper for FrodoKEM-1344-SHAKE KEM operations. Provides secure key generation, encapsulation, and decapsulation with automatic memory management.
Memory Management:
Example