Skip to content

Commit

Permalink
Change signature data
Browse files Browse the repository at this point in the history
Miner now has to sign the hash_checkpoint list to avoid
using the signature on blocks having invalid proofs of
work
  • Loading branch information
christobias committed Feb 1, 2019
1 parent d93be60 commit a77743d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/cryptonote_basic/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,16 @@ namespace cryptonote
b.hash_checkpoints.push_back(h);
b.invalidate_hashes();

crypto::hash tree_hash;
crypto::tree_hash(b.hash_checkpoints.data(), b.hash_checkpoints.size(), tree_hash);

blobdata data;
data.append(epee::string_tools::pod_to_hex(b.miner_specific));
data.append("@");
data.append(boost::lexical_cast<std::string>(boost::get<cryptonote::txin_gen>(b.miner_tx.vin[0]).height));
data.append("@");
data.append(epee::string_tools::pod_to_hex(tree_hash));

crypto::hash hash;
crypto::cn_fast_hash(data.data(), data.size(), hash);
crypto::signature signature;
Expand Down
14 changes: 14 additions & 0 deletions src/cryptonote_protocol/cryptonote_protocol_handler.inl
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,17 @@ namespace cryptonote
LOG_DEBUG_CC(context, "Could not parse new block");
return 1;
}

crypto::hash tree_hash;
crypto::tree_hash(b.hash_checkpoints.data(), b.hash_checkpoints.size(), tree_hash);

blobdata data;
data.append(epee::string_tools::pod_to_hex(b.miner_specific));
data.append("@");
data.append(boost::lexical_cast<std::string>(boost::get<cryptonote::txin_gen>(b.miner_tx.vin[0]).height));
data.append("@");
data.append(epee::string_tools::pod_to_hex(tree_hash));

crypto::hash hash;
crypto::cn_fast_hash(data.data(), data.size(), hash);

Expand Down Expand Up @@ -507,10 +514,17 @@ namespace cryptonote
LOG_DEBUG_CC(context, "Could not parse new block");
return 1;
}

crypto::hash tree_hash;
crypto::tree_hash(b.hash_checkpoints.data(), b.hash_checkpoints.size(), tree_hash);

blobdata data;
data.append(epee::string_tools::pod_to_hex(b.miner_specific));
data.append("@");
data.append(boost::lexical_cast<std::string>(boost::get<cryptonote::txin_gen>(b.miner_tx.vin[0]).height));
data.append("@");
data.append(epee::string_tools::pod_to_hex(tree_hash));

crypto::hash hash;
crypto::cn_fast_hash(data.data(), data.size(), hash);

Expand Down

0 comments on commit a77743d

Please sign in to comment.