pub struct CanonicalHasher { /* private fields */ }Expand description
A canonical, order-stable SHA-256 sealer. Build a preimage from labelled fields, then finalize.
Implementations§
Source§impl CanonicalHasher
impl CanonicalHasher
pub fn new() -> Self
Sourcepub fn field(&mut self, label: &str, bytes: &[u8]) -> &mut Self
pub fn field(&mut self, label: &str, bytes: &[u8]) -> &mut Self
Absorb a labelled byte field. Both label and value are length-prefixed (little-endian u64) so no two
distinct (label, value) sequences can collide by concatenation.
Sourcepub fn u64(&mut self, label: &str, v: u64) -> &mut Self
pub fn u64(&mut self, label: &str, v: u64) -> &mut Self
Absorb a labelled u64 (8 bytes little-endian).
Sourcepub fn hash32(&mut self, label: &str, h: &[u8; 32]) -> &mut Self
pub fn hash32(&mut self, label: &str, h: &[u8; 32]) -> &mut Self
Absorb a labelled 32-byte digest.
Sourcepub fn finalize_hex(self) -> String
pub fn finalize_hex(self) -> String
Finalise to a 64-char lowercase hex digest.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CanonicalHasher
impl RefUnwindSafe for CanonicalHasher
impl Send for CanonicalHasher
impl Sync for CanonicalHasher
impl Unpin for CanonicalHasher
impl UnsafeUnpin for CanonicalHasher
impl UnwindSafe for CanonicalHasher
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