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