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