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