Skip to content

Commit

Permalink
add basic trait impl to Merlin and IOPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
alxiong committed Jan 5, 2025
1 parent 8a68d70 commit 28a2bc4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions nimue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = "BSD-3-Clause"
zeroize = { version = "1.6.0", features = ["zeroize_derive"] }
rand = { version = "0.8", features = ["getrandom"] }
digest = "^0.10.7"
serde = "^1.0"
# used as default hasher for the prover
keccak = { version = "0.1.4"}
log = "0.4.20"
Expand Down
3 changes: 2 additions & 1 deletion nimue/src/iopattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::marker::PhantomData;

use super::errors::IOPatternError;
use super::hash::{DuplexHash, Unit};
use serde::{Deserialize, Serialize};

/// This is the separator between operations in the IO Pattern
/// and as such is the only forbidden character in labels.
Expand All @@ -34,7 +35,7 @@ const SEP_BYTE: &str = "\0";
/// The struct [`IOPattern`] guarantees the creation of a valid IO Pattern string, whose lengths are coherent with the types described in the protocol. No information about the types themselves is stored in an IO Pattern.
/// This means that [`Merlin`][`crate::Merlin`] or [`Arthur`][`crate::Arthur`] instances can generate successfully a protocol transcript respecting the length constraint but not the types. See [issue #6](https://github.com/arkworks-rs/nimue/issues/6) for a discussion on the topic.
#[derive(Clone)]
#[derive(Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct IOPattern<H = crate::DefaultHash, U = u8>
where
U: Unit,
Expand Down
2 changes: 2 additions & 0 deletions nimue/src/merlin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use super::{DefaultHash, DefaultRng, IOPatternError};
/// it is seeded by a cryptographic random number generator (by default, [`rand::rngs::OsRng`]).
///
/// Every time the prover's sponge is squeeze, the state of the sponge is ratcheted, so that it can't be inverted and the randomness recovered.
#[derive(Clone)]
pub(crate) struct ProverRng<R: RngCore + CryptoRng> {
/// The sponge that is used to generate the random coins.
pub(crate) sponge: Keccak,
Expand Down Expand Up @@ -88,6 +89,7 @@ where
/// Unless otherwise specified,
/// [`Merlin`] is set to work over bytes with [`DefaultHash`] and
/// rely on the default random number generator [`DefaultRng`].
#[derive(Clone)]
pub struct Merlin<H = DefaultHash, U = u8, R = DefaultRng>
where
U: Unit,
Expand Down

0 comments on commit 28a2bc4

Please sign in to comment.