aboutsummaryrefslogtreecommitdiff
path: root/src/key.h
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-03-27 20:10:46 -0400
committerLuke Dashjr <luke-jr+git@utopios.org>2012-03-27 20:10:46 -0400
commit2eba535348e9ecfe5f718ef7a663f12b9056f349 (patch)
tree1c01811a2f704a41b4734fe41c35eddcf1d566d3 /src/key.h
parent6085033f31456533ba874fa90aceebf871b0203c (diff)
parentddd0d9ae54e52a299589c3655b5b2afc7c2bfd5e (diff)
downloadbitcoin-2eba535348e9ecfe5f718ef7a663f12b9056f349.tar.xz
Merge branch 'vfycompsig_0.5.0' into 0.5.0.x
Diffstat (limited to 'src/key.h')
-rw-r--r--src/key.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/key.h b/src/key.h
index b1869505fb..8c06a45749 100644
--- a/src/key.h
+++ b/src/key.h
@@ -169,6 +169,11 @@ protected:
EC_KEY* pkey;
bool fSet;
+ void SetCompressedPubKey()
+ {
+ EC_KEY_set_conv_form(pkey, POINT_CONVERSION_COMPRESSED);
+ }
+
public:
CKey()
{
@@ -350,7 +355,8 @@ public:
{
if (vchSig.size() != 65)
return false;
- if (vchSig[0]<27 || vchSig[0]>=31)
+ int nV = vchSig[0];
+ if (nV<27 || nV>=35)
return false;
ECDSA_SIG *sig = ECDSA_SIG_new();
BN_bin2bn(&vchSig[1],32,sig->r);
@@ -358,7 +364,12 @@ public:
EC_KEY_free(pkey);
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
- if (ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), vchSig[0] - 27, 0) == 1)
+ if (nV >= 31)
+ {
+ SetCompressedPubKey();
+ nV -= 4;
+ }
+ if (ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), nV - 27, 0) == 1)
{
fSet = true;
ECDSA_SIG_free(sig);