Provides frontend utilities for the low-level use of Verifiably Encrypted Threshold Keys (VetKeys) on the Internet Computer (IC) such as decryption of encrypted VetKeys, identity based encryption (IBE), and symmetric key derivation from a VetKey.
Usage Example: IBE
This example demonstrates the complete flow from key generation to message encryption and decryption:
// 1. Generate a Transport Secret Key for decrypting VetKD-derived keys consttsk = TransportSecretKey.random();
// 2. Load a Derived Public Key (obtained from the IC) constdpkBytes = newUint8Array([...]); // Replace with actual bytes from IC constdpk = DerivedPublicKey.deserialize(dpkBytes);
// 3. Perform second-stage key derivation with a specific input, e.g., other user's principal as bytes constinput = newUint8Array([1, 2, 3]); // Your application-specific input constderivedKey = dpk.deriveKey(input); console.log("Derived Public Key:", derivedKey.publicKeyBytes());
// 4. Decrypt a VetKey using the transport secret key constencKeyBytes = newUint8Array([...]); // Replace with encrypted key from IC constencryptedKey = newEncryptedKey(encKeyBytes); constvetKey = encryptedKey.decryptAndVerify(tsk, dpk, input); console.log('Decrypted VetKey:', vetKey.signatureBytes());
// 5. Use Identity-Based Encryption to encrypt and decrypt a message constmessage = newTextEncoder().encode("Secret message");
Description
Provides frontend utilities for the low-level use of Verifiably Encrypted Threshold Keys (VetKeys) on the Internet Computer (IC) such as decryption of encrypted VetKeys, identity based encryption (IBE), and symmetric key derivation from a VetKey.
Usage Example: IBE
This example demonstrates the complete flow from key generation to message encryption and decryption:
Security Considerations