Skip to content

Commit

Permalink
bench: Don't depend on FieldElement and elligator_ristretto_flavor
Browse files Browse the repository at this point in the history
An Elligator benchmark was added for the "lizard" extensions, and it
made sure it was only measuring the Elligator part of the work by
expanding a set of bytes into a FieldElement ahead of time. However,
this requires the FieldElement alias to be pub, and depends on the
elligator_ristretto_flavor helper function being pub as well. Changing
it to test the lizard-based entry point means we're diverging less
from upstream, and it's more realistic anyway.
  • Loading branch information
jrose-signal committed Jun 18, 2024
1 parent fa03398 commit 7c6d347
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions curve25519-dalek/benches/dalek_benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use criterion::{
};

use curve25519_dalek::constants;
use curve25519_dalek::field::FieldElement;
use curve25519_dalek::scalar::Scalar;

static BATCH_SIZES: [usize; 5] = [1, 2, 4, 8, 16];
Expand Down Expand Up @@ -245,11 +244,8 @@ mod ristretto_benches {
}

fn elligator<M: Measurement>(c: &mut BenchmarkGroup<M>) {
let fe_bytes = [0u8; 32];
let fe = FieldElement::from_bytes(&fe_bytes);

c.bench_function("RistrettoPoint Elligator", |b| {
b.iter(|| RistrettoPoint::elligator_ristretto_flavor(&fe));
b.iter(|| RistrettoPoint::from_uniform_bytes_single_elligator(&[0u8; 32]));
});
}

Expand Down
2 changes: 1 addition & 1 deletion curve25519-dalek/src/ristretto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ impl RistrettoPoint {
///
/// This method is not public because it's just used for hashing
/// to a point -- proper elligator support is deferred for now.
pub fn elligator_ristretto_flavor(r_0: &FieldElement) -> RistrettoPoint {
pub(crate) fn elligator_ristretto_flavor(r_0: &FieldElement) -> RistrettoPoint {
let i = &constants::SQRT_M1;
let d = &constants::EDWARDS_D;
let one_minus_d_sq = &constants::ONE_MINUS_EDWARDS_D_SQUARED;
Expand Down

0 comments on commit 7c6d347

Please sign in to comment.