|
1 | 1 | use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; |
2 | 2 | use ed448_goldilocks::{ |
3 | | - Decaf448, DecafPoint, DecafScalar, Ed448, EdwardsPoint, EdwardsScalar, MontgomeryScalar, |
4 | | - MontgomeryXpoint, ProjectiveMontgomeryXpoint, |
| 3 | + Curve448, Decaf448, DecafPoint, DecafScalar, Ed448, EdwardsPoint, EdwardsScalar, |
| 4 | + MontgomeryScalar, MontgomeryXpoint, ProjectiveMontgomeryPoint, ProjectiveMontgomeryXpoint, |
5 | 5 | }; |
6 | 6 | use elliptic_curve::group::GroupEncoding; |
7 | 7 | use elliptic_curve::{Field, Group}; |
@@ -124,6 +124,48 @@ pub fn decaf448(c: &mut Criterion) { |
124 | 124 | group.finish(); |
125 | 125 | } |
126 | 126 |
|
| 127 | +pub fn curve448(c: &mut Criterion) { |
| 128 | + let mut group = c.benchmark_group("Curve448"); |
| 129 | + |
| 130 | + group.bench_function("scalar multiplication", |b| { |
| 131 | + b.iter_batched( |
| 132 | + || { |
| 133 | + let point = ProjectiveMontgomeryPoint::try_from_rng(&mut OsRng).unwrap(); |
| 134 | + let scalar = MontgomeryScalar::try_from_rng(&mut OsRng).unwrap(); |
| 135 | + (point, scalar) |
| 136 | + }, |
| 137 | + |(point, scalar)| point * scalar, |
| 138 | + BatchSize::SmallInput, |
| 139 | + ) |
| 140 | + }); |
| 141 | + |
| 142 | + group.bench_function("point addition", |b| { |
| 143 | + b.iter_batched( |
| 144 | + || { |
| 145 | + let p1 = ProjectiveMontgomeryPoint::try_from_rng(&mut OsRng).unwrap(); |
| 146 | + let p2 = ProjectiveMontgomeryPoint::try_from_rng(&mut OsRng).unwrap(); |
| 147 | + (p1, p2) |
| 148 | + }, |
| 149 | + |(p1, p2)| p1 + p2, |
| 150 | + BatchSize::SmallInput, |
| 151 | + ) |
| 152 | + }); |
| 153 | + |
| 154 | + group.bench_function("encode_to_curve", |b| { |
| 155 | + b.iter_batched( |
| 156 | + || { |
| 157 | + let mut msg = [0; 64]; |
| 158 | + OsRng.try_fill_bytes(&mut msg).unwrap(); |
| 159 | + msg |
| 160 | + }, |
| 161 | + |msg| Curve448::encode_from_bytes(&msg, b"test DST"), |
| 162 | + BatchSize::SmallInput, |
| 163 | + ) |
| 164 | + }); |
| 165 | + |
| 166 | + group.finish(); |
| 167 | +} |
| 168 | + |
127 | 169 | pub fn x448(c: &mut Criterion) { |
128 | 170 | let mut group = c.benchmark_group("X448"); |
129 | 171 |
|
|
0 commit comments