aboutsummaryrefslogtreecommitdiff
path: root/src/key.cpp
diff options
context:
space:
mode:
authorPieter Wuille <[email protected]>2014-09-29 18:00:10 +0200
committerPieter Wuille <[email protected]>2014-09-29 18:36:04 +0200
commit2884b9a4aef53245798e4f50793eb3e70aa73a6d (patch)
treea158e359f766ece2fe8b567830ed90d64efd91ae /src/key.cpp
parentdoc: update gpg command line for SHA256SUMS.asc in release process (diff)
parentAdd automatic script test generation, and actual checksig tests (diff)
downloaddiscoin-2884b9a4aef53245798e4f50793eb3e70aa73a6d.tar.xz
discoin-2884b9a4aef53245798e4f50793eb3e70aa73a6d.zip
Merge pull request #4960
8138cbe Add automatic script test generation, and actual checksig tests (Pieter Wuille)
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 8ed787654..c2251b4f2 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
}