Adding non-deterministic sentinel values to avoid attacks due to well-known values.
Using no_an_account sentinal in votes container instead of always using 0.
This commit is contained in:
parent
7a95b77e51
commit
e5d7eb072b
2 changed files with 12 additions and 1 deletions
|
@ -61,6 +61,9 @@ genesis_account (rai::rai_network == rai::rai_networks::rai_test_network ? rai_t
|
|||
genesis_block (rai::rai_network == rai::rai_networks::rai_test_network ? rai_test_genesis : rai::rai_network == rai::rai_networks::rai_beta_network ? rai_beta_genesis : rai_live_genesis),
|
||||
genesis_amount (std::numeric_limits <rai::uint128_t>::max ())
|
||||
{
|
||||
// Randomly generating these mean no two nodes will ever have the same sentinal values which protects against some insecure algorithms
|
||||
rai::random_pool.GenerateBlock (not_a_block.bytes.data (), not_a_block.bytes.size ());
|
||||
rai::random_pool.GenerateBlock (not_an_account.bytes.data (), not_an_account.bytes.size ());
|
||||
}
|
||||
rai::keypair zero_key;
|
||||
rai::keypair test_genesis_key;
|
||||
|
@ -74,6 +77,8 @@ rai::account genesis_account;
|
|||
std::string genesis_block;
|
||||
rai::uint128_t genesis_amount;
|
||||
CryptoPP::AutoSeededRandomPool random_pool;
|
||||
rai::block_hash not_a_block;
|
||||
rai::account not_an_account;
|
||||
};
|
||||
ledger_constants globals;
|
||||
}
|
||||
|
@ -96,6 +101,8 @@ rai::account const & rai::genesis_account (globals.genesis_account);
|
|||
std::string const & rai::genesis_block (globals.genesis_block);
|
||||
rai::uint128_t const & rai::genesis_amount (globals.genesis_amount);
|
||||
CryptoPP::AutoSeededRandomPool & rai::random_pool (globals.random_pool);
|
||||
rai::block_hash const & rai::not_a_block (globals.not_a_block);
|
||||
rai::block_hash const & rai::not_an_account (globals.not_an_account);
|
||||
|
||||
boost::filesystem::path rai::working_path ()
|
||||
{
|
||||
|
@ -163,7 +170,7 @@ std::map <rai::uint128_t, std::unique_ptr <rai::block>, std::greater <rai::uint1
|
|||
rai::votes::votes (rai::block const & block_a) :
|
||||
id (block_a.root ())
|
||||
{
|
||||
rep_votes.insert (std::make_pair (0, block_a.clone ()));
|
||||
rep_votes.insert (std::make_pair (rai::not_an_account, block_a.clone ()));
|
||||
}
|
||||
|
||||
rai::tally_result rai::votes::vote (rai::vote const & vote_a)
|
||||
|
|
|
@ -526,6 +526,10 @@ extern std::string const & rai_live_genesis;
|
|||
extern std::string const & genesis_block;
|
||||
extern rai::account const & genesis_account;
|
||||
extern rai::uint128_t const & genesis_amount;
|
||||
// A block hash that compares inequal to any real block hash
|
||||
extern rai::block_hash const & not_a_block;
|
||||
// An account number that compares inequal to any real account number
|
||||
extern rai::block_hash const & not_an_account;
|
||||
class genesis
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue