New wallet system. Still missing unit tests, ledger synchronization,

and SQL code. This uses some of the 'magic' properties of elliptic
curves to create related families of public and private keys.
Wallet encryption is not needed because the private keys do not
need to be stored.
This commit is contained in:
JoelKatz
2011-12-26 18:42:50 -08:00
parent 780f94798e
commit 5cec2e9a11
11 changed files with 477 additions and 242 deletions

24
key.h
View File

@@ -86,7 +86,6 @@ protected:
EC_KEY* pkey;
bool fSet;
static EC_KEY* GenerateDeterministicKey(const uint256& base, uint32 n, bool private_key);
public:
typedef boost::shared_ptr<CKey> pointer;
@@ -123,13 +122,26 @@ public:
EC_KEY_free(pkey);
}
CKey(const uint256& base, uint32 seq, bool private_key) : fSet(true)
static uint256 PassPhraseToKey(const std::string& passPhrase);
static EC_KEY* GenerateRootDeterministicKey(const uint256& passPhrase);
static EC_KEY* GeneratePublicDeterministicKey(const uint160& family, EC_POINT* rootPub, int n);
static EC_KEY* GeneratePrivateDeterministicKey(const uint160& family, BIGNUM* rootPriv, int n);
CKey(const uint256& passPhrase) : fSet(true)
{
pkey=GenerateDeterministicKey(base, seq, private_key);
pkey = GenerateRootDeterministicKey(passPhrase);
}
static uint256 GetBaseFromString(const std::string& base);
static uint256 GetRandomBase(void);
CKey(const uint160& base, EC_POINT* rootPubKey, int n) : fSet(true)
{ // public deterministic key
pkey = GeneratePublicDeterministicKey(base, rootPubKey, n);
}
CKey(const uint160& base, BIGNUM* rootPrivKey, int n) : fSet(true)
{ // private deterministic key
pkey = GeneratePrivateDeterministicKey(base, rootPrivKey, n);
}
bool IsNull() const
{
@@ -184,7 +196,7 @@ public:
int n=BN_bn2bin(bn,&vchRet[32 - nBytes]);
if (n != nBytes)
throw key_error("CKey::GetSecret(): BN_bn2bin failed");
return vchRet;
return vchRet;
}
CPrivKey GetPrivKey() const