Struct SHA256Commitment

Source
pub struct SHA256Commitment<'a, T: 'a + Serialize> { /* private fields */ }
Expand description

An implementation of the Hash Commitment Scheme using the SHA256 hash function.

We store the party’s secret and random number as references because we don’t want to take ownership over those variables and avoid useless copies (we only perform read operations with them).

We use lifetime annotations as we need to store references to existing variables in our structure, so that an instance of SHA256Commitment can not outlive the references it holds.

Implementations§

Source§

impl<'a, T: 'a + Serialize> SHA256Commitment<'a, T>

Source

pub fn new(s: &'a T, r: &'a [u8]) -> SHA256Commitment<'a, T>

Creates a new party for the SHA256 Commitment Scheme using its secret and random number.

Trait Implementations§

Source§

impl<'a, T: 'a + Serialize> HashCommitmentScheme<T> for SHA256Commitment<'a, T>

Source§

fn commit(&self) -> Result<Vec<u8>>

Creates the commitment used during the commit phase.

Source§

fn verify(&self, com: &[u8], s: &T, r: &[u8]) -> Result<bool>

Creates the expected commitment using the prover’s secret and random number. Then, compares the expected commitment with the prover’s one to verify if the commitment holds.

Auto Trait Implementations§

§

impl<'a, T> Freeze for SHA256Commitment<'a, T>

§

impl<'a, T> RefUnwindSafe for SHA256Commitment<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for SHA256Commitment<'a, T>
where T: Sync,

§

impl<'a, T> Sync for SHA256Commitment<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for SHA256Commitment<'a, T>

§

impl<'a, T> UnwindSafe for SHA256Commitment<'a, T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.