aboutsummaryrefslogtreecommitdiff
path: root/src/test/canonical_tests.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2014-02-07 02:19:48 +0100
committerlangerhans <[email protected]>2014-06-29 15:38:41 +0200
commit4644e65561fdb6a4af64af8f2a228151116e39b6 (patch)
tree85b70d96bbdcf274a483d17f5ba25b307d3e5e2b /src/test/canonical_tests.cpp
parentTest CHECKMULTISIG with m == 0 and n == 0 (diff)
downloaddiscoin-4644e65561fdb6a4af64af8f2a228151116e39b6.tar.xz
discoin-4644e65561fdb6a4af64af8f2a228151116e39b6.zip
Also switch the (unused) verification code to low-s instead of even-s.
a81cd968 introduced a malleability breaker for signatures (using an even value for S). In e0e14e43 this 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.
Diffstat (limited to 'src/test/canonical_tests.cpp')
-rw-r--r--src/test/canonical_tests.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/canonical_tests.cpp b/src/test/canonical_tests.cpp
index a26ad335a..23dd74296 100644
--- a/src/test/canonical_tests.cpp
+++ b/src/test/canonical_tests.cpp
@@ -93,4 +93,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()