bench: Don't depend on FieldElement and elligator_ristretto_flavor
Some checks failed
All / Check formatting (push) Has been cancelled
All / Check docs (push) Has been cancelled
Cross / Test (stable, aarch64-unknown-linux-gnu) (push) Has been cancelled
Cross / Test (stable, armv7-unknown-linux-gnueabihf) (push) Has been cancelled
Cross / Test (stable, powerpc-unknown-linux-gnu) (push) Has been cancelled
curve25519 Rust / Test fiat backend (sudo apt update && sudo apt install gcc-multilib, i686-unknown-linux-gnu) (push) Has been cancelled
curve25519 Rust / Test fiat backend (x86_64-unknown-linux-gnu) (push) Has been cancelled
curve25519 Rust / Build fiat on no_std target (thumbv7em-none-eabi) (curve25519-dalek) (push) Has been cancelled
All / Check that clippy is happy (push) Has been cancelled
curve25519 Rust / Test serial backend (sudo apt update && sudo apt install gcc-multilib, i686-unknown-linux-gnu) (push) Has been cancelled
curve25519 Rust / Test serial backend (x86_64-unknown-linux-gnu) (push) Has been cancelled
curve25519 Rust / Test Build Script (push) Has been cancelled
curve25519 Rust / Test simd backend (nightly) (push) Has been cancelled
curve25519 Rust / Test simd backend (stable) (push) Has been cancelled
curve25519 Rust / Current MSRV is 1.60.0 (push) Has been cancelled
All / Test 32/64 bit stable (sudo apt update && sudo apt install gcc-multilib, i686-unknown-linux-gnu) (push) Has been cancelled
All / Test 32/64 bit stable (x86_64-unknown-linux-gnu) (push) Has been cancelled
All / Test Nightly (push) Has been cancelled
All / Check that benchmarks compile (push) Has been cancelled
All / Build serial on no_std target (thumbv7em-none-eabi) (curve25519-dalek) (push) Has been cancelled
All / Build serial on no_std target (thumbv7em-none-eabi) (ed25519-dalek) (push) Has been cancelled
All / Build serial on no_std target (thumbv7em-none-eabi) (x25519-dalek) (push) Has been cancelled

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.
This commit is contained in:
Jordan Rose 2024-05-13 16:05:27 -07:00
parent fa03398012
commit 7c6d347563
2 changed files with 2 additions and 6 deletions

View File

@ -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];
@ -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]));
});
}

View File

@ -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;