Skip to content

Commit 04469a8

Browse files
committed
use option type for proptest tweaks
1 parent 2f1d16f commit 04469a8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

schnorr_fun/src/frost.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -722,15 +722,15 @@ mod test {
722722
nonce::Deterministic,
723723
proptest::{
724724
arbitrary::any,
725-
proptest,
725+
option, proptest,
726726
strategy::{Just, Strategy},
727727
},
728728
};
729729
use sha2::Sha256;
730730

731731
proptest! {
732732
#[test]
733-
fn frost_prop_test((n_parties, threshold) in (3u32..8).prop_flat_map(|n| (Just(n), 3u32..=n)), signers_mask_seed in any::<u32>(), tweak1 in any::<Scalar<Public, Zero>>(), tweak2 in any::<Scalar<Public, Zero>>(), use_tweak2 in any::<bool>()) {
733+
fn frost_prop_test((n_parties, threshold) in (3u32..8).prop_flat_map(|n| (Just(n), 3u32..=n)), signers_mask_seed in any::<u32>(), tweak1 in option::of(any::<Scalar<Public, Zero>>()), tweak2 in option::of(any::<Scalar<Public, Zero>>())) {
734734
let frost = Frost::new(Schnorr::<Sha256, Deterministic<Sha256>>::new(
735735
Deterministic::<Sha256>::default(),
736736
));
@@ -773,12 +773,12 @@ mod test {
773773
proofs_of_possession.clone(),
774774
)
775775
.unwrap();
776-
frost_key = frost_key.tweak(tweak1.clone()).expect("applying tweak1");
777-
frost_key = if use_tweak2 {
778-
frost_key.tweak(tweak2.clone()).expect("applying tweak2")
779-
} else {
780-
frost_key
781-
};
776+
777+
for tweak in [tweak1, tweak2] {
778+
if let Some(tweak) = tweak {
779+
frost_key = frost_key.tweak(tweak).unwrap();
780+
}
781+
}
782782
(secret_share, frost_key)
783783
}).unzip();
784784

0 commit comments

Comments
 (0)