You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do not test secret->public derivation or pk validity in fuzzing cfg
In the next commit the secret->public key derivation in fuzzing cfg
is changed to be simpler, as well as the validity rules of public
keys relaxed.
This adds a new test to ensure random keys can be added, not just
the hard-coded keys test that exists today.
Copy file name to clipboardExpand all lines: src/key.rs
+29-2Lines changed: 29 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -690,7 +690,13 @@ mod test {
690
690
691
691
let s = Secp256k1::signing_only();
692
692
let sk = SecretKey::from_slice(&SK_BYTES).expect("sk");
693
+
694
+
// In fuzzing mode secret->public key derivation is different, so
695
+
// hard-code the epected result.
696
+
#[cfg(not(fuzzing))]
693
697
let pk = PublicKey::from_secret_key(&s,&sk);
698
+
#[cfg(fuzzing)]
699
+
let pk = PublicKey::from_slice(&[0x02,0x18,0x84,0x57,0x81,0xf6,0x31,0xc4,0x8f,0x1c,0x97,0x09,0xe2,0x30,0x92,0x06,0x7d,0x06,0x83,0x7f,0x30,0xaa,0x0c,0xd0,0x54,0x4a,0xc8,0x87,0xfe,0x91,0xdd,0xd1,0x66]).expect("pk");
694
700
695
701
assert_eq!(
696
702
sk.to_string(),
@@ -733,6 +739,9 @@ mod test {
733
739
}
734
740
735
741
#[test]
742
+
// In fuzzing mode the Y coordinate is expected to match the X, so this
let sk = KeyPair::from_seckey_slice(&secp,&SK_BYTES).expect("sk");
730
+
731
+
// In fuzzing mode secret->public key derivation is different, so
732
+
// hard-code the epected result.
733
+
#[cfg(not(fuzzing))]
727
734
let pk = PublicKey::from_keypair(&s,&sk);
735
+
#[cfg(fuzzing)]
736
+
let pk = PublicKey::from_slice(&[0x18,0x84,0x57,0x81,0xf6,0x31,0xc4,0x8f,0x1c,0x97,0x09,0xe2,0x30,0x92,0x06,0x7d,0x06,0x83,0x7f,0x30,0xaa,0x0c,0xd0,0x54,0x4a,0xc8,0x87,0xfe,0x91,0xdd,0xd1,0x66]).expect("pk");
728
737
729
738
assert_eq!(
730
739
pk.to_string(),
@@ -762,6 +771,9 @@ mod tests {
762
771
}
763
772
764
773
#[test]
774
+
// In fuzzing mode secret->public key derivation is different, so
775
+
// this test will never correctly derive the static pubkey.
0 commit comments