pub struct Commitment {
pub hash: [u8; 32],
}Expand description
A commitment: hash of (randomness || value).
Fields§
§hash: [u8; 32]32-byte SHA-256 hash.
Implementations§
Source§impl Commitment
impl Commitment
Sourcepub fn create(value: &[u8]) -> (Self, Decommitment)
pub fn create(value: &[u8]) -> (Self, Decommitment)
Create a commitment to value with fresh randomness.
Returns (commitment, decommitment).
Sourcepub fn create_with_randomness(
value: &[u8],
randomness: [u8; 32],
) -> (Self, Decommitment)
pub fn create_with_randomness( value: &[u8], randomness: [u8; 32], ) -> (Self, Decommitment)
Create a commitment with explicit randomness (for testing or deterministic protocols).
Sourcepub fn verify(&self, decommitment: &Decommitment) -> bool
pub fn verify(&self, decommitment: &Decommitment) -> bool
Verify a decommitment against this commitment.
Trait Implementations§
Source§impl Clone for Commitment
impl Clone for Commitment
Source§fn clone(&self) -> Commitment
fn clone(&self) -> Commitment
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Commitment
impl Debug for Commitment
Source§impl<'de> Deserialize<'de> for Commitment
impl<'de> Deserialize<'de> for Commitment
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Commitment
Source§impl Hash for Commitment
impl Hash for Commitment
Source§impl PartialEq for Commitment
impl PartialEq for Commitment
Source§fn eq(&self, other: &Commitment) -> bool
fn eq(&self, other: &Commitment) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for Commitment
impl Serialize for Commitment
impl StructuralPartialEq for Commitment
Auto Trait Implementations§
impl Freeze for Commitment
impl RefUnwindSafe for Commitment
impl Send for Commitment
impl Sync for Commitment
impl Unpin for Commitment
impl UnsafeUnpin for Commitment
impl UnwindSafe for Commitment
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