pub struct Poseidon<F: PrimeField> { /* private fields */ }
Expand description

A stateful sponge performing Poseidon hash computation.

Implementations§

source§

impl<F: PrimeField> Poseidon<F>

source

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>

source

pub fn new_circom(nr_inputs: usize) -> Result<Poseidon<Fr>, PoseidonError>

source

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>

source§

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>

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>

source§

fn hash(&mut self, inputs: &[F]) -> Result<F, PoseidonError>

Calculates a Poseidon hash for the given input of prime fields and returns the result as a prime field. Read more

Auto Trait Implementations§

§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V