Skip to content

Commit

Permalink
cargo xclippy
Browse files Browse the repository at this point in the history
  • Loading branch information
avras committed Sep 14, 2023
1 parent fd8147c commit f96a0bf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions crates/bellpepper-ed25519/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ mod tests {
let mut rng = rand::thread_rng();

let mut scalar = rng.gen_biguint(256u64);
scalar = scalar >> 3; // scalar now has 253 significant bits
scalar >>= 3; // scalar now has 253 significant bits
let p = Ed25519Curve::scalar_multiplication(&b, &scalar);

let mut scalar_vec: Vec<Boolean> = vec![];
Expand All @@ -563,7 +563,7 @@ mod tests {
} else {
scalar_vec.push(Boolean::constant(false))
};
scalar = scalar >> 1;
scalar >>= 1;
}

let mut cs = TestConstraintSystem::<Fp>::new();
Expand Down Expand Up @@ -603,7 +603,7 @@ mod tests {
let mut rng = rand::thread_rng();

let mut scalar = rng.gen_biguint(256u64);
scalar = scalar >> 3; // scalar now has 253 significant bits
scalar >>= 3; // scalar now has 253 significant bits
let p = Ed25519Curve::scalar_multiplication(&b, &scalar);

let mut scalar_vec: Vec<Boolean> = vec![];
Expand All @@ -613,7 +613,7 @@ mod tests {
} else {
scalar_vec.push(Boolean::constant(false))
};
scalar = scalar >> 1;
scalar >>= 1;
}

let mut cs = TestConstraintSystem::<Fp>::new();
Expand Down
6 changes: 3 additions & 3 deletions crates/bellpepper-ed25519/src/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ mod tests {
.unwrap();

let x = x_sq.sqrt();
if bool::from(x.is_some()) {
point.x = x.unwrap();
if let Some(x) = x {
point.x = x;
point.y = y;
break;
}
Expand Down Expand Up @@ -236,7 +236,7 @@ mod tests {
let b = &Ed25519Curve::basepoint();
assert!(Ed25519Curve::is_on_curve(b));
let scalar = BigUint::from(6u8);
let p = Ed25519Curve::scalar_multiplication(&b, &scalar);
let p = Ed25519Curve::scalar_multiplication(b, &scalar);
assert_eq!(p, b + b + b + b + b + b);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bellpepper-ed25519/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ mod tests {
let y_ref = &y;
assert_eq!(&x + &y, &x + y_ref);
x += y_ref;
assert_eq!(&x - &y, &x - &y_ref);
assert_eq!(&x - &y, &x - y_ref);
x -= y_ref;
assert_eq!(&x + &y, &x + y_ref);
}
Expand Down
22 changes: 11 additions & 11 deletions crates/bellpepper-emulated/src/field_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ mod tests {
let p = Ed25519Fp::modulus();
let p_minus_2 = &p - BigInt::from(2);
// b^(p-1) = 1 mod p for non-zero b. So b^(-1) = b^(p-2)
let b_inv_int = (&b_int).modpow(&p_minus_2, &p);
let b_inv_int = b_int.modpow(&p_minus_2, &p);

let b_const = EmulatedFieldElement::<Fp, Ed25519Fp>::from(&b_int);
let b_inv_const = EmulatedFieldElement::<Fp, Ed25519Fp>::from(&b_inv_int);
Expand Down Expand Up @@ -994,7 +994,7 @@ mod tests {
} else {
// Execution should not reach this line
eprintln!("res should have allocated limbs");
assert!(false);
unreachable!();
}

if !cs.is_satisfied() {
Expand Down Expand Up @@ -1054,7 +1054,7 @@ mod tests {
} else {
// Execution should not reach this line
eprintln!("res should have allocated limbs");
assert!(false);
unreachable!();
}

if !cs.is_satisfied() {
Expand Down Expand Up @@ -1083,15 +1083,15 @@ mod tests {

let a_consts = a_ints
.iter()
.map(|i| EmulatedFieldElement::<Fp, Ed25519Fp>::from(i))
.map(EmulatedFieldElement::<Fp, Ed25519Fp>::from)
.collect::<Vec<_>>();
let one = TestConstraintSystem::<Fp>::one();

let mut conditions: Vec<Vec<bool>> = vec![];
for i in 0..num_inputs {
let mut bool_vec = vec![];
for j in 0..num_selector_bits {
let bit = if (i >> j) & 1 == 1 { true } else { false };
let bit = (i >> j) & 1 == 1;
bool_vec.push(bit);
}
conditions.push(bool_vec); // little-endian
Expand All @@ -1100,7 +1100,7 @@ mod tests {
for i in 0..num_inputs {
let condition_bools = &conditions[i];
let condition_booleans = condition_bools
.into_iter()
.iter()
.rev() // mux_tree takes slice with MSB first
.map(|b| Boolean::constant(*b))
.collect::<Vec<_>>();
Expand All @@ -1117,7 +1117,7 @@ mod tests {
&a_consts,
);
assert!(res.is_ok());
if condition_bools.iter().all(|&x| x == false) {
if condition_bools.iter().all(|&x| !x) {
println!("Number of constraints for window size {num_selector_bits} = {:?}. Constant inputs",
cs.num_constraints()
);
Expand Down Expand Up @@ -1152,7 +1152,7 @@ mod tests {
} else {
// Execution should not reach this line
eprintln!("res should have allocated limbs");
assert!(false);
unreachable!();
}

if !cs.is_satisfied() {
Expand All @@ -1177,7 +1177,7 @@ mod tests {
for i in 0..num_inputs {
let condition_bools = &conditions[i];
let condition_booleans = condition_bools
.into_iter()
.iter()
.rev() // mux_tree takes slice with MSB first
.map(|b| Boolean::constant(*b))
.collect::<Vec<_>>();
Expand All @@ -1194,7 +1194,7 @@ mod tests {
&a_vars,
);
assert!(res.is_ok());
if condition_bools.iter().all(|&x| x == false) {
if condition_bools.iter().all(|&x| !x) {
println!("Number of constraints for window size {num_selector_bits} = {:?}. Variable inputs",
cs.num_constraints() - num_constraints_here
);
Expand Down Expand Up @@ -1229,7 +1229,7 @@ mod tests {
} else {
// Execution should not reach this line
eprintln!("res should have allocated limbs");
assert!(false);
unreachable!();
}

if !cs.is_satisfied() {
Expand Down
2 changes: 1 addition & 1 deletion crates/bellpepper-emulated/src/field_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ where

let padding_limbs = upper_bound_limbs
.into_iter()
.zip(padding_delta.into_iter())
.zip(padding_delta)
.map(|(a, b)| bigint_to_scalar(&(a + b)))
.collect::<Vec<F>>();

Expand Down

0 comments on commit f96a0bf

Please sign in to comment.