mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-12 15:49:22 -08:00
Address feedback
This commit is contained in:
@@ -194,6 +194,33 @@ mod aead {
|
|||||||
let nonce = [23; NONCE_LEN];
|
let nonce = [23; NONCE_LEN];
|
||||||
let ad = [];
|
let ad = [];
|
||||||
|
|
||||||
|
c.bench_function(&aead_benchid("encrypt", "0byte"), |bench| {
|
||||||
|
const DATA_LEN: usize = 0;
|
||||||
|
|
||||||
|
let ptxt = [];
|
||||||
|
let mut ctxt = [0; DATA_LEN + TAG_LEN];
|
||||||
|
|
||||||
|
bench.iter(|| {
|
||||||
|
scheme.encrypt(&mut ctxt, &key, &nonce, &ad, &ptxt).unwrap();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
c.bench_function(&aead_benchid("decrypt", "0byte"), |bench| {
|
||||||
|
const DATA_LEN: usize = 0;
|
||||||
|
|
||||||
|
let ptxt = [];
|
||||||
|
let mut ctxt = [0; DATA_LEN + TAG_LEN];
|
||||||
|
let mut ptxt_out = [0u8; DATA_LEN];
|
||||||
|
|
||||||
|
scheme.encrypt(&mut ctxt, &key, &nonce, &ad, &ptxt).unwrap();
|
||||||
|
|
||||||
|
bench.iter(|| {
|
||||||
|
scheme
|
||||||
|
.decrypt(&mut ptxt_out, &key, &nonce, &ad, &mut ctxt)
|
||||||
|
.unwrap()
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
c.bench_function(&aead_benchid("encrypt", "32byte"), |bench| {
|
c.bench_function(&aead_benchid("encrypt", "32byte"), |bench| {
|
||||||
const DATA_LEN: usize = 32;
|
const DATA_LEN: usize = 32;
|
||||||
|
|
||||||
@@ -312,7 +339,14 @@ mod keyed_hash {
|
|||||||
];
|
];
|
||||||
let keyedhash_benchid = |len| benchid(KvPairs(&base), KvPairs(&[KvPair("length", len)]));
|
let keyedhash_benchid = |len| benchid(KvPairs(&base), KvPairs(&[KvPair("length", len)]));
|
||||||
|
|
||||||
c.bench_function(&keyedhash_benchid("32byte"), |bench| {
|
c.bench_function(&keyedhash_benchid("0byte"), |bench| {
|
||||||
|
let bytes = [];
|
||||||
|
|
||||||
|
bench.iter(|| {
|
||||||
|
H::keyed_hash(&key, &bytes, &mut out).unwrap();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.bench_function(&keyedhash_benchid("32byte"), |bench| {
|
||||||
let bytes = [34u8; 32];
|
let bytes = [34u8; 32];
|
||||||
|
|
||||||
bench.iter(|| {
|
bench.iter(|| {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// Standard library imports
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
hint::black_box,
|
hint::black_box,
|
||||||
@@ -7,17 +6,18 @@ use std::{
|
|||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
// External crate imports
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use libcrux_test_utils::tracing::{EventType, Trace as _};
|
use libcrux_test_utils::tracing::{EventType, Trace as _};
|
||||||
use rosenpass::protocol::{
|
|
||||||
CryptoServer, HandleMsgResult, MsgBuf, PeerPtr, ProtocolVersion, SPk, SSk, SymKey,
|
|
||||||
};
|
|
||||||
use rosenpass_cipher_traits::primitives::Kem;
|
use rosenpass_cipher_traits::primitives::Kem;
|
||||||
use rosenpass_ciphers::StaticKem;
|
use rosenpass_ciphers::StaticKem;
|
||||||
use rosenpass_secret_memory::secret_policy_try_use_memfd_secrets;
|
use rosenpass_secret_memory::secret_policy_try_use_memfd_secrets;
|
||||||
use rosenpass_util::trace_bench::{RpEventType, TRACE};
|
use rosenpass_util::trace_bench::{RpEventType, TRACE};
|
||||||
|
|
||||||
|
use rosenpass::protocol::{
|
||||||
|
CryptoServer, HandleMsgResult, MsgBuf, PeerPtr, ProtocolVersion, SPk, SSk, SymKey,
|
||||||
|
};
|
||||||
|
|
||||||
const ITERATIONS: usize = 100;
|
const ITERATIONS: usize = 100;
|
||||||
|
|
||||||
fn handle(
|
fn handle(
|
||||||
@@ -116,8 +116,11 @@ fn main() {
|
|||||||
.expect("error writing json data");
|
.expect("error writing json data");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes a vector of trace events, bins them by label, extracts durations,
|
/// Performs a simple statistical analysis:
|
||||||
/// filters empty bins, calculates aggregate statistics (mean, std dev), and returns them.
|
/// - bins trace events by label
|
||||||
|
/// - extracts durations of spamns
|
||||||
|
/// - filters out empty bins
|
||||||
|
/// - calculates aggregate statistics (mean, std dev)
|
||||||
fn statistical_analysis(trace: Vec<RpEventType>) -> Vec<(&'static str, AggregateStat<Duration>)> {
|
fn statistical_analysis(trace: Vec<RpEventType>) -> Vec<(&'static str, AggregateStat<Duration>)> {
|
||||||
bin_events(trace)
|
bin_events(trace)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -132,9 +135,9 @@ fn statistical_analysis(trace: Vec<RpEventType>) -> Vec<(&'static str, Aggregate
|
|||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * `w` - The writer to output JSON to (e.g., stdout, file).
|
/// * `w` - The writer to output JSON to (e.g., stdout, file).
|
||||||
/// * `item_groups` - An iterator producing tuples of (`&'static str`, `II`), where
|
/// * `item_groups` - An iterator producing tuples `(version, stats): (&'static str, II)`.
|
||||||
/// `II` is itself an iterator producing (`&'static str`, `AggregateStat<Duration>`).
|
/// Here `II` is itself an iterator producing `(label, agg_stat): (&'static str, AggregateStat<Duration>)`,
|
||||||
/// Represents the protocol_version name and the statistics items within that protocol_version.
|
/// where the label is the label of the span, e.g. "IHI2".
|
||||||
///
|
///
|
||||||
/// # Type Parameters
|
/// # Type Parameters
|
||||||
/// * `W` - A type that implements `std::io::Write`.
|
/// * `W` - A type that implements `std::io::Write`.
|
||||||
|
|||||||
@@ -3548,7 +3548,7 @@ impl CryptoServer {
|
|||||||
|
|
||||||
/// Marks a section of the protocol using the same identifiers as are used in the whitepaper.
|
/// Marks a section of the protocol using the same identifiers as are used in the whitepaper.
|
||||||
/// When building with the trace benchmarking feature enabled, this also emits span events into the
|
/// When building with the trace benchmarking feature enabled, this also emits span events into the
|
||||||
/// trace, which allows reconstructing the run times of the individual sections for performace
|
/// trace, which allows reconstructing the run times of the individual sections for performance
|
||||||
/// measurement.
|
/// measurement.
|
||||||
macro_rules! protocol_section {
|
macro_rules! protocol_section {
|
||||||
($label:expr, $body:tt) => {{
|
($label:expr, $body:tt) => {{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub type RpTrace = tracing::MutexTrace<&'static str, Instant>;
|
|||||||
/// The trace event type used to trace Rosenpass for performance measurement.
|
/// The trace event type used to trace Rosenpass for performance measurement.
|
||||||
pub type RpEventType = tracing::TraceEvent<&'static str, Instant>;
|
pub type RpEventType = tracing::TraceEvent<&'static str, Instant>;
|
||||||
|
|
||||||
// Re-export to make functionality availalable and callers don't need to also directly depend on
|
// Re-export to make functionality available and callers don't need to also directly depend on
|
||||||
// [`libcrux_test_utils`].
|
// [`libcrux_test_utils`].
|
||||||
pub use libcrux_test_utils::tracing::trace_span;
|
pub use libcrux_test_utils::tracing::trace_span;
|
||||||
pub use tracing::Trace;
|
pub use tracing::Trace;
|
||||||
|
|||||||
Reference in New Issue
Block a user