Skip to content

Commit c36601e

Browse files
committed
Merge remote-tracking branch 'upstream/master' into vec-allocator
* upstream/master: (29 commits) Fix some clippy lints (arkworks-rs#570) Correct tag name & complete command suggestion (arkworks-rs#569) Open a "release-PR" against a `releases` branch (arkworks-rs#566) Allow to overwrite default impl of `msm` in TwistedEdwards form (arkworks-rs#567) Remove poly-benches. (arkworks-rs#558) DO NOT MERGE YET. Release 0.4 (arkworks-rs#512) otherwise downstream users that have not migrated will not see warning (arkworks-rs#563) use `into_bigint()` in `Debug` for `Fp<P, N>` (arkworks-rs#562) Add `frobenius_map_in_place` (arkworks-rs#557) Fix test_sw_properties for some cofactor groups (arkworks-rs#555) Move h2c tests to test-templates (arkworks-rs#554) impl `CanonicalSerialize/Deserialize` for `BigUint` (arkworks-rs#551) Fix MontFp issue in fields with 64 * k bits (arkworks-rs#550) Fix tests for Modulus plus one div four (arkworks-rs#552) fix (arkworks-rs#547) Rename all `*Parameters` to `*Config` (arkworks-rs#545) Fix doc-comment on `SWUMap` and CamelCase `(CO)DOMAIN` Small cleanups in hash-to-curve (arkworks-rs#544) Allow to overwrite the default implementation of `msm` (arkworks-rs#528) Move `multi_miller_loop` and `final_exponentiation` into `BW6Config` (arkworks-rs#542) ...
2 parents 9547f2f + 7300a0d commit c36601e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+1952
-1161
lines changed

.github/release-pr-template.ejs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This is a release PR for version **<%= version.actual %>**<%
2+
if (version.actual != version.desired) {
3+
%> (performing a <%= version.desired %> bump).<%
4+
} else {
5+
%>.<%
6+
}
7+
%>
8+
9+
You will still need to manually publish the cargo crate:
10+
11+
```
12+
$ make VERSION=<%= version.actual %> release
13+
```

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,14 @@ jobs:
110110

111111
- name: Test assembly on nightly
112112
env:
113-
RUSTFLAGS: -C target-cpu=native
113+
RUSTFLAGS: -C target-cpu=native -Z macro-backtrace
114114
uses: actions-rs/cargo@v1
115115
with:
116116
command: test
117117
args: "--workspace \
118118
--package ark-test-curves \
119-
--all-features"
119+
--all-features
120+
"
120121
if: matrix.rust == 'nightly'
121122

122123
test_assembly:

.github/workflows/release_pr.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Open a release PR
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: Version to release
7+
required: true
8+
type: choice
9+
# Currently only alpha and patch releases are supported by this workflow, due to https://github.com/rust-lang/cargo/issues/4242
10+
options:
11+
- alpha
12+
- patch
13+
base_branch:
14+
description: Branch to target
15+
required: true
16+
type: string
17+
default: 'releases'
18+
19+
jobs:
20+
make-release-pr:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Install cargo-release
24+
uses: taiki-e/install-action@v1
25+
with:
26+
tool: cargo-release
27+
28+
- uses: actions/checkout@v3
29+
- uses: cargo-bins/release-pr@v2
30+
with:
31+
pr-template-file: .github/release-pr-template.ejs
32+
github-token: ${{ secrets.GITHUB_TOKEN }}
33+
version: ${{ inputs.version }}
34+
crate-release-all: true
35+
base-branch: ${{ inputs.base_branch }}

CHANGELOG.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
### Breaking changes
66

7+
### Features
8+
9+
### Improvements
10+
11+
### Bugfixes
12+
13+
## v0.4.0
14+
15+
### Breaking changes
16+
717
- [\#300](https://github.com/arkworks-rs/algebra/pull/300) (`ark-ec`) Change the implementation of `Hash` trait of `GroupProjective` to use the affine coordinates.
818
- [\#302](https://github.com/arkworks-rs/algebra/pull/302) (`ark-ff`) Rename `find_wnaf` to `find_naf`.
919
- [\#310](https://github.com/arkworks-rs/algebra/pull/310) (`ark-ec`, `ark-ff`) Remove unnecessary internal `PhantomData`.
@@ -31,7 +41,7 @@
3141
- [\#386](https://github.com/arkworks-rs/algebra/pull/386) (`ark-ff`) Remove `PrimeField::GENERATOR`, since it already exists on `FftField`.
3242
- [\#393](https://github.com/arkworks-rs/algebra/pull/393) (`ark-ec`, `ark-ff`) Rename `FpXParams` to `FpXConfig` and `FpXParamsWrapper` to `FpXConfigWrapper`.
3343
- [\#396](https://github.com/arkworks-rs/algebra/pull/396) (`ark-ec`) Remove `mul_bits` feature, and remove default implementations of `mul` and `mul_by_cofactor_to_projective`.
34-
- [\#408](https://github.com/arkworks-rs/algebra/pull/408) (`ark-ff`) Change the output of `Display` formatting for BigInt & Fp from hex to decimal.
44+
- [\#408](https://github.com/arkworks-rs/algebra/pull/408) (`ark-ff`) Change the output of `Display` formatting for `BigInt` and `Fp` from hex to decimal.
3545
- [\#412](https://github.com/arkworks-rs/algebra/pull/412) (`ark-poly`) Rename UV/MVPolynomial to DenseUV/MVPolynomial.
3646
- [\#417](https://github.com/arkworks-rs/algebra/pull/417) (`ark-ff`) Remove `ToBytes` and `FromBytes`.
3747
- [\#418](https://github.com/arkworks-rs/algebra/pull/418) (`ark-ff`) Add `sums_of_products` to `Field` and `Fp`
@@ -90,7 +100,7 @@
90100
- `miller_loop``multi_miller_loop`
91101
- `pairing``multi_pairing`
92102
- Change method signatures:
93-
- `product_of_pairings` -> `multi_pairing`
103+
- `product_of_pairings` `multi_pairing`
94104
- take two references to element iterators instead of an iterator of tuples.
95105
- `miller_loop` and `multi_miller_loop` now
96106
- take two iterators over `impl Into<G1Prepared>` and `impl Into<G2Prepared>` as input, and
@@ -136,6 +146,20 @@
136146
- Splits the contents of `ff/src/fields/mod.rs` into smaller files for easier management.
137147
- Moves `BitIterator` out of `ark_ff::fields` and into `ark_ff` directly.
138148
- Adds `impl<'a, 'b> Add/Sub/Mul/Div<&'a F> for &'b F`
149+
- [\#517](https://github.com/arkworks-rs/algebra/pull/517) (`ark-ec`) Move the definition of the isogeny map of WB hash-to-curve to a separate struct
150+
- [\#519](https://github.com/arkworks-rs/algebra/pull/519) (`ark-ec`) Refactor variable-base MSM to be checked by default, returning a `Result` if the lengths of the bases and scalars do not match.
151+
- [\#545](https://github.com/arkworks-rs/algebra/pull/545) (`ark-ec`, `ark-ff`) Rename all `*Parameters` or `*Params` to `*Config`, including:
152+
- `SWUParams``SWUConfig`
153+
- `WBParams``WBConfig`
154+
- `Bls12Parameters``Bls12Config`
155+
- `G1Parameters``G1Config`
156+
- `G2Parameters``G2Config`
157+
- `BnParameters``BnConfig`
158+
- `BW6Parameters``BW6Config`
159+
- `MNT4Parameters``MNT4Config`
160+
- `MNT6Parameters``MNT6Config`
161+
- `GLVParameters``GLVConfig`
162+
- [\#557](https://github.com/arkworks-rs/algebra/pull/557) (`ark-ff`) Change `frobenius_map` to return the result, instead of mutating the input. Add `frobenius_map_in_place` for the old behavior.
139163

140164
### Features
141165

@@ -160,6 +184,8 @@
160184
- Add constructor `new_coset`.
161185
- Add convenience method `get_coset`.
162186
- Add methods `coset_offset`, `coset_offset_inv` and `coset_offset_pow_size`.
187+
- [\#539](https://github.com/arkworks-rs/algebra/pull/539) (`ark-ec`) Implement wNAF-based MSM, resulting in 5-10% speedups.
188+
- [\#528](https://github.com/arkworks-rs/algebra/pull/528) (`ark-ec`) Allow to overwrite the default implementation of the `msm` function provided by the `VariableBaseMSM` trait by a specialized version in `SWCurveConfig`.
163189

164190
### Improvements
165191

@@ -169,6 +195,8 @@
169195
- [\#352](https://github.com/arkworks-rs/algebra/pull/352) (`ark-ff`) Update `QuadExtField::sqrt` for better performance.
170196
- [\#357](https://github.com/arkworks-rs/algebra/pull/357) (`ark-poly`) Speedup division by vanishing polynomials for dense polynomials.
171197
- [\#445](https://github.com/arkworks-rs/algebra/pull/445) (`ark-ec`) Use 2-NAF for ate pairing in MNT4/6 curves.
198+
- [\#509](https://github.com/arkworks-rs/algebra/pull/509) (`ark-ff`, `ark-ff-macros`) Support prime fields with (64 * k)-bit modulus.
199+
- [\#567](https://github.com/arkworks-rs/algebra/pull/567) (`ark-ec`) Allow to overwrite the default implementation of the `msm` function for TwistedEdwards form provided by the `VariableBaseMSM` trait by a specialized version in `TECurveConfig`.
172200

173201
### Bugfixes
174202

@@ -178,6 +206,8 @@
178206
- [\#394](https://github.com/arkworks-rs/algebra/pull/394) (`ark-ff`, `ark-serialize`) Remove `EmptyFlags` construction checks.
179207
- [\#442](https://github.com/arkworks-rs/algebra/pull/442) (`ark-ff`) Fix deserialization for modulo with 64 shaving bits.
180208
- [\#460](https://github.com/arkworks-rs/algebra/pull/460) (`ark-ec`) Fix a corner case for ate pairing in BLS12 and BW6 models.
209+
- [\#521](https://github.com/arkworks-rs/algebra/pull/521) (`ark-poly`) Change `DensePolynomial::evaluate_over_domain` to not truncate terms higher than the size of the domain.
210+
- [\#526](https://github.com/arkworks-rs/algebra/pull/526) (`ark-ff`) Fix squaring for `Fp128`.
181211

182212
## v0.3.0
183213

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ members = [
1212
"bench-templates",
1313

1414
"poly",
15-
"poly-benches",
1615
"test-curves",
1716
"test-templates",
1817
]
@@ -42,6 +41,5 @@ incremental = true
4241
debug-assertions = true
4342
debug = true
4443

45-
# To be removed in the new release.
46-
[patch.crates-io]
47-
ark-std = { git = "https://github.com/arkworks-rs/std"}
44+
[workspace.metadata.release]
45+
dependent-version = "fix"

bench-templates/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ark-algebra-bench-templates"
3-
version = "0.3.0"
3+
version = "0.4.0-alpha.6"
44
authors = [ "arkworks contributors" ]
55
description = "A benchmark library for finite fields and elliptic curves"
66
homepage = "https://arkworks.rs"
@@ -16,10 +16,10 @@ edition = "2021"
1616

1717
[dependencies]
1818
criterion = { version = "0.4.0", features = [ "html_reports" ] }
19-
ark-std = { version = "^0.3.0", default-features = false }
20-
ark-ec = { version = "^0.3.0", path = "../ec", default-features = false }
21-
ark-ff = { version = "^0.3.0", path = "../ff", default-features = false }
22-
ark-serialize = { version = "^0.3.0", path = "../serialize", default-features = false }
19+
ark-std = { version = "0.4.0-alpha", default-features = false }
20+
ark-ec = { version = "0.4.0-alpha", path = "../ec", default-features = false }
21+
ark-ff = { version = "0.4.0-alpha", path = "../ff", default-features = false }
22+
ark-serialize = { version = "0.4.0-alpha", path = "../serialize", default-features = false }
2323
paste = { version = "1.0" }
2424

2525
[features]

ec/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ark-ec"
3-
version = "0.3.0"
3+
version = "0.4.0-alpha.6"
44
authors = [ "arkworks contributors" ]
55
description = "A library for elliptic curves and pairings"
66
homepage = "https://arkworks.rs"
@@ -14,10 +14,10 @@ edition = "2021"
1414
rust-version = "1.57"
1515

1616
[dependencies]
17-
ark-std = { version = "^0.3.0", default-features = false }
18-
ark-serialize = { version = "^0.3.0", path = "../serialize", default-features = false }
19-
ark-ff = { version = "^0.3.0", path = "../ff", default-features = false }
20-
ark-poly = { version = "^0.3.0", path = "../poly", default-features = false }
17+
ark-std = { version = "0.4.0-alpha", default-features = false }
18+
ark-serialize = { version = "0.4.0-alpha", path = "../serialize", default-features = false }
19+
ark-ff = { version = "0.4.0-alpha", path = "../ff", default-features = false }
20+
ark-poly = { version = "0.4.0-alpha", path = "../poly", default-features = false }
2121
derivative = { version = "2", features = ["use_core"] }
2222
num-traits = { version = "0.2", default-features = false }
2323
rayon = { version = "1", optional = true }
@@ -26,7 +26,7 @@ hashbrown = "0.13.1"
2626
itertools = { version = "0.10", default-features = false }
2727

2828
[dev-dependencies]
29-
ark-test-curves = { version = "^0.3.0", path = "../test-curves", default-features = false, features = ["bls12_381_curve"] }
29+
ark-test-curves = { version = "0.4.0-alpha", path = "../test-curves", default-features = false, features = ["bls12_381_curve"] }
3030
sha2 = { version = "0.10", default-features = false }
3131
libtest-mimic = "0.6.0"
3232
serde = "1.0.110"

ec/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ let s2 = ScalarField::rand(&mut rng);
7474
//
7575
// The `VariableBaseMSM` trait allows specializing the input group element representation to allow
7676
// for more efficient implementations.
77-
let result = G::msm(&[a, b], &[s1, s2]);
78-
assert_eq!(result, a * s1 + b * s2);
77+
let r = G::msm(&[a, b], &[s1, s2]).unwrap();
78+
assert_eq!(r, a * s1 + b * s2);
7979
```
8080

8181
### Elliptic curve groups

ec/src/hashing/curve_maps/swu/mod.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
/// y^2 = x^3 + a*x + b where ab != 0. From [\[WB2019\]]
1414
///
1515
/// - [\[WB2019\]] <https://eprint.iacr.org/2019/403>
16-
pub trait SWUParams: SWCurveConfig {
16+
pub trait SWUConfig: SWCurveConfig {
1717
/// An element of the base field that is not a square root see \[WB2019, Section 4\].
1818
/// It is also convenient to have $g(b/ZETA * a)$ to be square. In general
1919
/// we use a `ZETA` with low absolute value coefficients when they are
@@ -22,9 +22,7 @@ pub trait SWUParams: SWCurveConfig {
2222
}
2323

2424
/// Represents the SWU hash-to-curve map defined by `P`.
25-
pub struct SWUMap<P: SWUParams> {
26-
curve_params: PhantomData<fn() -> P>,
27-
}
25+
pub struct SWUMap<P: SWUConfig>(PhantomData<fn() -> P>);
2826

2927
/// Trait defining a parity method on the Field elements based on [\[1\]] Section 4.1
3028
///
@@ -36,7 +34,7 @@ pub fn parity<F: Field>(element: &F) -> bool {
3634
.map_or(false, |x| x.into_bigint().is_odd())
3735
}
3836

39-
impl<P: SWUParams> MapToCurve<Projective<P>> for SWUMap<P> {
37+
impl<P: SWUConfig> MapToCurve<Projective<P>> for SWUMap<P> {
4038
/// Constructs a new map if `P` represents a valid map.
4139
fn new() -> Result<Self, HashToCurveError> {
4240
// Verifying that ZETA is a non-square
@@ -51,9 +49,7 @@ impl<P: SWUParams> MapToCurve<Projective<P>> for SWUMap<P> {
5149
return Err(HashToCurveError::MapToCurveError("Simplified SWU requires a * b != 0 in the short Weierstrass form of y^2 = x^3 + a*x + b ".to_string()));
5250
}
5351

54-
Ok(SWUMap {
55-
curve_params: PhantomData,
56-
})
52+
Ok(SWUMap(PhantomData))
5753
}
5854

5955
/// Map an arbitrary base field element to a curve point.
@@ -175,9 +171,9 @@ mod test {
175171

176172
const F127_ONE: F127 = MontFp!("1");
177173

178-
struct TestSWUMapToCurveParams;
174+
struct TestSWUMapToCurveConfig;
179175

180-
impl CurveConfig for TestSWUMapToCurveParams {
176+
impl CurveConfig for TestSWUMapToCurveConfig {
181177
const COFACTOR: &'static [u64] = &[1];
182178

183179
#[rustfmt::skip]
@@ -186,6 +182,7 @@ mod test {
186182
type BaseField = F127;
187183
type ScalarField = F127;
188184
}
185+
189186
/// just because not defining another field
190187
///
191188
/// from itertools import product
@@ -200,19 +197,18 @@ mod test {
200197
/// pass
201198
///
202199
/// y^2 = x^3 + x + 63
203-
impl SWCurveConfig for TestSWUMapToCurveParams {
200+
impl SWCurveConfig for TestSWUMapToCurveConfig {
204201
/// COEFF_A = 1
205202
const COEFF_A: F127 = F127_ONE;
206203

207-
/// COEFF_B = 1
208-
#[rustfmt::skip]
204+
/// COEFF_B = 63
209205
const COEFF_B: F127 = MontFp!("63");
210206

211207
/// AFFINE_GENERATOR_COEFFS = (G1_GENERATOR_X, G1_GENERATOR_Y)
212208
const GENERATOR: Affine<Self> = Affine::new_unchecked(MontFp!("62"), MontFp!("70"));
213209
}
214210

215-
impl SWUParams for TestSWUMapToCurveParams {
211+
impl SWUConfig for TestSWUMapToCurveConfig {
216212
const ZETA: F127 = MontFp!("-1");
217213
}
218214

@@ -241,9 +237,9 @@ mod test {
241237
#[test]
242238
fn hash_arbitary_string_to_curve_swu() {
243239
let test_swu_to_curve_hasher = MapToCurveBasedHasher::<
244-
Projective<TestSWUMapToCurveParams>,
240+
Projective<TestSWUMapToCurveConfig>,
245241
DefaultFieldHasher<Sha256, 128>,
246-
SWUMap<TestSWUMapToCurveParams>,
242+
SWUMap<TestSWUMapToCurveConfig>,
247243
>::new(&[1])
248244
.unwrap();
249245

@@ -260,9 +256,9 @@ mod test {
260256
/// elements should be mapped to curve successfully. everything can be mapped
261257
#[test]
262258
fn map_field_to_curve_swu() {
263-
let test_map_to_curve = SWUMap::<TestSWUMapToCurveParams>::new().unwrap();
259+
let test_map_to_curve = SWUMap::<TestSWUMapToCurveConfig>::new().unwrap();
264260

265-
let mut map_range: Vec<Affine<TestSWUMapToCurveParams>> = vec![];
261+
let mut map_range: Vec<Affine<TestSWUMapToCurveConfig>> = vec![];
266262
for current_field_element in 0..127 {
267263
map_range.push(
268264
test_map_to_curve

0 commit comments

Comments
 (0)