Add benchmarks for OPRF functions (under a bench feature)
This commit is contained in:
+5
-1
@@ -383,7 +383,7 @@
|
||||
//! match `client_shared_secret`. Otherwise, on failure, the `finish` algorithm outputs the error `InvalidLoginError`.
|
||||
//!
|
||||
|
||||
#![deny(missing_docs)]
|
||||
#![cfg_attr(not(feature = "bench"), deny(missing_docs))]
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
// Error types
|
||||
@@ -401,7 +401,11 @@ pub mod map_to_curve;
|
||||
pub mod key_exchange;
|
||||
pub mod keypair;
|
||||
|
||||
#[cfg(feature = "bench")]
|
||||
pub mod oprf;
|
||||
#[cfg(not(feature = "bench"))]
|
||||
mod oprf;
|
||||
|
||||
pub mod slow_hash;
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
+33
-3
@@ -8,9 +8,9 @@ use generic_array::{typenum::U32, GenericArray};
|
||||
use hkdf::Hkdf;
|
||||
use rand_core::{CryptoRng, RngCore};
|
||||
|
||||
pub(crate) struct OprfClientBytes<Grp: Group> {
|
||||
pub(crate) alpha: Grp,
|
||||
pub(crate) blinding_factor: Grp::Scalar,
|
||||
pub struct OprfClientBytes<Grp: Group> {
|
||||
pub alpha: Grp,
|
||||
pub blinding_factor: Grp::Scalar,
|
||||
}
|
||||
|
||||
/// Computes the first step for the multiplicative blinding version of DH-OPRF. This
|
||||
@@ -53,6 +53,36 @@ pub(crate) fn generate_oprf3<G: Group>(
|
||||
Ok(prk)
|
||||
}
|
||||
|
||||
// Benchmarking shims
|
||||
#[cfg(feature = "bench")]
|
||||
#[inline]
|
||||
pub fn generate_oprf1_shim<R: RngCore + CryptoRng, G: GroupWithMapToCurve>(
|
||||
input: &[u8],
|
||||
pepper: Option<&[u8]>,
|
||||
blinding_factor_rng: &mut R,
|
||||
) -> Result<OprfClientBytes<G>, InternalPakeError> {
|
||||
generate_oprf1(input, pepper, blinding_factor_rng)
|
||||
}
|
||||
|
||||
#[cfg(feature = "bench")]
|
||||
#[inline]
|
||||
pub fn generate_oprf2_shim<G: Group>(
|
||||
point: G,
|
||||
oprf_key: &G::Scalar,
|
||||
) -> Result<G, InternalPakeError> {
|
||||
generate_oprf2(point, oprf_key)
|
||||
}
|
||||
|
||||
#[cfg(feature = "bench")]
|
||||
#[inline]
|
||||
pub fn generate_oprf3_shim<G: Group>(
|
||||
input: &[u8],
|
||||
point: G,
|
||||
blinding_factor: &G::Scalar,
|
||||
) -> Result<GenericArray<u8, U32>, InternalPakeError> {
|
||||
generate_oprf3(input, point, blinding_factor)
|
||||
}
|
||||
|
||||
// Tests
|
||||
// =====
|
||||
|
||||
|
||||
Reference in New Issue
Block a user