pub struct RpoRandomCoin { /* private fields */ }
Expand description

A simplified version of the SPONGE_PRG reseedable pseudo-random number generator algorithm described in https://eprint.iacr.org/2011/499.pdf. The simplification is related to to the following facts:

  1. A call to the reseed method implies one and only one call to the permutation function. This is possible because in our case we never reseed with more than 4 field elements.
  2. As a result of the previous point, we dont make use of an input buffer to accumulate seed material. It is important to note that the current implementation of RPORandomCoin assumes that draw_integers() is called immediately after reseed_with_int().

Trait Implementations§

source§

impl RandomCoin for RpoRandomCoin

§

type BaseField = BaseElement

Base field for random elements which can be generated by this random coin.
§

type Hasher = Rpo256

Hash function which is used by the random coin to generate random field elements.
source§

fn new(seed: &[Self::BaseField]) -> Self

Returns a new random coin instantiated with the provided seed.
source§

fn reseed(&mut self, data: RpoDigest)

Reseeds the coin with the specified data by setting the new seed to hash(seed || data).
source§

fn reseed_with_int(&mut self, value: u64)

Reseeds the coin with the specified value by setting the new seed to hash(seed || value).
source§

fn leading_zeros(&self) -> u32

Returns the number of leading zeros in the seed if it is interpreted as an integer in big-endian byte order.
source§

fn check_leading_zeros(&self, value: u64) -> u32

Computes hash(seed || value) and returns the number of leading zeros in the resulting value if it is interpreted as an integer in big-endian byte order.
source§

fn draw<E: FieldElement<BaseField = Felt>>( &mut self ) -> Result<E, RandomCoinError>

Returns the next pseudo-random field element. Read more
source§

fn draw_integers( &mut self, num_values: usize, domain_size: usize ) -> Result<Vec<usize>, RandomCoinError>

Returns a vector of unique integers selected from the range [0, domain_size). Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.