Skip to content

Commit 582e50f

Browse files
committed
clippy + fmt
1 parent e34c57b commit 582e50f

13 files changed

+22
-28
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ repository = "https://github.com/warlock-labs/sylow.git"
1212
name = "sylow"
1313
version = "0.1.0"
1414
edition = "2021"
15-
rust-version = "1.70.0"
1615
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1716

1817
[[example]]

src/fields/extensions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
//! Other specifics must be dealt with on a case-by-case basis.
2121
2222
use crate::fields::fp::FieldExtensionTrait;
23+
use core::ops::{Add, AddAssign, Neg, Sub, SubAssign};
2324
use crypto_bigint::subtle::{Choice, ConstantTimeEq};
2425
use num_traits::Zero;
25-
use core::ops::{Add, AddAssign, Neg, Sub, SubAssign};
2626

2727
/// A generic struct representing a field extension.
2828
///

src/fields/fp.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
//! ----------
3737
//! 1. <https://cacr.uwaterloo.ca/hac/about/chap14.pdf>
3838
39-
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};
4039
use alloc::vec::Vec;
40+
use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};
4141
use crypto_bigint::subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
4242
use crypto_bigint::{
4343
impl_modulus, modular::ConstMontyParams, rand_core::CryptoRngCore, ConcatMixed, NonZero,
@@ -782,8 +782,8 @@ impl FieldExtensionTrait<2, 2> for Fp {
782782
// The reference values for non-obvious field elements are generated with Sage.
783783
#[cfg(test)]
784784
mod tests {
785-
use alloc::format;
786785
use super::*;
786+
use alloc::format;
787787

788788
fn create_field(value: [u64; 4]) -> Fp {
789789
Fp::new(U256::from_words(value))
@@ -1503,10 +1503,10 @@ mod tests {
15031503
}
15041504

15051505
mod hash_tests {
1506+
use super::*;
15061507
use core::hash::{Hash, Hasher};
15071508
use proptest::std_facade::hash_map::DefaultHasher;
15081509
use proptest::std_facade::HashSet;
1509-
use super::*;
15101510

15111511
fn calculate_hash<T: Hash>(t: &T) -> u64 {
15121512
let mut s = DefaultHasher::new();

src/fields/fp12.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ use crate::fields::extensions::FieldExtension;
1717
use crate::fields::fp::{FieldExtensionTrait, Fp};
1818
use crate::fields::fp2::Fp2;
1919
use crate::fields::fp6::Fp6;
20+
use core::ops::{Div, DivAssign, Mul, MulAssign};
2021
use crypto_bigint::{rand_core::CryptoRngCore, subtle::ConditionallySelectable, U256};
2122
use num_traits::{Inv, One, Zero};
22-
use core::ops::{Div, DivAssign, Mul, MulAssign};
2323
use subtle::Choice;
2424

2525
/// Frobenius coefficients for 𝔽ₚ¹².

src/fields/fp2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
1010
use crate::fields::extensions::FieldExtension;
1111
use crate::fields::fp::{FieldExtensionTrait, Fp, BN254_FP_MODULUS, FP_QUADRATIC_NON_RESIDUE};
12+
use core::ops::{Div, DivAssign, Mul, MulAssign};
1213
use crypto_bigint::{rand_core::CryptoRngCore, subtle::ConditionallySelectable, U256};
1314
use num_traits::{Inv, One, Zero};
14-
use core::ops::{Div, DivAssign, Mul, MulAssign};
1515
use subtle::{Choice, ConstantTimeEq, CtOption};
1616

1717
/// Constant representing 1/2 in the base field 𝔽ₚ

src/fields/fp6.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use crate::fields::extensions::FieldExtension;
1111
use crate::fields::fp::{FieldExtensionTrait, Fp};
1212
use crate::fields::fp2::Fp2;
13+
use core::ops::{Div, DivAssign, Mul, MulAssign};
1314
use crypto_bigint::{rand_core::CryptoRngCore, subtle::ConditionallySelectable, U256};
1415
use num_traits::{Inv, One, Zero};
15-
use core::ops::{Div, DivAssign, Mul, MulAssign};
1616
use subtle::Choice;
1717

1818
// the following values are a bit difficult to compute. The reason

src/groups/g1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use crate::Fr;
2525
use alloc::vec::Vec;
2626
use crypto_bigint::rand_core::CryptoRngCore;
2727
use num_traits::{One, Zero};
28-
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
2928
use once_cell::sync::OnceCell;
29+
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, CtOption};
3030

3131
/// Affine representation of a point in the 𝔾₁ group
3232
pub type G1Affine = GroupAffine<1, 1, Fp>;

src/groups/g2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
// TODO(Notably missing here is the representation as 𝔾₂(𝔽ₚ⁶))
3434
// rather than as projective or affine coordinates.
3535

36-
use alloc::vec::Vec;
3736
use crate::fields::fp::{FieldExtensionTrait, Fp, Fr};
3837
use crate::fields::fp2::Fp2;
3938
use crate::groups::group::{GroupAffine, GroupError, GroupProjective, GroupTrait};
4039
use crate::hasher::Expander;
40+
use alloc::vec::Vec;
4141
use crypto_bigint::rand_core::CryptoRngCore;
4242
use crypto_bigint::U256;
4343
use num_traits::{One, Zero};

src/groups/group.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
3030
use crate::fields::fp::{FieldExtensionTrait, Fp};
3131
use crate::hasher::Expander;
32+
use core::ops::{Add, Mul, Neg, Sub};
3233
use crypto_bigint::rand_core::CryptoRngCore;
3334
use crypto_bigint::subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
34-
use core::ops::{Add, Mul, Neg, Sub};
3535

3636
/// Errors that can occur when working with group elements.
3737
#[derive(Debug, Copy, Clone)]

src/groups/gt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ use crate::fields::fp6::Fp6;
55
use crate::groups::group::{GroupError, GroupTrait};
66
use crate::hasher::Expander;
77
use crate::pairing::MillerLoopResult;
8+
use core::ops::{Add, Mul, Neg, Sub};
89
use crypto_bigint::rand_core::CryptoRngCore;
910
use crypto_bigint::U256;
1011
use num_traits::{One, Zero};
11-
use core::ops::{Add, Mul, Neg, Sub};
1212
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
1313

1414
// Do you have vertigo?

src/groups/mod.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ pub(crate) mod gt;
2121
/// this means each group operation takes sub millisecond time, which is nice.
2222
#[cfg(test)]
2323
mod tests {
24-
use alloc::string::String;
25-
use alloc::vec::Vec;
26-
use lazy_static::lazy_static;
27-
use serde::{Deserialize, Serialize};
2824
#[allow(unused_imports)]
29-
3025
use crate::fields::fp::{FieldExtensionTrait, Fp};
3126
use crate::fields::fp2::Fp2;
3227
use crate::groups::g1::{G1Affine, G1Projective};
3328
use crate::groups::g2::{G2Affine, G2Projective};
29+
use alloc::string::String;
30+
use alloc::vec::Vec;
31+
use lazy_static::lazy_static;
32+
use serde::{Deserialize, Serialize};
3433

3534
#[derive(Serialize, Deserialize, Clone)]
3635
struct _G2Coords {
@@ -170,7 +169,7 @@ mod tests {
170169
lazy_static! {
171170
static ref REFERENCE_DATA: ReferenceData = {
172171
let file_content = include_str!("../../src/bn254_reference.json");
173-
serde_json::from_str(&file_content).expect("Failed to parse JSON")
172+
serde_json::from_str(file_content).expect("Failed to parse JSON")
174173
};
175174
static ref G1_REFERENCE_DATA: G1ReferenceData = G1ReferenceData {
176175
a: REFERENCE_DATA

src/hasher.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
//! These expansion functions are crucial for secure hashing to curve operations,
1010
//! ensuring uniform distribution and domain separation in cryptographic protocols.
1111
12-
use alloc::vec;
13-
use alloc::vec::Vec;
1412
use crate::fields::fp::Fp;
1513
use crate::utils::u256_to_u512;
14+
use alloc::vec;
15+
use alloc::vec::Vec;
16+
use core::array::TryFromSliceError;
1617
use crypto_bigint::{Encoding, NonZero, U256, U512};
1718
use sha3::digest::crypto_common::BlockSizeUser;
1819
use sha3::digest::{ExtendableOutput, FixedOutput};
19-
use core::array::TryFromSliceError;
2020

2121
/// Possible errors which may occur during hashing operations.
2222
#[derive(Debug, Copy, Clone)]
@@ -332,11 +332,11 @@ impl<D: Default + ExtendableOutput> Expander for XOFExpander<D> {
332332
}
333333
#[cfg(test)]
334334
mod tests {
335+
use super::*;
335336
use alloc::format;
336337
use alloc::string::String;
337338
use once_cell::sync::OnceCell;
338339
use proptest::std_facade::HashMap;
339-
use super::*;
340340

341341
fn to_hex(bytes: &[u8]) -> String {
342342
// A simple utility function to convert a byte array into a big endian hex string

src/svdw.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,7 @@ mod tests {
307307
assert_eq!(bn254_svdw.z.value(), z, "SvdW z failed");
308308
Ok(())
309309
}
310-
Err(e) => {
311-
Err(e)
312-
}
310+
Err(e) => Err(e),
313311
};
314312
res.expect("Failed to generate constants for curve");
315313
}
@@ -341,9 +339,7 @@ mod tests {
341339
GroupProjective::<1, 1, Fp>::new([_d.x, _d.y, _d.z]).expect("Map failed");
342340
Ok(())
343341
}
344-
Err(e) => {
345-
Err(e)
346-
}
342+
Err(e) => Err(e),
347343
};
348344
res.expect("Failed to generate value on curve");
349345
}

0 commit comments

Comments
 (0)