#substrate #quantus-network #poseidon-hash #hash-functions #cryptography #poseidon

no-std qp-poseidon

Poseidon hash implementation for Substrate/Polkadot ecosystem using plonky3 field arithmetic

5 releases (1 stable)

new 1.0.1 Oct 30, 2025
0.9.5 Sep 24, 2025
0.9.4 Sep 24, 2025
0.9.3 Sep 23, 2025
0.9.1 Sep 4, 2025

#79 in Magic Beans

Download history 268/week @ 2025-09-03 216/week @ 2025-09-10 332/week @ 2025-09-17 700/week @ 2025-09-24 101/week @ 2025-10-01 152/week @ 2025-10-08 84/week @ 2025-10-15 106/week @ 2025-10-22

495 downloads per month
Used in 2 crates

MIT-0 license

88KB
1.5K SLoC

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, and TypeInfo traits from parity-scale-codec
  • Serde support: Optional serialization support via the serde feature
  • 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:

[dependencies]
qp-poseidon = { path = "path/to/qp-poseidon/crates/substrate" }

Basic Hashing

use qp_poseidon::PoseidonHasher;

// Hash bytes with circuit-compatible padding
let data = b"hello world";
let hash = PoseidonHasher::hash_padded(data);
println!("Hash: {:?}", hash);

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 qp_poseidon::PoseidonHasher;
use frame_support::pallet_prelude::*;

#[pallet::config]
pub trait Config: frame_system::Config {
    type Hasher: sp_runtime::traits::Hash<Output = sp_core::H256>;
}

// Use PoseidonHasher as the pallet's hasher
impl pallet::Config for Runtime {
    type Hasher = PoseidonHasher;
}

Dependencies

~26–41MB
~638K SLoC