aboutsummaryrefslogtreecommitdiff
path: root/src/key.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-09-20 03:13:04 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-09-26 21:58:48 +0200
commit8138cbea3c405e142d70b43b6c452e1738de3332 (patch)
tree0e472b02e62a705b34954d2f8a8eff61cf4c21a3 /src/key.cpp
parent64cfaf891fe539b36f6be37dac6c28a712d70b96 (diff)
downloadbitcoin-8138cbea3c405e142d70b43b6c452e1738de3332.tar.xz
Add automatic script test generation, and actual checksig tests
Diffstat (limited to 'src/key.cpp')
-rw-r--r--src/key.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/key.cpp b/src/key.cpp
index 8ed787654a..c2251b4f2a 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -220,7 +220,7 @@ public:
return o2i_ECPublicKey(&pkey, &pbegin, pubkey.size()) != NULL;
}
- bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) {
+ bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig, bool lowS) {
vchSig.clear();
ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey);
if (sig == NULL)
@@ -232,7 +232,7 @@ public:
BIGNUM *halforder = BN_CTX_get(ctx);
EC_GROUP_get_order(group, order, ctx);
BN_rshift1(halforder, order);
- if (BN_cmp(sig->s, halforder) > 0) {
+ if (lowS && BN_cmp(sig->s, halforder) > 0) {
// enforce low S values, by negating the value (modulo the order) if above order/2.
BN_sub(sig->s, order, sig->s);
}
@@ -467,7 +467,7 @@ CPubKey CKey::GetPubKey() const {
return pubkey;
}
-bool CKey::Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) const {
+bool CKey::Sign(const uint256 &hash, std::vector<unsigned char>& vchSig, bool lowS) const {
if (!fValid)
return false;
#ifdef USE_SECP256K1
@@ -484,7 +484,7 @@ bool CKey::Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) const {
#else
CECKey key;
key.SetSecretBytes(vch);
- return key.Sign(hash, vchSig);
+ return key.Sign(hash, vchSig, lowS);
#endif
}