arnaucube
arnaucube/miden-cryptoPublic Self-hosted repository
miden-crypto/src/rand/mod.rs
src/rand/mod.rsRaw
 1//! Pseudo-random element generation.
 2
 3use rand::RngCore;
 4pub use winter_crypto::{DefaultRandomCoin as WinterRandomCoin, RandomCoin, RandomCoinError};
 5pub use winter_utils::Randomizable;
 6
 7use crate::{Felt, FieldElement, Word, ZERO};
 8
 9mod rpo;
10mod rpx;
11pub use rpo::RpoRandomCoin;
12pub use rpx::RpxRandomCoin;
13
14/// Pseudo-random element generator.
15///
16/// An instance can be used to draw, uniformly at random, base field elements as well as [Word]s.
17pub trait FeltRng: RngCore {
18    /// Draw, uniformly at random, a base field element.
19    fn draw_element(&mut self) -> Felt;
20
21    /// Draw, uniformly at random, a [Word].
22    fn draw_word(&mut self) -> Word;
23}