Skip to content
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2351c4e
add multilinear trait
tsunrise Dec 16, 2020
68a5b33
add dense multilinear poly structure
tsunrise Dec 16, 2020
4d81c31
tweaks
tsunrise Dec 16, 2020
e54ff27
Merge branch 'master' into multilinear
tsunrise Dec 16, 2020
77a5cfd
add interfaces for multilinear poly
tsunrise Dec 16, 2020
ec753d9
add evaluate & relabel for multilinear
tsunrise Dec 16, 2020
bd8c8fb
Merge branch 'master' of https://github.com/arkworks-rs/algebra into …
tsunrise Dec 16, 2020
e330ead
tweaks
tsunrise Dec 17, 2020
adcb68c
temporarily rely on ark-std in "rand" branch
tsunrise Dec 17, 2020
ac68907
add unit tests for arithmetic
tsunrise Dec 17, 2020
72776d7
Merge branch 'master' into multilinear
tsunrise Dec 17, 2020
a652356
add support for serialization
tsunrise Dec 17, 2020
51ac893
tweak
tsunrise Dec 17, 2020
cec05f1
add sparse multilinear polynomial, add evaluation method
tsunrise Dec 18, 2020
3a424ec
impl sparse polynomial arithmetic
tsunrise Dec 19, 2020
2a7f80c
add relabel feature for sparse multilinear poly
tsunrise Dec 19, 2020
fe558db
Merge branch 'master' into multilinear
tsunrise Dec 19, 2020
65ae89c
tweaks
tsunrise Dec 19, 2020
14527c4
update changelog
tsunrise Dec 19, 2020
2a148a2
update changelog (add pending section)
tsunrise Dec 19, 2020
a2bab48
change wording to avoid confusion
tsunrise Dec 21, 2020
74c61bf
add Index
tsunrise Dec 21, 2020
2c1ec95
Merge branch 'master' into multilinear
tsunrise Dec 21, 2020
e6ce297
Merge branch 'master' into multilinear
tsunrise Dec 23, 2020
52cb95d
put sparse multilinear public, add benchmark
tsunrise Dec 24, 2020
5f68180
add IntoIter for multilinear polynomials
tsunrise Dec 24, 2020
54dda76
tweak benchmarks
tsunrise Dec 24, 2020
6a0318d
change CHANGELOG.md
tsunrise Dec 24, 2020
e7954b1
some tweaks on comments and remove unused import
tsunrise Dec 24, 2020
2b0387f
update README.md
tsunrise Dec 24, 2020
afa1b5f
update ark-poly/README.md
tsunrise Dec 25, 2020
c8fa76b
tweak README.md
tsunrise Dec 25, 2020
ba0bd0c
rename `partial_evaluate` to `fix_variables`
tsunrise Dec 28, 2020
dd8707e
move multilinear extension to evaluations module
tsunrise Dec 29, 2020
3e6dd90
tweak benchmarks
tsunrise Dec 29, 2020
916a95f
run fmt
tsunrise Dec 29, 2020
cbf099a
update CHANGELOG.md
tsunrise Dec 29, 2020
7de1ae9
change API described in README.md
tsunrise Dec 29, 2020
18eb780
Merge branch 'master' into multilinear
tsunrise Dec 31, 2020
a1ed89b
tweak some apis
tsunrise Dec 31, 2020
5054bb4
add api for ml
tsunrise Jan 1, 2021
e075040
Merge branch 'master' into multilinear
tsunrise Jan 4, 2021
6ef9c17
bug fix
tsunrise Jan 4, 2021
366749f
bug fix (trivial sparse poly)
tsunrise Jan 4, 2021
4b8cda8
change API of `evaluate`, tweak some documentations
tsunrise Jan 7, 2021
c237053
tweak benchmark
tsunrise Jan 7, 2021
4b4eb8d
Merge branch 'master' into multilinear
tsunrise Jan 7, 2021
e8f52ed
undo "Rename `Evaluations` to `UVEvaluations` "
tsunrise Jan 7, 2021
5f8a4fa
run cargo fmt
tsunrise Jan 7, 2021
3dee101
change README.md
tsunrise Jan 7, 2021
89c19a2
small tweaks on `index`
tsunrise Jan 8, 2021
2190738
Merge branch 'master' into multilinear
tsunrise Jan 11, 2021
5ce208c
tweak documentations
tsunrise Jan 11, 2021
0d65000
tweak README (a small change on links)
tsunrise Jan 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ The main features of this release are:

- Adding the ability to define fields with integer parameters
- Multi-variate polynomial support
- Multilinear polynomial support
- Many speedups to operations involving polynomials
- Some speedups to `sqrt`
- Small speedups to `MSM`s
Expand All @@ -26,6 +27,7 @@ The main features of this release are:
by replacing `sparse_poly.evaluate(pt)` to `sparse_poly.evaluate(&pt)`.
- #129 (ark-ff) Move `ark_ff::{UniformRand, test_rng}` to `ark_std::{UniformRand, test_rng}`.
Importing these from `ark-ff` is still possible, but is deprecated and will be removed in the following release.
- #140 (ark-poly) Rename `Evaluations` to `UVEvaluations`
Comment thread
tsunrise marked this conversation as resolved.
Outdated
- #144 (ark-poly) Add `CanonicalSerialize` and `CanonicalDeserialize` trait bounds for `Polynomial`.
- #160 (ark-serialize, ark-ff, ark-ec)
- Remove `ConstantSerializedSize`; users should use `serialized_size*` (see next).
Expand Down Expand Up @@ -63,6 +65,7 @@ The main features of this release are:
- #125 (ark-poly) Add parallelization to applying coset shifts within `coset_fft`.
- #126 (ark-ec) Use `ark_ff::batch_inversion` for point normalization
- #131, #137 (ark-ff) Speedup `sqrt` on fields when a square root exists. (And slows it down when doesn't exist)
- #140 (ark-poly) Add support for multilinear extensions in dense and sparse evaluation form.
- #141 (ark-ff) Add `Fp64`
- #144 (ark-poly) Add serialization for polynomials and evaluations
- #149 (ark-serialize) Add an impl of `CanonicalSerialize/Deserialize` for `String`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This repository contains several Rust crates:

* [`ark-ff`](ff): Provides generic implementations of various finite fields
* [`ark-ec`](ec): Provides generic implementations for different kinds of elliptic curves, along with pairings over these
* [`ark-poly`](poly): Implements polynomials and FFTs over finite fields
* [`ark-poly`](poly): Implements polynomials (univariate, multivariate, and multilinear), and FFTs over finite fields.
Comment thread
tsunrise marked this conversation as resolved.
Outdated
* [`ark-serialize`](serialize): Provides efficient serialization and point compression for finite fields and elliptic curves

In addition, the [`curves`](https://github.com/arkworks-rs/curves) repository contains implementations of popular elliptic curves; see [here](https://github.com/arkworks-rs/curves/README.md) for details.
Expand Down
14 changes: 12 additions & 2 deletions poly-benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,18 @@ path = "benches/fft.rs"
harness = false

[[bench]]
name = "dense_polynomial"
path = "benches/dense_polynomial.rs"
name = "dense_uv_polynomial"
path = "benches/dense_uv_polynomial.rs"
harness = false

[[bench]]
name = "dense_multilinear"
path = "benches/dense_multilinear.rs"
harness = false

[[bench]]
name = "sparse_multilinear"
path = "benches/sparse_multilinear.rs"
harness = false

[lib]
Expand Down
56 changes: 56 additions & 0 deletions poly-benches/benches/dense_multilinear.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#[macro_use]
extern crate criterion;

use ark_ff::Field;
use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
use ark_std::ops::Range;
use ark_std::test_rng;
use ark_test_curves::bls12_381;
use criterion::{black_box, BenchmarkId, Criterion};

const NUM_VARIABLES_RANGE: Range<usize> = 10..21;

fn arithmetic_op_bench<F: Field>(c: &mut Criterion) {
let mut rng = test_rng();

let mut group = c.benchmark_group("Add");
for nv in NUM_VARIABLES_RANGE {
group.bench_with_input(BenchmarkId::new("Add", nv), &nv, |b, &nv| {
let poly1 = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng);
let poly2 = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng);
b.iter(|| black_box(&poly1 + &poly2))
});
}
group.finish();

let mut group = c.benchmark_group("Sub");
for nv in NUM_VARIABLES_RANGE {
group.bench_with_input(BenchmarkId::new("Sub", nv), &nv, |b, &nv| {
let poly1 = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng);
let poly2 = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng);
b.iter(|| black_box(&poly1 - &poly2))
});
}
group.finish();
}

fn evaluation_op_bench<F: Field>(c: &mut Criterion) {
let mut rng = test_rng();
let mut group = c.benchmark_group("Evaluate");
for nv in NUM_VARIABLES_RANGE {
group.bench_with_input(BenchmarkId::new("evaluate", nv), &nv, |b, &nv| {
let poly = DenseMultilinearExtension::<F>::rand(nv, nv, &mut rng);
let point: Vec<_> = (0..nv).map(|_| F::rand(&mut rng)).collect();
b.iter(|| black_box(poly.evaluate(&point)))
});
}
group.finish();
}

fn bench_bls_381(c: &mut Criterion) {
arithmetic_op_bench::<bls12_381::Fr>(c);
evaluation_op_bench::<bls12_381::Fr>(c);
}

criterion_group!(benches, bench_bls_381);
criterion_main!(benches);
91 changes: 91 additions & 0 deletions poly-benches/benches/sparse_multilinear.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#[macro_use]
extern crate criterion;

use ark_ff::Field;
use ark_poly::{MultilinearExtension, SparseMultilinearExtension};
use ark_std::ops::Range;
use ark_std::test_rng;
use ark_test_curves::bls12_381;
use criterion::{black_box, BenchmarkId, Criterion};

const NUM_VARIABLES_RANGE: Range<usize> = 12..23;

fn arithmetic_op_bench<F: Field>(c: &mut Criterion) {
let mut rng = test_rng();

let mut group = c.benchmark_group("Add");
for nv in NUM_VARIABLES_RANGE {
let num_nonzero_entries = 1 << (nv / 2);
group.bench_with_input(
BenchmarkId::new("add", num_nonzero_entries),
&num_nonzero_entries,
|b, &num_nonzero_entries| {
let poly1 = SparseMultilinearExtension::<F>::rand_with_config(
nv,
num_nonzero_entries,
&mut rng,
);
let poly2 = SparseMultilinearExtension::<F>::rand_with_config(
nv,
num_nonzero_entries,
&mut rng,
);
b.iter(|| black_box(&poly1 + &poly2))
},
);
}
group.finish();

let mut group = c.benchmark_group("Sub");
for nv in NUM_VARIABLES_RANGE {
let num_nonzero_entries = 1 << (nv / 2);
group.bench_with_input(
BenchmarkId::new("sub", num_nonzero_entries),
&num_nonzero_entries,
|b, &num_nonzero_entries| {
let poly1 = SparseMultilinearExtension::<F>::rand_with_config(
nv,
num_nonzero_entries,
&mut rng,
);
let poly2 = SparseMultilinearExtension::<F>::rand_with_config(
nv,
num_nonzero_entries,
&mut rng,
);
b.iter(|| black_box(&poly1 - &poly2))
},
);
}
group.finish();
}

fn evaluation_op_bench<F: Field>(c: &mut Criterion) {
let mut rng = test_rng();
let mut group = c.benchmark_group("Evaluate");
for nv in NUM_VARIABLES_RANGE {
let num_nonzero_entries = 1 << (nv / 2);
group.bench_with_input(
BenchmarkId::new("evaluate", num_nonzero_entries),
&num_nonzero_entries,
|b, &num_nonzero_entries| {
let poly = SparseMultilinearExtension::<F>::rand_with_config(
nv,
num_nonzero_entries,
&mut rng,
);
let point: Vec<_> = (0..nv).map(|_| F::rand(&mut rng)).collect();
b.iter(|| black_box(poly.evaluate(&point)))
},
);
}
group.finish();
}

fn bench_bls381(c: &mut Criterion) {
arithmetic_op_bench::<bls12_381::Fr>(c);
evaluation_op_bench::<bls12_381::Fr>(c);
}

criterion_group!(benches, bench_bls381);
criterion_main!(benches);
1 change: 1 addition & 0 deletions poly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ark-std = { git = "https://github.com/arkworks-rs/utils", default-features = fal
rand = { version = "0.7", default-features = false }
rayon = { version = "1", optional = true }
derivative = { version = "2", default-features = false, features = [ "use_core" ] }
hashbrown = {version = "0.9.1"}

[dev-dependencies]
ark-test-curves = { path = "../test-curves", default-features = false, features = [ "bls12_381_curve", "mnt4_753_curve"] }
Expand Down
22 changes: 21 additions & 1 deletion poly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This crate implements traits and implementations for polynomials, FFT-friendly s

### Polynomials

The `polynomial` module provides the following traits for defining polynomials:
The `polynomial` module provides the following traits for defining polynomials in coefficient form:

- [`Polynomial`](https://github.com/arkworks-rs/algebra/blob/master/poly/src/polynomial/mod.rs#L16):
Requires implementors to support common operations on polynomials,
Expand All @@ -30,6 +30,26 @@ Represents multivariate polynomials via a list containing all non-zero monomials

This crate also provides the [`univariate/DenseOrSparsePolynomial`](https://github.com/arkworks-rs/algebra/blob/master/poly/src/polynomial/univariate/mod.rs#L16) enum, which allows the user to abstract over the type of underlying univariate polynomial (dense or sparse).

### Evaluations

The `evaluations` module provides data structures to represent univariate polynomials in lagrange form.

- [`univariate/UVEvaluations`](./src/evaluations/univariate/mod.rs#L18)
Represents a univariate polynomial in evaluation form, which can be used for FFT.

The `evaluations` module also provides the following traits for defining multivariate polynomials in lagrange form:

- [`multivariate/multilinear/MultilinearExtension`](./src/evaluations/multivariate/multilinear/mod.rs#L20)
Specifies a multilinear polynomial evaluated over boolean hypercube.

This crate provides some data structures to implement these traits.

- [`multivariate/multilinear/DenseMultilinearExtension`](./src/evaluations/multivariate/multilinear/dense.rs#L24)
Represents multilinear extension via a list of evaluations over boolean hypercube.

- [`multivariate/multilinear/SparseMultilinearExtension`](./src/evaluations/multivariate/multilinear/sparse.rs#L20)
Represents multilinear extension via a list of non-zero evaluations over boolean hypercube.

### Domains

TODO
2 changes: 2 additions & 0 deletions poly/src/evaluations/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod multivariate;
pub mod univariate;
4 changes: 4 additions & 0 deletions poly/src/evaluations/multivariate/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub mod multilinear;
pub use multilinear::{
DenseMultilinearExtension, MultilinearExtension, SparseMultilinearExtension,
};
Loading