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
- Send encrypted handles to the covalidator
- Covalidator decrypts and returns plaintexts with Ed25519 signatures
- Build a transaction with Ed25519 verification instructions
- Add your program instruction that uses the decrypted values
- 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().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
Utility Functions
Error Handling
Errors
| Error Message | Cause | Solution |
|---|---|---|
No handles provided for decryption | Empty handles array [] | Pass at least one handle |
Maximum 10 handles per transaction. This is a Solana transaction size limit | More than 10 handles | Split into multiple calls of ≤10 handles |
At least one handle is required for decryption | Empty handles array | Pass at least one handle |
Covalidator API request failed: <details> | Covalidator error | Check network; handle may be invalid |
Covalidator returned empty plaintext | Missing plaintext | Handle may be invalid or not found |
Covalidator signature verification failed. The response may be tampered | Ed25519 verification failed | Response integrity compromised |
Failed to build attested decrypt transaction | Transaction construction failed | Check handles and instruction builder |
Transaction failed: <details> | On-chain execution failed | Check Solana explorer for details |
Failed to create Ed25519 verification instruction: <details> | Ed25519 instruction failed | Signature format may be invalid |
Attested decryption failed: <details> | General failure | Check error details |
When to Use Attested Decrypt vs Attested Reveal
| Use Case | Use |
|---|---|
| Conditional on-chain logic based on decrypted value | Attested Decrypt |
| Verify decryption proof on-chain | Attested Decrypt |
| Display balance in UI | Attested Reveal |
| Show transaction result to user | Attested Reveal |