mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Trivial changes.
This commit is contained in:
8
key.h
8
key.h
@@ -132,16 +132,19 @@ public:
|
|||||||
CKey(const uint256& passPhrase) : fSet(true)
|
CKey(const uint256& passPhrase) : fSet(true)
|
||||||
{
|
{
|
||||||
pkey = GenerateRootDeterministicKey(passPhrase);
|
pkey = GenerateRootDeterministicKey(passPhrase);
|
||||||
|
assert(pkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
CKey(const uint160& base, const EC_POINT* rootPubKey, int n) : fSet(true)
|
CKey(const uint160& base, const EC_POINT* rootPubKey, int n) : fSet(true)
|
||||||
{ // public deterministic key
|
{ // public deterministic key
|
||||||
pkey = GeneratePublicDeterministicKey(base, rootPubKey, n);
|
pkey = GeneratePublicDeterministicKey(base, rootPubKey, n);
|
||||||
|
assert(pkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
CKey(const uint160& base, const BIGNUM* rootPrivKey, int n) : fSet(true)
|
CKey(const uint160& base, const BIGNUM* rootPrivKey, int n) : fSet(true)
|
||||||
{ // private deterministic key
|
{ // private deterministic key
|
||||||
pkey = GeneratePrivateDeterministicKey(base, rootPrivKey, n);
|
pkey = GeneratePrivateDeterministicKey(base, rootPrivKey, n);
|
||||||
|
assert(pkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsNull() const
|
bool IsNull() const
|
||||||
@@ -239,13 +242,14 @@ public:
|
|||||||
return vchPubKey;
|
return vchPubKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)
|
bool Sign(const uint256& hash, std::vector<unsigned char>& vchSig)
|
||||||
{
|
{
|
||||||
vchSig.clear();
|
vchSig.clear();
|
||||||
unsigned char pchSig[10000];
|
unsigned char pchSig[10000];
|
||||||
unsigned int nSize = 0;
|
unsigned int nSize = 0;
|
||||||
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey))
|
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), pchSig, &nSize, pkey))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while(nSize<72)
|
while(nSize<72)
|
||||||
{ // enlarge to 72 bytes
|
{ // enlarge to 72 bytes
|
||||||
pchSig[nSize]=0;
|
pchSig[nSize]=0;
|
||||||
@@ -257,7 +261,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Verify(uint256 hash, const std::vector<unsigned char>& vchSig) const
|
bool Verify(const uint256& hash, const std::vector<unsigned char>& vchSig) const
|
||||||
{
|
{
|
||||||
// -1 = error, 0 = bad sig, 1 = good
|
// -1 = error, 0 = bad sig, 1 = good
|
||||||
if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1)
|
if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user