From f8755030a0d8f6c7b87367cb788fa80127e23570 Mon Sep 17 00:00:00 2001 From: Khashayar Barooti Date: Tue, 13 May 2025 11:34:46 +0100 Subject: [PATCH 1/4] added benchmarks for BLS12_381_Fr --- src/benchmarks/bignum_benchmarks.nr | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/benchmarks/bignum_benchmarks.nr b/src/benchmarks/bignum_benchmarks.nr index f85c6792..18f5b3ed 100644 --- a/src/benchmarks/bignum_benchmarks.nr +++ b/src/benchmarks/bignum_benchmarks.nr @@ -1,6 +1,9 @@ -use crate::fields::{bls12_381Fq::BLS12_381_Fq, bn254Fq::BN254_Fq, U2048::U2048, U256::U256}; +use crate::fields::{ + bls12_381Fq::BLS12_381_Fq, bls12_381Fr::BLS12_381_Fr, bn254Fq::BN254_Fq, U2048::U2048, + U256::U256, +}; -comptime fn make_bench(m: Module, params: Quoted) -> Quoted { +comptime fn make_bench(m: Module, params: Quoted, MOD_BITS: u32) -> Quoted { let module_name = m.name(); let add_bench_name = f"add_{module_name}".quoted_contents(); let sub_bench_name = f"sub_{module_name}".quoted_contents(); @@ -81,10 +84,10 @@ comptime fn make_bench(m: Module, params: Quoted) -> Quoted { crate::bignum::evaluate_quadratic_expression(lhs, lhs_flags, rhs, rhs_flags, add, add_flags) } - #[export] - fn $from_field_bench_name(a: Field) -> $typ { - $typ::from(a) - } + // #[export] + // fn $from_field_bench_name(a: Field) -> $typ { + // $typ::from(a) + // } // #[export] // fn $to_be_bytes_bench_name(a: $typ) -> [u8; ($MOD_BITS+7) / 8] { @@ -122,5 +125,8 @@ mod U256_Bench {} #[make_bench(quote { BLS12_381_Fq })] mod BLS12_381Fq_Bench {} +#[make_bench(quote { BLS12_381_Fr })] +mod BLS12_381Fr_Bench {} + #[make_bench(quote { U2048 })] mod U2048_Bench {} From 4d9c80a43477d4acbeec1ff5a529ced6893563f7 Mon Sep 17 00:00:00 2001 From: Khashayar Barooti Date: Tue, 13 May 2025 11:36:08 +0100 Subject: [PATCH 2/4] add the from_field back --- src/benchmarks/bignum_benchmarks.nr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/benchmarks/bignum_benchmarks.nr b/src/benchmarks/bignum_benchmarks.nr index 18f5b3ed..8a401c69 100644 --- a/src/benchmarks/bignum_benchmarks.nr +++ b/src/benchmarks/bignum_benchmarks.nr @@ -84,10 +84,10 @@ comptime fn make_bench(m: Module, params: Quoted, MOD_BITS: u32) -> Quoted { crate::bignum::evaluate_quadratic_expression(lhs, lhs_flags, rhs, rhs_flags, add, add_flags) } - // #[export] - // fn $from_field_bench_name(a: Field) -> $typ { - // $typ::from(a) - // } + #[export] + fn $from_field_bench_name(a: Field) -> $typ { + $typ::from(a) + } // #[export] // fn $to_be_bytes_bench_name(a: $typ) -> [u8; ($MOD_BITS+7) / 8] { From 4e400c2d3c943b6a947610426f78d7823b5ce7b1 Mon Sep 17 00:00:00 2001 From: Khashayar Barooti Date: Tue, 13 May 2025 11:39:02 +0100 Subject: [PATCH 3/4] remove MOD_BITS --- src/benchmarks/bignum_benchmarks.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchmarks/bignum_benchmarks.nr b/src/benchmarks/bignum_benchmarks.nr index 8a401c69..5329273a 100644 --- a/src/benchmarks/bignum_benchmarks.nr +++ b/src/benchmarks/bignum_benchmarks.nr @@ -3,7 +3,7 @@ use crate::fields::{ U256::U256, }; -comptime fn make_bench(m: Module, params: Quoted, MOD_BITS: u32) -> Quoted { +comptime fn make_bench(m: Module, params: Quoted) -> Quoted { let module_name = m.name(); let add_bench_name = f"add_{module_name}".quoted_contents(); let sub_bench_name = f"sub_{module_name}".quoted_contents(); From b7113d69b8b8324c102d88f747bcfe6232cd7f7d Mon Sep 17 00:00:00 2001 From: Khashayar Barooti Date: Tue, 13 May 2025 11:59:06 +0100 Subject: [PATCH 4/4] aded more types --- src/benchmarks/bignum_benchmarks.nr | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/benchmarks/bignum_benchmarks.nr b/src/benchmarks/bignum_benchmarks.nr index 5329273a..db4a78a7 100644 --- a/src/benchmarks/bignum_benchmarks.nr +++ b/src/benchmarks/bignum_benchmarks.nr @@ -1,6 +1,6 @@ use crate::fields::{ - bls12_381Fq::BLS12_381_Fq, bls12_381Fr::BLS12_381_Fr, bn254Fq::BN254_Fq, U2048::U2048, - U256::U256, + bls12_377Fq::BLS12_377_Fq, bls12_377Fr::BLS12_377_Fr, bls12_381Fq::BLS12_381_Fq, + bls12_381Fr::BLS12_381_Fr, bn254Fq::BN254_Fq, U2048::U2048, U256::U256, }; comptime fn make_bench(m: Module, params: Quoted) -> Quoted { @@ -128,5 +128,10 @@ mod BLS12_381Fq_Bench {} #[make_bench(quote { BLS12_381_Fr })] mod BLS12_381Fr_Bench {} +#[make_bench(quote { BLS12_377_Fr })] +mod BLS12_377Fr_Bench {} + +#[make_bench(quote { BLS12_377_Fq })] +mod BLS12_377Fq_Bench {} #[make_bench(quote { U2048 })] mod U2048_Bench {}