Fix compile on arm-linux-androideabi (32-bit) using a newer NDK

- @tobtoht reported err with size_t -> uint64_t
- Also address some PR comments (@vtnerd namespace comment +
@boog900 freeing unallocated rust type)
- Some cleaning
This commit is contained in:
j-berman 2024-09-03 13:38:44 -07:00
parent 47d47bdd20
commit 41b1985f63
4 changed files with 19 additions and 12 deletions

View File

@ -644,8 +644,7 @@ static typename fcmp_pp::curve_trees::LayerReduction<C_PARENT> get_next_layer_re
// CurveTrees public member functions // CurveTrees public member functions
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
template<> template<>
CurveTrees<Helios, Selene>::LeafTuple CurveTrees<Helios, Selene>::leaf_tuple( CurveTrees<Helios, Selene>::LeafTuple CurveTrees<Helios, Selene>::leaf_tuple(const OutputPair &output_pair) const
const OutputPair &output_pair) const
{ {
const crypto::public_key &output_pubkey = output_pair.output_pubkey; const crypto::public_key &output_pubkey = output_pair.output_pubkey;
const rct::key &commitment = output_pair.commitment; const rct::key &commitment = output_pair.commitment;

View File

@ -164,7 +164,10 @@ template<typename C1, typename C2>
class CurveTrees class CurveTrees
{ {
public: public:
CurveTrees(std::unique_ptr<C1> &&c1, std::unique_ptr<C2> &&c2, const uint64_t c1_width, const uint64_t c2_width): CurveTrees(std::unique_ptr<C1> &&c1,
std::unique_ptr<C2> &&c2,
const std::size_t c1_width,
const std::size_t c2_width):
m_c1{std::move(c1)}, m_c1{std::move(c1)},
m_c2{std::move(c2)}, m_c2{std::move(c2)},
m_c1_width{c1_width}, m_c1_width{c1_width},
@ -240,7 +243,7 @@ public:
//member functions //member functions
public: public:
// Convert output pairs into leaf tuples, from {output pubkey,commitment} -> {O,C} -> {O.x,I.x,C.x} // Convert output pairs into leaf tuples, from {output pubkey,commitment} -> {O,C} -> {O.x,I.x,C.x}
LeafTuple leaf_tuple(const OutputPair &outpout_pair) const; LeafTuple leaf_tuple(const OutputPair &output_pair) const;
// Flatten leaves [(O.x, I.x, C.x),(O.x, I.x, C.x),...] -> [O.x, I.x, C.x, O.x, I.x, C.x...] // Flatten leaves [(O.x, I.x, C.x),(O.x, I.x, C.x),...] -> [O.x, I.x, C.x, O.x, I.x, C.x...]
std::vector<typename C2::Scalar> flatten_leaves(std::vector<LeafTuple> &&leaves) const; std::vector<typename C2::Scalar> flatten_leaves(std::vector<LeafTuple> &&leaves) const;

View File

@ -1,10 +1,12 @@
namespace fcmp_pp_rust {
#include <cstdarg> #include <cstdarg>
#include <cstdint> #include <cstdint>
#include <cstdlib> #include <cstdlib>
#include <ostream> #include <ostream>
#include <new> #include <new>
namespace fcmp_pp_rust
{
// ----- deps C bindings ----- // ----- deps C bindings -----
/// Inner integer type that the [`Limb`] newtype wraps. /// Inner integer type that the [`Limb`] newtype wraps.
@ -137,5 +139,4 @@ CResult hash_trim_selene(SelenePoint existing_hash,
SeleneScalar child_to_grow_back); SeleneScalar child_to_grow_back);
} // extern "C" } // extern "C"
}//namespace fcmp_pp
}

View File

@ -152,6 +152,7 @@ pub extern "C" fn hash_grow_helios(
if let Some(hash) = hash { if let Some(hash) = hash {
CResult::ok(hash) CResult::ok(hash)
} else { } else {
// TODO: return defined error here: https://github.com/monero-project/monero/pull/9436#discussion_r1720477391
CResult::err(()) CResult::err(())
} }
} }
@ -174,6 +175,7 @@ pub extern "C" fn hash_trim_helios(
if let Some(hash) = hash { if let Some(hash) = hash {
CResult::ok(hash) CResult::ok(hash)
} else { } else {
// TODO: return defined error here: https://github.com/monero-project/monero/pull/9436#discussion_r1720477391
CResult::err(()) CResult::err(())
} }
} }
@ -196,6 +198,7 @@ pub extern "C" fn hash_grow_selene(
if let Some(hash) = hash { if let Some(hash) = hash {
CResult::ok(hash) CResult::ok(hash)
} else { } else {
// TODO: return defined error here: https://github.com/monero-project/monero/pull/9436#discussion_r1720477391
CResult::err(()) CResult::err(())
} }
} }
@ -218,6 +221,7 @@ pub extern "C" fn hash_trim_selene(
if let Some(hash) = hash { if let Some(hash) = hash {
CResult::ok(hash) CResult::ok(hash)
} else { } else {
// TODO: return defined error here: https://github.com/monero-project/monero/pull/9436#discussion_r1720477391
CResult::err(()) CResult::err(())
} }
} }