Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion bench/benches/primitives/mldsa44.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//! loop rather than one message's luck. `mldsa44_sign` signs hedged, with
//! fresh randomness, in every library; `mldsa44_sign_deterministic` is
//! verified-garbage's deterministic signing (`rnd` all zeros), whose time
//! for the same messages repeats exactly from run to run.
//! for the same messages repeats exactly from run to run. The `_prepared`
//! groups sign and verify with keys prepared once (`prepare`), whose cost
//! `mldsa44_prepare` measures (with the key generation, for a signing
//! key).

use criterion::Criterion;

Expand Down Expand Up @@ -176,6 +179,42 @@ pub fn bench(c: &mut Criterion) {
})
});
g.finish();
// Keys prepared once, for a stream of signatures and verifications, as
// the other libraries' keys are used above.
let prepared = SigningKey44::from_seed(&seed).unwrap().prepare();
let prepared_public = key.verifying_key().clone().prepare();
let mut g = c.benchmark_group("mldsa44_sign_prepared");
g.bench(BenchmarkId::new(VG, 2420), |b| {
b.iter(|| {
i = (i + 1) % MESSAGES;
prepared.sign(black_box(&msgs[i]), b"").unwrap()
})
});
g.finish();
let mut g = c.benchmark_group("mldsa44_sign_deterministic_prepared");
g.bench(BenchmarkId::new(VG, 2420), |b| {
b.iter(|| {
i = (i + 1) % MESSAGES;
prepared
.sign_deterministic(black_box(&msgs[i]), b"")
.unwrap()
})
});
g.finish();
let mut g = c.benchmark_group("mldsa44_verify_prepared");
g.bench(BenchmarkId::new(VG, 64), |b| {
b.iter(|| prepared_public.verify(black_box(&msg), b"", &sig).unwrap())
});
g.finish();
// Preparing a key, the cost a stream of operations shares.
let mut g = c.benchmark_group("mldsa44_prepare");
g.bench(BenchmarkId::new(VG, "signing"), |b| {
b.iter(|| SigningKey44::from_seed(black_box(&seed)).unwrap().prepare())
});
g.bench(BenchmarkId::new(VG, "verifying"), |b| {
b.iter(|| key.verifying_key().clone().prepare())
});
g.finish();
// A public key from its bytes: verified-garbage hashes it (`tr`), which
// each verification then reuses.
let pk = *key.verifying_key().as_bytes();
Expand Down
41 changes: 40 additions & 1 deletion bench/benches/primitives/mldsa65.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//! loop rather than one message's luck. `mldsa65_sign` signs hedged, with
//! fresh randomness, in every library; `mldsa65_sign_deterministic` is
//! verified-garbage's deterministic signing (`rnd` all zeros), whose time
//! for the same messages repeats exactly from run to run.
//! for the same messages repeats exactly from run to run. The `_prepared`
//! groups sign and verify with keys prepared once (`prepare`), whose cost
//! `mldsa65_prepare` measures (with the key generation, for a signing
//! key).

use criterion::Criterion;

Expand Down Expand Up @@ -176,6 +179,42 @@ pub fn bench(c: &mut Criterion) {
})
});
g.finish();
// Keys prepared once, for a stream of signatures and verifications, as
// the other libraries' keys are used above.
let prepared = SigningKey65::from_seed(&seed).unwrap().prepare();
let prepared_public = key.verifying_key().clone().prepare();
let mut g = c.benchmark_group("mldsa65_sign_prepared");
g.bench(BenchmarkId::new(VG, 3309), |b| {
b.iter(|| {
i = (i + 1) % MESSAGES;
prepared.sign(black_box(&msgs[i]), b"").unwrap()
})
});
g.finish();
let mut g = c.benchmark_group("mldsa65_sign_deterministic_prepared");
g.bench(BenchmarkId::new(VG, 3309), |b| {
b.iter(|| {
i = (i + 1) % MESSAGES;
prepared
.sign_deterministic(black_box(&msgs[i]), b"")
.unwrap()
})
});
g.finish();
let mut g = c.benchmark_group("mldsa65_verify_prepared");
g.bench(BenchmarkId::new(VG, 64), |b| {
b.iter(|| prepared_public.verify(black_box(&msg), b"", &sig).unwrap())
});
g.finish();
// Preparing a key, the cost a stream of operations shares.
let mut g = c.benchmark_group("mldsa65_prepare");
g.bench(BenchmarkId::new(VG, "signing"), |b| {
b.iter(|| SigningKey65::from_seed(black_box(&seed)).unwrap().prepare())
});
g.bench(BenchmarkId::new(VG, "verifying"), |b| {
b.iter(|| key.verifying_key().clone().prepare())
});
g.finish();
// A public key from its bytes: verified-garbage hashes it (`tr`), which
// each verification then reuses.
let pk = *key.verifying_key().as_bytes();
Expand Down
41 changes: 40 additions & 1 deletion bench/benches/primitives/mldsa87.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
//! loop rather than one message's luck. `mldsa87_sign` signs hedged, with
//! fresh randomness, in every library; `mldsa87_sign_deterministic` is
//! verified-garbage's deterministic signing (`rnd` all zeros), whose time
//! for the same messages repeats exactly from run to run.
//! for the same messages repeats exactly from run to run. The `_prepared`
//! groups sign and verify with keys prepared once (`prepare`), whose cost
//! `mldsa87_prepare` measures (with the key generation, for a signing
//! key).

use criterion::Criterion;

Expand Down Expand Up @@ -176,6 +179,42 @@ pub fn bench(c: &mut Criterion) {
})
});
g.finish();
// Keys prepared once, for a stream of signatures and verifications, as
// the other libraries' keys are used above.
let prepared = SigningKey87::from_seed(&seed).unwrap().prepare();
let prepared_public = key.verifying_key().clone().prepare();
let mut g = c.benchmark_group("mldsa87_sign_prepared");
g.bench(BenchmarkId::new(VG, 4627), |b| {
b.iter(|| {
i = (i + 1) % MESSAGES;
prepared.sign(black_box(&msgs[i]), b"").unwrap()
})
});
g.finish();
let mut g = c.benchmark_group("mldsa87_sign_deterministic_prepared");
g.bench(BenchmarkId::new(VG, 4627), |b| {
b.iter(|| {
i = (i + 1) % MESSAGES;
prepared
.sign_deterministic(black_box(&msgs[i]), b"")
.unwrap()
})
});
g.finish();
let mut g = c.benchmark_group("mldsa87_verify_prepared");
g.bench(BenchmarkId::new(VG, 64), |b| {
b.iter(|| prepared_public.verify(black_box(&msg), b"", &sig).unwrap())
});
g.finish();
// Preparing a key, the cost a stream of operations shares.
let mut g = c.benchmark_group("mldsa87_prepare");
g.bench(BenchmarkId::new(VG, "signing"), |b| {
b.iter(|| SigningKey87::from_seed(black_box(&seed)).unwrap().prepare())
});
g.bench(BenchmarkId::new(VG, "verifying"), |b| {
b.iter(|| key.verifying_key().clone().prepare())
});
g.finish();
// A public key from its bytes: verified-garbage hashes it (`tr`), which
// each verification then reuses.
let pk = *key.verifying_key().as_bytes();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// The functions of `src/internal/vg_mldsa44_sign_prepared.rs` of `verified-garbage-asm-aarch64`, as text: generated from
// Lean (`lean/VerifiedGarbage/TCB/Rust.lean`) with them, and not compiled.
// Each instruction the printer encodes is here as its text, and in
// `src/` as its machine code, which `lean/VerifiedGarbage/TCB/<ISA>/Encode.lean`
// gives.

vg_mldsa44_sign_prepared:
str x30, [sp, #-16]!
add x5, x0, #2560
movz x6, #12288, lsl #0
bl {vg_mldsa44_sign_with_cache}
ldr x30, [sp], #16
ret
.p2align 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// The functions of `src/internal/vg_mldsa44_sign_prepared_sha3.rs` of `verified-garbage-asm-aarch64`, as text: generated from
// Lean (`lean/VerifiedGarbage/TCB/Rust.lean`) with them, and not compiled.
// Each instruction the printer encodes is here as its text, and in
// `src/` as its machine code, which `lean/VerifiedGarbage/TCB/<ISA>/Encode.lean`
// gives.

vg_mldsa44_sign_prepared_sha3:
str x30, [sp, #-16]!
add x5, x0, #2560
movz x6, #12288, lsl #0
bl {vg_mldsa44_sign_with_cache_sha3}
ldr x30, [sp], #16
ret
.p2align 6
Loading
Loading