A Rust library providing post-quantum XMSS (eXtended Merkle Signature Scheme) key generation, message signing, and signature verification for Lean Ethereum, the redesigned Ethereum consensus layer.
pq-leansig is a cryptographic library that implements post-quantum secure key and signatures using XMSS with Poseidon hash functions. It provides both a Rust API and C FFI bindings for interoperability with other languages (particularly Go), along with SSZ (Simple Serialize) support for Ethereum compatibility.
This library is designed for use in Lean Ethereum's consensus layer, where quantum-resistant keys and signatures are essential for long-term security.
- Post-Quantum Security: XMSS-based signatures resistant to quantum computer attacks
- Epoch-Based Signing: Support for time-bounded key usage with activation and expiration epochs
- SSZ Serialization: Full support for Ethereum's Simple Serialize format
- FFI Interface: C-compatible API for cross-language integration (Go, C, C++)
- Type Safety: Strongly-typed Rust API with comprehensive error handling
- Optimized Implementation: Uses Poseidon hash with optimized parameters (Lifetime 2^32, Dim 64, Base 8)
Add this to your Cargo.toml:
[dependencies]
pq-leansig = { git = "https://github.com/shaaibu/pq-leansig" }The library provides both a Rust API and C FFI interface for cross-language integration. Key operations include:
- Key generation with epoch parameters
- Message signing with epoch-based validation
- Signature verification
- SSZ serialization and deserialization for all types
LeanSignatureScheme: XMSS instantiation with Poseidon hash (Lifetime 2^32, Dim 64, Base 8)SecretKey: Private key for signing operationsPublicKey: Public key for signature verificationSignature: XMSS signature structureKeypair: Combined public and private key pair
Keys are generated with specific activation and expiration parameters:
activation_epoch: The epoch when the key becomes validnum_active_epochs: Number of epochs the key remains valid
This design enables:
- Time-bounded key validity
- Planned key rotation
- Forward security guarantees
The library provides typed errors for robust error handling:
SigningError: Errors during message signingSignatureVerificationError: Errors during signature verification
- Quantum Resistance: XMSS is a hash-based signature scheme proven secure against quantum attacks
- Stateful Signatures: XMSS requires careful state management - never reuse the same key state
- Epoch Management: Ensure signatures are created and verified with correct epoch values
- Key Lifetime: Plan key rotation according to your
num_active_epochsparameter
- leansig: Core XMSS implementation from Lean Ethereum
- ethereum_ssz: SSZ serialization for Ethereum compatibility
- rand: Cryptographically secure random number generation
- serde: Serialization framework
- thiserror: Error handling utilities
Run the test suite:
cargo testThe library includes comprehensive tests covering key generation, signing, verification, SSZ serialization, FFI interface correctness, and error conditions.
See LICENSE file for details.
For issues, questions, or contributions, please open an issue on the GitHub repository.