mirror of
https://github.com/jwinterm/aeon.git
synced 2026-10-17 05:01:26 +02:00
+23
@@ -0,0 +1,23 @@
|
||||
.DS_Store
|
||||
/doc
|
||||
/build
|
||||
/tags
|
||||
|
||||
# vim swap files
|
||||
*.swp
|
||||
*.swo
|
||||
TAGS
|
||||
!TAGS/
|
||||
tags
|
||||
!tags/
|
||||
gtags.files
|
||||
GTAGS
|
||||
GRTAGS
|
||||
GPATH
|
||||
cscope.files
|
||||
cscope.out
|
||||
cscope.in.out
|
||||
cscope.po.out
|
||||
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ Copyright (c) 2014, AEON, The Monero Project
|
||||
Development Resources
|
||||
---------------------
|
||||
|
||||
Web: aeoncoin.net
|
||||
Mail: aeon.coin@gmail.com
|
||||
Github: https://github.com/aeonix/aeon
|
||||
IRC: #aeon on Freenode
|
||||
Web: tbd
|
||||
Mail: tbd
|
||||
Github: https://github.com/iamsmooth/aeon
|
||||
IRC: tbd
|
||||
|
||||
------------
|
||||
Introduction
|
||||
|
||||
+55
-8
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014, AEON, The Monero Project
|
||||
// Copyright (c) 2014, The Monero Project
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@@ -28,14 +28,55 @@
|
||||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#include <alloca.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "hash-ops.h"
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
#include <alloca.h>
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/// Quick check if this is power of two (use on unsigned types; in this case for size_t only)
|
||||
bool ispowerof2_size_t(size_t x) {
|
||||
return x && !(x & (x - 1));
|
||||
}
|
||||
|
||||
/***
|
||||
* Round to power of two, for count>=3 and for count being not too large (as reasonable for tree hash calculations)
|
||||
*/
|
||||
size_t tree_hash_cnt(size_t count) {
|
||||
assert( count >= 3); // cases for 0,1,2 are handled elsewhere
|
||||
// Round down the count size: fun(2**n)= 2**(n-1) to round down to power of two
|
||||
size_t tmp = count - 1;
|
||||
size_t jj = 1;
|
||||
for (jj=1 ; tmp != 0 ; ++jj) {
|
||||
tmp /= 2; // dividing by 2 until to get how many powers of 2 fits size_to tmp
|
||||
}
|
||||
size_t cnt = 1 << (jj-2); // cnt is the count, but rounded down to power of two
|
||||
// printf("count=%zu cnt=%zu jj=%zu tmp=%zu \n" , count,cnt,jj,tmp);
|
||||
assert( cnt > 0 ); assert( cnt >= count/2 ); assert( cnt <= count );
|
||||
assert( ispowerof2_size_t( cnt ));
|
||||
return cnt;
|
||||
}
|
||||
|
||||
void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) {
|
||||
// The blockchain block at height 202612 http://monerochain.info/block/bbd604d2ba11ba27935e006ed39c9bfdd99b76bf4a50654bc1e1e61217962698
|
||||
// contained 514 transactions, that triggered bad calculation of variable "cnt" in the original version of this function
|
||||
// as from CryptoNote code.
|
||||
//
|
||||
// This bug applies to all CN altcoins.
|
||||
//
|
||||
// Mathematical bug here was first published on 14:45:34 (GMT+2) 2014-09-04 by Rafal Freeman <rfree>
|
||||
// https://github.com/rfree2monero/bitmonero/commit/b417abfb7a297d09f1bbb6de29030f8de9952ac8
|
||||
// and soon also applied to CryptoNote (15:10 GMT+2), and BoolBerry used not fully correct work around:
|
||||
// the work around of sizeof(size_t)*8 or <<3 as used before in 2 coins and in BBL later was blocking
|
||||
// exploitation on normal platforms, how ever we strongly recommend the following fix because it removes
|
||||
// mistake in mathematical formula.
|
||||
|
||||
assert(count > 0);
|
||||
if (count == 1) {
|
||||
memcpy(root_hash, hashes, HASH_SIZE);
|
||||
@@ -43,24 +84,30 @@ void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) {
|
||||
cn_fast_hash(hashes, 2 * HASH_SIZE, root_hash);
|
||||
} else {
|
||||
size_t i, j;
|
||||
size_t cnt = count - 1;
|
||||
|
||||
size_t cnt = tree_hash_cnt( count );
|
||||
size_t max_size_t = (size_t) -1; // max allowed value of size_t
|
||||
assert( cnt < max_size_t/2 ); // reasonable size to avoid any overflows. /2 is extra; Anyway should be limited much stronger by logical code
|
||||
// as we have sane limits on transactions counts in blockchain rules
|
||||
|
||||
char (*ints)[HASH_SIZE];
|
||||
for (i = 1; i < sizeof(size_t); i <<= 1) {
|
||||
cnt |= cnt >> i;
|
||||
}
|
||||
cnt &= ~(cnt >> 1);
|
||||
ints = alloca(cnt * HASH_SIZE);
|
||||
size_t ints_size = cnt * HASH_SIZE;
|
||||
ints = alloca(ints_size); memset( ints , 0 , ints_size); // allocate, and zero out as extra protection for using uninitialized mem
|
||||
|
||||
memcpy(ints, hashes, (2 * cnt - count) * HASH_SIZE);
|
||||
|
||||
for (i = 2 * cnt - count, j = 2 * cnt - count; j < cnt; i += 2, ++j) {
|
||||
cn_fast_hash(hashes[i], 64, ints[j]);
|
||||
}
|
||||
assert(i == count);
|
||||
|
||||
while (cnt > 2) {
|
||||
cnt >>= 1;
|
||||
for (i = 0, j = 0; j < cnt; i += 2, ++j) {
|
||||
cn_fast_hash(ints[i], 64, ints[j]);
|
||||
}
|
||||
}
|
||||
|
||||
cn_fast_hash(ints[0], 64, root_hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,7 +985,6 @@ size_t blockchain_storage::find_end_of_allowed_index(const std::vector<std::pair
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res)
|
||||
{
|
||||
srand(static_cast<unsigned int>(time(NULL)));
|
||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||
BOOST_FOREACH(uint64_t amount, req.amounts)
|
||||
{
|
||||
@@ -1008,7 +1007,7 @@ bool blockchain_storage::get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDO
|
||||
size_t try_count = 0;
|
||||
for(uint64_t j = 0; j != req.outs_count && try_count < up_index_limit;)
|
||||
{
|
||||
size_t i = rand()%up_index_limit;
|
||||
size_t i = crypto::rand<size_t>()%up_index_limit;
|
||||
if(used.count(i))
|
||||
continue;
|
||||
bool added = add_out_to_get_random_outs(amount_outs, result_outs, amount, i);
|
||||
|
||||
@@ -38,8 +38,13 @@
|
||||
namespace cryptonote {
|
||||
inline bool create_checkpoints(cryptonote::checkpoints& checkpoints)
|
||||
{
|
||||
ADD_CHECKPOINT(10000, "1ac1ebd25baf0d6ec593daa3389f1aa7e860ff2cc29f3cf1be586d245b379da4");
|
||||
ADD_CHECKPOINT(15000, "15567af42afc1ed00538f53b5e3822d421e3ed6372ca79f4ea4e3e3bab709a87");
|
||||
ADD_CHECKPOINT(1, "1440a20f078bf3264822234b347f8382606577d73d4e9d3cb7296d73889bc421");
|
||||
ADD_CHECKPOINT(100, "6dd13aaab16679f49ee6b2b75c7dc99b1fd09ab2282b18cb4b55b73110655742");
|
||||
ADD_CHECKPOINT(1000, "bc6458452fd0575a314089bf302f6fd68ebaa2d689c42f3365293b96bbdf1f25");
|
||||
ADD_CHECKPOINT(10000, "1ac1ebd25baf0d6ec593daa3389f1aa7e860ff2cc29f3cf1be586d245b379da4");
|
||||
ADD_CHECKPOINT(15000, "15567af42afc1ed00538f53b5e3822d421e3ed6372ca79f4ea4e3e3bab709a87");
|
||||
ADD_CHECKPOINT(175500, "3f7dd748b3b863b04654d87a387f2b65a365f467188971f3192eab2368e64a35");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace nodetool
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::init(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
ADD_HARDCODED_SEED_NODE("seed.aeoncoin.net:11180");
|
||||
ADD_HARDCODED_SEED_NODE("195.154.170.196:11180");
|
||||
|
||||
bool res = handle_command_line(vm);
|
||||
CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line");
|
||||
|
||||
Reference in New Issue
Block a user