UniformGrindingChallenger

Trait UniformGrindingChallenger 

Source
pub trait UniformGrindingChallenger: GrindingChallenger + CanSampleUniformBits<Self::Witness> {
    // Required methods
    fn grind_uniform(&mut self, bits: usize) -> Self::Witness;
    fn grind_uniform_may_error(&mut self, bits: usize) -> Self::Witness;

    // Provided methods
    fn check_witness_uniform(
        &mut self,
        bits: usize,
        witness: Self::Witness,
    ) -> bool { ... }
    fn check_witness_uniform_may_error(
        &mut self,
        bits: usize,
        witness: Self::Witness,
    ) -> bool { ... }
}
Expand description

Trait for challengers that support proof-of-work (PoW) grinding with guaranteed uniformly sampled bits.

Required Methods§

Source

fn grind_uniform(&mut self, bits: usize) -> Self::Witness

Grinds based on uniformly sampled bits. This variant is allowed to do rejection sampling if a value is sampled that would violate our uniformity requirement (chance of about 1/P).

Use this together with check_witness_uniform.

Source

fn grind_uniform_may_error(&mut self, bits: usize) -> Self::Witness

Grinds based on uniformly sampled bits. This variant errors if a value is sampled, which would violate our uniformity requirement (chance of about 1/P). See the UniformSamplingField trait implemented for each field for details.

Use this together with check_witness_uniform_may_error.

Provided Methods§

Source

fn check_witness_uniform(&mut self, bits: usize, witness: Self::Witness) -> bool

Check whether a given witness satisfies the PoW condition.

After absorbing the witness, the challenger samples bits random bits uniformly and verifies that all bits sampled are zero. The uniform sampling implies we do rejection sampling in about ~1/P cases.

Returns true if the witness passes the PoW check, false otherwise.

Source

fn check_witness_uniform_may_error( &mut self, bits: usize, witness: Self::Witness, ) -> bool

Check whether a given witness satisfies the PoW condition.

After absorbing the witness, the challenger samples bits random bits uniformly and verifies that all bits sampled are zero. In about ~1/P cases this function may error if a sampled value lies outside a range in which we can guarantee uniform bits.

Returns true if the witness passes the PoW check, false otherwise.

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.

Implementors§

Source§

impl<F, P, const WIDTH: usize, const RATE: usize> UniformGrindingChallenger for DuplexChallenger<F, P, WIDTH, RATE>