Skip to content

Commit 0b40031

Browse files
Remove explicit calls to setup functions throughout the codebase
1 parent 0ec3b97 commit 0b40031

File tree

14 files changed

+5
-53
lines changed

14 files changed

+5
-53
lines changed

benchmarks/guest/ecrecover/src/main.rs

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ openvm_ecc_guest::sw_macros::sw_init! {
2424
}
2525

2626
pub fn main() {
27-
setup_all_moduli();
28-
setup_all_curves();
29-
3027
let expected_address = read_vec();
3128
for _ in 0..5 {
3229
let input = read_vec();

benchmarks/guest/kitchen-sink/src/main.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ openvm_algebra_guest::complex_macros::complex_init! {
4848
}
4949

5050
pub fn main() {
51-
// Setup will materialize every chip
52-
setup_all_moduli();
53-
setup_all_complex_extensions();
54-
setup_all_curves();
51+
// TODO: Since we don't explicitly call setup functions anymore, we should rewrite this test
52+
// to use every declared modulus and curve to ensure that every chip is materialized.
5553

5654
let [one, six] = [1, 6].map(Seven::from_u32);
5755
assert_eq!(one + six, Seven::ZERO);

benchmarks/guest/pairing/src/main.rs

-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ openvm_algebra_guest::complex_macros::complex_init! {
2222
const PAIR_ELEMENT_LEN: usize = 32 * (2 + 4); // 1 G1Affine (2 Fp), 1 G2Affine (4 Fp)
2323

2424
pub fn main() {
25-
setup_all_moduli();
26-
setup_all_complex_extensions();
27-
// Pairing doesn't need G1Affine intrinsics, but we trigger it anyways to test the chips
28-
setup_all_curves();
29-
3025
// copied from https://github.com/bluealloy/revm/blob/9e39df5dbc5fdc98779c644629b28b8bee75794a/crates/precompile/src/bn128.rs#L395
3126
let input = hex::decode(
3227
"\

examples/algebra/src/main.rs

-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ openvm_algebra_complex_macros::complex_init! {
3131
*/
3232

3333
pub fn main() {
34-
// Since we only use an arithmetic operation with `Mod1` and not `Mod2`,
35-
// we only need to call `setup_0()` here.
36-
setup_0();
37-
setup_all_complex_extensions();
3834
let a = Complex1::new(Mod1::ZERO, Mod1::from_u32(0x3b8) * Mod1::from_u32(0x100000)); // a = -i in the corresponding field
3935
let b = Complex2::new(Mod2::ZERO, Mod2::from_u32(1000000006)); // b = -i in the corresponding field
4036
assert_eq!(a.clone() * &a * &a * &a * &a, a); // a^5 = a

examples/ecc/src/main.rs

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ openvm_ecc_guest::sw_macros::sw_init! {
2323

2424
// ANCHOR: main
2525
pub fn main() {
26-
setup_all_moduli();
27-
setup_all_curves();
2826
let x1 = Secp256k1Coord::from_u32(1);
2927
let y1 = Secp256k1Coord::from_le_bytes(&hex!(
3028
"EEA7767E580D75BC6FDD7F58D2A84C2614FB22586068DB63B346C6E60AF21842"

examples/pairing/src/main.rs

-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ openvm_algebra_complex_macros::complex_init! {
2626

2727
// ANCHOR: main
2828
pub fn main() {
29-
// ANCHOR: setup
30-
setup_0();
31-
setup_all_complex_extensions();
32-
// ANCHOR_END: setup
33-
3429
let p0 = AffinePoint::new(
3530
Fp::from_be_bytes(&hex!("17f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb")),
3631
Fp::from_be_bytes(&hex!("08b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e1"))

extensions/pairing/tests/programs/examples/bls_ec.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@ openvm_ecc_sw_macros::sw_init! {
1515

1616
openvm::entry!(main);
1717

18-
pub fn main() {
19-
setup_all_moduli();
20-
setup_all_curves();
21-
}
18+
pub fn main() {}

extensions/pairing/tests/programs/examples/fp12_mul.rs

-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ mod bn254 {
2323
}
2424

2525
pub fn test_fp12_mul(io: &[u8]) {
26-
setup_0();
27-
setup_all_complex_extensions();
2826
assert_eq!(io.len(), 32 * 36);
2927

3028
let f0 = &io[0..32 * 12];
@@ -62,8 +60,6 @@ mod bls12_381 {
6260
}
6361

6462
pub fn test_fp12_mul(io: &[u8]) {
65-
setup_0();
66-
setup_all_complex_extensions();
6763
assert_eq!(io.len(), 48 * 36);
6864

6965
let f0 = &io[0..48 * 12];

extensions/pairing/tests/programs/examples/pairing_check.rs

-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ mod bn254 {
2929
}
3030

3131
pub fn test_pairing_check(io: &[u8]) {
32-
setup_0();
33-
setup_all_complex_extensions();
3432
let s0 = &io[0..32 * 2];
3533
let s1 = &io[32 * 2..32 * 4];
3634
let q0 = &io[32 * 4..32 * 8];
@@ -71,8 +69,6 @@ mod bls12_381 {
7169
}
7270

7371
pub fn test_pairing_check(io: &[u8]) {
74-
setup_0();
75-
setup_all_complex_extensions();
7672
let s0 = &io[0..48 * 2];
7773
let s1 = &io[48 * 2..48 * 4];
7874
let q0 = &io[48 * 4..48 * 8];

extensions/pairing/tests/programs/examples/pairing_check_fallback.rs

-4
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ mod bn254 {
101101
}
102102

103103
pub fn test_pairing_check(io: &[u8]) {
104-
setup_0();
105-
setup_all_complex_extensions();
106104
let s0 = &io[0..32 * 2];
107105
let s1 = &io[32 * 2..32 * 4];
108106
let q0 = &io[32 * 4..32 * 8];
@@ -216,8 +214,6 @@ mod bls12_381 {
216214
}
217215

218216
pub fn test_pairing_check(io: &[u8]) {
219-
setup_0();
220-
setup_all_complex_extensions();
221217
let s0 = &io[0..48 * 2];
222218
let s1 = &io[48 * 2..48 * 4];
223219
let q0 = &io[48 * 4..48 * 8];

extensions/pairing/tests/programs/examples/pairing_line.rs

-4
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,11 @@ pub fn main() {
150150

151151
#[cfg(feature = "bn254")]
152152
{
153-
bn254::setup_0();
154-
bn254::setup_all_complex_extensions();
155153
bn254::test_mul_013_by_013(&io[..32 * 18]);
156154
bn254::test_mul_by_01234(&io[32 * 18..32 * 52]);
157155
}
158156
#[cfg(feature = "bls12_381")]
159157
{
160-
bls12_381::setup_0();
161-
bls12_381::setup_all_complex_extensions();
162158
bls12_381::test_mul_023_by_023(&io[..48 * 18]);
163159
bls12_381::test_mul_by_02345(&io[48 * 18..48 * 52]);
164160
}

extensions/pairing/tests/programs/examples/pairing_miller_loop.rs

-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ mod bn254 {
2727
}
2828

2929
pub fn test_miller_loop(io: &[u8]) {
30-
setup_0();
31-
setup_all_complex_extensions();
3230
let s0 = &io[0..32 * 2];
3331
let s1 = &io[32 * 2..32 * 4];
3432
let q0 = &io[32 * 4..32 * 8];
@@ -70,8 +68,6 @@ mod bls12_381 {
7068
}
7169

7270
pub fn test_miller_loop(io: &[u8]) {
73-
setup_0();
74-
setup_all_complex_extensions();
7571
let s0 = &io[0..48 * 2];
7672
let s1 = &io[48 * 2..48 * 4];
7773
let q0 = &io[48 * 4..48 * 8];

extensions/pairing/tests/programs/examples/pairing_miller_step.rs

-4
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,11 @@ pub fn main() {
169169

170170
#[cfg(feature = "bn254")]
171171
{
172-
bn254::setup_0();
173-
bn254::setup_all_complex_extensions();
174172
bn254::test_miller_step(&io[..32 * 12]);
175173
bn254::test_miller_double_and_add_step(&io[32 * 12..]);
176174
}
177175
#[cfg(feature = "bls12_381")]
178176
{
179-
bls12_381::setup_0();
180-
bls12_381::setup_all_complex_extensions();
181177
bls12_381::test_miller_step(&io[..48 * 12]);
182178
bls12_381::test_miller_double_and_add_step(&io[48 * 12..]);
183179
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// This file is automatically generated by cargo openvm. Do not rename or edit.
2-
openvm_algebra_guest::moduli_macros::moduli_init! { "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787" }
3-
openvm_algebra_guest::complex_macros::complex_init! { Bls12_381Fp2 { mod_idx = 0 } }
2+
openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583" }
3+
openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } }
44
openvm_ecc_guest::sw_macros::sw_init! { }

0 commit comments

Comments
 (0)