From ba66033aad2407fc928ab19a77e6e946d36ef30f Mon Sep 17 00:00:00 2001 From: weikeng Date: Tue, 25 May 2021 20:43:47 -0700 Subject: [PATCH 1/4] fix the bench test failure --- poly-benches/benches/fft.rs | 50 ++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/poly-benches/benches/fft.rs b/poly-benches/benches/fft.rs index 86704845d..61fe9a404 100644 --- a/poly-benches/benches/fft.rs +++ b/poly-benches/benches/fft.rs @@ -12,7 +12,8 @@ use criterion::{criterion_group, criterion_main, Bencher, Criterion}; // degree bounds to benchmark on // e.g. degree bound of 2^{15}, means we do an FFT for a degree (2^{15} - 1) polynomial const BENCHMARK_MIN_DEGREE: usize = 1 << 15; -const BENCHMARK_MAX_DEGREE: usize = 1 << 22; +const BENCHMARK_MAX_DEGREE_BLS12_381: usize = 1 << 22; +const BENCHMARK_MAX_DEGREE_MNT6_753: usize = 1 << 17; const BENCHMARK_LOG_INTERVAL_DEGREE: usize = 1; const ENABLE_RADIX2_BENCHES: bool = true; @@ -22,17 +23,30 @@ const ENABLE_MIXED_RADIX_BENCHES: bool = true; // interval = BENCHMARK_LOG_INTERVAL_DEGREE // min = ceil(log_2(BENCHMARK_MIN_DEGREE)) // max = ceil(log_2(BENCHMARK_MAX_DEGREE)) -fn default_size_range() -> Vec { +fn default_size_range_bls12_381() -> Vec { size_range( BENCHMARK_LOG_INTERVAL_DEGREE, BENCHMARK_MIN_DEGREE, - BENCHMARK_MAX_DEGREE, + BENCHMARK_MAX_DEGREE_BLS12_381, ) } -fn setup_bench(c: &mut Criterion, name: &str, bench_fn: fn(&mut Bencher, &usize)) { +fn default_size_range_mnt6_753() -> Vec { + size_range( + BENCHMARK_LOG_INTERVAL_DEGREE, + BENCHMARK_MIN_DEGREE, + BENCHMARK_MAX_DEGREE_MNT6_753, + ) +} + +fn setup_bench( + c: &mut Criterion, + name: &str, + bench_fn: fn(&mut Bencher, &usize), + size_range: &[usize], +) { let mut group = c.benchmark_group(name); - for degree in default_size_range().iter() { + for degree in size_range.iter() { group.bench_with_input(BenchmarkId::from_parameter(degree), degree, bench_fn); } group.finish(); @@ -83,28 +97,40 @@ fn bench_coset_ifft_in_place>(b: &mut Benche }); } -fn fft_benches>(c: &mut Criterion, name: &'static str) { +fn fft_benches>( + c: &mut Criterion, + name: &'static str, + size_range: &[usize], +) { let cur_name = format!("{:?} - subgroup_fft_in_place", name.clone()); - setup_bench(c, &cur_name, bench_fft_in_place::); + setup_bench(c, &cur_name, bench_fft_in_place::, size_range); let cur_name = format!("{:?} - subgroup_ifft_in_place", name.clone()); - setup_bench(c, &cur_name, bench_ifft_in_place::); + setup_bench(c, &cur_name, bench_ifft_in_place::, size_range); let cur_name = format!("{:?} - coset_fft_in_place", name.clone()); - setup_bench(c, &cur_name, bench_coset_fft_in_place::); + setup_bench(c, &cur_name, bench_coset_fft_in_place::, size_range); let cur_name = format!("{:?} - coset_ifft_in_place", name.clone()); - setup_bench(c, &cur_name, bench_coset_ifft_in_place::); + setup_bench(c, &cur_name, bench_coset_ifft_in_place::, size_range); } fn bench_bls12_381(c: &mut Criterion) { let name = "bls12_381 - radix2"; if ENABLE_RADIX2_BENCHES { - fft_benches::>(c, name); + fft_benches::>( + c, + name, + &default_size_range_bls12_381(), + ); } } fn bench_mnt6_753(c: &mut Criterion) { let name = "mnt6_753 - mixed radix"; if ENABLE_MIXED_RADIX_BENCHES { - fft_benches::>(c, name); + fft_benches::>( + c, + name, + &default_size_range_mnt6_753(), + ); } } From 5e9ed08066e9418bdc8b7659d6d0d6f0cf2c2a59 Mon Sep 17 00:00:00 2001 From: weikeng Date: Tue, 25 May 2021 20:48:21 -0700 Subject: [PATCH 2/4] update the CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52784b4e4..51e2c33ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ ### Bug fixes - [\#252](https://github.com/arkworks-rs/algebra/pull/252) (ark-ff) Fix prime field sampling when `REPR_SHIFT_BITS` is 64. +- [\#284](https://github.com/arkworks-rs/algebra/pull/284) (ark-poly-benches) Fix the panic `subgroup_fft_in_place` benchmark for MNT6-753's Fr. ## v0.2.0 From 06bf1683178ceabfcb832c1932a1ccfdf67c1e79 Mon Sep 17 00:00:00 2001 From: weikeng Date: Tue, 25 May 2021 21:49:16 -0700 Subject: [PATCH 3/4] lint --- CHANGELOG.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51e2c33ee..c80545888 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +# CHANGELOG + ## Pending ### Breaking changes @@ -14,6 +16,7 @@ ### Improvements ### Bug fixes + - [\#252](https://github.com/arkworks-rs/algebra/pull/252) (ark-ff) Fix prime field sampling when `REPR_SHIFT_BITS` is 64. - [\#284](https://github.com/arkworks-rs/algebra/pull/284) (ark-poly-benches) Fix the panic `subgroup_fft_in_place` benchmark for MNT6-753's Fr. @@ -33,6 +36,7 @@ The main features of this release are: - Adding new traits for basic curve cycles and pairing based curve cycles ### Breaking changes + - [\#20](https://github.com/arkworks-rs/algebra/pull/20) (ark-poly) Move univariate DensePolynomial and SparsePolynomial into a univariate sub-crate. Make this change by: find w/ regex `ark_poly::(Dense|Sparse)Polynomial`, and replace with `ark_poly::univariate::$1Polynomial`. @@ -52,18 +56,19 @@ The main features of this release are: Importing these from `ark-ff` is still possible, but is deprecated and will be removed in the following release. - [\#144](https://github.com/arkworks-rs/algebra/pull/144) (ark-poly) Add `CanonicalSerialize` and `CanonicalDeserialize` trait bounds for `Polynomial`. - [\#160](https://github.com/arkworks-rs/algebra/pull/160) (ark-serialize, ark-ff, ark-ec) - - Remove `ConstantSerializedSize`; users should use `serialized_size*` (see next). - - Add `serialized_size_with_flags` method to `CanonicalSerializeWithFlags`. - - Change `from_random_bytes_with_flags` to output `ark_serialize::Flags`. - - Change signatures of `Flags::from_u8*` to output `Option`. - - Change `Flags::from_u8*` to be more strict about the inputs they accept: - if the top bits of the `u8` value do *not* correspond to one of the possible outputs of `Flags::u8_bitmask`, then these methods output `None`, whereas before they output - a default value. - Downstream users other than `ark-curves` should not see breakage unless they rely on these methods/traits explicitly. + - Remove `ConstantSerializedSize`; users should use `serialized_size*` (see next). + - Add `serialized_size_with_flags` method to `CanonicalSerializeWithFlags`. + - Change `from_random_bytes_with_flags` to output `ark_serialize::Flags`. + - Change signatures of `Flags::from_u8*` to output `Option`. + - Change `Flags::from_u8*` to be more strict about the inputs they accept: + if the top bits of the `u8` value do *not* correspond to one of the possible outputs of `Flags::u8_bitmask`, then these methods output `None`, whereas before they output + a default value. + Downstream users other than `ark-curves` should not see breakage unless they rely on these methods/traits explicitly. - [\#165](https://github.com/arkworks-rs/algebra/pull/165) (ark-ff) Add `from_base_field_elements` as a method to the `Field` trait. - [\#166](https://github.com/arkworks-rs/algebra/pull/166) (ark-ff) Change `BigInt::{from_bytes, to_bits}` to `from_bytes_le, from_bytes_be, to_bits_le, to_bits_be`. ### Features + - [\#20](https://github.com/arkworks-rs/algebra/pull/20) (ark-poly) Add structs/traits for multivariate polynomials. - [\#96](https://github.com/arkworks-rs/algebra/pull/96) (ark-ff) Make the `field_new` macro accept values in integer form, without requiring decomposition into limbs, and without requiring encoding in Montgomery form. - [\#106](https://github.com/arkworks-rs/algebra/pull/106) (ark-ff, ark-ec) Add `Zeroize` trait bound to `Field, ProjectiveGroup, AffineGroup` traits. @@ -73,6 +78,7 @@ The main features of this release are: - [\#197](https://github.com/arkworks-rs/algebra/pull/197) (ark-test-curves) Add a BN384 curve with low two-arity for mixed-radix testing. ### Improvements + - [\#22](https://github.com/arkworks-rs/algebra/pull/22) (ark-ec) Speedup fixed-base MSMs. - [\#28](https://github.com/arkworks-rs/algebra/pull/28) (ark-poly) Add `domain()` method on the `evaluations` struct. - [\#31](https://github.com/arkworks-rs/algebra/pull/31) (ark-ec) Speedup point doubling on twisted edwards curves. @@ -110,6 +116,7 @@ The main features of this release are: - [\#242](https://github.com/arkworks-rs/algebra/pull/242), [\#244][https://github.com/arkworks-rs/algebra/pull/244] (ark-poly) Speedup the sequential radix-2 FFT significantly by making the method in which it accesses roots more cache-friendly. ### Bug fixes + - [\#36](https://github.com/arkworks-rs/algebra/pull/36) (ark-ec) In Short-Weierstrass curves, include an infinity bit in `ToConstraintField`. - [\#107](https://github.com/arkworks-rs/algebra/pull/107) (ark-serialize) Fix handling of `(de)serialize_uncompressed/unchecked` in various impls of `CanonicalSerialize/Deserialize`. - [\#112](https://github.com/arkworks-rs/algebra/pull/112) (ark-serialize) Make `bool`s checked serialization methods non-malleable. From 5a6d1163f30b9ddb23b7922a464b0d5855461918 Mon Sep 17 00:00:00 2001 From: weikeng Date: Tue, 25 May 2021 21:53:07 -0700 Subject: [PATCH 4/4] lint --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c80545888..4970d6d10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,6 @@ - [\#252](https://github.com/arkworks-rs/algebra/pull/252) (ark-ff) Fix prime field sampling when `REPR_SHIFT_BITS` is 64. - [\#284](https://github.com/arkworks-rs/algebra/pull/284) (ark-poly-benches) Fix the panic `subgroup_fft_in_place` benchmark for MNT6-753's Fr. - ## v0.2.0 The main features of this release are: