mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-05 20:40:02 -08:00
Address feedback
This commit is contained in:
@@ -194,6 +194,33 @@ mod aead {
|
||||
let nonce = [23; NONCE_LEN];
|
||||
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| {
|
||||
const DATA_LEN: usize = 32;
|
||||
|
||||
@@ -312,7 +339,14 @@ mod keyed_hash {
|
||||
];
|
||||
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];
|
||||
|
||||
bench.iter(|| {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// Standard library imports
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
hint::black_box,
|
||||
@@ -7,17 +6,18 @@ use std::{
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
// External crate imports
|
||||
use anyhow::Result;
|
||||
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_ciphers::StaticKem;
|
||||
use rosenpass_secret_memory::secret_policy_try_use_memfd_secrets;
|
||||
use rosenpass_util::trace_bench::{RpEventType, TRACE};
|
||||
|
||||
use rosenpass::protocol::{
|
||||
CryptoServer, HandleMsgResult, MsgBuf, PeerPtr, ProtocolVersion, SPk, SSk, SymKey,
|
||||
};
|
||||
|
||||
const ITERATIONS: usize = 100;
|
||||
|
||||
fn handle(
|
||||
@@ -116,8 +116,11 @@ fn main() {
|
||||
.expect("error writing json data");
|
||||
}
|
||||
|
||||
/// Takes a vector of trace events, bins them by label, extracts durations,
|
||||
/// filters empty bins, calculates aggregate statistics (mean, std dev), and returns them.
|
||||
/// Performs a simple statistical analysis:
|
||||
/// - 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>)> {
|
||||
bin_events(trace)
|
||||
.into_iter()
|
||||
@@ -132,9 +135,9 @@ fn statistical_analysis(trace: Vec<RpEventType>) -> Vec<(&'static str, Aggregate
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `w` - The writer to output JSON to (e.g., stdout, file).
|
||||
/// * `item_groups` - An iterator producing tuples of (`&'static str`, `II`), where
|
||||
/// `II` is itself an iterator producing (`&'static str`, `AggregateStat<Duration>`).
|
||||
/// Represents the protocol_version name and the statistics items within that protocol_version.
|
||||
/// * `item_groups` - An iterator producing tuples `(version, stats): (&'static str, II)`.
|
||||
/// Here `II` is itself an iterator producing `(label, agg_stat): (&'static str, AggregateStat<Duration>)`,
|
||||
/// where the label is the label of the span, e.g. "IHI2".
|
||||
///
|
||||
/// # Type Parameters
|
||||
/// * `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.
|
||||
/// 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.
|
||||
macro_rules! protocol_section {
|
||||
($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.
|
||||
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`].
|
||||
pub use libcrux_test_utils::tracing::trace_span;
|
||||
pub use tracing::Trace;
|
||||
|
||||
Reference in New Issue
Block a user