From 077c5c26ae20ff3f4caa3dcc79e9e0ba5da9e87e Mon Sep 17 00:00:00 2001 From: CryptoManiac Date: Sat, 19 Jul 2014 04:01:05 +0400 Subject: [PATCH] Fix order comparison. --- src/key.cpp | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/key.cpp b/src/key.cpp index 4a7d7fd..85391ed 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -344,7 +344,7 @@ bool CKey::Sign(uint256 hash, std::vector& vchSig) EC_GROUP_get_order(group, &order, NULL); BN_rshift1(&halforder, &order); // enforce low S values, by negating the value (modulo the order) if above order/2. - if (BN_cmp(sig->s, &halforder)) { + if (BN_cmp(sig->s, &halforder) > 0) { BN_sub(sig->s, &order, sig->s); } unsigned int nSize = ECDSA_size(pkey); @@ -376,7 +376,7 @@ bool CKey::SignCompact(uint256 hash, std::vector& vchSig) EC_GROUP_get_order(group, &order, NULL); BN_rshift1(&halforder, &order); // enforce low S values, by negating the value (modulo the order) if above order/2. - if (BN_cmp(sig->s, &halforder)) { + if (BN_cmp(sig->s, &halforder) > 0) { BN_sub(sig->s, &order, sig->s); } vchSig.clear(); -- 1.7.1