pub struct Poseidon<F: PrimeField> { /* private fields */ }
Expand description
A stateful sponge performing Poseidon hash computation.
Implementations§
Source§impl<F: PrimeField> Poseidon<F>
impl<F: PrimeField> Poseidon<F>
Sourcepub fn new(params: PoseidonParameters<F>) -> Self
pub fn new(params: PoseidonParameters<F>) -> Self
Returns a new Poseidon hasher based on the given parameters.
Optionally, a domain tag can be provided. If it is not provided, it will be set to zero.
Source§impl<F: PrimeField> Poseidon<F>
impl<F: PrimeField> Poseidon<F>
pub fn new_circom(nr_inputs: usize) -> Result<Poseidon<Fr>, PoseidonError>
pub fn with_domain_tag_circom( nr_inputs: usize, domain_tag: Fr, ) -> Result<Poseidon<Fr>, PoseidonError>
Trait Implementations§
Source§impl<F: PrimeField> PoseidonBytesHasher for Poseidon<F>
impl<F: PrimeField> PoseidonBytesHasher for Poseidon<F>
Source§fn hash_bytes_le(&mut self, inputs: &[&[u8]]) -> Result<[u8; 32], PoseidonError>
fn hash_bytes_le(&mut self, inputs: &[&[u8]]) -> Result<[u8; 32], PoseidonError>
Calculates a Poseidon hash for the given input of little-endian byte
slices and returns the result as a byte array. Read more
Source§fn hash_bytes_be(&mut self, inputs: &[&[u8]]) -> Result<[u8; 32], PoseidonError>
fn hash_bytes_be(&mut self, inputs: &[&[u8]]) -> Result<[u8; 32], PoseidonError>
Calculates a Poseidon hash for the given input of big-endian byte slices
and returns the result as a byte array. Read more
Source§impl<F: PrimeField> PoseidonHasher<F> for Poseidon<F>
impl<F: PrimeField> PoseidonHasher<F> for Poseidon<F>
Auto Trait Implementations§
impl<F> Freeze for Poseidon<F>where
F: Freeze,
impl<F> RefUnwindSafe for Poseidon<F>where
F: RefUnwindSafe,
impl<F> Send for Poseidon<F>
impl<F> Sync for Poseidon<F>
impl<F> Unpin for Poseidon<F>where
F: Unpin,
impl<F> UnwindSafe for Poseidon<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more