-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
25,086 additions
and
305 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
use std::time::Duration; | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use rand::{rngs::OsRng, RngCore}; | ||
|
||
use libcrux_ml_dsa::ml_dsa_65; | ||
|
||
pub fn comparisons_key_generation(c: &mut Criterion) { | ||
let mut rng = OsRng; | ||
let mut group = c.benchmark_group("ML-DSA-65 Key Generation"); | ||
group.measurement_time(Duration::from_secs(10)); | ||
|
||
group.bench_function("libcrux portable (external random)", |b| { | ||
let mut randomness = [0; 32]; | ||
rng.fill_bytes(&mut randomness); | ||
b.iter(|| { | ||
let _ = ml_dsa_65::generate_key_pair(randomness); | ||
}) | ||
}); | ||
|
||
group.bench_function("pqclean reference implementation (internal random)", |b| { | ||
b.iter(|| { | ||
let (_, _) = pqcrypto_dilithium::dilithium3::keypair(); | ||
}) | ||
}); | ||
} | ||
|
||
pub fn comparisons_signing(c: &mut Criterion) { | ||
let mut rng = OsRng; | ||
let mut group = c.benchmark_group("ML-DSA-65 Signing"); | ||
group.measurement_time(Duration::from_secs(10)); | ||
|
||
let mut message = [0u8; 511]; | ||
rng.fill_bytes(&mut message); | ||
|
||
group.bench_function("libcrux portable (external random)", |b| { | ||
let mut randomness = [0; 32]; | ||
rng.fill_bytes(&mut randomness); | ||
let keypair = ml_dsa_65::generate_key_pair(randomness); | ||
|
||
rng.fill_bytes(&mut randomness); | ||
b.iter(|| { | ||
let _ = ml_dsa_65::sign(keypair.signing_key, &message, randomness); | ||
}) | ||
}); | ||
|
||
group.bench_function("pqclean reference implementation (internal random)", |b| { | ||
let (_, sk) = pqcrypto_dilithium::dilithium3::keypair(); | ||
b.iter(|| { | ||
let _ = pqcrypto_dilithium::dilithium3::detached_sign(&message, &sk); | ||
}) | ||
}); | ||
} | ||
|
||
pub fn comparisons_verification(c: &mut Criterion) { | ||
let mut rng = OsRng; | ||
let mut group = c.benchmark_group("ML-DSA-65 Verification"); | ||
group.measurement_time(Duration::from_secs(10)); | ||
|
||
let mut message = [0u8; 511]; | ||
rng.fill_bytes(&mut message); | ||
|
||
group.bench_function("libcrux portable (external random)", |b| { | ||
let mut randomness = [0; 32]; | ||
rng.fill_bytes(&mut randomness); | ||
let keypair = ml_dsa_65::generate_key_pair(randomness); | ||
|
||
rng.fill_bytes(&mut randomness); | ||
let signature = ml_dsa_65::sign(keypair.signing_key, &message, randomness); | ||
b.iter(|| { | ||
let _ = ml_dsa_65::verify(keypair.verification_key, &message, signature).unwrap(); | ||
}) | ||
}); | ||
|
||
group.bench_function("pqclean reference implementation (internal random)", |b| { | ||
let (vk, sk) = pqcrypto_dilithium::dilithium3::keypair(); | ||
let signature = pqcrypto_dilithium::dilithium3::detached_sign(&message, &sk); | ||
b.iter(|| { | ||
let _ = pqcrypto_dilithium::dilithium3::verify_detached_signature( | ||
&signature, &message, &vk, | ||
) | ||
.unwrap(); | ||
}) | ||
}); | ||
} | ||
|
||
pub fn comparisons(c: &mut Criterion) { | ||
comparisons_key_generation(c); | ||
comparisons_signing(c); | ||
comparisons_verification(c); | ||
} | ||
|
||
criterion_group!(benches, comparisons); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use libcrux_ml_dsa::ml_dsa_65; | ||
use rand::{rngs::OsRng, RngCore}; | ||
|
||
fn random_array<const L: usize>() -> [u8; L] { | ||
let mut rng = OsRng; | ||
let mut seed = [0; L]; | ||
rng.try_fill_bytes(&mut seed).unwrap(); | ||
seed | ||
} | ||
|
||
fn main() { | ||
let key_generation_seed = random_array(); | ||
|
||
for _i in 0..100_000 { | ||
let _ = ml_dsa_65::generate_key_pair(key_generation_seed); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use libcrux_ml_dsa::ml_dsa_65; | ||
use rand::{rngs::OsRng, RngCore}; | ||
|
||
fn random_array<const L: usize>() -> [u8; L] { | ||
let mut rng = OsRng; | ||
let mut seed = [0; L]; | ||
rng.try_fill_bytes(&mut seed).unwrap(); | ||
seed | ||
} | ||
|
||
fn main() { | ||
let key_generation_seed = random_array(); | ||
let signing_randomness = random_array(); | ||
let message = random_array::<1023>(); | ||
|
||
let keypair = ml_dsa_65::generate_key_pair(key_generation_seed); | ||
|
||
for _i in 0..100_000 { | ||
let _ = ml_dsa_65::sign(keypair.signing_key, &message, signing_randomness); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use libcrux_ml_dsa::ml_dsa_65; | ||
use rand::{rngs::OsRng, RngCore}; | ||
|
||
fn random_array<const L: usize>() -> [u8; L] { | ||
let mut rng = OsRng; | ||
let mut seed = [0; L]; | ||
rng.try_fill_bytes(&mut seed).unwrap(); | ||
seed | ||
} | ||
|
||
fn main() { | ||
let key_generation_seed = random_array(); | ||
let signing_randomness = random_array(); | ||
let message = random_array::<1023>(); | ||
|
||
let keypair = ml_dsa_65::generate_key_pair(key_generation_seed); | ||
let signature = ml_dsa_65::sign(keypair.signing_key, &message, signing_randomness); | ||
|
||
for _i in 0..100_000 { | ||
ml_dsa_65::verify(keypair.verification_key, &message, signature).unwrap(); | ||
} | ||
} |
Oops, something went wrong.