Skip to main content

o1_utils/
lib.rs

1//! A collection of utility functions and constants that can be reused from
2//! multiple projects
3
4// Enable unstable `is_multiple_of` on nightly for Wasm builds until nightly is updated
5// See: https://github.com/o1-labs/mina-rust/issues/1997
6#![cfg_attr(target_arch = "wasm32", feature(unsigned_is_multiple_of))]
7#![deny(unsafe_code)]
8#![deny(clippy::all)]
9#![deny(clippy::pedantic)]
10#![deny(clippy::nursery)]
11
12pub mod adjacent_pairs;
13pub mod biguint_helpers;
14pub mod bitwise_operations;
15pub mod chunked_evaluations;
16pub mod chunked_polynomial;
17pub mod dense_polynomial;
18pub mod evaluations;
19pub mod field_helpers;
20pub mod foreign_field;
21pub mod hasher;
22pub mod lazy_cache;
23pub mod math;
24pub mod serialization;
25
26pub use biguint_helpers::BigUintHelpers;
27pub use bitwise_operations::BitwiseOps;
28pub use chunked_evaluations::ChunkedEvaluations;
29pub use dense_polynomial::ExtendedDensePolynomial;
30pub use evaluations::ExtendedEvaluations;
31pub use field_helpers::{BigUintFieldHelpers, FieldHelpers, RandomField, Two};
32pub use foreign_field::ForeignElement;
33
34/// Utils only for testing
35pub mod tests {
36    use rand::{rngs::StdRng, thread_rng, Rng, SeedableRng};
37
38    /// Create a new test rng with a random seed
39    #[must_use]
40    pub fn make_test_rng(seed: Option<[u8; 32]>) -> StdRng {
41        let seed = seed.unwrap_or_else(|| thread_rng().gen());
42        eprintln!("Seed: {seed:?}");
43        StdRng::from_seed(seed)
44    }
45}