qp-poseidon
A Poseidon hash implementation for the Substrate/Polkadot ecosystem using plonky2 field arithmetic.
Overview
This crate provides a Poseidon hash function implementation that integrates with Substrate's hashing traits and storage systems. It uses Goldilocks field arithmetic from plonky2 for efficient cryptographic operations.
Features
- Substrate Integration: Implements
sp_core::Hasherandsp_runtime::traits::Hashtraits - Efficient Field Arithmetic: Uses plonky2's Goldilocks field for optimal performance
- Trie Support: Compatible with Substrate's trie storage systems (V0 and V1 layouts)
- No-std Support: Can be used in no-std environments
- Serde Support: Optional serialization support
Usage
Add this to your Cargo.toml:
[]
= "0.0.1"
Basic Hashing
use PoseidonHasher;
use Hasher;
let data = b"hello world";
let hash = hash;
println!;
As Substrate Hash Function
use PoseidonHasher;
use Hash;
let data = b"substrate data";
let hash = hash;
Field Element Operations
use ;
let data = b"some data";
let field_elements = injective_bytes_to_felts;
let hash = hash_no_pad;
Features
std(default): Enables standard library supportserde: Enables serialization support for types
License
This project is licensed under the MIT-0 License.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.