Struct nimue::IOPattern

source ·
pub struct IOPattern<H = DefaultHash, U = u8>
where U: Unit, H: DuplexHash<U>,
{ /* private fields */ }
Expand description

The IO Pattern of an interactive protocol.

An IO pattern is a string that specifies the protocol in a simple, non-ambiguous, human-readable format. A typical example is the following:

    domain-separator A32generator A32public-key R A32commitment S32challenge A32response

The domain-separator is a user-specified string uniquely identifying the end-user application (to avoid cross-protocol attacks). The letter A indicates the absorption of a public input (an ABSORB), while the letter S indicates the squeezing (a SQUEEZE) of a challenge. The letter R indicates a ratcheting operation: ratcheting means invoking the hash function even on an incomplete block. It provides forward secrecy and allows it to start from a clean rate. After the operation type, is the number of elements in base 10 that are being absorbed/squeezed. Then, follows the label associated with the element being absorbed/squeezed. This often comes from the underlying description of the protocol. The label cannot start with a digit or contain the NULL byte.

§Guarantees

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 Arthur or Merlin instances can generate successfully a protocol transcript respecting the length constraint but not the types. See issue #6 for a discussion on the topic.

Implementations§

source§

impl<H: DuplexHash<U>, U: Unit> IOPattern<H, U>

source

pub fn new(domsep: &str) -> Self

Create a new IOPattern with the domain separator.

source

pub fn absorb(self, count: usize, label: &str) -> Self

Absorb count native elements.

source

pub fn squeeze(self, count: usize, label: &str) -> Self

Squeeze count native elements.

source

pub fn ratchet(self) -> Self

Ratchet the state.

source

pub fn as_bytes(&self) -> &[u8]

Return the IO Pattern as bytes.

source

pub fn to_arthur(&self) -> Arthur<H, U, DefaultRng>

Create an crate::Arthur instance from the IO Pattern.

source

pub fn to_merlin<'a>(&self, transcript: &'a [u8]) -> Merlin<'a, H, U>

Create a crate::Merlin instance from the IO Pattern and the protocol transcript (bytes).

Trait Implementations§

source§

impl<H: DuplexHash> ByteIOPattern for IOPattern<H>

source§

fn add_bytes(self, count: usize, label: &str) -> Self

source§

fn challenge_bytes(self, count: usize, label: &str) -> Self

source§

impl<C, H, const N: usize> ByteIOPattern for IOPattern<H, Fp<C, N>>
where C: FpConfig<N>, H: DuplexHash<Fp<C, N>>,

source§

fn add_bytes(self, count: usize, label: &str) -> Self

source§

fn challenge_bytes(self, count: usize, label: &str) -> Self

source§

impl<H, U> Clone for IOPattern<H, U>
where U: Unit + Clone, H: DuplexHash<U> + Clone,

source§

fn clone(&self) -> IOPattern<H, U>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<U: Unit, H: DuplexHash<U>> Debug for IOPattern<H, U>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<F, H> FieldIOPattern<F> for IOPattern<H>
where F: PrimeField, H: DuplexHash,

source§

fn add_scalars(self, count: usize, label: &str) -> Self

source§

fn challenge_scalars(self, count: usize, label: &str) -> Self

source§

impl<F, H> FieldIOPattern<F> for IOPattern<H>
where F: PrimeField, H: DuplexHash,

source§

fn add_scalars(self, count: usize, label: &str) -> Self

source§

fn challenge_scalars(self, count: usize, label: &str) -> Self

source§

impl<C, H, const N: usize> FieldIOPattern<Fp<C, N>> for IOPattern<H, Fp<C, N>>
where C: FpConfig<N>, H: DuplexHash<Fp<C, N>>,

source§

fn add_scalars(self, count: usize, label: &str) -> Self

source§

fn challenge_scalars(self, count: usize, label: &str) -> Self

source§

impl<G, H> GroupIOPattern<G> for IOPattern<H>
where G: Group + GroupEncoding, G::Repr: AsRef<[u8]>, H: DuplexHash,

source§

fn add_points(self, count: usize, label: &str) -> Self

source§

impl<G, H> GroupIOPattern<G> for IOPattern<H>
where G: CurveGroup, H: DuplexHash,

source§

fn add_points(self, count: usize, label: &str) -> Self

source§

impl<G, H, C, const N: usize> GroupIOPattern<G> for IOPattern<H, Fp<C, N>>
where G: CurveGroup<BaseField = Fp<C, N>>, H: DuplexHash<Fp<C, N>>, C: FpConfig<N>, IOPattern<H, Fp<C, N>>: FieldIOPattern<Fp<C, N>>,

source§

fn add_points(self, count: usize, label: &str) -> Self

Auto Trait Implementations§

§

impl<H, U> RefUnwindSafe for IOPattern<H, U>

§

impl<H, U> Send for IOPattern<H, U>
where H: Send, U: Send,

§

impl<H, U> Sync for IOPattern<H, U>
where H: Sync, U: Sync,

§

impl<H, U> Unpin for IOPattern<H, U>
where H: Unpin, U: Unpin,

§

impl<H, U> UnwindSafe for IOPattern<H, U>
where H: UnwindSafe, U: UnwindSafe,

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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V