Overview
TheverifyZeroCiphertext function creates instructions to verify that an ElGamal ciphertext encrypts the value zero. This is useful for proving that a balance has been fully depleted or that no value is being transferred.
Function Signature
Parameters
Solana RPC client with rent exemption API support
Transaction signer that will pay for the account creation fees
The zero-ciphertext proof data. Can be either:
Uint8Array- Raw proof bytes for ephemeral verification{ account: Address; offset: number }- Reference to proof data stored in a record account
Optional context state configuration for storing the verified proof on-chain:
contextAccount: KeyPairSigner- New account to store the proofauthority: Address- Authority that can close the context account
ZK ElGamal Proof program address. Defaults to
ZK_ELGAMAL_PROOF_PROGRAM_ADDRESSReturns
Promise<Instruction[]> - Array of instructions to execute:
- Create context account instruction (if
contextStateis provided) - Verify zero-ciphertext proof instruction
Usage Examples
Ephemeral Verification (No Context State)
Verify the proof within a transaction without storing it on-chain:With Context State Storage
Store the verified proof on-chain for later use:Using Proof from Record Account
Reference proof data stored in a record account:Notes
Ephemeral vs Persistent Verification
- Without
contextState: The proof is verified within the transaction and discarded - With
contextState: The proof is stored on-chain and can be referenced by other programs
Related Functions
closeContextStateProof- Close a context state account and reclaim rentverifyCiphertextCiphertextEquality- Verify two ciphertexts encrypt the same value