diff options
Diffstat (limited to 'src/key.cpp')
| -rw-r--r-- | src/key.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/key.cpp b/src/key.cpp index acf62360a..2235c271d 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -1,9 +1,10 @@ -// Copyright (c) 2009-2014 The Bitcoin developers +// Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "key.h" +#include "arith_uint256.h" #include "crypto/hmac_sha512.h" #include "crypto/rfc6979_hmac_sha256.h" #include "eccryptoverify.h" @@ -34,6 +35,7 @@ bool CKey::Check(const unsigned char *vch) { } void CKey::MakeNewKey(bool fCompressedIn) { + RandAddSeedPerfmon(); do { GetRandBytes(vch, sizeof(vch)); } while (!Check(vch)); @@ -80,10 +82,10 @@ bool CKey::Sign(const uint256 &hash, std::vector<unsigned char>& vchSig, uint32_ do { uint256 nonce; prng.Generate((unsigned char*)&nonce, 32); - nonce += test_case; + nonce = ArithToUint256(UintToArith256(nonce) + test_case); int nSigLen = 72; - int ret = secp256k1_ecdsa_sign((const unsigned char*)&hash, 32, (unsigned char*)&vchSig[0], &nSigLen, begin(), (unsigned char*)&nonce); - nonce = 0; + int ret = secp256k1_ecdsa_sign((const unsigned char*)&hash, (unsigned char*)&vchSig[0], &nSigLen, begin(), (unsigned char*)&nonce); + nonce = uint256(); if (ret) { vchSig.resize(nSigLen); return true; @@ -114,8 +116,8 @@ bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) do { uint256 nonce; prng.Generate((unsigned char*)&nonce, 32); - int ret = secp256k1_ecdsa_sign_compact((const unsigned char*)&hash, 32, &vchSig[1], begin(), (unsigned char*)&nonce, &rec); - nonce = 0; + int ret = secp256k1_ecdsa_sign_compact((const unsigned char*)&hash, &vchSig[1], begin(), (unsigned char*)&nonce, &rec); + nonce = uint256(); if (ret) break; } while(true); |