Skip to content

Commit f0791dc

Browse files
committed
fix mod position
1 parent 3b9e364 commit f0791dc

File tree

7 files changed

+78
-29
lines changed

7 files changed

+78
-29
lines changed

.github/workflows/benchmark.yml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ jobs:
3333
env:
3434
BACKEND: /home/runner/.bb/bb
3535

36-
- name: Compare gates reports
37-
id: gates_diff
38-
uses: noir-lang/noir-gates-diff@dbe920a8dcc3370af4be4f702ca9cef29317bec1
39-
with:
40-
report: gates_report.json
41-
summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)
42-
4336
- name: Store ACIR opcode benchmark result
4437
uses: benchmark-action/github-action-benchmark@v1
4538
with:
@@ -91,16 +84,6 @@ jobs:
9184
- name: Generate brillig report
9285
run: ./scripts/build-brillig-report.sh
9386

94-
- name: Compare brillig reports
95-
id: brillig_bytecode_diff
96-
uses: noir-lang/noir-gates-diff@dbe920a8dcc3370af4be4f702ca9cef29317bec1
97-
with:
98-
report: brillig_report.json
99-
header: |
100-
# Changes to Brillig bytecode sizes
101-
brillig_report: true
102-
summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)
103-
10487
- name: Store brillig benchmark result
10588
uses: benchmark-action/github-action-benchmark@v1
10689
with:

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ The most efficient method to evaluate curve operations is `BigCurve::evaluate_li
2929
- Add method to check point is in prime-order subgroup for curves with a cofactor
3030
- Parametrise and test with a degree-2 extension field instead of `BigNum`
3131
- [x] Add curve parameters for commonly used curves (BN254, BLS12-381, MNT4, MNT6, Pasta, Vella, Secp256K1, Secp256R1)
32-
- Create benchmarks
3332
- Add support for curve endomorphisms where applicable (if base field and scalar field both contain cube roots of unity, we can reduce the number of point doublings required for an MSM in half)
3433

3534
# FAQ

scripts/build-gates-report.sh

100644100755
File mode changed.
Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,73 @@
1-
use crate::curves::bn254::{BN254};
2-
use crate::curves::secp256k1::{Secp256k1};
1+
use crate::curves::bls12_377::BLS12_377;
2+
use crate::curves::bls12_381::BLS12_381;
3+
use crate::curves::bn254::BN254;
4+
use crate::curves::mnt4_753::MNT4_753;
5+
use crate::curves::mnt6_753::MNT6_753;
6+
use crate::curves::pallas::Pallas;
7+
use crate::curves::secp256k1::Secp256k1;
8+
use crate::curves::secp256r1::Secp256r1;
9+
use crate::curves::secp384r1::Secp384r1;
10+
use crate::curves::vesta::Vesta;
311
comptime fn make_bench(m: Module, params: Quoted) -> Quoted {
412
let module_name = m.name();
513
let add_bench_name = f"add_{module_name}".quoted_contents();
614
let sub_bench_name = f"sub_{module_name}".quoted_contents();
15+
let neg_bench_name = f"neg_{module_name}".quoted_contents();
716
let one_bench_name = f"one_{module_name}".quoted_contents();
17+
let mul_bench_name = f"mul_{module_name}".quoted_contents();
18+
let eq_bench_name = f"eq_{module_name}".quoted_contents();
19+
let validate_on_curve_bench_name = f"validate_on_curve_{module_name}".quoted_contents();
20+
let evaluate_linear_expression_bench_name =
21+
f"evaluate_linear_expression_{module_name}".quoted_contents();
22+
let hash_to_curve_bench_name = f"hash_to_curve_{module_name}".quoted_contents();
823
let BigCurve = quote { crate::BigCurve };
24+
let ScalarField = quote { crate::ScalarField };
925

10-
let from_field_bench_name = f"from_field_{module_name}".quoted_contents();
1126
let typ = params.as_type();
1227

1328
quote {
1429
#[export]
1530
fn $add_bench_name(a: $typ, b: $typ) -> $typ {
16-
a.add(b)
31+
a + b
1732
}
1833

1934
#[export]
2035
fn $sub_bench_name(a: $typ, b: $typ) -> $typ {
21-
a.sub(b)
36+
a-b
37+
}
38+
39+
#[export]
40+
fn $neg_bench_name(a: $typ) -> $typ {
41+
-a
42+
}
43+
44+
#[export]
45+
fn $eq_bench_name(a: $typ, b: $typ) -> bool {
46+
a==b
47+
}
48+
#[export]
49+
fn $validate_on_curve_bench_name(a: $typ) {
50+
$BigCurve::validate_on_curve(a);
51+
}
52+
53+
#[export]
54+
fn $mul_bench_name(a: $typ, b: $ScalarField<64>) -> $typ {
55+
$BigCurve::mul(a, b)
2256
}
2357

2458
#[export]
2559
fn $one_bench_name() -> $typ {
26-
$typ::one()
60+
$BigCurve::one()
61+
}
62+
63+
#[export]
64+
fn $hash_to_curve_bench_name(a: [u8; 10]) -> $typ {
65+
$BigCurve::hash_to_curve(a)
66+
}
67+
68+
#[export]
69+
fn $evaluate_linear_expression_bench_name(a: [$typ; 3], b: [$ScalarField<64>; 3], c: [$typ; 2]) -> $typ {
70+
$BigCurve::evaluate_linear_expression(a, b, c)
2771
}
2872

2973
}
@@ -32,5 +76,29 @@ comptime fn make_bench(m: Module, params: Quoted) -> Quoted {
3276
#[make_bench(quote { BN254 })]
3377
mod BN254_Bench {}
3478

79+
#[make_bench(quote { BLS12_381 })]
80+
mod BLS12_381_Bench {}
81+
82+
#[make_bench(quote { BLS12_377 })]
83+
mod BLS12_377_Bench {}
84+
85+
#[make_bench(quote { MNT4_753 })]
86+
mod MNT4_753_Bench {}
87+
88+
#[make_bench(quote { MNT6_753 })]
89+
mod MNT6_753_Bench {}
90+
91+
#[make_bench(quote { Pallas })]
92+
mod Pallas_Bench {}
93+
3594
#[make_bench(quote { Secp256k1 })]
36-
mod Secp256k1_Bench {}
95+
mod Secp256k1_Bench {}
96+
97+
#[make_bench(quote { Secp256r1 })]
98+
mod Secp256r1_Bench {}
99+
100+
#[make_bench(quote { Secp384r1 })]
101+
mod Secp384r1_Bench {}
102+
103+
#[make_bench(quote { Vesta })]
104+
mod Vesta_Bench {}

src/benchmarks/mod.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mod bigcurve_benchmarks;
1+
mod bigcurve_benchmarks;

src/lib.nr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
21
pub(crate) mod curve_jac;
32
mod test_data;
43
mod bigcurve_test;
54
pub mod scalar_field;
6-
mod benchmarks;
75
pub(crate) mod utils;
86
pub(crate) mod curves;
97

@@ -13,6 +11,7 @@ use bignum::bignum::evaluate_quadratic_expression;
1311
use crate::curve_jac::AffineTranscript;
1412
use crate::scalar_field::ScalarField;
1513
use std::ops::{Add, Neg, Sub};
14+
mod benchmarks;
1615

1716
/// Implements an elliptic curve over a prime field that is not the circuit's native field.
1817

src/utils/derive_offset_generators.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102
#[test]
103103
fn test_compute_and_print_offset_generators() {
104104
unsafe {
105-
let _ = <BN254 as BigCurve<BN254_Fq>>::one();
105+
let _ = BN254::one();
106106
compute_and_print_offset_generators::<BN254_Fq, _, _, 64, BN254>("BN254_Fq", "BN254", 1);
107107
// compute_and_print_offset_generators::<PallasBN, _, _, 64>("Pallas_Fq", "Pallas", 1);
108108
// compute_and_print_offset_generators::<VestaBN, _, _, 64>("Vesta_Fq", "Vesta", 1);

0 commit comments

Comments
 (0)