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
Merge #425: Add sign_ecdsa_with_noncedata and sign_ecdsa_recoverable_with_noncedata
f93ca81 Add sign_ecdsa_with_noncedata and sign_ecdsa_recoverable_with_noncedata (junderw)
Pull request description:
Fixes#424
As discussed on [IRC](https://gnusha.org/bitcoin-rust/2022-03-19.log) (starts at 09:14).
These methods will allow for users to generate multiple signatures with the same private key and message by utilizing one of the `Variants` mention in RFC6979 which is exposed by libsecp256k1 via the `noncedata` argument.
The reasoning behind adding this is to allow our library to migrate from using the -sys crate. Currently we support using this noncedata argument, and would like to continue doing so while at the same time migrating away from -sys crate.
ACKs for top commit:
apoelstra:
ACK f93ca81
Tree-SHA512: 494d4f9046960779e199b18ff908fe74feda66a5cfc066c9ae6f3836fcaabd56defaa2138a913b25f1af3aa7dd48986e058804223224b76b303837c0c7adbaed
let grind_r_sig = s.sign_ecdsa_grind_r(&msg,&sk,1);
@@ -927,6 +930,23 @@ mod tests {
927
930
assert!(from_hex("ag",&mut[0u8;4]).is_err());
928
931
}
929
932
933
+
#[test]
934
+
#[cfg(not(fuzzing))]// fuzz-sigs have fixed size/format
935
+
#[cfg(any(feature = "alloc", feature = "std"))]
936
+
fntest_noncedata(){
937
+
let secp = Secp256k1::new();
938
+
let msg = hex!("887d04bb1cf1b1554f1b268dfe62d13064ca67ae45348d50d1392ce2d13418ac");
939
+
let msg = Message::from_slice(&msg).unwrap();
940
+
let noncedata = [42u8;32];
941
+
let sk = SecretKey::from_str("57f0148f94d13095cfda539d0da0d1541304b678d8b36e243980aab4e1b7cead").unwrap();
942
+
let expected_sig = hex!("24861b3edd4e7da43319c635091405feced6efa4ec99c3c3c35f6c3ba0ed8816116772e84994084db85a6c20589f6a85af569d42275c2a5dd900da5776b99d5d");
943
+
let expected_sig = ecdsa::Signature::from_compact(&expected_sig).unwrap();
944
+
945
+
let sig = secp.sign_ecdsa_with_noncedata(&msg,&sk,&noncedata);
946
+
947
+
assert_eq!(expected_sig, sig);
948
+
}
949
+
930
950
#[test]
931
951
#[cfg(not(fuzzing))]// fixed sig vectors can't work with fuzz-sigs
0 commit comments