mirror of
https://github.com/tlsnotary/tlsn.git
synced 2026-01-10 23:28:06 -05:00
add new_with_nonce()
This commit is contained in:
@@ -18,7 +18,7 @@ pub struct Nonce([u8; 32]);
|
||||
|
||||
impl Nonce {
|
||||
/// Creates a random 32 byte nonce
|
||||
pub fn random() -> Self {
|
||||
fn random() -> Self {
|
||||
Self(thread_rng().gen())
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new decommitment with the provided nonce
|
||||
pub fn new_with_nonce(data: T, nonce: Nonce) -> Self {
|
||||
Self { nonce, data }
|
||||
}
|
||||
|
||||
/// Creates a hash commitment
|
||||
pub fn commit(&self) -> Hash {
|
||||
self.hash()
|
||||
@@ -64,6 +69,11 @@ where
|
||||
&self.data
|
||||
}
|
||||
|
||||
/// Returns the nonce
|
||||
pub fn nonce(&self) -> &Nonce {
|
||||
&self.nonce
|
||||
}
|
||||
|
||||
/// Returns the data
|
||||
pub fn into_inner(self) -> T {
|
||||
self.data
|
||||
|
||||
Reference in New Issue
Block a user