pub struct Hashlock {
pub hash: [u8; 32],
pub preimage: Vec<u8>,
}Expand description
A hashlock condition requiring SHA-256 preimage verification.
The condition is satisfied when SHA-256(preimage) == hash.
§Example
use sha2::{Digest, Sha256};
use zescrow_core::Condition;
let preimage = b"my-secret-preimage".to_vec();
let hash: [u8; 32] = Sha256::digest(&preimage).into();
let condition = Condition::hashlock(hash, preimage);
assert!(condition.verify().is_ok());Fields§
§hash: [u8; 32]The expected SHA-256 digest of the preimage.
preimage: Vec<u8>Secret preimage as UTF-8 string.
Implementations§
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for Hashlock
impl<'__de, __Context> BorrowDecode<'__de, __Context> for Hashlock
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
impl Eq for Hashlock
impl StructuralPartialEq for Hashlock
Auto Trait Implementations§
impl Freeze for Hashlock
impl RefUnwindSafe for Hashlock
impl Send for Hashlock
impl Sync for Hashlock
impl Unpin for Hashlock
impl UnwindSafe for Hashlock
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