Skip to content

Commit

Permalink
Merge pull request #3 from distributed-lab/feature/bls12-377fr
Browse files Browse the repository at this point in the history
Add support of bls12-377fr
  • Loading branch information
olegfomenko authored Jan 10, 2025
2 parents c00d439 + 2be659b commit b8dc480
Show file tree
Hide file tree
Showing 7 changed files with 1,049 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
Cargo.lock
flamegraph.svg
.idea
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"baby-bear",
"blake3",
"blake3-air",
"bls12-377-fr",
"bn254-fr",
"challenger",
"circle",
Expand Down Expand Up @@ -74,6 +75,7 @@ p3-air = { path = "air", version = "0.1.0" }
p3-baby-bear = { path = "baby-bear", version = "0.1.0" }
p3-blake3 = { path = "blake3", version = "0.1.0" }
p3-blake3-air = { path = "blake3-air", version = "0.1.0" }
p3-bls12-377-fr = { path = "bls12-377-fr", version = "0.1.0" }
p3-bn254-fr = { path = "bn254-fr", version = "0.1.0" }
p3-challenger = { path = "challenger", version = "0.1.0" }
p3-circle = { path = "circle", version = "0.1.0" }
Expand Down
34 changes: 34 additions & 0 deletions bls12-377-fr/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "p3-bls12-377-fr"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
p3-field.workspace = true
p3-poseidon2.workspace = true
p3-symmetric.workspace = true

num-bigint.workspace = true
rand.workspace = true
serde = { workspace = true, features = ["derive"] }
lazy_static = { version = "1.5.0" }

# Ark
ark-bls12-377 = { version = "0.5.0" }
ark-serialize = { version = "0.5.0" }
ark-ff = { version = "0.5.0" }

[dev-dependencies]
p3-field-testing.workspace = true

criterion.workspace = true
num-traits.workspace = true
serde_json.workspace = true

[features]
default = []

[[bench]]
name = "bench_field"
harness = false
28 changes: 28 additions & 0 deletions bls12-377-fr/benches/bench_field.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use criterion::{criterion_group, criterion_main, Criterion};
use p3_bls12_377_fr::Bls12_377Fr;
use p3_field_testing::bench_func::{
benchmark_add_latency, benchmark_add_throughput, benchmark_inv, benchmark_iter_sum,
benchmark_sub_latency, benchmark_sub_throughput,
};

type F = Bls12_377Fr;

fn bench_field(c: &mut Criterion) {
let name = "Bls12-377Fr";
const REPS: usize = 1000;
benchmark_inv::<F>(c, name);
benchmark_iter_sum::<F, 4, REPS>(c, name);
benchmark_iter_sum::<F, 8, REPS>(c, name);
benchmark_iter_sum::<F, 12, REPS>(c, name);

// Note that each round of throughput has 10 operations
// So we should have 10 * more repetitions for latency tests.
const L_REPS: usize = 10 * REPS;
benchmark_add_latency::<F, L_REPS>(c, name);
benchmark_add_throughput::<F, REPS>(c, name);
benchmark_sub_latency::<F, L_REPS>(c, name);
benchmark_sub_throughput::<F, REPS>(c, name);
}

criterion_group!(bls12377fr_arithmetic, bench_field);
criterion_main!(bls12377fr_arithmetic);
Loading

0 comments on commit b8dc480

Please sign in to comment.