mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
Make signing follow BIP340 exactly w.r.t. aux randomness
libsecp256k1's secp256k1_schnorrsig_sign only follows BIP340 exactly if an aux_rand32 argument is passed. When no randomness is used (as is the case in the current codebase here), there is no impact on security between not providing aux_rand32 at all, or providing an empty one. Yet, for repeatability/testability it is simpler to always use an all-zero one.
This commit is contained in:
@@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(bip340_test_vectors)
|
||||
key.Set(sec.begin(), sec.end(), true);
|
||||
XOnlyPubKey pubkey(key.GetPubKey());
|
||||
BOOST_CHECK(std::equal(pubkey.begin(), pubkey.end(), pub.begin(), pub.end()));
|
||||
bool ok = key.SignSchnorr(msg256, sig64, nullptr, &aux256);
|
||||
bool ok = key.SignSchnorr(msg256, sig64, nullptr, aux256);
|
||||
BOOST_CHECK(ok);
|
||||
BOOST_CHECK(std::vector<unsigned char>(sig64, sig64 + 64) == sig);
|
||||
// Verify those signatures for good measure.
|
||||
@@ -337,7 +337,7 @@ BOOST_AUTO_TEST_CASE(bip340_test_vectors)
|
||||
BOOST_CHECK(tweaked);
|
||||
XOnlyPubKey tweaked_key = tweaked->first;
|
||||
aux256 = InsecureRand256();
|
||||
bool ok = key.SignSchnorr(msg256, sig64, &merkle_root, &aux256);
|
||||
bool ok = key.SignSchnorr(msg256, sig64, &merkle_root, aux256);
|
||||
BOOST_CHECK(ok);
|
||||
BOOST_CHECK(tweaked_key.VerifySchnorr(msg256, sig64));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user