Installation
Add the dependency to yourCargo.toml:
Basic Key Generation
Generating an ElGamal Keypair
The SDK provides multiple ways to generate ElGamal keypairs:Key Derivation from Seed
You can derive deterministic keys from a seed:Key Derivation from Solana Signer
Derive ElGamal keys from an existing Solana signer:Encryption and Decryption
Basic Encryption
Encrypt values using ElGamal encryption:Decryption with Discrete Log
Since messages are encrypted in the exponent, decryption requires solving the discrete log:Creating Zero-Knowledge Proofs
Pubkey Validity Proof
Prove that you know the secret key for a given public key:Ciphertext-Ciphertext Equality Proof
Prove that two ciphertexts encrypt the same value under different public keys:Zero Ciphertext Proof
Prove that a ciphertext encrypts zero:Range Proofs
Batched Range Proof for u64
Prove that multiple committed values are within specified bit ranges:Working with Pedersen Commitments
Creating Commitments
Homomorphic Operations
Pedersen commitments support homomorphic addition:Serialization
Converting to/from Bytes
Error Handling
All proof operations returnResult types:
Next Steps
- See JavaScript Usage for client-side integration
- See WASM Integration for browser usage
- Refer to the Rust SDK Overview for detailed API documentation