pub struct Hasher<const BITS: usize>(/* private fields */);Expand description
handy method to create a hash of given SIZE bit size.
The hash algorithm is Blake2b and the constant parameter is
the number of bits to generate. Good values are 256 or 224 for
Cardano.
§Generate a cryptographic hash with Blake2b 256
The following will generate a 32 bytes digest output
let mut hasher = Hasher::<256>::new();
hasher.input(b"My transaction");
let digest = hasher.finalize();§Generate a cryptographic hash with Blake2b 224
The following will generate a 28 bytes digest output. This is used to generate the hash of public keys for addresses.
let digest = Hasher::<224>::hash(b"My Public Key");Implementations§
Source§impl Hasher<160>
impl Hasher<160>
Sourcepub fn hash(
bytes: &[u8],
) -> Hash<pallas_crypto::::hash::hasher::{impl#2}::hash::{constant#0}>
pub fn hash( bytes: &[u8], ) -> Hash<pallas_crypto::::hash::hasher::{impl#2}::hash::{constant#0}>
convenient function to directly generate the hash
of the given bytes without creating the intermediary
types Hasher and calling Hasher::input.
pub fn hash_tagged( bytes: &[u8], tag: u8, ) -> Hash<pallas_crypto::::hash::hasher::{impl#2}::hash_tagged::{constant#0}>
Sourcepub fn hash_cbor(
data: &impl Encode<()>,
) -> Hash<pallas_crypto::::hash::hasher::{impl#2}::hash_cbor::{constant#0}>
pub fn hash_cbor( data: &impl Encode<()>, ) -> Hash<pallas_crypto::::hash::hasher::{impl#2}::hash_cbor::{constant#0}>
convenient function to directly generate the hash of the given minicbor::Encode data object
pub fn hash_tagged_cbor( data: &impl Encode<()>, tag: u8, ) -> Hash<pallas_crypto::::hash::hasher::{impl#2}::hash_tagged_cbor::{constant#0}>
Source§impl Hasher<224>
impl Hasher<224>
Sourcepub fn hash(
bytes: &[u8],
) -> Hash<pallas_crypto::::hash::hasher::{impl#4}::hash::{constant#0}>
pub fn hash( bytes: &[u8], ) -> Hash<pallas_crypto::::hash::hasher::{impl#4}::hash::{constant#0}>
convenient function to directly generate the hash
of the given bytes without creating the intermediary
types Hasher and calling Hasher::input.
pub fn hash_tagged( bytes: &[u8], tag: u8, ) -> Hash<pallas_crypto::::hash::hasher::{impl#4}::hash_tagged::{constant#0}>
Sourcepub fn hash_cbor(
data: &impl Encode<()>,
) -> Hash<pallas_crypto::::hash::hasher::{impl#4}::hash_cbor::{constant#0}>
pub fn hash_cbor( data: &impl Encode<()>, ) -> Hash<pallas_crypto::::hash::hasher::{impl#4}::hash_cbor::{constant#0}>
convenient function to directly generate the hash of the given minicbor::Encode data object
pub fn hash_tagged_cbor( data: &impl Encode<()>, tag: u8, ) -> Hash<pallas_crypto::::hash::hasher::{impl#4}::hash_tagged_cbor::{constant#0}>
Source§impl Hasher<256>
impl Hasher<256>
Sourcepub fn hash(
bytes: &[u8],
) -> Hash<pallas_crypto::::hash::hasher::{impl#6}::hash::{constant#0}>
pub fn hash( bytes: &[u8], ) -> Hash<pallas_crypto::::hash::hasher::{impl#6}::hash::{constant#0}>
convenient function to directly generate the hash
of the given bytes without creating the intermediary
types Hasher and calling Hasher::input.
pub fn hash_tagged( bytes: &[u8], tag: u8, ) -> Hash<pallas_crypto::::hash::hasher::{impl#6}::hash_tagged::{constant#0}>
Sourcepub fn hash_cbor(
data: &impl Encode<()>,
) -> Hash<pallas_crypto::::hash::hasher::{impl#6}::hash_cbor::{constant#0}>
pub fn hash_cbor( data: &impl Encode<()>, ) -> Hash<pallas_crypto::::hash::hasher::{impl#6}::hash_cbor::{constant#0}>
convenient function to directly generate the hash of the given minicbor::Encode data object
pub fn hash_tagged_cbor( data: &impl Encode<()>, tag: u8, ) -> Hash<pallas_crypto::::hash::hasher::{impl#6}::hash_tagged_cbor::{constant#0}>
Trait Implementations§
Auto Trait Implementations§
impl<const BITS: usize> Freeze for Hasher<BITS>
impl<const BITS: usize> RefUnwindSafe for Hasher<BITS>
impl<const BITS: usize> Send for Hasher<BITS>
impl<const BITS: usize> Sync for Hasher<BITS>
impl<const BITS: usize> Unpin for Hasher<BITS>
impl<const BITS: usize> UnsafeUnpin for Hasher<BITS>
impl<const BITS: usize> UnwindSafe for Hasher<BITS>
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
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>
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>
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