Introduction
Thesolana-zk-sdk crate provides tools to create and verify zero-knowledge proofs on encrypted data using ElGamal encryption and Pedersen commitments over Curve25519.
Module Structure
The SDK is organized into the following main modules:Core Modules
encryption
Encryption-related data structures including:
- Pedersen commitments using Ristretto/Curve25519
- Twisted ElGamal encryption scheme
- AES-GCM-SIV authenticated encryption
zk_elgamal_proof_program
Zero-knowledge proof program containing:
- Instruction types for proof verification
- Proof data types and contexts
- State management for proof contexts
errors
Error types for ElGamal operations and proof generation/verification
pod
Plain Old Data types for serialization
Available Proof Types
The SDK supports multiple zero-knowledge proof types:- Zero Ciphertext - Proves an ElGamal ciphertext encrypts zero
- Ciphertext-Ciphertext Equality - Proves two ciphertexts encrypt the same message
- Ciphertext-Commitment Equality - Proves a ciphertext and commitment encode the same value
- Public Key Validity - Proves an ElGamal public key is well-formed
- Percentage with Cap - Proves percentage relations between commitments
- Batched Range Proofs - Proves values are within specific bit ranges (64, 128, 256-bit)
- Grouped Ciphertext Validity - Proves grouped ciphertexts are well-formed (2 or 3 handles)
Constants
Global transcript domain separator for proof generation.
Byte length of a compressed Ristretto point or scalar in Curve25519 (32 bytes)
Byte length of a compressed Ristretto point (32 bytes)
Byte length of a scalar in Curve25519 (32 bytes)
Quick Start
Creating an ElGamal Keypair
Encrypting a Value
Creating a Zero-Knowledge Proof
Features
Homomorphic Operations
ElGamal ciphertexts support homomorphic addition and scalar multiplication:Discrete Log Decryption
Decryption returns aDiscreteLog instance that must be solved to recover the plaintext:
Program ID
The ZK ElGamal Proof program has a fixed program ID on Solana:Next Steps
Encryption
Learn about ElGamal encryption and Pedersen commitments
Proof Data
Explore available proof types and their usage
Instructions
Build proof verification instructions
State
Manage proof context state accounts