Rename everything from fcmp* to fcmp_pp

This commit is contained in:
j-berman 2024-08-08 14:10:34 -07:00
parent d72f405cee
commit d4847f649e
28 changed files with 114 additions and 113 deletions

View File

@ -89,7 +89,7 @@ add_subdirectory(ringct)
add_subdirectory(checkpoints)
add_subdirectory(cryptonote_basic)
add_subdirectory(cryptonote_core)
add_subdirectory(fcmp)
add_subdirectory(fcmp_pp)
add_subdirectory(lmdb)
add_subdirectory(multisig)
add_subdirectory(net)

View File

@ -314,7 +314,7 @@ uint64_t BlockchainDB::add_block( const std::pair<block, blobdata>& blck
// When adding a block, we also need to add all the leaf tuples included in
// the block to a table keeping track of locked leaf tuples. Once those leaf
// tuples unlock, we use them to grow the tree.
std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext> leaf_tuples_by_unlock_block;
std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext> leaf_tuples_by_unlock_block;
// Get miner tx's leaf tuples
CHECK_AND_ASSERT_THROW_MES(m_curve_trees != nullptr, "curve trees must be set");

View File

@ -42,7 +42,7 @@
#include "cryptonote_basic/difficulty.h"
#include "cryptonote_basic/hardfork.h"
#include "cryptonote_protocol/enums.h"
#include "fcmp/curve_trees.h"
#include "fcmp_pp/curve_trees.h"
/** \file
* Cryptonote Blockchain Database Interface
@ -418,7 +418,7 @@ private:
, const uint64_t& coins_generated
, uint64_t num_rct_outs
, const crypto::hash& blk_hash
, const std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
, const std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
) = 0;
/**
@ -592,7 +592,7 @@ protected:
HardFork* m_hardfork;
std::shared_ptr<fcmp::curve_trees::CurveTreesV1> m_curve_trees;
std::shared_ptr<fcmp_pp::curve_trees::CurveTreesV1> m_curve_trees;
public:
@ -1783,7 +1783,7 @@ public:
virtual bool for_all_alt_blocks(std::function<bool(const crypto::hash &blkid, const alt_block_data_t &data, const cryptonote::blobdata_ref *blob)> f, bool include_blob = false) const = 0;
// TODO: description and make private
virtual void grow_tree(std::vector<fcmp::curve_trees::LeafTupleContext> &&new_leaves) = 0;
virtual void grow_tree(std::vector<fcmp_pp::curve_trees::LeafTupleContext> &&new_leaves) = 0;
virtual void trim_tree(const uint64_t trim_n_leaf_tuples) = 0;

View File

@ -798,7 +798,7 @@ estim:
}
void BlockchainLMDB::add_block(const block& blk, size_t block_weight, uint64_t long_term_block_weight, const difficulty_type& cumulative_difficulty, const uint64_t& coins_generated,
uint64_t num_rct_outs, const crypto::hash& blk_hash, const std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext> &leaf_tuples_by_unlock_block)
uint64_t num_rct_outs, const crypto::hash& blk_hash, const std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext> &leaf_tuples_by_unlock_block)
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
@ -1344,7 +1344,7 @@ void BlockchainLMDB::remove_spent_key(const crypto::key_image& k_image)
}
}
void BlockchainLMDB::grow_tree(std::vector<fcmp::curve_trees::LeafTupleContext> &&new_leaves)
void BlockchainLMDB::grow_tree(std::vector<fcmp_pp::curve_trees::LeafTupleContext> &&new_leaves)
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
if (new_leaves.empty())
@ -1403,7 +1403,7 @@ void BlockchainLMDB::grow_tree(std::vector<fcmp::curve_trees::LeafTupleContext>
throw0(DB_ERROR(("Growing odd c2 layer, expected even layer idx for c1: "
+ std::to_string(layer_idx)).c_str()));
this->grow_layer<fcmp::curve_trees::Selene>(m_curve_trees->m_c2,
this->grow_layer<fcmp_pp::curve_trees::Selene>(m_curve_trees->m_c2,
c2_extensions,
c2_idx,
layer_idx);
@ -1416,7 +1416,7 @@ void BlockchainLMDB::grow_tree(std::vector<fcmp::curve_trees::LeafTupleContext>
throw0(DB_ERROR(("Growing even c1 layer, expected odd layer idx for c2: "
+ std::to_string(layer_idx)).c_str()));
this->grow_layer<fcmp::curve_trees::Helios>(m_curve_trees->m_c1,
this->grow_layer<fcmp_pp::curve_trees::Helios>(m_curve_trees->m_c1,
c1_extensions,
c1_idx,
layer_idx);
@ -1430,7 +1430,7 @@ void BlockchainLMDB::grow_tree(std::vector<fcmp::curve_trees::LeafTupleContext>
template<typename C>
void BlockchainLMDB::grow_layer(const std::unique_ptr<C> &curve,
const std::vector<fcmp::curve_trees::LayerExtension<C>> &layer_extensions,
const std::vector<fcmp_pp::curve_trees::LayerExtension<C>> &layer_extensions,
const uint64_t ext_idx,
const uint64_t layer_idx)
{
@ -1596,7 +1596,7 @@ void BlockchainLMDB::trim_tree(const uint64_t trim_n_leaf_tuples)
template<typename C>
void BlockchainLMDB::trim_layer(const std::unique_ptr<C> &curve,
const fcmp::curve_trees::LayerReduction<C> &layer_reduction,
const fcmp_pp::curve_trees::LayerReduction<C> &layer_reduction,
const uint64_t layer_idx)
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
@ -1718,7 +1718,7 @@ std::array<uint8_t, 32UL> BlockchainLMDB::get_tree_root() const
return root;
}
fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_tree_last_hashes() const
fcmp_pp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_tree_last_hashes() const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
@ -1726,7 +1726,7 @@ fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_tree_last_hashes
TXN_PREFIX_RDONLY();
RCURSOR(layers)
fcmp::curve_trees::CurveTreesV1::LastHashes last_hashes;
fcmp_pp::curve_trees::CurveTreesV1::LastHashes last_hashes;
auto &c1_last_hashes = last_hashes.c1_last_hashes;
auto &c2_last_hashes = last_hashes.c2_last_hashes;
@ -1772,8 +1772,8 @@ fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_tree_last_hashes
return last_hashes;
}
fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_last_chunk_children_to_trim(
const std::vector<fcmp::curve_trees::TrimLayerInstructions> &trim_instructions) const
fcmp_pp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_last_chunk_children_to_trim(
const std::vector<fcmp_pp::curve_trees::TrimLayerInstructions> &trim_instructions) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
@ -1783,7 +1783,7 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las
TXN_PREFIX_RDONLY();
RCURSOR(layers)
fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim last_chunk_children_to_trim;
fcmp_pp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim last_chunk_children_to_trim;
auto &c1_last_children_out = last_chunk_children_to_trim.c1_children;
auto &c2_last_children_out = last_chunk_children_to_trim.c2_children;
@ -1793,17 +1793,17 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las
CHECK_AND_ASSERT_THROW_MES(!trim_instructions.empty(), "no instructions");
const auto &trim_leaf_layer_instructions = trim_instructions[0];
std::vector<fcmp::curve_trees::Selene::Scalar> leaves_to_trim;
std::vector<fcmp_pp::curve_trees::Selene::Scalar> leaves_to_trim;
if (trim_leaf_layer_instructions.end_trim_idx > trim_leaf_layer_instructions.start_trim_idx)
{
leaves_to_trim.reserve(trim_leaf_layer_instructions.end_trim_idx - trim_leaf_layer_instructions.start_trim_idx);
uint64_t idx = trim_leaf_layer_instructions.start_trim_idx;
CHECK_AND_ASSERT_THROW_MES(idx % fcmp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE == 0,
CHECK_AND_ASSERT_THROW_MES(idx % fcmp_pp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE == 0,
"expected divisble by leaf tuple size");
const uint64_t leaf_tuple_idx = idx / fcmp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE;
const uint64_t leaf_tuple_idx = idx / fcmp_pp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE;
MDB_val_copy<uint64_t> k(leaf_tuple_idx);
MDB_cursor_op leaf_op = MDB_SET;
@ -1817,7 +1817,7 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las
if (result != MDB_SUCCESS)
throw0(DB_ERROR(lmdb_error("Failed to get leaf: ", result).c_str()));
const auto preprocessed_leaf_tuple = *(fcmp::curve_trees::PreprocessedLeafTuple *)v.mv_data;
const auto preprocessed_leaf_tuple = *(fcmp_pp::curve_trees::PreprocessedLeafTuple *)v.mv_data;
// TODO: parallelize calls to this function
auto leaf = m_curve_trees->leaf_tuple(preprocessed_leaf_tuple);
@ -1826,7 +1826,7 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las
leaves_to_trim.emplace_back(std::move(leaf.I_x));
leaves_to_trim.emplace_back(std::move(leaf.C_x));
idx += fcmp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE;
idx += fcmp_pp::curve_trees::CurveTreesV1::LEAF_TUPLE_SIZE;
}
while (idx < trim_leaf_layer_instructions.end_trim_idx);
}
@ -1841,8 +1841,8 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las
{
const auto &trim_layer_instructions = trim_instructions[i];
std::vector<fcmp::curve_trees::Helios::Scalar> c1_children;
std::vector<fcmp::curve_trees::Selene::Scalar> c2_children;
std::vector<fcmp_pp::curve_trees::Helios::Scalar> c1_children;
std::vector<fcmp_pp::curve_trees::Selene::Scalar> c2_children;
if (trim_layer_instructions.end_trim_idx > trim_layer_instructions.start_trim_idx)
{
@ -1895,8 +1895,8 @@ fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim BlockchainLMDB::get_las
return last_chunk_children_to_trim;
}
fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_last_hashes_to_trim(
const std::vector<fcmp::curve_trees::TrimLayerInstructions> &trim_instructions) const
fcmp_pp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_last_hashes_to_trim(
const std::vector<fcmp_pp::curve_trees::TrimLayerInstructions> &trim_instructions) const
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
check_open();
@ -1904,7 +1904,7 @@ fcmp::curve_trees::CurveTreesV1::LastHashes BlockchainLMDB::get_last_hashes_to_t
TXN_PREFIX_RDONLY();
RCURSOR(layers)
fcmp::curve_trees::CurveTreesV1::LastHashes last_hashes_out;
fcmp_pp::curve_trees::CurveTreesV1::LastHashes last_hashes_out;
// Traverse the tree layer-by-layer starting at the layer closest to leaf layer
uint64_t layer_idx = 0;
@ -1975,7 +1975,7 @@ bool BlockchainLMDB::audit_tree(const uint64_t expected_n_leaf_tuples) const
while (1)
{
// Get next leaf chunk
std::vector<fcmp::curve_trees::CurveTreesV1::LeafTuple> leaf_tuples_chunk;
std::vector<fcmp_pp::curve_trees::CurveTreesV1::LeafTuple> leaf_tuples_chunk;
leaf_tuples_chunk.reserve(m_curve_trees->m_c2_width);
// Iterate until chunk is full or we get to the end of all leaves
@ -1989,7 +1989,7 @@ bool BlockchainLMDB::audit_tree(const uint64_t expected_n_leaf_tuples) const
if (result != MDB_SUCCESS)
throw0(DB_ERROR(lmdb_error("Failed to add leaf: ", result).c_str()));
const auto preprocessed_leaf_tuple = *(fcmp::curve_trees::PreprocessedLeafTuple *)v.mv_data;
const auto preprocessed_leaf_tuple = *(fcmp_pp::curve_trees::PreprocessedLeafTuple *)v.mv_data;
auto leaf = m_curve_trees->leaf_tuple(preprocessed_leaf_tuple);
leaf_tuples_chunk.emplace_back(std::move(leaf));
@ -2022,13 +2022,13 @@ bool BlockchainLMDB::audit_tree(const uint64_t expected_n_leaf_tuples) const
// Get the expected leaf chunk hash
const auto leaves = m_curve_trees->flatten_leaves(std::move(leaf_tuples_chunk));
const fcmp::curve_trees::Selene::Chunk chunk{leaves.data(), leaves.size()};
const fcmp_pp::curve_trees::Selene::Chunk chunk{leaves.data(), leaves.size()};
// Hash the chunk of leaves
for (uint64_t i = 0; i < leaves.size(); ++i)
MDEBUG("Hashing " << m_curve_trees->m_c2->to_string(leaves[i]));
const fcmp::curve_trees::Selene::Point chunk_hash = fcmp::curve_trees::get_new_parent(m_curve_trees->m_c2, chunk);
const auto chunk_hash = fcmp_pp::curve_trees::get_new_parent(m_curve_trees->m_c2, chunk);
MDEBUG("chunk_hash " << m_curve_trees->m_c2->to_string(chunk_hash) << " , hash init point: "
<< m_curve_trees->m_c2->to_string(m_curve_trees->m_c2->hash_init_point()) << " (" << leaves.size() << " leaves)");
@ -2173,7 +2173,7 @@ bool BlockchainLMDB::audit_layer(const std::unique_ptr<C_CHILD> &c_child,
for (uint64_t i = 0; i < child_scalars.size(); ++i)
MDEBUG("Hashing " << c_parent->to_string(child_scalars[i]));
const auto chunk_hash = fcmp::curve_trees::get_new_parent(c_parent, chunk);
const auto chunk_hash = fcmp_pp::curve_trees::get_new_parent(c_parent, chunk);
MDEBUG("chunk_hash " << c_parent->to_string(chunk_hash) << " , hash init point: "
<< c_parent->to_string(c_parent->hash_init_point()) << " (" << child_scalars.size() << " children)");
@ -2194,7 +2194,7 @@ bool BlockchainLMDB::audit_layer(const std::unique_ptr<C_CHILD> &c_child,
chunk_width);
}
std::vector<fcmp::curve_trees::LeafTupleContext> BlockchainLMDB::get_leaf_tuples_at_unlock_block_id(
std::vector<fcmp_pp::curve_trees::LeafTupleContext> BlockchainLMDB::get_leaf_tuples_at_unlock_block_id(
uint64_t block_id)
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
@ -2207,7 +2207,7 @@ std::vector<fcmp::curve_trees::LeafTupleContext> BlockchainLMDB::get_leaf_tuples
MDB_val v_tuple;
// Get all the locked outputs at the provided block id
std::vector<fcmp::curve_trees::LeafTupleContext> leaf_tuples;
std::vector<fcmp_pp::curve_trees::LeafTupleContext> leaf_tuples;
MDB_cursor_op op = MDB_SET;
while (1)
@ -2223,8 +2223,8 @@ std::vector<fcmp::curve_trees::LeafTupleContext> BlockchainLMDB::get_leaf_tuples
if (blk_id != block_id)
throw0(DB_ERROR(("Blk id " + std::to_string(blk_id) + " not the expected" + std::to_string(block_id)).c_str()));
const auto range_begin = ((const fcmp::curve_trees::LeafTupleContext*)v_tuple.mv_data);
const auto range_end = range_begin + v_tuple.mv_size / sizeof(fcmp::curve_trees::LeafTupleContext);
const auto range_begin = ((const fcmp_pp::curve_trees::LeafTupleContext*)v_tuple.mv_data);
const auto range_end = range_begin + v_tuple.mv_size / sizeof(fcmp_pp::curve_trees::LeafTupleContext);
auto it = range_begin;
@ -2279,7 +2279,7 @@ BlockchainLMDB::~BlockchainLMDB()
BlockchainLMDB::close();
}
BlockchainLMDB::BlockchainLMDB(bool batch_transactions, std::shared_ptr<fcmp::curve_trees::CurveTreesV1> curve_trees): BlockchainDB()
BlockchainLMDB::BlockchainLMDB(bool batch_transactions, std::shared_ptr<fcmp_pp::curve_trees::CurveTreesV1> curve_trees): BlockchainDB()
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
// initialize folder to something "safe" just in case
@ -6836,7 +6836,7 @@ void BlockchainLMDB::migrate_5_6()
}
// Convert the output into a leaf tuple context
fcmp::curve_trees::LeafTupleContext tuple_context;
fcmp_pp::curve_trees::LeafTupleContext tuple_context;
try
{
tuple_context = m_curve_trees->output_to_leaf_context(

View File

@ -30,7 +30,7 @@
#include "blockchain_db/blockchain_db.h"
#include "cryptonote_basic/blobdatatype.h" // for type blobdata
#include "fcmp/curve_trees.h"
#include "fcmp_pp/curve_trees.h"
#include "ringct/rctTypes.h"
#include <boost/thread/tss.hpp>
@ -194,7 +194,7 @@ struct mdb_txn_safe
class BlockchainLMDB : public BlockchainDB
{
public:
BlockchainLMDB(bool batch_transactions=true, std::shared_ptr<fcmp::curve_trees::CurveTreesV1> curve_trees = fcmp::curve_trees::curve_trees_v1());
BlockchainLMDB(bool batch_transactions=true, std::shared_ptr<fcmp_pp::curve_trees::CurveTreesV1> curve_trees = fcmp_pp::curve_trees::curve_trees_v1());
~BlockchainLMDB();
virtual void open(const std::string& filename, const int mdb_flags=0);
@ -368,7 +368,7 @@ public:
static int compare_string(const MDB_val *a, const MDB_val *b);
// make private
virtual void grow_tree(std::vector<fcmp::curve_trees::LeafTupleContext> &&new_leaves);
virtual void grow_tree(std::vector<fcmp_pp::curve_trees::LeafTupleContext> &&new_leaves);
virtual void trim_tree(const uint64_t trim_n_leaf_tuples);
@ -388,7 +388,7 @@ private:
, const uint64_t& coins_generated
, uint64_t num_rct_outs
, const crypto::hash& block_hash
, const std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
, const std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
);
virtual void remove_block();
@ -420,26 +420,26 @@ private:
template<typename C>
void grow_layer(const std::unique_ptr<C> &curve,
const std::vector<fcmp::curve_trees::LayerExtension<C>> &layer_extensions,
const std::vector<fcmp_pp::curve_trees::LayerExtension<C>> &layer_extensions,
const uint64_t c_idx,
const uint64_t layer_idx);
template<typename C>
void trim_layer(const std::unique_ptr<C> &curve,
const fcmp::curve_trees::LayerReduction<C> &layer_reduction,
const fcmp_pp::curve_trees::LayerReduction<C> &layer_reduction,
const uint64_t layer_idx);
virtual uint64_t get_num_leaf_tuples() const;
virtual std::array<uint8_t, 32UL> get_tree_root() const;
fcmp::curve_trees::CurveTreesV1::LastHashes get_tree_last_hashes() const;
fcmp_pp::curve_trees::CurveTreesV1::LastHashes get_tree_last_hashes() const;
fcmp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim get_last_chunk_children_to_trim(
const std::vector<fcmp::curve_trees::TrimLayerInstructions> &trim_instructions) const;
fcmp_pp::curve_trees::CurveTreesV1::LastChunkChildrenToTrim get_last_chunk_children_to_trim(
const std::vector<fcmp_pp::curve_trees::TrimLayerInstructions> &trim_instructions) const;
fcmp::curve_trees::CurveTreesV1::LastHashes get_last_hashes_to_trim(
const std::vector<fcmp::curve_trees::TrimLayerInstructions> &trim_instructions) const;
fcmp_pp::curve_trees::CurveTreesV1::LastHashes get_last_hashes_to_trim(
const std::vector<fcmp_pp::curve_trees::TrimLayerInstructions> &trim_instructions) const;
template<typename C_CHILD, typename C_PARENT>
bool audit_layer(const std::unique_ptr<C_CHILD> &c_child,
@ -449,7 +449,7 @@ private:
const uint64_t child_chunk_idx,
const uint64_t chunk_width) const;
std::vector<fcmp::curve_trees::LeafTupleContext> get_leaf_tuples_at_unlock_block_id(uint64_t block_id);
std::vector<fcmp_pp::curve_trees::LeafTupleContext> get_leaf_tuples_at_unlock_block_id(uint64_t block_id);
void del_locked_leaf_tuples_at_block_id(uint64_t block_id);

View File

@ -116,7 +116,7 @@ public:
virtual void add_tx_amount_output_indices(const uint64_t tx_index, const std::vector<uint64_t>& amount_output_indices) override {}
virtual void add_spent_key(const crypto::key_image& k_image) override {}
virtual void remove_spent_key(const crypto::key_image& k_image) override {}
virtual void grow_tree(std::vector<fcmp::curve_trees::LeafTupleContext> &&new_leaves) override {};
virtual void grow_tree(std::vector<fcmp_pp::curve_trees::LeafTupleContext> &&new_leaves) override {};
virtual void trim_tree(const uint64_t trim_n_leaf_tuples) override {};
virtual bool audit_tree(const uint64_t expected_n_leaf_tuples) const override { return false; };
virtual std::array<uint8_t, 32UL> get_tree_root() const override { return {}; };
@ -149,7 +149,7 @@ public:
, const uint64_t& coins_generated
, uint64_t num_rct_outs
, const crypto::hash& blk_hash
, const std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
, const std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
) override { }
virtual cryptonote::block get_block_from_height(const uint64_t& height) const override { return cryptonote::block(); }
virtual void set_hard_fork_version(uint64_t height, uint8_t version) override {}

View File

@ -141,6 +141,7 @@ target_link_libraries(blockchain_import
PRIVATE
cryptonote_core
blockchain_db
fcmp_pp
version
epee
${Boost_FILESYSTEM_LIBRARY}

View File

@ -32,11 +32,11 @@ set(fcmp_pp_sources
monero_find_all_headers(fcmp_pp_headers "${CMAKE_CURRENT_SOURCE_DIR}")
add_subdirectory(fcmp_rust)
add_subdirectory(fcmp_pp_rust)
monero_add_library_with_deps(
NAME fcmp_pp
DEPENDS fcmp_rust
DEPENDS fcmp_pp_rust
SOURCES
${fcmp_pp_sources}
${fcmp_pp_headers})
@ -54,6 +54,6 @@ target_link_libraries(fcmp_pp
epee
ringct
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/fcmp_rust/libfcmp_rust.a
${CMAKE_CURRENT_BINARY_DIR}/fcmp_pp_rust/libfcmp_pp_rust.a
${EXTRA_LIBRARIES}
${EXTRA_RUST_LIBRARIES})

View File

@ -31,7 +31,7 @@
#include "ringct/rctOps.h"
namespace fcmp
namespace fcmp_pp
{
namespace curve_trees
{
@ -549,7 +549,7 @@ static TrimLayerInstructions get_trim_layer_instructions(
}
//----------------------------------------------------------------------------------------------------------------------
template<typename C_CHILD, typename C_PARENT>
static typename fcmp::curve_trees::LayerReduction<C_PARENT> get_next_layer_reduction(
static typename fcmp_pp::curve_trees::LayerReduction<C_PARENT> get_next_layer_reduction(
const std::unique_ptr<C_CHILD> &c_child,
const std::unique_ptr<C_PARENT> &c_parent,
const TrimLayerInstructions &trim_layer_instructions,
@ -1028,4 +1028,4 @@ GrowLayerInstructions CurveTrees<C1, C2>::set_next_layer_extension(
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
} //namespace curve_trees
} //namespace fcmp
} //namespace fcmp_pp

View File

@ -38,7 +38,7 @@
#include <vector>
namespace fcmp
namespace fcmp_pp
{
namespace curve_trees
{
@ -309,4 +309,4 @@ std::shared_ptr<CurveTreesV1> curve_trees_v1(
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
} //namespace curve_trees
} //namespace fcmp
} //namespace fcmp_pp

View File

@ -93,9 +93,9 @@ else ()
set(TARGET_DIR "release")
endif ()
set(FCMP_PP_RUST_HEADER_DIR "${MONERO_GENERATED_HEADERS_DIR}/fcmp_rust")
set(FCMP_PP_RUST_HEADER_DIR "${MONERO_GENERATED_HEADERS_DIR}/fcmp_pp_rust")
set(FCMP_PP_RUST_HEADER "${FCMP_PP_RUST_HEADER_DIR}/fcmp++.h")
set(FCMP_PP_RUST_LIB "${CMAKE_CURRENT_BINARY_DIR}/libfcmp_rust.a")
set(FCMP_PP_RUST_LIB "${CMAKE_CURRENT_BINARY_DIR}/libfcmp_pp_rust.a")
# Removing OUTPUT files makes sure custom command runs every time
file(REMOVE_RECURSE "${FCMP_PP_RUST_HEADER_DIR}")
@ -109,10 +109,10 @@ add_custom_command(
OUTPUT ${FCMP_PP_RUST_LIB}
COMMAND CARGO_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} ${CARGO_CMD}
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/fcmp++.h ${FCMP_PP_RUST_HEADER}
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/${RUST_TARGET}/${TARGET_DIR}/libfcmp_rust.a ${FCMP_PP_RUST_LIB}
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/${RUST_TARGET}/${TARGET_DIR}/libfcmp_pp_rust.a ${FCMP_PP_RUST_LIB}
COMMAND echo "Finished copying fcmp++ rust targets"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
add_custom_target(fcmp_rust DEPENDS ${FCMP_PP_RUST_LIB})
add_custom_target(fcmp_pp_rust DEPENDS ${FCMP_PP_RUST_LIB})

View File

@ -239,7 +239,7 @@ dependencies = [
]
[[package]]
name = "fcmp_rust"
name = "fcmp_pp_rust"
version = "0.0.0"
dependencies = [
"ciphersuite",

View File

@ -1,10 +1,10 @@
[package]
name = "fcmp_rust"
name = "fcmp_pp_rust"
version = "0.0.0"
edition = "2021"
[lib]
name = "fcmp_rust"
name = "fcmp_pp_rust"
crate-type = ["staticlib"]
[dependencies]

View File

@ -30,16 +30,16 @@
#include <cstdint>
namespace fcmp
namespace fcmp_pp
{
// Byte buffer containing the fcmp++ proof
using FcmpPpProof = std::vector<uint8_t>;
static inline std::size_t fcmp_pp_len(const std::size_t n_inputs)
static inline std::size_t proof_len(const std::size_t n_inputs)
{
// TODO: implement
return n_inputs * 4;
};
}//namespace fcmp
}//namespace fcmp_pp

View File

@ -29,7 +29,7 @@
#include "string_tools.h"
#include "tower_cycle.h"
namespace fcmp
namespace fcmp_pp
{
namespace tower_cycle
{
@ -280,4 +280,4 @@ template void extend_scalars_from_cycle_points<Selene, Helios>(const std::unique
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
} //namespace tower_cycle
} //namespace fcmp
} //namespace fcmp_pp

View File

@ -29,12 +29,12 @@
#pragma once
#include "crypto/crypto.h"
#include "fcmp_rust/fcmp++.h"
#include "fcmp_pp_rust/fcmp++.h"
#include "ringct/rctTypes.h"
#include <string>
namespace fcmp
namespace fcmp_pp
{
namespace tower_cycle
{
@ -188,4 +188,4 @@ void extend_scalars_from_cycle_points(const std::unique_ptr<C_POINTS> &curve,
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
}//namespace tower_cycle
}//namespace fcmp
}//namespace fcmp_pp

View File

@ -45,7 +45,7 @@ extern "C" {
}
#include "crypto/generic-ops.h"
#include "crypto/crypto.h"
#include "fcmp/proof.h"
#include "fcmp_pp/proof.h"
#include "hex.h"
#include "span.h"
#include "memwipe.h"
@ -426,7 +426,7 @@ namespace rct {
std::vector<mgSig> MGs; // simple rct has N, full has 1
std::vector<clsag> CLSAGs;
keyV pseudoOuts; //C - for simple rct
fcmp::FcmpPpProof fcmp_pp;
fcmp_pp::FcmpPpProof fcmp_pp;
// when changing this function, update cryptonote::get_pruned_transaction_weight
template<bool W, template <bool> class Archive>
@ -503,7 +503,7 @@ namespace rct {
{
ar.tag("fcmp_pp");
ar.begin_object();
const std::size_t proof_len = fcmp::fcmp_pp_len(inputs);
const std::size_t proof_len = fcmp_pp::proof_len(inputs);
if (!typename Archive<W>::is_saving())
fcmp_pp.resize(proof_len);
if (fcmp_pp.size() != proof_len)

View File

@ -32,7 +32,7 @@
#include <math.h>
#include "cryptonote_core/cryptonote_core.h"
#include "blockchain_db/testdb.h"
#include "fcmp/curve_trees.h"
#include "fcmp_pp/curve_trees.h"
#define LONG_TERM_BLOCK_WEIGHT_WINDOW 5000
@ -65,7 +65,7 @@ public:
, const uint64_t& coins_generated
, uint64_t num_rct_outs
, const crypto::hash& blk_hash
, const std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
, const std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
) override {
blocks.push_back({block_weight, long_term_block_weight});
}

View File

@ -88,7 +88,7 @@ namespace
, const uint64_t& coins_generated
, uint64_t num_rct_outs
, const crypto::hash& blk_hash
, const std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
, const std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
) override
{
blocks.push_back({blk, blk_hash});

View File

@ -62,7 +62,7 @@ static bool validate_layer(const std::unique_ptr<C> &curve,
for (std::size_t i = 0; i < chunk_size; ++i)
MDEBUG("Hashing " << curve->to_string(chunk_start[i]));
const typename C::Point chunk_hash = fcmp::curve_trees::get_new_parent(curve, chunk);
const typename C::Point chunk_hash = fcmp_pp::curve_trees::get_new_parent(curve, chunk);
MDEBUG("chunk_start_idx: " << chunk_start_idx << " , chunk_size: " << chunk_size << " , chunk_hash: " << curve->to_string(chunk_hash));
@ -193,7 +193,7 @@ void CurveTreesGlobalTree::extend_tree(const CurveTreesV1::TreeExtension &tree_e
if (use_c2)
{
CHECK_AND_ASSERT_THROW_MES(c2_idx < c2_extensions.size(), "unexpected c2 layer extension");
const fcmp::curve_trees::LayerExtension<Selene> &c2_ext = c2_extensions[c2_idx];
const fcmp_pp::curve_trees::LayerExtension<Selene> &c2_ext = c2_extensions[c2_idx];
CHECK_AND_ASSERT_THROW_MES(!c2_ext.hashes.empty(), "empty c2 layer extension");
@ -226,7 +226,7 @@ void CurveTreesGlobalTree::extend_tree(const CurveTreesV1::TreeExtension &tree_e
else
{
CHECK_AND_ASSERT_THROW_MES(c1_idx < c1_extensions.size(), "unexpected c1 layer extension");
const fcmp::curve_trees::LayerExtension<Helios> &c1_ext = c1_extensions[c1_idx];
const fcmp_pp::curve_trees::LayerExtension<Helios> &c1_ext = c1_extensions[c1_idx];
CHECK_AND_ASSERT_THROW_MES(!c1_ext.hashes.empty(), "empty c1 layer extension");
@ -338,7 +338,7 @@ void CurveTreesGlobalTree::reduce_tree(const CurveTreesV1::TreeReduction &tree_r
//----------------------------------------------------------------------------------------------------------------------
// TODO: template
CurveTreesV1::LastChunkChildrenToTrim CurveTreesGlobalTree::get_all_last_chunk_children_to_trim(
const std::vector<fcmp::curve_trees::TrimLayerInstructions> &trim_instructions)
const std::vector<fcmp_pp::curve_trees::TrimLayerInstructions> &trim_instructions)
{
CurveTreesV1::LastChunkChildrenToTrim all_children_to_trim;
@ -424,7 +424,7 @@ CurveTreesV1::LastChunkChildrenToTrim CurveTreesGlobalTree::get_all_last_chunk_c
}
//----------------------------------------------------------------------------------------------------------------------
CurveTreesV1::LastHashes CurveTreesGlobalTree::get_last_hashes_to_trim(
const std::vector<fcmp::curve_trees::TrimLayerInstructions> &trim_instructions) const
const std::vector<fcmp_pp::curve_trees::TrimLayerInstructions> &trim_instructions) const
{
CurveTreesV1::LastHashes last_hashes;
CHECK_AND_ASSERT_THROW_MES(!trim_instructions.empty(), "no instructions");
@ -532,7 +532,7 @@ bool CurveTreesGlobalTree::audit_tree(const std::size_t expected_n_leaf_tuples)
CHECK_AND_ASSERT_MES(!children.empty(), false, "no children at c1_idx " + std::to_string(c1_idx));
std::vector<Selene::Scalar> child_scalars;
fcmp::tower_cycle::extend_scalars_from_cycle_points<Helios, Selene>(m_curve_trees.m_c1,
fcmp_pp::tower_cycle::extend_scalars_from_cycle_points<Helios, Selene>(m_curve_trees.m_c1,
children,
child_scalars);
@ -559,7 +559,7 @@ bool CurveTreesGlobalTree::audit_tree(const std::size_t expected_n_leaf_tuples)
CHECK_AND_ASSERT_MES(!children.empty(), false, "no children at c2_idx " + std::to_string(c2_idx));
std::vector<Helios::Scalar> child_scalars;
fcmp::tower_cycle::extend_scalars_from_cycle_points<Selene, Helios>(m_curve_trees.m_c2,
fcmp_pp::tower_cycle::extend_scalars_from_cycle_points<Selene, Helios>(m_curve_trees.m_c2,
children,
child_scalars);
@ -660,7 +660,7 @@ void CurveTreesGlobalTree::log_tree_extension(const CurveTreesV1::TreeExtension
{
CHECK_AND_ASSERT_THROW_MES(c2_idx < c2_extensions.size(), "unexpected c2 layer");
const fcmp::curve_trees::LayerExtension<Selene> &c2_layer = c2_extensions[c2_idx];
const fcmp_pp::curve_trees::LayerExtension<Selene> &c2_layer = c2_extensions[c2_idx];
MDEBUG("Selene tree extension start idx: " << c2_layer.start_idx);
for (std::size_t j = 0; j < c2_layer.hashes.size(); ++j)
@ -673,7 +673,7 @@ void CurveTreesGlobalTree::log_tree_extension(const CurveTreesV1::TreeExtension
{
CHECK_AND_ASSERT_THROW_MES(c1_idx < c1_extensions.size(), "unexpected c1 layer");
const fcmp::curve_trees::LayerExtension<Helios> &c1_layer = c1_extensions[c1_idx];
const fcmp_pp::curve_trees::LayerExtension<Helios> &c1_layer = c1_extensions[c1_idx];
MDEBUG("Helios tree extension start idx: " << c1_layer.start_idx);
for (std::size_t j = 0; j < c1_layer.hashes.size(); ++j)
@ -743,11 +743,11 @@ void CurveTreesGlobalTree::log_tree()
//----------------------------------------------------------------------------------------------------------------------
// Test helpers
//----------------------------------------------------------------------------------------------------------------------
static const std::vector<fcmp::curve_trees::LeafTupleContext> generate_random_leaves(const CurveTreesV1 &curve_trees,
static const std::vector<fcmp_pp::curve_trees::LeafTupleContext> generate_random_leaves(const CurveTreesV1 &curve_trees,
const std::size_t old_n_leaf_tuples,
const std::size_t new_n_leaf_tuples)
{
std::vector<fcmp::curve_trees::LeafTupleContext> tuples;
std::vector<fcmp_pp::curve_trees::LeafTupleContext> tuples;
tuples.reserve(new_n_leaf_tuples);
for (std::size_t i = 0; i < new_n_leaf_tuples; ++i)
@ -777,7 +777,7 @@ static const Selene::Scalar generate_random_selene_scalar()
rct::key S_x;
CHECK_AND_ASSERT_THROW_MES(rct::point_to_wei_x(rct::pk2rct(S), S_x), "failed to convert to wei x");
return fcmp::tower_cycle::selene_scalar_from_bytes(S_x);
return fcmp_pp::tower_cycle::selene_scalar_from_bytes(S_x);
}
//----------------------------------------------------------------------------------------------------------------------
static bool grow_tree(CurveTreesV1 &curve_trees,
@ -941,7 +941,7 @@ TEST(curve_trees, grow_tree)
LOG_PRINT_L1("Test grow tree with helios chunk width " << helios_chunk_width
<< ", selene chunk width " << selene_chunk_width);
const auto curve_trees = fcmp::curve_trees::curve_trees_v1(helios_chunk_width, selene_chunk_width);
const auto curve_trees = fcmp_pp::curve_trees::curve_trees_v1(helios_chunk_width, selene_chunk_width);
// Constant for how deep we want the tree
static const std::size_t TEST_N_LAYERS = 4;
@ -984,7 +984,7 @@ TEST(curve_trees, trim_tree)
LOG_PRINT_L1("Test trim tree with helios chunk width " << helios_chunk_width
<< ", selene chunk width " << selene_chunk_width);
const auto curve_trees = fcmp::curve_trees::curve_trees_v1(helios_chunk_width, selene_chunk_width);
const auto curve_trees = fcmp_pp::curve_trees::curve_trees_v1(helios_chunk_width, selene_chunk_width);
// Constant for how deep we want the tree
static const std::size_t TEST_N_LAYERS = 4;
@ -1028,7 +1028,7 @@ TEST(curve_trees, trim_tree)
// Make sure the result of hash_trim is the same as the equivalent hash_grow excluding the trimmed children
TEST(curve_trees, hash_trim)
{
const auto curve_trees = fcmp::curve_trees::curve_trees_v1();
const auto curve_trees = fcmp_pp::curve_trees::curve_trees_v1();
// 1. Trim 1
{
@ -1183,7 +1183,7 @@ TEST(curve_trees, hash_trim)
//----------------------------------------------------------------------------------------------------------------------
TEST(curve_trees, hash_grow)
{
const auto curve_trees = fcmp::curve_trees::curve_trees_v1();
const auto curve_trees = fcmp_pp::curve_trees::curve_trees_v1();
// Start by hashing: {selene_scalar_0, selene_scalar_1}
// Then grow 1: {selene_scalar_0, selene_scalar_1, selene_scalar_2}

View File

@ -28,12 +28,12 @@
#pragma once
#include "fcmp/curve_trees.h"
#include "fcmp/tower_cycle.h"
#include "fcmp_pp/curve_trees.h"
#include "fcmp_pp/tower_cycle.h"
using Helios = fcmp::curve_trees::Helios;
using Selene = fcmp::curve_trees::Selene;
using CurveTreesV1 = fcmp::curve_trees::CurveTreesV1;
using Helios = fcmp_pp::curve_trees::Helios;
using Selene = fcmp_pp::curve_trees::Selene;
using CurveTreesV1 = fcmp_pp::curve_trees::CurveTreesV1;
// Helper class to read/write a global tree in memory. It's only used in testing because normally the tree isn't kept
// in memory (it's stored in the db)
@ -85,10 +85,10 @@ public:
// - This function is useful to collect all tree data necessary to perform the actual trim operation
// - This function can return elems from each last chunk that will need to be trimmed
CurveTreesV1::LastHashes get_last_hashes_to_trim(
const std::vector<fcmp::curve_trees::TrimLayerInstructions> &trim_instructions) const;
const std::vector<fcmp_pp::curve_trees::TrimLayerInstructions> &trim_instructions) const;
CurveTreesV1::LastChunkChildrenToTrim get_all_last_chunk_children_to_trim(
const std::vector<fcmp::curve_trees::TrimLayerInstructions> &trim_instructions);
const std::vector<fcmp_pp::curve_trees::TrimLayerInstructions> &trim_instructions);
private:
CurveTreesV1 &m_curve_trees;

View File

@ -35,7 +35,7 @@
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_basic/hardfork.h"
#include "blockchain_db/testdb.h"
#include "fcmp/curve_trees.h"
#include "fcmp_pp/curve_trees.h"
using namespace cryptonote;
@ -55,7 +55,7 @@ public:
, const uint64_t& coins_generated
, uint64_t num_rct_outs
, const crypto::hash& blk_hash
, const std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
, const std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
) override {
blocks.push_back(blk);
}

View File

@ -58,7 +58,7 @@ public:
, const uint64_t& coins_generated
, uint64_t num_rct_outs
, const crypto::hash& blk_hash
, const std::multimap<uint64_t, fcmp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
, const std::multimap<uint64_t, fcmp_pp::curve_trees::LeafTupleContext>& leaf_tuples_by_unlock_block
) override {
blocks.push_back({block_weight, long_term_block_weight});
}

View File

@ -1370,8 +1370,8 @@ TEST(Serialization, tx_fcmp_pp)
tx.rct_signatures.referenceBlock = referenceBlock;
// 1 fcmp++ proof
fcmp::FcmpPpProof fcmp_pp;
const std::size_t proof_len = fcmp::fcmp_pp_len(n_inputs);
fcmp_pp::FcmpPpProof fcmp_pp;
const std::size_t proof_len = fcmp_pp::proof_len(n_inputs);
fcmp_pp.reserve(proof_len);
for (std::size_t i = 0; i < proof_len; ++i)
fcmp_pp.push_back(i);
@ -1400,7 +1400,7 @@ TEST(Serialization, tx_fcmp_pp)
string blob;
// Extend fcmp++ proof
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp::fcmp_pp_len(n_inputs));
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp_pp::proof_len(n_inputs));
tx.rct_signatures.p.fcmp_pp.push_back(0x01);
ASSERT_FALSE(serialization::dump_binary(tx, blob));
@ -1411,7 +1411,7 @@ TEST(Serialization, tx_fcmp_pp)
transaction tx = make_dummy_fcmp_pp_tx();
// Shorten the fcmp++ proof
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp::fcmp_pp_len(n_inputs));
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() == fcmp_pp::proof_len(n_inputs));
ASSERT_TRUE(tx.rct_signatures.p.fcmp_pp.size() > 1);
tx.rct_signatures.p.fcmp_pp.pop_back();

View File

@ -34,7 +34,7 @@
#include "blockchain_db/blockchain_db.h"
#include "blockchain_db/lmdb/db_lmdb.h"
#include "fcmp/curve_trees.h"
#include "fcmp_pp/curve_trees.h"
#include "misc_log_ex.h"
#include <atomic>
@ -84,7 +84,7 @@ namespace unit_test
remove_files();
}
void init_new_db(std::shared_ptr<fcmp::curve_trees::CurveTreesV1> curve_trees)
void init_new_db(std::shared_ptr<fcmp_pp::curve_trees::CurveTreesV1> curve_trees)
{
CHECK_AND_ASSERT_THROW_MES(this->m_db == nullptr, "expected nullptr m_db");
this->m_db = new cryptonote::BlockchainLMDB(true/*batch_transactions*/, curve_trees);