pub struct Hasher<const BODY_SIZE: usize = DEFAULT_BODY_SIZE> { /* private fields */ }Expand description
BMT hasher with configurable body size.
Implementations§
Source§impl<const BODY_SIZE: usize> Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> Hasher<BODY_SIZE>
Sourcepub fn prefix_with(&mut self, prefix: &[u8])
pub fn prefix_with(&mut self, prefix: &[u8])
Add a prefix to the hash calculation.
The prefix is applied to every Keccak256 invocation in the tree (leaf
sections, internal nodes and the final span wrap), matching bee’s
swarm.NewPrefixHasher semantics where Reset() re-writes the prefix as
the first bytes before each node hash. This makes the resulting root
byte-identical to bee’s transformedAddress.
Sourcepub fn with_prefix(prefix: &[u8]) -> Self
pub fn with_prefix(prefix: &[u8]) -> Self
Create a new BMT hasher pre-configured with an anchor prefix.
Equivalent to Hasher::new followed by Hasher::prefix_with. The
prefix is mixed into every node hash (see Hasher::prefix_with), so
the produced root matches bee’s anchor-keyed transformedAddress.
Trait Implementations§
Source§impl<const BODY_SIZE: usize> FixedOutput for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> FixedOutput for Hasher<BODY_SIZE>
Source§fn finalize_into(self, out: &mut Array<u8, Self::OutputSize>)
fn finalize_into(self, out: &mut Array<u8, Self::OutputSize>)
Consume value and write result into provided array.
Source§fn finalize_fixed(self) -> Array<u8, Self::OutputSize>
fn finalize_fixed(self) -> Array<u8, Self::OutputSize>
Retrieve result and consume the hasher instance.
Source§impl<const BODY_SIZE: usize> FixedOutputReset for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> FixedOutputReset for Hasher<BODY_SIZE>
Source§fn finalize_into_reset(&mut self, out: &mut Array<u8, Self::OutputSize>)
fn finalize_into_reset(&mut self, out: &mut Array<u8, Self::OutputSize>)
Write result into provided array and reset the hasher state.
Source§fn finalize_fixed_reset(&mut self) -> Array<u8, Self::OutputSize>
fn finalize_fixed_reset(&mut self) -> Array<u8, Self::OutputSize>
Retrieve result and reset the hasher state.
impl<const BODY_SIZE: usize> HashMarker for Hasher<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> OutputSizeUser for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> OutputSizeUser for Hasher<BODY_SIZE>
Source§impl<const BODY_SIZE: usize> Write for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> Write for Hasher<BODY_SIZE>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<const BODY_SIZE: usize> Freeze for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> RefUnwindSafe for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> Send for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> Sync for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> Unpin for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> UnsafeUnpin for Hasher<BODY_SIZE>
impl<const BODY_SIZE: usize> UnwindSafe for Hasher<BODY_SIZE>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D> Digest for D
impl<D> Digest for D
Source§fn new_with_prefix(data: impl AsRef<[u8]>) -> D
fn new_with_prefix(data: impl AsRef<[u8]>) -> D
Create new hasher instance which has processed the provided data.
Source§fn chain_update(self, data: impl AsRef<[u8]>) -> D
fn chain_update(self, data: impl AsRef<[u8]>) -> D
Process input data in a chained manner.
Source§fn finalize(self) -> Array<u8, <D as OutputSizeUser>::OutputSize>
fn finalize(self) -> Array<u8, <D as OutputSizeUser>::OutputSize>
Retrieve result and consume hasher instance.
Source§fn finalize_into(self, out: &mut Array<u8, <D as OutputSizeUser>::OutputSize>)
fn finalize_into(self, out: &mut Array<u8, <D as OutputSizeUser>::OutputSize>)
Write result into provided array and consume the hasher instance.
Source§fn finalize_reset(&mut self) -> Array<u8, <D as OutputSizeUser>::OutputSize>where
D: FixedOutputReset,
fn finalize_reset(&mut self) -> Array<u8, <D as OutputSizeUser>::OutputSize>where
D: FixedOutputReset,
Retrieve result and reset hasher instance.
Source§fn finalize_into_reset(
&mut self,
out: &mut Array<u8, <D as OutputSizeUser>::OutputSize>,
)where
D: FixedOutputReset,
fn finalize_into_reset(
&mut self,
out: &mut Array<u8, <D as OutputSizeUser>::OutputSize>,
)where
D: FixedOutputReset,
Write result into provided array and reset the hasher instance.
Source§fn output_size() -> usize
fn output_size() -> usize
Get output size of the hasher
Source§fn digest(
data: impl AsRef<[u8]>,
) -> Array<u8, <D as OutputSizeUser>::OutputSize>
fn digest( data: impl AsRef<[u8]>, ) -> Array<u8, <D as OutputSizeUser>::OutputSize>
Compute hash of
data.Source§impl<D> DynDigest for D
impl<D> DynDigest for D
Source§fn finalize_into(self, buf: &mut [u8]) -> Result<(), InvalidBufferSize>
fn finalize_into(self, buf: &mut [u8]) -> Result<(), InvalidBufferSize>
Write result into provided array and consume the hasher instance. Read more
Source§fn finalize_into_reset(
&mut self,
buf: &mut [u8],
) -> Result<(), InvalidBufferSize>
fn finalize_into_reset( &mut self, buf: &mut [u8], ) -> Result<(), InvalidBufferSize>
Write result into provided array and reset the hasher instance. Read more
Source§fn output_size(&self) -> usize
fn output_size(&self) -> usize
Get output size of the hasher
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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