Skip to main content

BatchHasher

Struct BatchHasher 

Source
pub struct BatchHasher<B: RawEncodingBuf> { /* private fields */ }
👎Deprecated:

bee-crypto will not be supported in future versions. You can use functions from iota-crypto instead.

Expand description

A hasher that can process several inputs at the same time in batches.

This hasher works by interleaving the trits of the inputs in each batch and hashing this interleaved representation. It is also able to fall back to the regular CurlP algorithm if required.

Implementations§

Source§

impl<B> BatchHasher<B>
where B: RawEncodingBuf, B::Slice: RawEncoding<Trit = Btrit>,

Source

pub fn new(input_length: usize, rounds: CurlPRounds) -> Self

👎Deprecated:

bee-crypto will not be supported in future versions. You can use functions from iota-crypto instead.

Create a new hasher.

It requires the length of the input, the length of the output hash and the number of rounds.

Source

pub fn add(&mut self, input: TritBuf<B>)

👎Deprecated:

bee-crypto will not be supported in future versions. You can use functions from iota-crypto instead.

Add a new input to the batch.

It panics if the size of the batch exceeds BATCH_SIZE or if input.len() is not equal to the input_length parameter of the constructor.

Source

pub fn len(&self) -> usize

👎Deprecated:

bee-crypto will not be supported in future versions. You can use functions from iota-crypto instead.

Return the length of the current batch.

Source

pub fn is_empty(&self) -> bool

👎Deprecated:

bee-crypto will not be supported in future versions. You can use functions from iota-crypto instead.

Check if the current batch is empty.

Source

pub fn hash_batched(&mut self) -> impl Iterator<Item = TritBuf> + '_

👎Deprecated:

bee-crypto will not be supported in future versions. You can use functions from iota-crypto instead.

Hash the received inputs using the batched version of CurlP.

This function also takes care of cleaning the buffers of the struct and resetting the batched CurlP hasher so it can be called at any time.

Source

pub fn hash_unbatched(&mut self) -> impl Iterator<Item = TritBuf> + '_

👎Deprecated:

bee-crypto will not be supported in future versions. You can use functions from iota-crypto instead.

Hash the received inputs using the regular version of CurlP.

In particular this function does not use the bct_inputs and bct_hashes buffers, takes care of cleaning the trit_inputs buffer and resets the regular CurlP hasher so it can be called at any time.

Auto Trait Implementations§

§

impl<B> Freeze for BatchHasher<B>

§

impl<B> RefUnwindSafe for BatchHasher<B>
where B: RefUnwindSafe,

§

impl<B> Send for BatchHasher<B>
where B: Send,

§

impl<B> Sync for BatchHasher<B>
where B: Sync,

§

impl<B> Unpin for BatchHasher<B>
where B: Unpin,

§

impl<B> UnsafeUnpin for BatchHasher<B>

§

impl<B> UnwindSafe for BatchHasher<B>
where B: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.