Struct massa_hash::HashXof
source · pub struct HashXof<const SIZE: usize>(pub [u8; SIZE]);
Expand description
Extended Hash
Tuple Fields§
§0: [u8; SIZE]
Implementations§
source§impl<const SIZE: usize> HashXof<SIZE>
impl<const SIZE: usize> HashXof<SIZE>
sourcepub fn from_bytes(bytes: &[u8; SIZE]) -> Self
pub fn from_bytes(bytes: &[u8; SIZE]) -> Self
From bytes
sourcepub fn compute_from(data: &[u8]) -> HashXof<SIZE>
pub fn compute_from(data: &[u8]) -> HashXof<SIZE>
Compute from raw data
sourcepub fn compute_from_tuple(data: &[&[u8]]) -> Self
pub fn compute_from_tuple(data: &[&[u8]]) -> Self
Compute from tuple of byte arrays
sourcepub fn to_bs58_check(&self) -> String
pub fn to_bs58_check(&self) -> String
Serialize a Hash using bs58
encoding with checksum.
Motivations for using base58 encoding:
base58_check is like base64 but-
- fully standardized (no = vs /)
- no weird characters (eg. +) only alphanumeric
- ambiguous letters combined (eg. O vs 0, or l vs 1)
- contains a checksum at the end to detect typing errors
Trait Implementations§
source§impl<const SIZE: usize> BitXorAssign for HashXof<SIZE>
impl<const SIZE: usize> BitXorAssign for HashXof<SIZE>
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
Performs the
^=
operation. Read moresource§impl<const SIZE: usize> Deserializer<HashXof<SIZE>> for HashXofDeserializer
impl<const SIZE: usize> Deserializer<HashXof<SIZE>> for HashXofDeserializer
source§fn deserialize<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>>(
&self,
buffer: &'a [u8],
) -> IResult<&'a [u8], HashXof<SIZE>, E>
fn deserialize<'a, E: ParseError<&'a [u8]> + ContextError<&'a [u8]>>( &self, buffer: &'a [u8], ) -> IResult<&'a [u8], HashXof<SIZE>, E>
§Example
use massa_hash::{HashXof, HASH_XOF_SIZE_BYTES, HashXofDeserializer};
use massa_serialization::{Serializer, Deserializer, DeserializeError};
let hash_deserializer = HashXofDeserializer::new();
let hash: HashXof<HASH_XOF_SIZE_BYTES> = HashXof::compute_from(&"hello world".as_bytes());
let (rest, deserialized) = hash_deserializer.deserialize::<DeserializeError>(hash.to_bytes()).unwrap();
assert_eq!(deserialized, hash);
assert_eq!(rest.len(), 0);
source§impl<const SIZE: usize> PartialEq for HashXof<SIZE>
impl<const SIZE: usize> PartialEq for HashXof<SIZE>
source§impl<const SIZE: usize> Serializer<HashXof<SIZE>> for HashXofSerializer
impl<const SIZE: usize> Serializer<HashXof<SIZE>> for HashXofSerializer
impl<const SIZE: usize> Copy for HashXof<SIZE>
impl<const SIZE: usize> Eq for HashXof<SIZE>
impl<const SIZE: usize> StructuralPartialEq for HashXof<SIZE>
Auto Trait Implementations§
impl<const SIZE: usize> Freeze for HashXof<SIZE>
impl<const SIZE: usize> RefUnwindSafe for HashXof<SIZE>
impl<const SIZE: usize> Send for HashXof<SIZE>
impl<const SIZE: usize> Sync for HashXof<SIZE>
impl<const SIZE: usize> Unpin for HashXof<SIZE>
impl<const SIZE: usize> UnwindSafe for HashXof<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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)