vetkeys-client-utils
v0.1.2
Published
Makes ic-vetkd-utils usable in Expo and smartphone WebViews
Maintainers
Readme
vetkeys-client-utils
Makes ic-vetkd-utils usable in Expo and smartphone WebViews. This package provides a TypeScript-friendly wrapper around the Internet Computer's VETKeys (Verifiable Encrypted Threshold Keys) functionality.
Installation
npm install vetkeys-client-utils ic-vetkd-utils-wasm2jsFeatures
- Identity-Based Encryption (IBE) operations
- Transport Secret Key management
- Full TypeScript support
- Version-independent principal handling (accepts raw Uint8Array)
Usage
Encrypting Data with IBE
import { ibeEncrypt } from 'vetkeys-client-utils';
const ciphertext = await ibeEncrypt({
data: new TextEncoder().encode('Hello, World!'), // Data to encrypt
principal: principalBytes, // Principal as Uint8Array
publicKey: publicKeyBytes, // From your canister
seed: new Uint8Array(32), // Random seed for encryption
});Decrypting Data with IBE
import { ibeDecrypt } from 'vetkeys-client-utils';
import * as vetkd from 'ic-vetkd-utils-wasm2js';
const plaintext = await ibeDecrypt({
ciphertext: encryptedData, // Encrypted data
principal: principalBytes, // Principal as Uint8Array
encryptedKey: encryptedKeyBytes, // From your canister
publicKey: publicKeyBytes, // From your canister
tsk: new vetkd.TransportSecretKey(seed), // Your transport secret key
});API Reference
ibeEncrypt(params: IBEEncryptParams): Promise<Uint8Array>
Encrypts data using Identity-Based Encryption.
ibeDecrypt(params: IBEDecryptParams): Promise<Uint8Array>
Decrypts data using Identity-Based Encryption.
Development
- Install dependencies:
npm install- Run tests:
npm test- Build the package:
npm run buildLicense
MIT
