Skip to main content

TranscriptGadget

Trait TranscriptGadget 

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

Source

type Config: Clone

TranscriptGadget::Config is the configuration for the underlying hash function of the transcript gadget.

Source

type Widget: Transcript<F, Gadget = Self>

TranscriptGadget::Widget points to the out-of-circuit widget for this transcript gadget.

Required Methods§

Source

fn new(config: Self::Config) -> Self

TranscriptGadget::new creates a new transcript / sponge variable under the given configuration config.

Source

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.

Source

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§

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Implementations on Foreign Types§

Source§

impl<F: PrimeField> TranscriptGadget<F> for PoseidonSpongeVar<F>

Source§

type Config = PoseidonConfig<F>

Source§

type Widget = PoseidonSponge<F>

Source§

fn new(config: PoseidonConfig<F>) -> Self
where Self: Sized,

Source§

fn add<A: AbsorbableVar<F>>( &mut self, input: &A, ) -> Result<&mut Self, SynthesisError>

Source§

fn get_field_elements( &mut self, num_elements: usize, ) -> Result<Vec<FpVar<F>>, SynthesisError>

Implementors§