pub trait Codec {
type Challenge;
// Required methods
fn new(
protocol_identifier: &[u8],
session_identifier: &[u8],
instance_label: &[u8],
) -> Self;
fn from_iv(iv: [u8; 32]) -> Self;
fn prover_message(&mut self, data: &[u8]);
fn verifier_challenge(&mut self) -> Self::Challenge;
}
Expand description
A trait defining the behavior of a domain-separated codec hashing, which is typically used for crate::traits::SigmaProtocol
s.
A domain-separated hashing codec is a codec, identified by a domain, which is incremented with successive messages (“absorb”). The codec can then output a bit stream of any length, which is typically used to generate a challenge unique to the given codec (“squeeze”). (See Sponge Construction).
The output is deterministic for a given set of input. Thus, both Prover and Verifier can generate the codec on their sides and ensure the same inputs have been used in both side of the protocol.
§Minimal Implementation
Types implementing Codec
must define:
new
prover_message
verifier_challenge
Required Associated Types§
Required Methods§
Sourcefn new(
protocol_identifier: &[u8],
session_identifier: &[u8],
instance_label: &[u8],
) -> Self
fn new( protocol_identifier: &[u8], session_identifier: &[u8], instance_label: &[u8], ) -> Self
Generates an empty codec that can be identified by a domain separator.
Sourcefn from_iv(iv: [u8; 32]) -> Self
fn from_iv(iv: [u8; 32]) -> Self
Allows for precomputed initialization of the codec with a specific IV.
Sourcefn prover_message(&mut self, data: &[u8])
fn prover_message(&mut self, data: &[u8])
Absorbs data into the codec.
Sourcefn verifier_challenge(&mut self) -> Self::Challenge
fn verifier_challenge(&mut self) -> Self::Challenge
Produces a scalar that can be used as a challenge from the codec.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.