Skip to content

Commit

Permalink
chore: Canonicalize use statements
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand committed Aug 19, 2024
1 parent aa340ff commit 920c5db
Show file tree
Hide file tree
Showing 37 changed files with 77 additions and 99 deletions.
1 change: 0 additions & 1 deletion twenty-first/benches/coset_extrapolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/evaluation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::other::random_elements;
use twenty_first::math::zerofier_tree::ZerofierTree;
use twenty_first::prelude::*;
Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/extrapolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::ntt::intt;
use twenty_first::math::other::random_elements;
use twenty_first::math::traits::PrimitiveRootOfUnity;
Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/formal_power_series_inverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/interpolation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::Throughput;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
5 changes: 4 additions & 1 deletion twenty-first/benches/inverses.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;
use itertools::Itertools;
use twenty_first::math::b_field_element::BFieldElement;
use twenty_first::math::other::random_elements;
Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::digest::Digest;
use twenty_first::math::other::random_elements;
use twenty_first::util_types::merkle_tree::CpuParallel;
Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/merkle_tree_auth_structure_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use rand::Rng;
use rand::RngCore;
use rand::SeedableRng;
use twenty_first::math::bfield_codec::BFieldCodec;

use twenty_first::math::tip5::Tip5;
use twenty_first::util_types::algebraic_hasher::AlgebraicHasher;
use twenty_first::util_types::merkle_tree::CpuParallel;
Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/merkle_tree_authenticate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use criterion::*;
use rand::rngs::StdRng;
use rand::*;

use twenty_first::math::digest::Digest;
use twenty_first::math::tip5::Tip5;
use twenty_first::util_types::algebraic_hasher::AlgebraicHasher;
Expand Down
9 changes: 6 additions & 3 deletions twenty-first/benches/ntt_forward.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::measurement::WallTime;
use criterion::{
criterion_group, criterion_main, BenchmarkGroup, BenchmarkId, Criterion, Throughput,
};
use criterion::BenchmarkGroup;
use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::Throughput;
use twenty_first::math::b_field_element::BFieldElement;
use twenty_first::math::ntt::ntt;
use twenty_first::math::other::random_elements;
Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/poly_clean_div.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/poly_mod_reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/poly_mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/poly_scalar_mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;
use rand::random;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/poly_scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;
use rand::random;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/polynomial_coset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::Throughput;

use twenty_first::math::b_field_element::BFieldElement;
use twenty_first::math::other::random_elements;
use twenty_first::math::polynomial::Polynomial;
Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/tip5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use criterion::BenchmarkId;
use criterion::Criterion;
use rand::random;
use rayon::prelude::*;

use twenty_first::math::other::random_elements;
use twenty_first::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/various_muls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use criterion::BenchmarkGroup;
use criterion::BenchmarkId;
use criterion::Criterion;
use criterion::Throughput;

use twenty_first::math::b_field_element::BFieldElement;
use twenty_first::math::other::random_elements;
use twenty_first::math::x_field_element::XFieldElement;
Expand Down
1 change: 0 additions & 1 deletion twenty-first/benches/zerofier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::criterion_group;
use criterion::criterion_main;
use criterion::BenchmarkId;
use criterion::Criterion;

use twenty_first::math::b_field_element::BFieldElement;
use twenty_first::math::other::random_elements;
use twenty_first::math::polynomial::Polynomial;
Expand Down
3 changes: 1 addition & 2 deletions twenty-first/src/amount/u32s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,8 @@ mod u32s_tests {
use rand::Rng;
use rand::RngCore;

use crate::math::other::random_elements;

use super::*;
use crate::math::other::random_elements;

#[test]
fn get_size_test() {
Expand Down
7 changes: 3 additions & 4 deletions twenty-first/src/math/b_field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ use serde::Deserializer;
use serde::Serialize;
use serde::Serializer;

use super::traits::Inverse;
use super::traits::PrimitiveRootOfUnity;
use super::x_field_element::XFieldElement;
use crate::error::ParseBFieldElementError;
use crate::math::traits::CyclicGroupGenerator;
use crate::math::traits::FiniteField;
use crate::math::traits::ModPowU32;
use crate::math::traits::ModPowU64;

use super::traits::Inverse;
use super::traits::PrimitiveRootOfUnity;
use super::x_field_element::XFieldElement;

const PRIMITIVE_ROOTS: phf::Map<u64, u64> = phf_map! {
0u64 => 1,
1u64 => 1,
Expand Down
9 changes: 3 additions & 6 deletions twenty-first/src/math/bfield_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ use num_traits::ConstOne;
use num_traits::ConstZero;
use thiserror::Error;

use crate::bfe_vec;

use super::b_field_element::BFieldElement;
use super::polynomial::Polynomial;
use super::traits::FiniteField;
use crate::bfe_vec;

/// This trait provides functions for encoding to and decoding from a Vec of [BFieldElement]s.
/// This encoding does not record the size of objects nor their type information; this is
Expand Down Expand Up @@ -547,9 +546,8 @@ mod tests {
use proptest_arbitrary_interop::arb;
use test_strategy::proptest;

use crate::prelude::*;

use super::*;
use crate::prelude::*;

#[derive(Debug, PartialEq, Eq, test_strategy::Arbitrary)]
struct BFieldCodecPropertyTestData<T>
Expand Down Expand Up @@ -834,15 +832,14 @@ mod tests {
use arbitrary::Arbitrary;
use num_traits::Zero;

use super::*;
use crate::math::digest::Digest;
use crate::math::tip5::Tip5;
use crate::math::x_field_element::XFieldElement;
use crate::util_types::algebraic_hasher::AlgebraicHasher;
use crate::util_types::mmr::mmr_accumulator::MmrAccumulator;
use crate::util_types::mmr::mmr_membership_proof::MmrMembershipProof;

use super::*;

#[derive(Debug, Clone, PartialEq, Eq, BFieldCodec, Arbitrary)]
struct UnitStruct;

Expand Down
3 changes: 1 addition & 2 deletions twenty-first/src/math/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,8 @@ pub(crate) mod digest_tests {
use proptest_arbitrary_interop::arb;
use test_strategy::proptest;

use crate::prelude::*;

use super::*;
use crate::prelude::*;

impl ProptestArbitrary for Digest {
type Parameters = ();
Expand Down
10 changes: 4 additions & 6 deletions twenty-first/src/math/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,12 @@ pub mod kem {
use sha3::Sha3_256;
use sha3::Shake256;

use crate::math::b_field_element::BFieldElement;

use super::embed_msg;
use super::extract_msg;
use super::CyclotomicRingElement;
use super::ModuleElement;
use super::CYCLOTOMIC_RING_ELEMENT_SIZE_IN_BFES;
use crate::math::b_field_element::BFieldElement;

#[derive(PartialEq, Eq, Copy, Clone, Debug, Serialize, Deserialize)]
pub struct SecretKey {
Expand Down Expand Up @@ -824,15 +823,14 @@ mod lattice_test {
use sha3::Digest as Sha3Digest;
use sha3::Sha3_256;

use super::kem::shake256;
use super::kem::SecretKey;
use super::kem::CIPHERTEXT_SIZE_IN_BFES;
use crate::math::b_field_element::BFieldElement;
use crate::math::lattice::kem::Ciphertext;
use crate::math::lattice::kem::PublicKey;
use crate::math::lattice::*;

use super::kem::shake256;
use super::kem::SecretKey;
use super::kem::CIPHERTEXT_SIZE_IN_BFES;

#[test]
fn test_kats() {
// KATs lifted from
Expand Down
3 changes: 2 additions & 1 deletion twenty-first/src/math/mds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ pub fn generated_function(input: &[u64]) -> [u64; 16] {
#[cfg(test)]
mod tests {
use itertools::Itertools;
use rand::{thread_rng, RngCore};
use rand::thread_rng;
use rand::RngCore;

use super::*;

Expand Down
3 changes: 1 addition & 2 deletions twenty-first/src/math/ntt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,13 @@ mod fast_ntt_attempt_tests {
use proptest_arbitrary_interop::arb;
use test_strategy::proptest;

use super::*;
use crate::math::other::random_elements;
use crate::math::traits::PrimitiveRootOfUnity;
use crate::math::x_field_element::EXTENSION_DEGREE;
use crate::prelude::*;
use crate::xfe;

use super::*;

#[test]
fn chu_ntt_b_field_prop_test() {
for log_2_n in 1..10 {
Expand Down
8 changes: 3 additions & 5 deletions twenty-first/src/math/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use num_traits::One;
use num_traits::Zero;
use rayon::prelude::*;

use super::traits::PrimitiveRootOfUnity;
use super::zerofier_tree::ZerofierTree;
use crate::math::ntt::intt;
use crate::math::ntt::ntt;
use crate::math::traits::FiniteField;
Expand All @@ -31,9 +33,6 @@ use crate::prelude::BFieldElement;
use crate::prelude::Inverse;
use crate::prelude::XFieldElement;

use super::traits::PrimitiveRootOfUnity;
use super::zerofier_tree::ZerofierTree;

impl<FF: FiniteField> Zero for Polynomial<FF> {
fn zero() -> Self {
Self {
Expand Down Expand Up @@ -2408,9 +2407,8 @@ mod test_polynomials {
use proptest_arbitrary_interop::arb;
use test_strategy::proptest;

use crate::prelude::*;

use super::*;
use crate::prelude::*;

impl proptest::arbitrary::Arbitrary for Polynomial<BFieldElement> {
type Parameters = ();
Expand Down
3 changes: 1 addition & 2 deletions twenty-first/src/math/tip5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,10 @@ pub(crate) mod tip5_tests {
use rayon::prelude::ParallelIterator;
use test_strategy::proptest;

use super::*;
use crate::math::other::random_elements;
use crate::math::x_field_element::XFieldElement;

use super::*;

impl Tip5 {
pub(crate) fn randomly_seeded() -> Self {
let mut sponge = Self::init();
Expand Down
3 changes: 1 addition & 2 deletions twenty-first/src/math/x_field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use rand_distr::Standard;
use serde::Deserialize;
use serde::Serialize;

use super::digest::Digest;
use crate::bfe_vec;
use crate::error::TryFromXFieldElementError;
use crate::math::b_field_element::BFieldElement;
Expand All @@ -32,8 +33,6 @@ use crate::math::traits::ModPowU32;
use crate::math::traits::ModPowU64;
use crate::math::traits::PrimitiveRootOfUnity;

use super::digest::Digest;

pub const EXTENSION_DEGREE: usize = 3;

#[derive(
Expand Down
Loading

0 comments on commit 920c5db

Please sign in to comment.