Overview
The Pedersen commitment module provides a cryptographically secure commitment scheme built on the Ristretto prime-order group. Pedersen commitments are hiding and binding, allowing you to commit to a value without revealing it while ensuring the commitment cannot be changed later.Key Concepts
Commitment Scheme
A Pedersen commitment to a valuex with opening r is computed as:
Gis the Ristretto basepoint (message generator)His a secondary generator derived from Gxis the committed value (as a scalar)ris the random opening (blinding factor)
Properties
- Hiding: The commitment reveals no information about the committed value
- Binding: Once created, the commitment cannot be changed to a different value
- Homomorphic: Commitments support addition, subtraction, and scalar multiplication
Base Points
H point is derived deterministically from G using SHA3-512 hashing.
Core Types
PedersenCommitment
A Pedersen commitment to a value.Methods
Operator Overloading
PedersenCommitment supports arithmetic operations:PedersenOpening
The opening (blinding factor) for a Pedersen commitment. Instances are zeroized on drop.Methods
Operator Overloading
PedersenOpening supports arithmetic operations:Algorithm Handle
ThePedersen struct provides commitment operations:
Methods
Usage Examples
Creating a Commitment
Deterministic Commitment
Homomorphic Addition
Homomorphic Subtraction
Scalar Multiplication
Working with Zero Amounts
Serialization and Deserialization
Commitment Verification
Security Considerations
Opening Security
- Openings are automatically zeroized on drop
- Keep openings secret - they can be used to reveal committed values
- Never reuse openings for different values
Hiding Property
Warning: The deprecatedPedersen::encode function creates a commitment with a zero opening:
Pedersen::new() for confidential commitments.
Constant-Time Operations
The implementation uses constant-time equality checks for openings to prevent timing side-channels:Integration with ElGamal
Pedersen commitments are the foundation of the twisted ElGamal encryption scheme:Mathematical Properties
Linearity
For valuesx1, x2 and openings r1, r2:
Scalar Homomorphism
For valuex, opening r, and scalar k: