Skip to content

Commit f9f16c7

Browse files
committed
FCMP++: output_to_pre_leaf_tuple
1 parent 564be61 commit f9f16c7

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/fcmp_pp/curve_trees.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,25 @@
3333
#include "fcmp_pp_types.h"
3434
#include "profile_tools.h"
3535

36+
namespace
37+
{
38+
// Struct composed of ec elems needed to get a full-fledged leaf tuple
39+
struct PreLeafTuple final
40+
{
41+
fcmp_pp::EdDerivatives O_derivatives;
42+
fcmp_pp::EdDerivatives I_derivatives;
43+
fcmp_pp::EdDerivatives C_derivatives;
44+
};
45+
}
3646

3747
namespace fcmp_pp
3848
{
3949
namespace curve_trees
4050
{
4151
//----------------------------------------------------------------------------------------------------------------------
4252
//----------------------------------------------------------------------------------------------------------------------
53+
// Public helper functions
54+
//----------------------------------------------------------------------------------------------------------------------
4355
OutputTuple output_to_tuple(const OutputPair &output_pair)
4456
{
4557
const crypto::public_key &output_pubkey = output_pubkey_cref(output_pair);
@@ -100,5 +112,39 @@ OutputTuple output_to_tuple(const OutputPair &output_pair)
100112
}
101113
//----------------------------------------------------------------------------------------------------------------------
102114
//----------------------------------------------------------------------------------------------------------------------
115+
// Static functions
116+
//----------------------------------------------------------------------------------------------------------------------
117+
static PreLeafTuple output_tuple_to_pre_leaf_tuple(const OutputTuple &o)
118+
{
119+
TIME_MEASURE_NS_START(point_to_ed_derivatives_ns);
120+
121+
const crypto::ec_point &O = (crypto::ec_point&) o.O;
122+
const crypto::ec_point &I = (crypto::ec_point&) o.I;
123+
const crypto::ec_point &C = (crypto::ec_point&) o.C;
124+
125+
// TODO: we end up decompressing O and C twice, both in here and when checking the points for torsion. It's worth
126+
// checking how much of an impact that has on performance.
127+
PreLeafTuple plt;
128+
if (!fcmp_pp::point_to_ed_derivatives(O, plt.O_derivatives))
129+
throw std::runtime_error("failed to get ed derivatives from O");
130+
if (!fcmp_pp::point_to_ed_derivatives(I, plt.I_derivatives))
131+
throw std::runtime_error("failed to get ed derivatives from I");
132+
if (!fcmp_pp::point_to_ed_derivatives(C, plt.C_derivatives))
133+
throw std::runtime_error("failed to get ed derivatives from C");
134+
135+
TIME_MEASURE_NS_FINISH(point_to_ed_derivatives_ns);
136+
137+
LOG_PRINT_L3("point_to_ed_derivatives_ns: " << point_to_ed_derivatives_ns);
138+
139+
return plt;
140+
}
141+
//----------------------------------------------------------------------------------------------------------------------
142+
static PreLeafTuple output_to_pre_leaf_tuple(const OutputPair &output_pair)
143+
{
144+
const auto o = output_to_tuple(output_pair);
145+
return output_tuple_to_pre_leaf_tuple(o);
146+
}
147+
//----------------------------------------------------------------------------------------------------------------------
148+
//----------------------------------------------------------------------------------------------------------------------
103149
} //namespace curve_trees
104150
} //namespace fcmp_pp

0 commit comments

Comments
 (0)