|
1 | 1 | use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; |
2 | 2 | use ed448_goldilocks::{ |
3 | | - CompressedDecaf, CompressedEdwardsY, Decaf448, DecafPoint, DecafScalar, EdwardsPoint, |
4 | | - EdwardsScalar, MontgomeryScalar, MontgomeryXpoint, |
| 3 | + CompressedDecaf, CompressedEdwardsY, Curve448, Decaf448, DecafPoint, DecafScalar, EdwardsPoint, |
| 4 | + EdwardsScalar, MontgomeryScalar, MontgomeryXpoint, ProjectiveMontgomeryPoint, |
5 | 5 | }; |
6 | 6 | use elliptic_curve::group::GroupEncoding; |
7 | 7 | use elliptic_curve::{Field, Group}; |
@@ -162,6 +162,53 @@ pub fn decaf448(c: &mut Criterion) { |
162 | 162 | pub fn curve448(c: &mut Criterion) { |
163 | 163 | let mut group = c.benchmark_group("Curve448"); |
164 | 164 |
|
| 165 | + group.bench_function("scalar multiplication", |b| { |
| 166 | + b.iter_batched( |
| 167 | + || { |
| 168 | + let point = ProjectiveMontgomeryPoint::try_from_rng(&mut OsRng).unwrap(); |
| 169 | + let scalar = MontgomeryScalar::try_from_rng(&mut OsRng).unwrap(); |
| 170 | + (point, scalar) |
| 171 | + }, |
| 172 | + |(point, scalar)| point * scalar, |
| 173 | + BatchSize::SmallInput, |
| 174 | + ) |
| 175 | + }); |
| 176 | + |
| 177 | + group.bench_function("point addition", |b| { |
| 178 | + b.iter_batched( |
| 179 | + || { |
| 180 | + let p1 = ProjectiveMontgomeryPoint::try_from_rng(&mut OsRng).unwrap(); |
| 181 | + let p2 = ProjectiveMontgomeryPoint::try_from_rng(&mut OsRng).unwrap(); |
| 182 | + (p1, p2) |
| 183 | + }, |
| 184 | + |(p1, p2)| p1 + p2, |
| 185 | + BatchSize::SmallInput, |
| 186 | + ) |
| 187 | + }); |
| 188 | + |
| 189 | + group.bench_function("encode_to_curve", |b| { |
| 190 | + b.iter_batched( |
| 191 | + || { |
| 192 | + let mut msg = [0; 64]; |
| 193 | + OsRng.try_fill_bytes(&mut msg).unwrap(); |
| 194 | + msg |
| 195 | + }, |
| 196 | + |msg| { |
| 197 | + Curve448::encode_from_bytes::<ExpandMsgXof<Shake256>>( |
| 198 | + &[&msg], |
| 199 | + &[b"curve448_XOF:SHAKE256_ELL2_NU_"], |
| 200 | + ) |
| 201 | + }, |
| 202 | + BatchSize::SmallInput, |
| 203 | + ) |
| 204 | + }); |
| 205 | + |
| 206 | + group.finish(); |
| 207 | +} |
| 208 | + |
| 209 | +pub fn x448(c: &mut Criterion) { |
| 210 | + let mut group = c.benchmark_group("X448"); |
| 211 | + |
165 | 212 | group.bench_function("scalar multiplication", |b| { |
166 | 213 | b.iter_batched( |
167 | 214 | || { |
|
0 commit comments