pub trait TranscriptGadget<F: PrimeField>: Clone {
type Config: Clone;
type Widget: Transcript<F, Gadget = Self>;
// Required methods
fn new(config: Self::Config) -> Self;
fn add<A: AbsorbableVar<F>>(
&mut self,
input: &A,
) -> Result<&mut Self, SynthesisError>;
fn get_field_elements(
&mut self,
num_elements: usize,
) -> Result<Vec<FpVar<F>>, SynthesisError>;
// Provided methods
fn new_with_pp_hash(
config: Self::Config,
pp_hash: &FpVar<F>,
) -> Result<Self, SynthesisError> { ... }
fn get_bits(
&mut self,
num_bits: usize,
) -> Result<Vec<Boolean<F>>, SynthesisError> { ... }
fn get_field_element(&mut self) -> Result<FpVar<F>, SynthesisError> { ... }
fn separate_domain(&self, domain: &[u8]) -> Result<Self, SynthesisError> { ... }
fn challenge_field_element(&mut self) -> Result<FpVar<F>, SynthesisError> { ... }
fn challenge_bits(
&mut self,
num_bits: usize,
) -> Result<Vec<Boolean<F>>, SynthesisError> { ... }
fn challenge_field_elements(
&mut self,
n: usize,
) -> Result<Vec<FpVar<F>>, SynthesisError> { ... }
}Expand description
TranscriptGadget is the in-circuit gadget for transcripts and sponges.
Required Associated Types§
Sourcetype Config: Clone
type Config: Clone
TranscriptGadget::Config is the configuration for the underlying
hash function of the transcript gadget.
Sourcetype Widget: Transcript<F, Gadget = Self>
type Widget: Transcript<F, Gadget = Self>
TranscriptGadget::Widget points to the out-of-circuit widget for
this transcript gadget.
Required Methods§
Sourcefn new(config: Self::Config) -> Self
fn new(config: Self::Config) -> Self
TranscriptGadget::new creates a new transcript / sponge variable
under the given configuration config.
Sourcefn add<A: AbsorbableVar<F>>(
&mut self,
input: &A,
) -> Result<&mut Self, SynthesisError>
fn add<A: AbsorbableVar<F>>( &mut self, input: &A, ) -> Result<&mut Self, SynthesisError>
TranscriptGadget::add absorbs a message input that can be any type
implementing the AbsorbableVar trait into the transcript / sponge
variable.
Sourcefn get_field_elements(
&mut self,
num_elements: usize,
) -> Result<Vec<FpVar<F>>, SynthesisError>
fn get_field_elements( &mut self, num_elements: usize, ) -> Result<Vec<FpVar<F>>, SynthesisError>
TranscriptGadget::get_field_elements squeezes num_elements field
element variables from the transcript / sponge variable.
Provided Methods§
Sourcefn new_with_pp_hash(
config: Self::Config,
pp_hash: &FpVar<F>,
) -> Result<Self, SynthesisError>
fn new_with_pp_hash( config: Self::Config, pp_hash: &FpVar<F>, ) -> Result<Self, SynthesisError>
TranscriptGadget::new_with_pp_hash is a convenience method for
creating a new transcript / sponge variable under the given
configuration config and additionally absorbing a hash of the public
parameters pp_hash.
Sourcefn get_bits(
&mut self,
num_bits: usize,
) -> Result<Vec<Boolean<F>>, SynthesisError>
fn get_bits( &mut self, num_bits: usize, ) -> Result<Vec<Boolean<F>>, SynthesisError>
TranscriptGadget::get_bits squeezes num_bits bit variables from
the transcript / sponge variable.
Sourcefn get_field_element(&mut self) -> Result<FpVar<F>, SynthesisError>
fn get_field_element(&mut self) -> Result<FpVar<F>, SynthesisError>
TranscriptGadget::get_field_element squeezes a single field element
variable from the transcript / sponge variable.
Sourcefn separate_domain(&self, domain: &[u8]) -> Result<Self, SynthesisError>
fn separate_domain(&self, domain: &[u8]) -> Result<Self, SynthesisError>
TranscriptGadget::separate_domain creates a new transcript / sponge
variable by applying domain separation using the provided domain byte
sequence.
Sourcefn challenge_field_element(&mut self) -> Result<FpVar<F>, SynthesisError>
fn challenge_field_element(&mut self) -> Result<FpVar<F>, SynthesisError>
TranscriptGadget::challenge_field_element squeezes a challenge from
the transcript variable as a field element variable.
Internally, it first squeezes a field element variable and then absorbs it back into the transcript variable to ensure security.
Sourcefn challenge_bits(
&mut self,
num_bits: usize,
) -> Result<Vec<Boolean<F>>, SynthesisError>
fn challenge_bits( &mut self, num_bits: usize, ) -> Result<Vec<Boolean<F>>, SynthesisError>
TranscriptGadget::challenge_bits squeezes a challenge from the
transcript variable as a vector of bit variables.
Internally, it squeezes several field element variables, absorbs them back to the transcript variable (for strong Fiat-Shamir), and decomposes them into bit variables.
Sourcefn challenge_field_elements(
&mut self,
n: usize,
) -> Result<Vec<FpVar<F>>, SynthesisError>
fn challenge_field_elements( &mut self, n: usize, ) -> Result<Vec<FpVar<F>>, SynthesisError>
TranscriptGadget::challenge_field_elements squeezes n challenges
from the transcript variable as field element variables.
Internally, it first squeezes the field element variables and then absorbs them back into the transcript variable to ensure security.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".