-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #524 from cryspen/franziskus/ml-dsa-boilerplate
ML-DSA 44 instantiations and multiplexing
- Loading branch information
Showing
60 changed files
with
3,315 additions
and
2,509 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
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,36 @@ | ||
use std::env; | ||
|
||
fn main() { | ||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); | ||
let disable_simd128 = read_env("LIBCRUX_DISABLE_SIMD128"); | ||
let disable_simd256 = read_env("LIBCRUX_DISABLE_SIMD256"); | ||
|
||
// Force a simd build. Make sure you know what you're doing. | ||
let enable_simd128 = read_env("LIBCRUX_ENABLE_SIMD128"); | ||
let enable_simd256 = read_env("LIBCRUX_ENABLE_SIMD256"); | ||
|
||
let simd128_possible = target_arch == "aarch64"; | ||
if (simd128_possible || enable_simd128) && !disable_simd128 { | ||
// We enable simd128 on all aarch64 builds. | ||
println!("cargo:rustc-cfg=feature=\"simd128\""); | ||
} | ||
let simd256_possible = target_arch == "x86_64"; | ||
if (simd256_possible || enable_simd256) && !disable_simd256 { | ||
// We enable simd256 on all x86_64 builds. | ||
// Note that this doesn't mean the required CPU features are available. | ||
// But the compiler will support them and the runtime checks ensure that | ||
// it's only used when available. | ||
// | ||
// We don't enable this on x86 because it seems to generate invalid code. | ||
println!("cargo:rustc-cfg=feature=\"simd256\""); | ||
} | ||
|
||
println!("cargo::rustc-check-cfg=cfg(eurydice)"); | ||
} | ||
|
||
fn read_env(key: &str) -> bool { | ||
match env::var(key) { | ||
Ok(s) => s == "1" || s == "y" || s == "Y", | ||
Err(_) => false, | ||
} | ||
} |
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_44::*; | ||
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 = generate_key_pair(key_generation_seed); | ||
|
||
for _i in 0..100_000 { | ||
let _ = core::hint::black_box(sign(&keypair.signing_key, &message, signing_randomness)); | ||
} | ||
} |
Oops, something went wrong.