Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Reed Solomon code #256

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ and follow [semantic versioning](https://semver.org/) for our releases.
- [#233](https://github.com/EspressoSystems/jellyfish/pull/233) BLS aggregation APIs
- [#234](https://github.com/EspressoSystems/jellyfish/pull/234) New `bytes_from_field_elements` util
- [#231](https://github.com/EspressoSystems/jellyfish/pull/231) Implemented FK23 for fast amortized opening for univariate PCS
- [#225](https://github.com/EspressoSystems/jellyfish/pull/225) Implemented Reed Solomon erasure code
- [#254](https://github.com/EspressoSystems/jellyfish/pull/254) Ensure `no_std` and target WASM support
- [#271](https://github.com/EspressoSystems/jellyfish/pull/271) Serde support for Aggregateable signatures
- [#291](https://github.com/EspressoSystems/jellyfish/pull/291) Non-native field operations and elliptic curve addition

### Changed

- [#256](https://github.com/EspressoSystems/jellyfish/pull/256) Refactored Reed Solomon erasure code
- [#238](https://github.com/EspressoSystems/jellyfish/pull/238) add public keys into signature aggregation APIs
- [#251](https://github.com/EspressoSystems/jellyfish/pull/251) add sign_key_ref api for BLSKeyPair
- [#297](https://github.com/EspressoSystems/jellyfish/pull/297) Updated `tagged-base64` dependency to the `crates.io` package
Expand Down
5 changes: 5 additions & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ harness = false
name = "pcs"
harness = false

[[bench]]
name = "reed-solomon"
path = "benches/reed_solomon.rs"
harness = false

[features]
default = ["parallel"]
std = ["ark-std/std", "ark-serialize/std", "ark-ff/std", "ark-ec/std",
Expand Down
51 changes: 51 additions & 0 deletions primitives/benches/reed_solomon.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2022 Espresso Systems (espressosys.com)
// This file is part of the Jellyfish library.

// You should have received a copy of the MIT License
// along with the Jellyfish library. If not, see <https://mit-license.org/>.

#![deny(warnings)]
#[macro_use]
extern crate criterion;
use ark_bn254::Fr as Fr254;
use ark_poly::{EvaluationDomain, GeneralEvaluationDomain};
use criterion::Criterion;
use jf_primitives::reed_solomon_code::reed_solomon_erasure_decode;
use std::time::Duration;

const BENCH_ENCODE: &str = "reed_solomon_encode_4096";
const BENCH_DECODE: &str = "reed_solomon_decode_4096";
const N: usize = 2048;
const N_HALF: usize = 1024;

fn reed_solomon(c: &mut Criterion) {
let domain = GeneralEvaluationDomain::<Fr254>::new(N).unwrap();

let mut bench = c.benchmark_group("reed_solomon");
bench.sample_size(10);
bench.measurement_time(Duration::new(5, 0));
let input = vec![Fr254::from(1u64); N_HALF];
bench.bench_function(BENCH_ENCODE, |b| b.iter(|| domain.fft(&input)));

let code = domain.fft(&input);
let eval_points = domain.elements().collect::<Vec<_>>();

bench.bench_function(BENCH_DECODE, |b| {
b.iter(|| {
reed_solomon_erasure_decode::<Fr254, _, _, _>(
eval_points.iter().zip(&code).take(N_HALF),
N_HALF,
)
.unwrap()
})
});
bench.finish();
}

fn bench(c: &mut Criterion) {
reed_solomon(c);
}

criterion_group!(benches, bench);

criterion_main!(benches);
46 changes: 0 additions & 46 deletions primitives/src/erasure_code/mod.rs

This file was deleted.

187 changes: 0 additions & 187 deletions primitives/src/erasure_code/reed_solomon_erasure.rs

This file was deleted.

2 changes: 1 addition & 1 deletion primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ pub mod commitment;
pub mod constants;
pub mod crhf;
pub mod elgamal;
pub mod erasure_code;
pub mod errors;
pub mod hash_to_group;
pub mod merkle_tree;
pub mod pcs;
pub mod prf;
pub mod reed_solomon_code;
pub mod rescue;
pub mod signatures;
pub mod toeplitz;
Expand Down
2 changes: 1 addition & 1 deletion primitives/src/pcs/univariate_kzg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ mod tests {
.zip(evals.into_iter())
.for_each(|((point, proof), eval)| {
assert_eq!(
UnivariateKzgPCS::<E>::open(&ck, &poly, &point).unwrap(),
UnivariateKzgPCS::<E>::open(&ck, &poly, point).unwrap(),
(proof, eval)
);
});
Expand Down
Loading