add new_with_nonce()

This commit is contained in:
themighty1
2023-05-12 15:29:16 +03:00
parent afc1f52221
commit cf280e14ab

View File

@@ -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