The data to encrypt (string or Blob)
The signed key from generateEncryptionKey
- MUST be a wallet signature
The platform adapter for crypto operations
The encrypted data as Blob
This is a pure cryptographic primitive that encrypts data using the Vana protocol's
standard encryption method. The key parameter must be a signature generated by the
generateEncryptionKey
utility - this ensures deterministic key generation from the
user's wallet, enabling the same key to be regenerated for decryption.
This function uses password-based encryption with the signature as the password, providing symmetric encryption that can be decrypted with the same signature.
// Generate the encryption key from wallet signature
const encryptionKey = await generateEncryptionKey(walletClient);
// Encrypt data with the signed key
const encryptedBlob = await encryptBlobWithSignedKey(
"My sensitive data",
encryptionKey,
platformAdapter
);
// Later, decrypt with the same key
const decryptedBlob = await decryptBlobWithSignedKey(
encryptedBlob,
encryptionKey,
platformAdapter
);
Encrypts data using a signed key generated from the user's wallet signature.