Overview
The grouped ElGamal module extends the twisted ElGamal encryption scheme to support multiple recipients. A grouped ElGamal ciphertext contains a single Pedersen commitment shared across all recipients, with individual decrypt handles for each recipient’s public key.Key Concepts
Shared Commitment Architecture
Instead of creating separate ciphertexts for each recipient, grouped ElGamal:- Creates one Pedersen commitment encoding the message
- Generates multiple decrypt handles, one per recipient public key
- Maintains the same opening for all handles
Use Cases
- Multi-party protocols requiring shared encrypted values
- Auditable transactions where multiple parties need decryption access
- Confidential token transfers with compliance features
Core Types
GroupedElGamalCiphertext
A ciphertext with multiple decrypt handles for different recipients.N specifies the number of recipients (decrypt handles).
Methods
GroupedElGamal
Algorithm handle for grouped encryption operations.Methods
GroupedElGamalError
Errors that can occur during grouped ElGamal operations.Usage Examples
Basic Encryption for Multiple Recipients
Deterministic Grouped Encryption
Converting to Regular ElGamal
Serialization and Deserialization
Working with Zero Recipients
Error Handling
Wrong Key at Valid Index
Byte Layout
The serialized format of a grouped ciphertext withN recipients:
(N + 1) * 32 bytes
Examples:
- N=0: 32 bytes (commitment only)
- N=1: 64 bytes
- N=2: 96 bytes
- N=3: 128 bytes
Security Considerations
Recipient Privacy
All recipients share the same commitment, so:- Recipients can verify they received the same encrypted value
- The number of recipients is visible from the ciphertext size
- Each recipient needs the correct index to decrypt
Key-Handle Binding
Each decrypt handle is cryptographically bound to its corresponding public key. Using the wrong secret key at a given index will fail to decrypt correctly.Constant-Time Operations
Thedecrypt_u32 method is not constant-time and may leak information through timing side channels.
Index Management
Callers must track which index corresponds to which recipient. Using the wrong index will result in decryption failure.Practical Considerations
Space Efficiency
Compared to individual ElGamal ciphertexts:- Individual:
N * 64bytes (N separate ciphertexts) - Grouped:
(N + 1) * 32bytes - Savings:
32 * (N - 1)bytes
- Individual: 192 bytes
- Grouped: 128 bytes
- Savings: 64 bytes (33%)
When to Use Grouped ElGamal
Use grouped ElGamal when:- Multiple parties need to decrypt the same value
- Space efficiency is important
- All recipients should be able to verify they received the same encrypted value
- Recipients should not know about each other
- Different values need to be sent to different recipients
- Maximum privacy is required