Overview
TheverifyCiphertextCiphertextEquality function creates instructions to verify that two ElGamal ciphertexts encrypt the same plaintext message. This is useful for proving consistency between encrypted values without revealing the underlying value.
Function Signature
Parameters
Solana RPC client with rent exemption API support
Transaction signer that will pay for the account creation fees
The ciphertext equality 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 ciphertext equality proof instruction
Usage Examples
Basic Ephemeral Verification
Verify that two ciphertexts encrypt the same value:With Context State Storage
Store the verified proof on-chain:Using Proof from Record Account
Reference proof data stored in a record account:Notes
Proof RequirementsThe proof must demonstrate that both ciphertexts encrypt the same plaintext value. The prover needs:
- The secret key for the first ciphertext
- The public key for the second ciphertext
- The Pedersen opening for the second ciphertext
- The plaintext amount
Use Cases
- Proving balance consistency across different encrypted representations
- Verifying confidential transfers maintain the same amount
- Demonstrating encrypted values match without revealing the plaintext
Related Functions
verifyZeroCiphertext- Verify a ciphertext encrypts zerocloseContextStateProof- Close a context state account