Skip to content

Commit affa984

Browse files
committed
ed448-goldilocks: clean up benchmarks
1 parent e25ccd1 commit affa984

File tree

1 file changed

+12
-42
lines changed

1 file changed

+12
-42
lines changed

ed448-goldilocks/benches/bench.rs

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
22
use ed448_goldilocks::{
3-
CompressedDecaf, CompressedEdwardsY, Decaf448, DecafPoint, DecafScalar, EdwardsPoint,
4-
EdwardsScalar, MontgomeryPoint,
3+
Decaf448, DecafPoint, DecafScalar, EdwardsPoint, EdwardsScalar, MontgomeryPoint,
54
};
65
use elliptic_curve::group::GroupEncoding;
76
use elliptic_curve::{Field, Group};
@@ -36,18 +35,6 @@ pub fn ed448(c: &mut Criterion) {
3635
)
3736
});
3837

39-
group.bench_function("hash_to_curve", |b| {
40-
b.iter_batched(
41-
|| {
42-
let mut msg = [0; 64];
43-
OsRng.try_fill_bytes(&mut msg).unwrap();
44-
msg
45-
},
46-
|msg| EdwardsPoint::hash_with_defaults(&msg),
47-
BatchSize::SmallInput,
48-
)
49-
});
50-
5138
group.bench_function("encode_to_curve", |b| {
5239
b.iter_batched(
5340
|| {
@@ -63,15 +50,15 @@ pub fn ed448(c: &mut Criterion) {
6350
group.bench_function("compress", |b| {
6451
b.iter_batched(
6552
|| EdwardsPoint::try_from_rng(&mut OsRng).unwrap(),
66-
|point| point.to_bytes().0,
53+
|point| point.to_bytes(),
6754
BatchSize::SmallInput,
6855
)
6956
});
7057

7158
group.bench_function("decompress", |b| {
7259
b.iter_batched(
73-
|| EdwardsPoint::try_from_rng(&mut OsRng).unwrap().to_bytes().0,
74-
|bytes| CompressedEdwardsY(bytes).decompress().unwrap(),
60+
|| EdwardsPoint::try_from_rng(&mut OsRng).unwrap().to_bytes(),
61+
|bytes| EdwardsPoint::from_bytes(&bytes).unwrap(),
7562
BatchSize::SmallInput,
7663
)
7764
});
@@ -106,23 +93,6 @@ pub fn decaf448(c: &mut Criterion) {
10693
)
10794
});
10895

109-
group.bench_function("hash_to_curve", |b| {
110-
b.iter_batched(
111-
|| {
112-
let mut msg = [0; 64];
113-
OsRng.try_fill_bytes(&mut msg).unwrap();
114-
msg
115-
},
116-
|msg| {
117-
Decaf448::hash_from_bytes::<ExpandMsgXof<Shake256>>(
118-
&[&msg],
119-
&[b"decaf448_XOF:SHAKE256_D448MAP_RO_"],
120-
)
121-
},
122-
BatchSize::SmallInput,
123-
)
124-
});
125-
12696
group.bench_function("encode_to_curve", |b| {
12797
b.iter_batched(
12898
|| {
@@ -140,27 +110,27 @@ pub fn decaf448(c: &mut Criterion) {
140110
)
141111
});
142112

143-
group.bench_function("compress", |b| {
113+
group.bench_function("encode", |b| {
144114
b.iter_batched(
145115
|| DecafPoint::try_from_rng(&mut OsRng).unwrap(),
146-
|point| point.compress().0,
116+
|point| point.to_bytes(),
147117
BatchSize::SmallInput,
148118
)
149119
});
150120

151-
group.bench_function("decompress", |b| {
121+
group.bench_function("decode", |b| {
152122
b.iter_batched(
153-
|| DecafPoint::try_from_rng(&mut OsRng).unwrap().compress().0,
154-
|bytes| CompressedDecaf(bytes).decompress().unwrap(),
123+
|| DecafPoint::try_from_rng(&mut OsRng).unwrap().to_bytes(),
124+
|bytes| DecafPoint::from_bytes(&bytes).unwrap(),
155125
BatchSize::SmallInput,
156126
)
157127
});
158128

159129
group.finish();
160130
}
161131

162-
pub fn curve448(c: &mut Criterion) {
163-
let mut group = c.benchmark_group("Curve448");
132+
pub fn x448(c: &mut Criterion) {
133+
let mut group = c.benchmark_group("X448");
164134

165135
group.bench_function("scalar multiplication", |b| {
166136
b.iter_batched(
@@ -178,5 +148,5 @@ pub fn curve448(c: &mut Criterion) {
178148
group.finish();
179149
}
180150

181-
criterion_group!(benches, ed448, decaf448, curve448);
151+
criterion_group!(benches, ed448, decaf448, x448);
182152
criterion_main!(benches);

0 commit comments

Comments
 (0)