2022-11-22 13:09:21 -08:00
|
|
|
use frost_core::tests::proptests::{tweak_strategy, SignatureCase};
|
|
|
|
use frost_secp256k1::*;
|
|
|
|
use proptest::prelude::*;
|
|
|
|
|
|
|
|
use rand_chacha::ChaChaRng;
|
|
|
|
use rand_core::SeedableRng;
|
|
|
|
|
|
|
|
proptest! {
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn tweak_signature(
|
|
|
|
tweaks in prop::collection::vec(tweak_strategy(), (0,5)),
|
|
|
|
rng_seed in prop::array::uniform32(any::<u8>()),
|
|
|
|
) {
|
|
|
|
// Use a deterministic RNG so that test failures can be reproduced.
|
|
|
|
// Seeding with 64 bits of entropy is INSECURE and this code should
|
|
|
|
// not be copied outside of this test!
|
2023-01-09 13:23:59 -08:00
|
|
|
let rng = ChaChaRng::from_seed(rng_seed);
|
2022-11-22 13:09:21 -08:00
|
|
|
|
|
|
|
// Create a test case for each signature type.
|
|
|
|
let msg = b"test message for proptests";
|
2023-01-09 13:23:59 -08:00
|
|
|
let mut sig = SignatureCase::<Secp256K1Sha256>::new(rng, msg.to_vec());
|
2022-11-22 13:09:21 -08:00
|
|
|
|
|
|
|
// Apply tweaks to each case.
|
|
|
|
for t in &tweaks {
|
|
|
|
sig.apply_tweak(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert!(sig.check());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|