Skip to content

Commit 3dcaa2a

Browse files
Fix lint
1 parent 7e41530 commit 3dcaa2a

File tree

17 files changed

+45
-29
lines changed

17 files changed

+45
-29
lines changed

.github/workflows/lints.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ jobs:
6060
if [[ "$crate_path" == *"extensions/ecc/tests/programs"* ]]; then
6161
echo "Running cargo clippy with k256 and p256 features for $crate_path"
6262
cargo clippy --manifest-path "$crate_path/Cargo.toml" --all-targets --features "std k256 p256" -- -D warnings
63-
elif [[ "$crate_path" == *"extensions/pairing/tests/programs"* ]]; then
63+
elif [[ "$crate_path" == *"guest-libs/pairing/tests/programs"* ]]; then
6464
echo "Running cargo clippy with openvm_pairing_guest::bn254 feature for $crate_path"
6565
cargo clippy --manifest-path "$crate_path/Cargo.toml" --all-targets --features "std bn254" -- -D warnings
6666
echo "Running cargo clippy with openvm_pairing_guest::bls12_381 feature for $crate_path"
6767
cargo clippy --manifest-path "$crate_path/Cargo.toml" --all-targets --features "std bls12_381" -- -D warnings
68-
elif [[ "$crate_path" == *"extensions/"* ]]; then
68+
elif [[ "$crate_path" == *"extensions/"* || "$crate_path" == *"guest-libs/"* ]]; then
6969
echo "Running cargo clippy for $crate_path"
7070
cargo clippy --manifest-path "$crate_path/Cargo.toml" --all-targets --features "std" -- -D warnings
7171
else

examples/algebra/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
extern crate alloc;
2+
13
use openvm_algebra_guest::{moduli_macros::*, IntMod};
24

35
// This macro will create two structs, `Mod1` and `Mod2`,

examples/pairing/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ openvm-algebra-guest = { path = "../../extensions/algebra/guest" }
1313
openvm-algebra-moduli-macros = { path = "../../extensions/algebra/moduli-macros" }
1414
openvm-algebra-complex-macros = { path = "../../extensions/algebra/complex-macros" }
1515
openvm-ecc-guest = { path = "../../extensions/ecc/guest" }
16+
openvm-pairing = { path = "../../guest-libs/pairing/guest", features = [
17+
"bls12_381",
18+
] }
1619
openvm-pairing-guest = { path = "../../extensions/pairing/guest", features = [
1720
"bls12_381",
1821
] }

examples/pairing/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use hex_literal::hex;
44
// ANCHOR: imports
55
use openvm_algebra_guest::{field::FieldExtension, IntMod};
66
use openvm_ecc_guest::AffinePoint;
7-
use openvm_pairing_guest::{
7+
use openvm_pairing::{
88
bls12_381::{Bls12_381, Fp, Fp2},
9-
pairing::PairingCheck,
9+
PairingCheck,
1010
};
1111
// ANCHOR_END: imports
1212

guest-libs/ff_derive/guest/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,8 @@ fn prime_field_impl(
11901190
// on our zkvm-compatible struct, so we need to conditionally implement them
11911191
#[cfg(not(target_os = "zkvm"))]
11921192
mod #impl_module_ident {
1193+
use super::{#name, MODULUS_LIMBS};
1194+
11931195
impl ::core::clone::Clone for #name {
11941196
fn clone(&self) -> #name {
11951197
*self

guest-libs/ff_derive/tests/programs/examples/constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ fn main() {
3535

3636
// ROOT_OF_UNITY^{2^s} mod m == 1
3737
assert_eq!(
38-
Bls381K12Scalar::ROOT_OF_UNITY.pow(&[1u64 << Bls381K12Scalar::S, 0, 0, 0]),
38+
Bls381K12Scalar::ROOT_OF_UNITY.pow([1u64 << Bls381K12Scalar::S, 0, 0, 0]),
3939
Bls381K12Scalar::ONE,
4040
);
4141

4242
// DELTA^{t} mod m == 1
4343
assert_eq!(
44-
Bls381K12Scalar::DELTA.pow(&[
44+
Bls381K12Scalar::DELTA.pow([
4545
0xfffe5bfeffffffff,
4646
0x09a1d80553bda402,
4747
0x299d7d483339d808,

guest-libs/ff_derive/tests/programs/examples/operations.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ fn main() {
2929
);
3030

3131
// Test Eq
32-
assert_eq!(Bls381K12Scalar::ZERO, Bls381K12Scalar::ZERO);
33-
assert_eq!(Bls381K12Scalar::ONE, Bls381K12Scalar::ONE);
34-
assert_eq!(neg_one, neg_one);
32+
#[allow(clippy::eq_op)]
33+
{
34+
assert_eq!(Bls381K12Scalar::ZERO, Bls381K12Scalar::ZERO);
35+
assert_eq!(Bls381K12Scalar::ONE, Bls381K12Scalar::ONE);
36+
assert_eq!(neg_one, neg_one);
37+
}
3538

3639
// Test is_zero
3740
assert!(bool::from(Bls381K12Scalar::ZERO.is_zero()));

guest-libs/k256/tests/programs/examples/mul.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
use elliptic_curve::{CurveArithmetic, Group, PrimeField};
55
use openvm_k256::Secp256k1;
6-
76
// clippy thinks this is unused, but it's used in the init! macro
87
#[allow(unused)]
98
use openvm_k256::Secp256k1Point;
@@ -34,7 +33,7 @@ pub fn main() {
3433
)
3534
}))
3635
{
37-
let p = generator * &k;
36+
let p = generator * k;
3837
assert_eq!(p.x_be_bytes(), coords.0);
3938
assert_eq!(p.y_be_bytes(), coords.1);
4039
}

guest-libs/k256/tests/programs/examples/test_vectors/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ pub const ADD_TEST_VECTORS: &[([u8; 32], [u8; 32])] = &[
9393
///
9494
/// Vectors for secp256k1 are difficult to find. These are the vectors from:
9595
/// <https://web.archive.org/web/20190724010836/https://chuckbatson.wordpress.com/2014/11/26/secp256k1-test-vectors/>
96+
// clippy thinks this is unused for some reason, but it's used in mul.rs
97+
#[allow(dead_code)]
9698
pub const MUL_TEST_VECTORS: &[([u8; 32], [u8; 32], [u8; 32])] = &[
9799
(
98100
hex!("000000000000000000000000000000000000000000000000018EBBB95EED0E13"),

guest-libs/p256/tests/programs/examples/mul.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn main() {
3434
)
3535
}))
3636
{
37-
let p = generator * &k;
37+
let p = generator * k;
3838
assert_eq!(p.x_be_bytes(), coords.0);
3939
assert_eq!(p.y_be_bytes(), coords.1);
4040
}

guest-libs/p256/tests/programs/examples/test_vectors/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ pub const ADD_TEST_VECTORS: &[([u8; 32], [u8; 32])] = &[
8888
),
8989
];
9090

91-
//// Scalar multiplication with the generator.
91+
/// Scalar multiplication with the generator.
9292
///
9393
/// These are the test vectors from <http://point-at-infinity.org/ecc/nisttv> that are not
9494
/// part of [`ADD_TEST_VECTORS`].
95+
// clippy thinks this is unused for some reason, but it's used in mul.rs
96+
#[allow(dead_code)]
9597
pub const MUL_TEST_VECTORS: &[([u8; 32], [u8; 32], [u8; 32])] = &[
9698
(
9799
hex!("000000000000000000000000000000000000000000000000018EBBB95EED0E13"),

guest-libs/pairing/guest/src/bls12_381/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate alloc;
22

33
use core::ops::Neg;
44

5-
use openvm_algebra_guest::{Field, IntMod};
5+
use openvm_algebra_guest::IntMod;
66
use openvm_algebra_moduli_macros::moduli_declare;
77
use openvm_ecc_guest::{weierstrass::IntrinsicCurve, CyclicGroup, Group};
88

guest-libs/pairing/guest/src/bn254/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ extern crate alloc;
33
use core::ops::{Add, Neg};
44

55
use hex_literal::hex;
6-
use openvm_algebra_guest::{Field, IntMod};
6+
use openvm_algebra_guest::IntMod;
77
use openvm_algebra_moduli_macros::moduli_declare;
88
use openvm_ecc_guest::{
99
weierstrass::{CachedMulTable, IntrinsicCurve},

guest-libs/pairing/tests/programs/examples/bn_ec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![cfg_attr(not(feature = "std"), no_std)]
33

44
#[allow(unused_imports)]
5+
#[cfg(feature = "bn254")]
56
use openvm_pairing::bn254::Bn254G1Affine;
67

78
openvm::init!("openvm_init_bn_ec_bn254.rs");

guest-libs/ruint/tests/programs/examples/matrix_power.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn mult(a: &Matrix, b: &Matrix) -> Matrix {
2222
for i in 0..N {
2323
for j in 0..N {
2424
for k in 0..N {
25-
c[i][j] += &a[i][k] * &b[k][j];
25+
c[i][j] += a[i][k] * b[k][j];
2626
}
2727
}
2828
}
@@ -42,11 +42,11 @@ pub fn bin_exp(mut base: Matrix, mut exp: U256) -> Matrix {
4242
let mut result = get_identity_matrix();
4343
let one = U256::from_u8(1).unwrap();
4444
while exp > U256::from_u8(0).unwrap() {
45-
if (&exp & &one) == one {
45+
if (exp & one) == one {
4646
result = mult(&result, &base);
4747
}
4848
base = mult(&base, &base);
49-
exp >>= &one;
49+
exp >>= one;
5050
}
5151
result
5252
}
@@ -64,7 +64,7 @@ pub fn main() {
6464

6565
let a: Matrix = get_matrix(1);
6666
let c = bin_exp(a, U256::from_u8(51).unwrap());
67-
let two_to_200 = one << &U256::from_u8(200).unwrap();
67+
let two_to_200 = one << U256::from_u8(200).unwrap();
6868

6969
for i in 0..N {
7070
for j in 0..N {
@@ -76,54 +76,54 @@ pub fn main() {
7676
}
7777

7878
// Shift right tests
79-
if two_to_200 >> &U256::from_u8(200).unwrap() != one {
79+
if two_to_200 >> U256::from_u8(200).unwrap() != one {
8080
print("FAIL: 2^200 >> 200 == 1 test failed");
8181
panic!();
8282
}
83-
if two_to_200 >> &U256::from_u8(201).unwrap() != zero {
83+
if two_to_200 >> U256::from_u8(201).unwrap() != zero {
8484
print("FAIL: 2^200 >> 201 == 0 test failed");
8585
panic!();
8686
}
8787

8888
// Xor tests
89-
if &two_to_200 ^ &two_to_200 != zero {
89+
if two_to_200 ^ two_to_200 != zero {
9090
print("FAIL: 2^200 ^ 2^200 == 0 test failed");
9191
panic!();
9292
}
9393

94-
if &two_to_200 ^ &one != &two_to_200 + &one {
94+
if two_to_200 ^ one != two_to_200 + one {
9595
print("FAIL: 2^200 ^ 1 == 2^200 + 1 test failed");
9696
panic!();
9797
}
9898

9999
// Or tests
100-
if &one | &one != one {
100+
if one | one != one {
101101
print("FAIL: 1 | 1 == 1 test failed");
102102
panic!();
103103
}
104104

105-
if &two_to_200 | &one != &two_to_200 + &one {
105+
if two_to_200 | one != two_to_200 + one {
106106
print("FAIL: 2^200 | 1 = 2^200 + 1 test failed");
107107
panic!();
108108
}
109109

110110
// Other tests
111-
if &zero - &one <= zero {
111+
if zero - one <= zero {
112112
print("FAIL: 0 - 1 > 0 test failed (should have wrapped)");
113113
panic!();
114114
}
115115

116-
if &zero - &one + &one != zero {
116+
if zero - one + one != zero {
117117
print("FAIL: 0 - 1 + 1 == 0 test failed (should have wrapped)");
118118
panic!();
119119
}
120120

121-
if one << &U256::from_u32(256).unwrap() != zero {
121+
if one << U256::from_u32(256).unwrap() != zero {
122122
print("FAIL: 1 << 256 == 0 test failed");
123123
panic!();
124124
}
125125

126-
if two_to_200.clone() != two_to_200 {
126+
if two_to_200 != two_to_200 {
127127
print("FAIL: 2^200 clone test failed");
128128
panic!();
129129
}

guest-libs/sha2/tests/programs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66

77
[dependencies]
88
openvm = { path = "../../../../crates/toolchain/openvm" }
9+
openvm-platform = { path = "../../../../crates/toolchain/platform" }
910
openvm-sha2 = { path = "../../guest" }
1011

1112
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }

guest-libs/sha2/tests/programs/examples/sha.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ extern crate alloc;
55

66
use alloc::vec::Vec;
77
use core::hint::black_box;
8+
89
use hex::FromHex;
910
use openvm_sha2::sha256;
1011

0 commit comments

Comments
 (0)