-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(decaf377): bump dep (#3806)
## Describe your changes Updates the `decaf377`, `decaf377-rdsa`, and `poseidon377` dep versions ## Issue ticket number and link References #3676 and consumes changes in #3678. unblocked by penumbra-zone/decaf377#101 ## Checklist before requesting a review - [x] If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: --------- Co-authored-by: Lucas Meier <lucas@cronokirby.com>
- Loading branch information
1 parent
6f90647
commit c1d7a84
Showing
101 changed files
with
1,358 additions
and
1,118 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
use ark_bls12_377::{Fq as ArkFq, Fr as ArkFr}; | ||
use ark_ff::fields::models::fp::{Fp256, Fp384}; | ||
use ark_ff::{Field, UniformRand}; | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
|
||
// ------------------------------------------------ BLS12-377 Base Field Modulus Fq in Arkworks ------------------------------------------------ | ||
|
||
fn generate_fq_arkworks() -> ArkFq { | ||
let mut rng = rand::thread_rng(); | ||
ArkFq::rand(&mut rng) | ||
} | ||
|
||
fn bench_base_field_addition(c: &mut Criterion) { | ||
let mut x = generate_fq_arkworks(); | ||
let y = generate_fq_arkworks(); | ||
|
||
c.bench_function("arkworks:fq field addition", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = black_box(x) + black_box(y); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_base_field_subtraction(c: &mut Criterion) { | ||
let mut x = generate_fq_arkworks(); | ||
let y = generate_fq_arkworks(); | ||
|
||
c.bench_function("arkworks: fq field subtraction", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = black_box(x) - black_box(y); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_base_field_mutliplication(c: &mut Criterion) { | ||
let mut x = generate_fq_arkworks(); | ||
let y = generate_fq_arkworks(); | ||
|
||
c.bench_function("arkworks: fq field multiplication", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = black_box(x) * black_box(y); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_base_field_negation(c: &mut Criterion) { | ||
let mut x = generate_fq_arkworks(); | ||
let y = generate_fq_arkworks(); | ||
|
||
c.bench_function("arkworks: fq field negation", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = black_box(x) + black_box(-y); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_base_field_square(c: &mut Criterion) { | ||
let mut x = generate_fq_arkworks(); | ||
c.bench_function("arkworks: fq field squaring", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = Fp384::square(&x) | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_base_field_inverse(c: &mut Criterion) { | ||
let mut x = generate_fq_arkworks(); | ||
|
||
c.bench_function("arkworks: fq field inverse", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = Fp384::inverse(&x).expect("inverse") | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
// ------------------------------------------------ BLS12-377 Scalar Field Modulus Fr in Arkworks ------------------------------------------------ | ||
|
||
fn generate_fr_arkworks() -> ArkFr { | ||
let mut rng = rand::thread_rng(); | ||
ArkFr::rand(&mut rng) | ||
} | ||
|
||
fn bench_scalar_field_addition(c: &mut Criterion) { | ||
let mut x = generate_fr_arkworks(); | ||
let y = generate_fr_arkworks(); | ||
|
||
c.bench_function("arkworks: fr field addition", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = black_box(x) + black_box(y); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_scalar_field_subtraction(c: &mut Criterion) { | ||
let mut x = generate_fr_arkworks(); | ||
let y = generate_fr_arkworks(); | ||
|
||
c.bench_function("arkworks: fr field subtraction", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = black_box(x) - black_box(y); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_scalar_field_mutliplication(c: &mut Criterion) { | ||
let mut x = generate_fr_arkworks(); | ||
let y = generate_fr_arkworks(); | ||
|
||
c.bench_function("arkworks: fr field multiplication", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = black_box(x) * black_box(y); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_scalar_field_negation(c: &mut Criterion) { | ||
let mut x = generate_fr_arkworks(); | ||
let y = generate_fr_arkworks(); | ||
|
||
c.bench_function("arkworks: fr field negation", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = black_box(x) + black_box(-y); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_scalar_field_square(c: &mut Criterion) { | ||
let mut x = generate_fr_arkworks(); | ||
c.bench_function("arkworks: fr field squaring", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = Fp256::square(&x) | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
fn bench_scalar_field_inverse(c: &mut Criterion) { | ||
let mut x = generate_fr_arkworks(); | ||
|
||
c.bench_function("arkworks: fr field inverse", |b| { | ||
b.iter(|| { | ||
for _ in 0..1000 { | ||
x = Fp256::inverse(&x).expect("inverse") | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!( | ||
benches, | ||
bench_base_field_addition, | ||
bench_base_field_subtraction, | ||
bench_base_field_mutliplication, | ||
bench_base_field_negation, | ||
bench_base_field_square, | ||
bench_base_field_inverse, | ||
bench_scalar_field_addition, | ||
bench_scalar_field_subtraction, | ||
bench_scalar_field_mutliplication, | ||
bench_scalar_field_negation, | ||
bench_scalar_field_square, | ||
bench_scalar_field_inverse | ||
); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.