qp-poseidon
Substrate-compatible Poseidon hash implementation for the Polkadot ecosystem. This crate wraps qp-poseidon-core and adds Substrate-specific functionality including codec traits and specialized storage operations.
Features
- Substrate integration: Implements required traits for use in Substrate/Polkadot projects
- Codec support: Implements
Encode,Decode, andTypeInfotraits fromparity-scale-codec - Serde support: Optional serialization support via the
serdefeature - Storage hashing: Specialized functions for Quantus Network storage operations
- Circuit compatibility: Maintains compatibility with zero-knowledge circuit implementations
- No-std support: Works in constrained environments
Usage
Add this to your Cargo.toml:
[]
= { = "path/to/qp-poseidon/crates/substrate" }
Basic Hashing
use PoseidonHasher;
// Hash bytes with circuit-compatible padding
let data = b"hello world";
let hash = hash_padded;
println!;
Performance
- Optimized for Substrate's encoding/decoding patterns
- Maintains deterministic behavior across different platforms
- Memory efficient for blockchain storage operations
- Circuit-compatible padding ensures consistency with ZK proofs
Security
- Built on
qp-poseidon-core's security guarantees - Uses standard Substrate codec patterns
- Specialized storage hashing prevents collision attacks
Integration
use PoseidonHasher;
use *;
// Use PoseidonHasher as the pallet's hasher
Related Crates
qp-poseidon-core- The underlying pure cryptographic implementationparity-scale-codec- Substrate's encoding libraryplonky3- The underlying field arithmetic library