| Crates.io | qp-poseidon-core |
| lib.rs | qp-poseidon-core |
| version | 1.0.7 |
| created_at | 2025-09-23 04:03:31.087612+00 |
| updated_at | 2026-01-19 08:25:25.965199+00 |
| description | Poseidon2 hash core over Goldilocks with a Plonky2/Plonky3-agnostic compatibility layer |
| homepage | https://quantus.com |
| repository | https://github.com/Quantus-Network/qp-poseidon |
| max_upload_size | |
| id | 1850982 |
| size | 102,652 |
A pure Rust implementation of the Poseidon hash function using plonky3 field arithmetic. This crate provides the core cryptographic functionality without any external dependencies beyond plonky3.
use qp_poseidon_core::PoseidonCore;
// Hash some bytes with padding (recommended for circuit compatibility)
let data = b"hello world";
let hash = PoseidonCore::hash_padded(data);
println!("Hash: {:?}", hash);
// Hash without padding
let hash_no_pad = PoseidonCore::hash_no_pad_bytes(data);
use qp_poseidon_core::{PoseidonCore, injective_bytes_to_felts};
use plonky3::field::goldilocks_field::GoldilocksField;
// Convert bytes to field elements
let data = b"test data";
let felts = injective_bytes_to_felts(data);
// Hash field elements directly
let hash = PoseidonCore::hash_padded_felts(felts);
The crate provides several utility functions for converting between different data types and field elements:
use qp_poseidon_core::{u64_to_felts, u128_to_felts, injective_string_to_felts};
// Convert numbers to field elements
let num_felts = u64_to_felts(12345);
let large_num_felts = u128_to_felts(123456789012345);
// Convert strings to field elements (max 8 bytes)
let string_felts = injective_string_to_felts("hello");
FIELD_ELEMENT_PREIMAGE_PADDING_LEN: usize = 190 - Minimum field elements for circuit-compatible paddingFIELD_ELEMENT_PREIMAGE_PADDING_LEN field elementsqp-poseidon - Substrate-compatible wrapper around this core implementationplonky3 - The underlying field arithmetic and Poseidon implementation