Attested Reveal
Attested Reveal allows you to decrypt encrypted handles and display the plaintext values off-chain (e.g., show a user’s balance in your UI) without any on-chain transaction.Import
Basic Usage
Attested Reveal uses the same
decrypt() function as Attested Decrypt. The difference is that you only use result.plaintexts for display, without building an on-chain verification transaction.How It Works
- Send encrypted handles to the covalidator
- Covalidator decrypts and returns plaintext values with signatures
- Display the plaintext values in your UI
Example: Reveal Arithmetic Result
Example: Reveal Multiple Values
Example: Reveal Comparison Result
Example: Reveal e_select Result
Client-Side 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: Reveal Confidential Token Balance
API Reference
decrypt(handles, options)
Decrypts encrypted handles and returns plaintext values.
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().Promise<DecryptResult>
Types
DecryptOptions
signMessage function can come from:
- Wallet adapter (e.g., Phantom):
wallet.signMessage - tweetnacl for testing:
async (msg) => nacl.sign.detached(msg, keypair.secretKey)
DecryptResult
Reveal with Allowance Voucher / Session Key
You can reveal using a session key instead of the wallet viadecryptWithVoucher() — use result.plaintexts for display only: