Skip to content
This repository has been archived by the owner on Dec 9, 2021. It is now read-only.

Implementation of Daira reduction #98

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ harness = false
name = "tweedledee_base"
harness = false

[[bench]]
name = "tweedledum_base"
harness = false

[[bench]]
name = "bls12_g1"
harness = false
Expand All @@ -66,6 +70,10 @@ harness = false

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1

[profile.bench]
opt-level = 3
lto = "fat"
codegen-units = 1
37 changes: 37 additions & 0 deletions benches/tweedledum_base.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use criterion::{black_box, Criterion};
use criterion::criterion_group;
use criterion::criterion_main;

use plonky::{Field, TweedledumBase};

fn criterion_benchmark(c: &mut Criterion) {
let x = TweedledumBase::from_canonical([11111111, 22222222, 33333333, 44444444]);
let y = TweedledumBase::from_canonical([44444444, 55555555, 66666666, 77777777]);

c.bench_function("TweedledumBase field addition", move |b| b.iter(|| {
black_box(y) + black_box(x)
}));

c.bench_function("TweedledumBase field subtraction (no underflow)", move |b| b.iter(|| {
black_box(y) - black_box(x)
}));

c.bench_function("TweedledumBase field subtraction (underflow)", move |b| b.iter(|| {
black_box(x) - black_box(y)
}));

c.bench_function("TweedledumBase field multiplication", move |b| b.iter(|| {
black_box(x) * black_box(y)
}));

c.bench_function("TweedledumBase field squaring", move |b| b.iter(|| {
black_box(x).square()
}));

c.bench_function("TweedledumBase field inversion", move |b| b.iter(|| {
black_box(x).multiplicative_inverse()
}));
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
8 changes: 4 additions & 4 deletions src/curve/tweedledee_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ impl Curve for Tweedledee {
impl HaloCurve for Tweedledee {
const ZETA: Self::BaseField = TweedledeeBase {
limbs: [
1444470991491022206,
3301226169728360777,
72516509137424193,
708688398506307241,
4869731214443914493,
7624468717990391489,
9776623610414440446,
3946962219815967320
],
};
const ZETA_SCALAR: Self::ScalarField = TweedledumBase {
Expand Down
8 changes: 4 additions & 4 deletions src/curve/tweedledum_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ impl HaloCurve for Tweedledum {
};
const ZETA_SCALAR: Self::ScalarField = TweedledeeBase {
limbs: [
9282944046338294407,
16421485501699768486,
18374227564572127422,
3902997619921080662,
4654449422605769475,
11077468875262875656,
8670120463295111169,
664723798611420583
]
};
}
Expand Down
Loading