Have setFamilySeedGeneric detect prohibited seeds.

This commit is contained in:
Arthur Britto
2012-05-17 20:31:37 -07:00
parent b06a785402
commit d3e2950941
2 changed files with 17 additions and 6 deletions

View File

@@ -298,7 +298,7 @@ void NewcoinAddress::setAccountPublic(const std::vector<unsigned char>& vPublic)
void NewcoinAddress::setAccountPublic(const NewcoinAddress& generator, int seq)
{
CKey pubkey = CKey(generator, seq+1);
CKey pubkey = CKey(generator, seq);
setAccountPublic(pubkey.GetPubKey());
}
@@ -371,7 +371,7 @@ void NewcoinAddress::setAccountPrivate(uint256 hash256)
void NewcoinAddress::setAccountPrivate(const NewcoinAddress& generator, const NewcoinAddress& seed, int seq)
{
CKey privkey = CKey(generator, seed.getFamilyPrivateKey(), seq+1);
CKey privkey = CKey(generator, seed.getFamilyPrivateKey(), seq);
setAccountPrivate(privkey.GetPrivKey());
}
@@ -646,9 +646,18 @@ bool NewcoinAddress::setFamilySeed(const std::string& strSeed)
return SetString(strSeed.c_str(), VER_FAMILY_SEED);
}
void NewcoinAddress::setFamilySeedGeneric(const std::string& strText)
bool NewcoinAddress::setFamilySeedGeneric(const std::string& strText)
{
if (setFamilySeed(strText))
NewcoinAddress naTemp;
bool bResult = true;
if (naTemp.setAccountID(strText)
|| naTemp.setAccountPublic(strText)
|| naTemp.setAccountPrivate(strText))
{
bResult = false;
}
else if (setFamilySeed(strText))
{
// std::cerr << "Recognized seed." << std::endl;
nothing();
@@ -663,6 +672,8 @@ void NewcoinAddress::setFamilySeedGeneric(const std::string& strText)
// std::cerr << "Creating seed from pass phrase." << std::endl;
setFamilySeed(CKey::PassPhraseToKey(strText));
}
return bResult;
}
void NewcoinAddress::setFamilySeed(uint128 hash128) {

View File

@@ -114,7 +114,7 @@ public:
//
// Family Seeds
//
// Clients must disallow reconizable entries from being seeds.
uint128 getFamilySeed() const;
BIGNUM* getFamilyPrivateKey() const;
@@ -123,7 +123,7 @@ public:
bool setFamilySeed(const std::string& strSeed);
int setFamilySeed1751(const std::string& strHuman1751);
void setFamilySeedGeneric(const std::string& strText);
bool setFamilySeedGeneric(const std::string& strText);
void setFamilySeed(uint128 hash128);
void setFamilySeedRandom();
};