mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
Remove ringct dep in fcmp_pp, impl in fcmp_pp_crypto
This commit is contained in:
parent
9ad49189bb
commit
b6bcca9899
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
set(fcmp_pp_sources
|
set(fcmp_pp_sources
|
||||||
curve_trees.cpp
|
curve_trees.cpp
|
||||||
|
fcmp_pp_crypto.cpp
|
||||||
tower_cycle.cpp)
|
tower_cycle.cpp)
|
||||||
|
|
||||||
monero_find_all_headers(fcmp_pp_headers "${CMAKE_CURRENT_SOURCE_DIR}")
|
monero_find_all_headers(fcmp_pp_headers "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
@ -52,7 +53,6 @@ target_link_libraries(fcmp_pp
|
|||||||
cncrypto
|
cncrypto
|
||||||
cryptonote_basic
|
cryptonote_basic
|
||||||
epee
|
epee
|
||||||
ringct_basic
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/fcmp_pp_rust/libfcmp_pp_rust.a
|
${CMAKE_CURRENT_BINARY_DIR}/fcmp_pp_rust/libfcmp_pp_rust.a
|
||||||
${EXTRA_LIBRARIES}
|
${EXTRA_LIBRARIES}
|
||||||
|
@ -26,8 +26,10 @@
|
|||||||
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
|
||||||
#include "curve_trees.h"
|
#include "curve_trees.h"
|
||||||
|
|
||||||
|
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||||
|
#include "fcmp_pp_crypto.h"
|
||||||
#include "ringct/rctOps.h"
|
#include "ringct/rctOps.h"
|
||||||
|
|
||||||
|
|
||||||
@ -705,9 +707,9 @@ CurveTrees<Helios, Selene>::LeafTuple CurveTrees<Helios, Selene>::leaf_tuple(
|
|||||||
const rct::key &commitment = output_pair.commitment;
|
const rct::key &commitment = output_pair.commitment;
|
||||||
|
|
||||||
rct::key O, C;
|
rct::key O, C;
|
||||||
if (!rct::clear_torsion(rct::pk2rct(output_pubkey), O))
|
if (!fcmp_pp::clear_torsion(rct::pk2rct(output_pubkey), O))
|
||||||
throw std::runtime_error("output pubkey is invalid");
|
throw std::runtime_error("output pubkey is invalid");
|
||||||
if (!rct::clear_torsion(commitment, C))
|
if (!fcmp_pp::clear_torsion(commitment, C))
|
||||||
throw std::runtime_error("commitment is invalid");
|
throw std::runtime_error("commitment is invalid");
|
||||||
|
|
||||||
if (O == rct::I)
|
if (O == rct::I)
|
||||||
@ -722,11 +724,11 @@ CurveTrees<Helios, Selene>::LeafTuple CurveTrees<Helios, Selene>::leaf_tuple(
|
|||||||
crypto::derive_key_image_generator(output_pubkey, I);
|
crypto::derive_key_image_generator(output_pubkey, I);
|
||||||
|
|
||||||
rct::key O_x, I_x, C_x;
|
rct::key O_x, I_x, C_x;
|
||||||
if (!rct::point_to_wei_x(O, O_x))
|
if (!fcmp_pp::point_to_wei_x(O, O_x))
|
||||||
throw std::runtime_error("failed to get wei x scalar from O");
|
throw std::runtime_error("failed to get wei x scalar from O");
|
||||||
if (!rct::point_to_wei_x(rct::pt2rct(I), I_x))
|
if (!fcmp_pp::point_to_wei_x(rct::pt2rct(I), I_x))
|
||||||
throw std::runtime_error("failed to get wei x scalar from I");
|
throw std::runtime_error("failed to get wei x scalar from I");
|
||||||
if (!rct::point_to_wei_x(C, C_x))
|
if (!fcmp_pp::point_to_wei_x(C, C_x))
|
||||||
throw std::runtime_error("failed to get wei x scalar from C");
|
throw std::runtime_error("failed to get wei x scalar from C");
|
||||||
|
|
||||||
return LeafTuple{
|
return LeafTuple{
|
||||||
|
@ -725,29 +725,4 @@ namespace rct {
|
|||||||
sc_sub(masked.amount.bytes, masked.amount.bytes, sharedSec2.bytes);
|
sc_sub(masked.amount.bytes, masked.amount.bytes, sharedSec2.bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool clear_torsion(const key &k, key &k_out) {
|
|
||||||
ge_p3 point;
|
|
||||||
if (ge_frombytes_vartime(&point, k.bytes) != 0)
|
|
||||||
return false;
|
|
||||||
// mul by inv 8, then mul by 8
|
|
||||||
ge_p2 point_inv_8;
|
|
||||||
ge_scalarmult(&point_inv_8, INV_EIGHT.bytes, &point);
|
|
||||||
ge_p1p1 point_inv_8_mul_8;
|
|
||||||
ge_mul8(&point_inv_8_mul_8, &point_inv_8);
|
|
||||||
ge_p3 torsion_cleared_point;
|
|
||||||
ge_p1p1_to_p3(&torsion_cleared_point, &point_inv_8_mul_8);
|
|
||||||
ge_p3_tobytes(k_out.bytes, &torsion_cleared_point);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool point_to_wei_x(const key &pub, key &wei_x) {
|
|
||||||
if (pub == I)
|
|
||||||
return false;
|
|
||||||
fe y;
|
|
||||||
if (fe_frombytes_vartime(y, pub.bytes) != 0)
|
|
||||||
return false;
|
|
||||||
fe_ed_y_to_wei_x(wei_x.bytes, y);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -188,9 +188,5 @@ namespace rct {
|
|||||||
key genCommitmentMask(const key &sk);
|
key genCommitmentMask(const key &sk);
|
||||||
void ecdhEncode(ecdhTuple & unmasked, const key & sharedSec, bool v2);
|
void ecdhEncode(ecdhTuple & unmasked, const key & sharedSec, bool v2);
|
||||||
void ecdhDecode(ecdhTuple & masked, const key & sharedSec, bool v2);
|
void ecdhDecode(ecdhTuple & masked, const key & sharedSec, bool v2);
|
||||||
|
|
||||||
// TODO: tests for these functions specifically
|
|
||||||
bool clear_torsion(const key &k, key &k_out);
|
|
||||||
bool point_to_wei_x(const key &pub, key &wei_x);
|
|
||||||
}
|
}
|
||||||
#endif /* RCTOPS_H */
|
#endif /* RCTOPS_H */
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||||
#include "curve_trees.h"
|
#include "curve_trees.h"
|
||||||
|
#include "fcmp_pp/fcmp_pp_crypto.h"
|
||||||
#include "misc_log_ex.h"
|
#include "misc_log_ex.h"
|
||||||
#include "ringct/rctOps.h"
|
#include "ringct/rctOps.h"
|
||||||
#include "unit_tests_utils.h"
|
#include "unit_tests_utils.h"
|
||||||
@ -777,7 +778,7 @@ static const Selene::Scalar generate_random_selene_scalar()
|
|||||||
crypto::generate_keys(S, s, s, false);
|
crypto::generate_keys(S, s, s, false);
|
||||||
|
|
||||||
rct::key S_x;
|
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");
|
CHECK_AND_ASSERT_THROW_MES(fcmp_pp::point_to_wei_x(rct::pk2rct(S), S_x), "failed to convert to wei x");
|
||||||
return fcmp_pp::tower_cycle::selene_scalar_from_bytes(S_x);
|
return fcmp_pp::tower_cycle::selene_scalar_from_bytes(S_x);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user