small cleanup

This commit is contained in:
j-berman 2024-05-23 12:34:48 -07:00
parent 5ad026975a
commit e68ea2e054
3 changed files with 31 additions and 32 deletions

View File

@ -73,7 +73,6 @@ static typename C::Point get_first_parent(const C &curve,
return get_new_parent<C>(curve, new_children);
std::vector<typename C::Scalar> prior_children;
if (child_layer_last_hash_updated)
{
// If the last chunk has updated children in it, then we need to get the delta to the old children
@ -299,18 +298,18 @@ typename CurveTrees<C1, C2>::TreeExtension CurveTrees<C1, C2>::get_tree_extensio
// TODO: calculate max number of layers it should take to add all leaves (existing leaves + new leaves)
while (true)
{
const LastChunkData<C1> *c1_last_chunk_ptr = (c1_last_chunks.size() <= c1_last_idx)
const LastChunkData<C1> *c1_last_chunk_ptr = (c1_last_idx >= c1_last_chunks.size())
? nullptr
: &c1_last_chunks[c1_last_idx];
const LastChunkData<C2> *c2_last_chunk_ptr = (c2_last_chunks.size() <= c2_last_idx)
const LastChunkData<C2> *c2_last_chunk_ptr = (c2_last_idx >= c2_last_chunks.size())
? nullptr
: &c2_last_chunks[c2_last_idx];
// TODO: templated function
if (parent_is_c1)
{
CHECK_AND_ASSERT_THROW_MES(c2_layer_extensions_out.size() > c2_last_idx, "missing c2 layer");
CHECK_AND_ASSERT_THROW_MES(c2_last_idx < c2_layer_extensions_out.size(), "missing c2 layer");
const auto &c2_child_extension = c2_layer_extensions_out[c2_last_idx];
@ -337,7 +336,7 @@ typename CurveTrees<C1, C2>::TreeExtension CurveTrees<C1, C2>::get_tree_extensio
}
else
{
CHECK_AND_ASSERT_THROW_MES(c1_layer_extensions_out.size() > c1_last_idx, "missing c1 layer");
CHECK_AND_ASSERT_THROW_MES(c1_last_idx < c1_layer_extensions_out.size(), "missing c1 layer");
const auto &c1_child_extension = c1_layer_extensions_out[c1_last_idx];

View File

@ -146,26 +146,6 @@ std::string Selene::to_string(const typename Selene::Point &point) const
//----------------------------------------------------------------------------------------------------------------------
// Exposed helper functions
//----------------------------------------------------------------------------------------------------------------------
Helios::Generators random_helios_generators(std::size_t n)
{
return fcmp_rust::random_helios_generators(n);
}
//----------------------------------------------------------------------------------------------------------------------
Selene::Generators random_selene_generators(std::size_t n)
{
return fcmp_rust::random_selene_generators(n);
}
//----------------------------------------------------------------------------------------------------------------------
Helios::Point random_helios_hash_init_point()
{
return fcmp_rust::random_helios_hash_init_point();
}
//----------------------------------------------------------------------------------------------------------------------
Selene::Point random_selene_hash_init_point()
{
return fcmp_rust::random_selene_hash_init_point();
}
//----------------------------------------------------------------------------------------------------------------------
SeleneScalar ed_25519_point_to_scalar(const crypto::ec_point &point)
{
static_assert(sizeof(RustEd25519Point) == sizeof(crypto::ec_point),
@ -221,6 +201,26 @@ template void extend_scalars_from_cycle_points<Selene, Helios>(const Selene &cur
const std::vector<Selene::Point> &points,
std::vector<Helios::Scalar> &scalars_out);
//----------------------------------------------------------------------------------------------------------------------
Helios::Generators random_helios_generators(std::size_t n)
{
return fcmp_rust::random_helios_generators(n);
}
//----------------------------------------------------------------------------------------------------------------------
Selene::Generators random_selene_generators(std::size_t n)
{
return fcmp_rust::random_selene_generators(n);
}
//----------------------------------------------------------------------------------------------------------------------
Helios::Point random_helios_hash_init_point()
{
return fcmp_rust::random_helios_hash_init_point();
}
//----------------------------------------------------------------------------------------------------------------------
Selene::Point random_selene_hash_init_point()
{
return fcmp_rust::random_selene_hash_init_point();
}
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
} //namespace tower_cycle
} //namespace fcmp

View File

@ -184,13 +184,6 @@ public:
};
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
// TODO: use static constants and get rid of the below functions (WARNING: number of generators must be >= curve's
// width, and also need to account for selene leaf layer 3x)
Helios::Generators random_helios_generators(std::size_t n);
Selene::Generators random_selene_generators(std::size_t n);
Helios::Point random_helios_hash_init_point();
Selene::Point random_selene_hash_init_point();
//----------------------------------------------------------------------------------------------------------------------
// Ed25519 point x-coordinates are Selene scalars
SeleneScalar ed_25519_point_to_scalar(const crypto::ec_point &point);
//----------------------------------------------------------------------------------------------------------------------
@ -204,6 +197,13 @@ void extend_scalars_from_cycle_points(const C_POINTS &curve,
const std::vector<typename C_POINTS::Point> &points,
std::vector<typename C_SCALARS::Scalar> &scalars_out);
//----------------------------------------------------------------------------------------------------------------------
// TODO: use static constants and get rid of the below functions (WARNING: number of generators must be >= curve's
// width, and also need to account for selene leaf layer 3x)
Helios::Generators random_helios_generators(std::size_t n);
Selene::Generators random_selene_generators(std::size_t n);
Helios::Point random_helios_hash_init_point();
Selene::Point random_selene_hash_init_point();
//----------------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------------
}//namespace tower_cycle
}//namespace fcmp