Cryptographic Building Blocks
The SDK is built on three fundamental cryptographic primitives:ElGamal Encryption
Twisted ElGamal encryption scheme for confidential amounts
Pedersen Commitments
Cryptographic commitments with homomorphic properties
Zero-Knowledge Proofs
Proving statements without revealing sensitive data
The Ristretto Group on Curve25519
All cryptographic operations in the SDK are performed over the Ristretto prime-order group representation of Curve25519. This provides:- Security: 128-bit security level
- Performance: Fast group operations optimized for modern processors
- Prime-order group: Eliminates cofactor-related vulnerabilities
- Canonical encoding: Each group element has exactly one valid encoding
curve25519-dalek implementation for all elliptic curve operations.
The Ristretto group was specifically designed to provide a clean, prime-order group abstraction over Curve25519, eliminating many of the pitfalls associated with cofactor handling in Edwards curves.
Base Points and Constants
The SDK defines two fundamental base points used throughout the cryptographic operations:- G: The standard Ristretto basepoint, used for encoding message values
- H: A secondary basepoint derived by hashing G, used for randomness in commitments
The base point
H is computed deterministically from G using SHA3-512 hashing. This ensures that the discrete log relationship between G and H is unknown, which is critical for the security of Pedersen commitments.Key Lengths and Constants
All cryptographic components have standardized byte lengths:The Twisted ElGamal Approach
Unlike traditional ElGamal encryption, the SDK implements a twisted variant where:- Messages are encrypted in the exponent: Values are encoded as
value * Grather than direct group elements - Ciphertexts are Pedersen commitments: Each ciphertext is a commitment with an additional decryption handle
- Proof systems are unified: The same proof techniques work for both commitments and ciphertexts
Homomorphic Properties
All three primitives support homomorphic operations:Addition
Subtraction
Scalar Multiplication
Discrete Logarithm Decryption
Since messages are encrypted “in the exponent”, decryption requires solving a discrete logarithm problem:DiscreteLog instance that must be solved to recover the original value. For small values (up to 2^32), this is computed efficiently using lookup tables and baby-step giant-step algorithms.
The discrete log computation is intentionally limited to small values. This is not a limitation in practice, as the SDK is designed for confidential token amounts, which are typically well within the 64-bit range.
Transcript and Fiat-Shamir
All zero-knowledge proofs use the Fiat-Shamir heuristic to convert interactive sigma protocols into non-interactive proofs. The SDK uses Merlin transcripts for this purpose.Security Considerations
Constant-Time Operations
Secret keys and openings implement constant-time equality checks to prevent timing attacks:Zeroization
Sensitive values are automatically zeroized when dropped:Identity Element Checks
Proof verification explicitly rejects identity elements to prevent malleability attacks:Next Steps
Now that you understand the foundational concepts, dive deeper into each component:ElGamal Encryption
Learn about twisted ElGamal encryption, key generation, and decryption
Pedersen Commitments
Understand cryptographic commitments and their properties
Zero-Knowledge Proofs
Explore the various proof systems available in the SDK