Overview
TheverifyPubkeyValidity function creates instructions to verify that an ElGamal public key is valid and that the prover knows the corresponding secret key. This is essential for establishing trust in encrypted communications.
Function Signature
Parameters
Solana RPC client with rent exemption API support
Transaction signer that will pay for the account creation fees
The public key validity 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 public key validity proof instruction
Usage Examples
Basic Ephemeral Verification
Prove knowledge of the secret key:With Context State Storage
Store the verified proof on-chain for later reference:Using Proof from Record Account
Reference proof data stored in a record account:Notes
Security PurposeThis proof demonstrates that:
- The public key is valid (correctly formed on the elliptic curve)
- The prover knows the corresponding secret key
Use Cases
- Establishing identity and key ownership
- Initializing confidential token accounts
- Setting up secure encrypted communication channels
- Verifying public keys before accepting encrypted transfers
Related Functions
verifyZeroCiphertext- Verify a ciphertext encrypts zerocloseContextStateProof- Close a context state account