Skip to main content

Attested Decrypt

Attested Decrypt allows you to decrypt encrypted handles and verify the decryption on-chain using Ed25519 signature verification. Use this when you need to perform on-chain logic based on decrypted values.

Import

Basic Usage

Attested Decrypt uses the same decrypt() function as Attested Reveal. The difference is that you use result.ed25519Instructions to build an on-chain verification transaction.

How It Works

  1. Send encrypted handles to the covalidator
  2. Covalidator decrypts and returns plaintexts with Ed25519 signatures
  3. Build a transaction with Ed25519 verification instructions
  4. Add your program instruction that uses the decrypted values
  5. Submit transaction - Solana verifies signatures before executing your instruction

Example: Verify Addition Result On-Chain

Example: Verify Multiple Values On-Chain

Example: Verify e_select Result On-Chain


React Integration


Getting Handles

There are two ways to get encrypted handles for decryption:

Option 1: From Transaction Logs

When your program emits handles in logs after an operation:

Option 2: From On-Chain Account (e.g., Token Balance PDA)

When the encrypted handle is stored in an account (like a confidential token balance):

Example: Verify Token Balance On-Chain


API Reference

decrypt(handles, options)

Decrypts encrypted handles and returns plaintexts with Ed25519 verification data. Parameters:
  • handles: string[] - Array of encrypted handles as decimal strings (max 10)
  • options: DecryptOptions - Wallet authentication options
Handles must be passed as decimal string representations (e.g., "123456789012345678901234567890"), not hex strings. When reading a handle from an on-chain account (stored as u128), convert it to a decimal string using .toString().
Returns: Promise<DecryptResult>

Types

DecryptOptions

The signMessage function can come from:
  • Wallet adapter (e.g., Phantom): wallet.signMessage
  • tweetnacl for testing: async (msg) => nacl.sign.detached(msg, keypair.secretKey)
For complete examples, see the lightning-rod-solana tests.

DecryptResult

Utility Functions


Error Handling

Errors


Attested Decrypt with Allowance Voucher / Session Key

For apps that need decrypt without a wallet popup on every request, grant a session key once, then call decryptWithVoucher():
See Allowance Voucher for revoke, compute-with-voucher, and security guidance.

When to Use Attested Decrypt vs Attested Reveal vs Attested Compute