|
|
@ -164,8 +164,10 @@ public: |
|
|
|
void SetSecretBytes(const unsigned char vch[32]) { |
|
|
|
void SetSecretBytes(const unsigned char vch[32]) { |
|
|
|
BIGNUM bn; |
|
|
|
BIGNUM bn; |
|
|
|
BN_init(&bn); |
|
|
|
BN_init(&bn); |
|
|
|
assert(BN_bin2bn(vch, 32, &bn)); |
|
|
|
bool check = BN_bin2bn(vch, 32, &bn); |
|
|
|
assert(EC_KEY_regenerate_key(pkey, &bn)); |
|
|
|
assert(check); |
|
|
|
|
|
|
|
check = EC_KEY_regenerate_key(pkey, &bn); |
|
|
|
|
|
|
|
assert(check); |
|
|
|
BN_clear_free(&bn); |
|
|
|
BN_clear_free(&bn); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -210,7 +212,8 @@ public: |
|
|
|
bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) { |
|
|
|
bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) { |
|
|
|
unsigned int nSize = ECDSA_size(pkey); |
|
|
|
unsigned int nSize = ECDSA_size(pkey); |
|
|
|
vchSig.resize(nSize); // Make sure it is big enough
|
|
|
|
vchSig.resize(nSize); // Make sure it is big enough
|
|
|
|
assert(ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey)); |
|
|
|
bool check = ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey); |
|
|
|
|
|
|
|
assert(check); |
|
|
|
vchSig.resize(nSize); // Shrink to fit actual size
|
|
|
|
vchSig.resize(nSize); // Shrink to fit actual size
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|