A workspace containing Poseidon hash implementations for different use cases, built on top of plonky3 field arithmetic.
This workspace contains two crates:
Pure Rust implementation of the Poseidon hash function without any external dependencies beyond plonky3 and plonky2.
- No-std compatible: Works in embedded and constrained environments
- Pure cryptography: No blockchain or Substrate-specific dependencies
- Circuit-compatible: Padding behavior matches zero-knowledge circuit implementations
- NOT CONSTANT TIME: Poseidon2 implementation could reveal hash inputs via timing attacks
Substrate-compatible wrapper that adds codec traits and blockchain-specific functionality.
- Substrate integration: Implements required traits for use in Substrate/Polkadot projects
- Codec support: Implements
Encode,Decode, andTypeInfotraits - Serde support: Optional serialization support
- Storage hashing: Specialized functions for Quantus storage operations
See respective README.md and README.md for more details.
The implementation is optimized for:
- Circuit compatibility (consistent padding)
- No-std environments
- Deterministic behavior across platforms
- Memory efficiency in constrained environments
- Implements the standard Poseidon2 permutation
- Constants are verifiably random, based on pi and ChaCha20
- Circuit-compatible padding
- Variable length padding consistent with original paper
- Code is roughly constant time, as indicated by dudect t-scores < 5. There are no branches in the processing of blocks, so we do not expect any side-channel attacks to reveal the contents of the preimage. There is a small amount of branching in the padding functions, but this should only depend on the length of the input, not the contents.
MIT-0
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Ensure all tests pass
- Submit a pull request
qp-poseidon-core- The underlying pure cryptographic implementationparity-scale-codec- Substrate's encoding libraryqp-zk-circuits- The underlying zero-knowledge circuit libraryplonky3- The underlying field arithmetic library