|
33 | 33 | #include "fcmp_pp_types.h" |
34 | 34 | #include "profile_tools.h" |
35 | 35 |
|
| 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 | +} |
36 | 46 |
|
37 | 47 | namespace fcmp_pp |
38 | 48 | { |
39 | 49 | namespace curve_trees |
40 | 50 | { |
41 | 51 | //---------------------------------------------------------------------------------------------------------------------- |
42 | 52 | //---------------------------------------------------------------------------------------------------------------------- |
| 53 | +// Public helper functions |
| 54 | +//---------------------------------------------------------------------------------------------------------------------- |
43 | 55 | OutputTuple output_to_tuple(const OutputPair &output_pair) |
44 | 56 | { |
45 | 57 | const crypto::public_key &output_pubkey = output_pubkey_cref(output_pair); |
@@ -100,5 +112,39 @@ OutputTuple output_to_tuple(const OutputPair &output_pair) |
100 | 112 | } |
101 | 113 | //---------------------------------------------------------------------------------------------------------------------- |
102 | 114 | //---------------------------------------------------------------------------------------------------------------------- |
| 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 | +//---------------------------------------------------------------------------------------------------------------------- |
103 | 149 | } //namespace curve_trees |
104 | 150 | } //namespace fcmp_pp |
0 commit comments