mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-03 22:03:01 +01:00
Also switch the (unused) verification code to low-s instead of even-s.
a81cd968introduced a malleability breaker for signatures (using an even value for S). Ine0e14e43this was changed to the lower of two potential values, rather than the even one. Only the signing code was changed though, the (for now unused) verification code wasn't adapted.
This commit is contained in:
committed by
Pieter Wuille
parent
a63f8b7b36
commit
6fd7ef2bbf
@@ -89,4 +89,21 @@ BOOST_AUTO_TEST_CASE(script_noncanon)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(script_signstrict)
|
||||
{
|
||||
for (int i=0; i<100; i++) {
|
||||
CKey key;
|
||||
key.MakeNewKey(i & 1);
|
||||
std::vector<unsigned char> sig;
|
||||
uint256 hash = GetRandHash();
|
||||
|
||||
BOOST_CHECK(key.Sign(hash, sig)); // Generate a random signature.
|
||||
BOOST_CHECK(key.GetPubKey().Verify(hash, sig)); // Check it.
|
||||
sig.push_back(0x01); // Append a sighash type.
|
||||
|
||||
BOOST_CHECK(IsCanonicalSignature(sig, SCRIPT_VERIFY_STRICTENC | SCRIPT_VERIFY_LOW_S));
|
||||
BOOST_CHECK(IsCanonicalSignature_OpenSSL(sig));
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user