mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix breakage.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
// Functions to add CKey support for deterministic EC keys
|
||||
|
||||
@@ -115,26 +116,32 @@ EC_KEY* CKey::GenerateRootDeterministicKey(const uint128& seed)
|
||||
// <-- root public generator in EC format
|
||||
EC_KEY* CKey::GenerateRootPubKey(BIGNUM* pubGenerator)
|
||||
{
|
||||
if(pubGenerator==NULL) return NULL;
|
||||
if (pubGenerator == NULL)
|
||||
{
|
||||
assert(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EC_KEY* pkey=EC_KEY_new_by_curve_name(NID_secp256k1);
|
||||
if(!pkey)
|
||||
EC_KEY* pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
|
||||
if (!pkey)
|
||||
{
|
||||
BN_free(pubGenerator);
|
||||
return NULL;
|
||||
}
|
||||
EC_KEY_set_conv_form(pkey, POINT_CONVERSION_COMPRESSED);
|
||||
|
||||
EC_POINT* pubPoint=EC_POINT_bn2point(EC_KEY_get0_group(pkey), pubGenerator, NULL, NULL);
|
||||
EC_POINT* pubPoint = EC_POINT_bn2point(EC_KEY_get0_group(pkey), pubGenerator, NULL, NULL);
|
||||
BN_free(pubGenerator);
|
||||
if(!pubPoint)
|
||||
{
|
||||
assert(false);
|
||||
EC_KEY_free(pkey);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!EC_KEY_set_public_key(pkey, pubPoint))
|
||||
{
|
||||
assert(false);
|
||||
EC_POINT_free(pubPoint);
|
||||
EC_KEY_free(pkey);
|
||||
return NULL;
|
||||
|
||||
@@ -490,7 +490,7 @@ std::vector<unsigned char> NewcoinAddress::accountPrivateDecrypt(const NewcoinAd
|
||||
//
|
||||
|
||||
BIGNUM* NewcoinAddress::getFamilyGeneratorBN() const
|
||||
{
|
||||
{ // returns the public generator
|
||||
switch (nVersion) {
|
||||
case VER_NONE:
|
||||
throw std::runtime_error("unset source");
|
||||
@@ -503,35 +503,13 @@ BIGNUM* NewcoinAddress::getFamilyGeneratorBN() const
|
||||
throw std::runtime_error(str(boost::format("bad source: %d") % int(nVersion)));
|
||||
}
|
||||
|
||||
assert(vchData.size() <= ((256 + 8) / 8));
|
||||
BIGNUM* ret = BN_bin2bn(&vchData[1], vchData.size() - 1, NULL);
|
||||
BIGNUM* ret = BN_bin2bn(&vchData[0], vchData.size(), NULL);
|
||||
assert(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint256 NewcoinAddress::getFamilyGeneratorU() const
|
||||
{
|
||||
switch (nVersion) {
|
||||
case VER_NONE:
|
||||
throw std::runtime_error("unset source");
|
||||
|
||||
case VER_FAMILY_GENERATOR:
|
||||
// Do nothing.
|
||||
break;
|
||||
|
||||
default:
|
||||
throw std::runtime_error(str(boost::format("bad source: %d") % int(nVersion)));
|
||||
}
|
||||
|
||||
assert(vchData.size() <= ((256 + 1) / 8));
|
||||
uint256 ret;
|
||||
memcpy(ret.begin() + (ret.size() - (vchData.size() - 1)), &vchData[1], vchData.size() - 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& NewcoinAddress::getFamilyGenerator() const
|
||||
{
|
||||
{ // returns the public generator
|
||||
switch (nVersion) {
|
||||
case VER_NONE:
|
||||
throw std::runtime_error("unset source");
|
||||
|
||||
@@ -136,7 +136,6 @@ public:
|
||||
// Use to generate a master or regular family.
|
||||
//
|
||||
BIGNUM* getFamilyGeneratorBN() const; // DEPRECATED
|
||||
uint256 getFamilyGeneratorU() const;
|
||||
const std::vector<unsigned char>& getFamilyGenerator() const;
|
||||
|
||||
std::string humanFamilyGenerator() const;
|
||||
|
||||
@@ -156,14 +156,16 @@ public:
|
||||
SetPrivateKeyU(privateKey);
|
||||
}
|
||||
|
||||
#if 0
|
||||
CKey(const NewcoinAddress& masterKey, int keyNum, bool isPublic) : pkey(NULL), fSet(false)
|
||||
{
|
||||
if (isPublic)
|
||||
SetPubSeq(masterKey, keyNum);
|
||||
else
|
||||
SetPrivSeq(masterKey, keyNum);
|
||||
SetPrivSeq(masterKey, keyNum); // broken, need seed
|
||||
fSet = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool IsNull() const
|
||||
{
|
||||
@@ -257,8 +259,9 @@ public:
|
||||
fSet = true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void SetPrivSeq(const NewcoinAddress& masterKey, int keyNum)
|
||||
{
|
||||
{ // broken: Need the seed
|
||||
uint256 privKey;
|
||||
EC_KEY* key = GeneratePrivateDeterministicKey(masterKey, masterKey.getFamilyGeneratorU(), keyNum);
|
||||
privKey.zero();
|
||||
@@ -267,6 +270,7 @@ public:
|
||||
pkey = key;
|
||||
fSet = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
CPrivKey GetPrivKey()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user