From 60dcb8ac3517eecc0afd931d4d835ce62ff3e92d Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 18 Jan 2012 14:19:04 -0800 Subject: [PATCH] Trivial changes. --- key.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/key.h b/key.h index 86ae60fbb..d0728f151 100644 --- a/key.h +++ b/key.h @@ -132,16 +132,19 @@ public: CKey(const uint256& passPhrase) : fSet(true) { pkey = GenerateRootDeterministicKey(passPhrase); + assert(pkey); } CKey(const uint160& base, const EC_POINT* rootPubKey, int n) : fSet(true) { // public deterministic key pkey = GeneratePublicDeterministicKey(base, rootPubKey, n); + assert(pkey); } CKey(const uint160& base, const BIGNUM* rootPrivKey, int n) : fSet(true) { // private deterministic key pkey = GeneratePrivateDeterministicKey(base, rootPrivKey, n); + assert(pkey); } bool IsNull() const @@ -239,13 +242,14 @@ public: return vchPubKey; } - bool Sign(uint256 hash, std::vector& vchSig) + bool Sign(const uint256& hash, std::vector& vchSig) { vchSig.clear(); unsigned char pchSig[10000]; unsigned int nSize = 0; if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey)) return false; + while(nSize<72) { // enlarge to 72 bytes pchSig[nSize]=0; @@ -257,7 +261,7 @@ public: return true; } - bool Verify(uint256 hash, const std::vector& vchSig) const + bool Verify(const uint256& hash, const std::vector& vchSig) const { // -1 = error, 0 = bad sig, 1 = good if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1)