What changed, and why it matters
This commit adds a new internal cryptography helper for X25519 curve operations in Monero. It does not change existing wallet, network, or consensus logic. There is no indication in the commit or supplied references that this fixes or introduces a security vulnerability; it appears to be a routine feature addition with tests.
No immediate security action is required. Treat as a normal code-review item: verify that downstream callers of the new unclamped X25519 API use it correctly and that the 'unclamped' semantics are appropriate for each future use case.
Security signals we found
New cryptographic wrapper added, but no existing call sites are modified
Functions are labeled 'unclamped' / 'does not conform to RFC 7748' by the developer
Unit tests include small-order point handling and cross-implementation convergence checks
No memory-safety issues (use of mlocked/scrubbed secret-key type) are visible in the diff
Evidence from the diff
The patch introduces src/crypto/x25519.{h,cpp}, a C++ wrapper around the existing mx25519 implementation. It exposes x25519_secret_key_gen, x25519_pubkey_gen, x25519_scmul_base_unclamped, and x25519_scmul_key_unclamped. The wrapper links cncrypto against mx25519_static and adds CMake logic to propagate include directories to object libraries. A unit-test file exercises the new wrapper and underlying mx25519 implementations against known small-order points and RFC 7748-style test vectors. The functions are explicitly documented as ‘unclamped’ and non-RFC-7748-conformant, which is a design choice, not a bug in itself.
Changed components
src/crypto/x25519.hsrc/crypto/x25519.cppsrc/crypto/CMakeLists.txtCMakeLists.txttests/unit_tests/x25519.cppInspect captured patch +468 / −1
### CMakeLists.txt
@@ -642,6 +642,11 @@ function (monero_add_library_with_deps)
set_property(TARGET "${MONERO_ADD_LIBRARY_NAME}" PROPERTY FOLDER "libs")
target_compile_definitions(${objlib}
PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_COMPILE_DEFINITIONS>)
+ # Propagate inherited include diretories of target to its obj_* counterparts
+ target_include_directories(${objlib}
+ PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INCLUDE_DIRECTORIES>)
+ target_include_directories(${objlib}
+ PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_INCLUDE_DIRECTORIES>)
endfunction ()
add_subdirectory(external)
### src/crypto/CMakeLists.txt
@@ -51,7 +51,8 @@ set(crypto_sources
slow-hash.c
rx-slow-hash.c
CryptonightR_JIT.c
- tree-hash.c)
+ tree-hash.c
+ x25519.cpp)
if(ARCH_ID STREQUAL "i386" OR ARCH_ID STREQUAL "x86_64" OR ARCH_ID STREQUAL "x86-64" OR ARCH_ID STREQUAL "amd64")
list(APPEND crypto_sources CryptonightR_template.S)
@@ -72,6 +73,7 @@ monero_add_library(cncrypto
target_link_libraries(cncrypto
PUBLIC
epee
+ mx25519_static
randomx
${Boost_SYSTEM_LIBRARY}
${sodium_LIBRARIES}
### src/crypto/x25519.cpp
@@ -0,0 +1,106 @@
+// Copyright (c) 2026, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// 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.
+
+//paired header
+#include "x25519.h"
+
+//local headers
+#include "crypto.h"
+extern "C"
+{
+#include "crypto-ops.h"
+}
+#include "mx25519.h"
+
+//third party headers
+
+//standard headers
+
+#undef MONERO_DEFAULT_LOG_CATEGORY
+#define MONERO_DEFAULT_LOG_CATEGORY "crypto"
+
+#if __cplusplus >= 202002L
+#include <type_traits>
+static_assert(std::is_layout_compatible_v<mx25519_pubkey, crypto::x25519_pubkey>);
+static_assert(std::is_layout_compatible_v<mx25519_privkey, crypto::x25519_scalar>);
+static_assert(std::is_layout_compatible_v<mx25519_privkey, crypto::x25519_secret_key>);
+#endif
+static_assert(sizeof(mx25519_pubkey) == sizeof(crypto::x25519_pubkey));
+static_assert(sizeof(mx25519_privkey) == sizeof(crypto::x25519_scalar));
+static_assert(sizeof(mx25519_privkey) == sizeof(crypto::x25519_secret_key));
+
+namespace
+{
+const mx25519_impl *get_impl()
+{
+ static const mx25519_impl *impl = mx25519_select_impl(MX25519_TYPE_AUTO);
+ return impl;
+}
+} //anonymous namespace
+
+namespace crypto
+{
+//-------------------------------------------------------------------------------------------------------------------
+x25519_secret_key x25519_secret_key_gen(bool scalar)
+{
+ x25519_secret_key privkey;
+ do
+ {
+ rand(sizeof(privkey.data), privkey.data);
+ if (scalar)
+ sc_reduce32(privkey.data);
+ } while (privkey == x25519_secret_key{});
+
+ return privkey;
+}
+//-------------------------------------------------------------------------------------------------------------------
+x25519_pubkey x25519_pubkey_gen()
+{
+ const x25519_secret_key privkey{x25519_secret_key_gen()};
+ x25519_pubkey pubkey;
+ x25519_scmul_base_unclamped(privkey, pubkey);
+
+ return pubkey;
+}
+//-------------------------------------------------------------------------------------------------------------------
+void x25519_scmul_base_unclamped(const x25519_scalar &scalar, x25519_pubkey &result_out)
+{
+ mx25519_scmul_base_unclamped(get_impl(),
+ reinterpret_cast<mx25519_pubkey*>(&result_out),
+ reinterpret_cast<const mx25519_privkey*>(&scalar));
+}
+//-------------------------------------------------------------------------------------------------------------------
+void x25519_scmul_key_unclamped(const x25519_scalar &scalar, const x25519_pubkey &pubkey, x25519_pubkey &result_out)
+{
+ mx25519_scmul_key_unclamped(get_impl(),
+ reinterpret_cast<mx25519_pubkey*>(&result_out),
+ reinterpret_cast<const mx25519_privkey*>(&scalar),
+ reinterpret_cast<const mx25519_pubkey*>(&pubkey));
+}
+//-------------------------------------------------------------------------------------------------------------------
+} //namespace crypto
### src/crypto/x25519.h
@@ -0,0 +1,93 @@
+// Copyright (c) 2026, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// 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.
+
+//! @file Interface for an x25519 implementation (mx25519).
+
+#pragma once
+
+//local headers
+#include "generic-ops.h"
+#include "memwipe.h"
+#include "mlocker.h"
+
+//third party headers
+
+//standard headers
+
+//forward declarations
+
+namespace crypto
+{
+
+struct x25519_pubkey
+{
+ uint8_t data[32];
+};
+struct x25519_scalar
+{
+ uint8_t data[32];
+};
+struct x25519_secret_key : public epee::mlocked<tools::scrubbed<x25519_scalar>>
+{
+ x25519_secret_key() = default;
+ x25519_secret_key(const x25519_scalar &other) { *this = other; }
+ x25519_secret_key& operator=(const x25519_scalar &other)
+ { unwrap(unwrap(*this)) = other; return *this; }
+};
+
+/**
+ * @brief Generate a random X25519 privkey
+ * @param scalar true to sample a scalar mod l, false to sample a uniform secret
+ * @return random X25519 privkey
+ */
+x25519_secret_key x25519_secret_key_gen(bool scalar = false);
+/**
+ * @brief Generate a random X25519 pubkey
+ * @return random X25519 pubkey
+ */
+x25519_pubkey x25519_pubkey_gen();
+/**
+ * @brief Compute scalar * xG [Unclamped, does not conform to RFC 7748]
+ * @param scalar scalar to multiply
+ * @param[out] result_out scalar * xG
+ */
+void x25519_scmul_base_unclamped(const x25519_scalar &scalar, x25519_pubkey &result_out);
+/**
+ * @brief Compute scalar * pubkey [Unclamped, does not conform to RFC 7748]
+ * @param scalar scalar to multiply
+ * @param pubkey public key to multiply against
+ * @param[out] result_out scalar * pubkey
+ */
+void x25519_scmul_key_unclamped(const x25519_scalar &scalar, const x25519_pubkey &pubkey, x25519_pubkey &result_out);
+
+} //namespace crypto
+
+/// upgrade x25519 keys
+CRYPTO_MAKE_HASHABLE(x25519_pubkey)
+CRYPTO_MAKE_HASHABLE_CONSTANT_TIME(x25519_scalar)
+CRYPTO_MAKE_HASHABLE_CONSTANT_TIME(x25519_secret_key)
### tests/unit_tests/CMakeLists.txt
@@ -106,6 +106,7 @@ set(unit_tests_sources
is_hdd.cpp
aligned.cpp
rpc_version_str.cpp
+ x25519.cpp
zmq_rpc.cpp)
set(unit_tests_headers
### tests/unit_tests/x25519.cpp
@@ -0,0 +1,260 @@
+// Copyright (c) 2017-2024, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// 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.
+
+#include <cstring>
+#include <gtest/gtest.h>
+
+extern "C"
+{
+#include "crypto/crypto-ops.h"
+}
+#include "crypto/generators.h"
+#include "misc_log_ex.h"
+#include "mx25519.h"
+#include "ringct/rctOps.h"
+#include "string_tools.h"
+
+namespace
+{
+ // https://github.com/jedisct1/libsodium/blob/master/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c#L17
+ static const mx25519_pubkey x25519_small_order_points[7] = {
+ /* 0 (order 4) */
+ {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }},
+ /* 1 (order 1) */
+ {{ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }},
+ /* 325606250916557431795983626356110631294008115727848805560023387167927233504
+ (order 8) */
+ {{ 0xe0, 0xeb, 0x7a, 0x7c, 0x3b, 0x41, 0xb8, 0xae, 0x16, 0x56, 0xe3,
+ 0xfa, 0xf1, 0x9f, 0xc4, 0x6a, 0xda, 0x09, 0x8d, 0xeb, 0x9c, 0x32,
+ 0xb1, 0xfd, 0x86, 0x62, 0x05, 0x16, 0x5f, 0x49, 0xb8, 0x00 }},
+ /* 39382357235489614581723060781553021112529911719440698176882885853963445705823
+ (order 8) */
+ {{ 0x5f, 0x9c, 0x95, 0xbc, 0xa3, 0x50, 0x8c, 0x24, 0xb1, 0xd0, 0xb1,
+ 0x55, 0x9c, 0x83, 0xef, 0x5b, 0x04, 0x44, 0x5c, 0xc4, 0x58, 0x1c,
+ 0x8e, 0x86, 0xd8, 0x22, 0x4e, 0xdd, 0xd0, 0x9f, 0x11, 0x57 }},
+ /* p-1 (order 2) */
+ {{ 0xec, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }},
+ /* p (=0, order 4) */
+ {{ 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }},
+ /* p+1 (=1, order 1) */
+ {{ 0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }}
+ };
+
+ static std::vector<const mx25519_impl*> get_available_mx25519_impls()
+ {
+ static constexpr const mx25519_type ALL_IMPL_TYPES[4] = {MX25519_TYPE_PORTABLE,
+ MX25519_TYPE_ARM64,
+ MX25519_TYPE_AMD64,
+ MX25519_TYPE_AMD64X};
+ static constexpr const size_t NUM_IMPLS = sizeof(ALL_IMPL_TYPES) / sizeof(ALL_IMPL_TYPES[0]);
+
+ std::vector<const mx25519_impl*> available_impls;
+ available_impls.reserve(NUM_IMPLS);
+ for (int i = 0; i < NUM_IMPLS; ++i)
+ {
+ const mx25519_type impl_type = ALL_IMPL_TYPES[i];
+ const mx25519_impl * const impl = mx25519_select_impl(impl_type);
+ if (nullptr == impl)
+ continue;
+ available_impls.push_back(impl);
+ }
+
+ return available_impls;
+ }
+
+ static std::string get_name_of_mx25519_impl(const mx25519_impl* impl)
+ {
+# define get_name_of_mx25519_impl_CASE(x) case x: return #x;
+ CHECK_AND_ASSERT_THROW_MES(impl != nullptr, "null impl");
+ const mx25519_type impl_type = mx25519_impl_type(impl);
+ switch (impl_type)
+ {
+ get_name_of_mx25519_impl_CASE(MX25519_TYPE_PORTABLE)
+ get_name_of_mx25519_impl_CASE(MX25519_TYPE_ARM64)
+ get_name_of_mx25519_impl_CASE(MX25519_TYPE_AMD64)
+ get_name_of_mx25519_impl_CASE(MX25519_TYPE_AMD64X)
+ default:
+ throw std::runtime_error("get name of mx25519 impl: unrecognized impl type");
+ }
+# undef get_name_of_mx25519_impl_CASE
+ }
+
+ void dump_mx25519_impls(const std::vector<const mx25519_impl*> &impls)
+ {
+ std::cout << "Testing " << impls.size() << " mx25519 implementations:" << std::endl;
+ for (const mx25519_impl *impl : impls)
+ std::cout << " - " << get_name_of_mx25519_impl(impl) << std::endl;
+ }
+
+ template <typename T>
+ static T hex2pod(boost::string_ref s)
+ {
+ T v;
+ if (!epee::string_tools::hex_to_pod(s, v))
+ throw std::runtime_error("hex2pod conversion failed");
+ return v;
+ }
+} // namespace
+
+static bool operator==(const mx25519_pubkey &a, const mx25519_pubkey &b)
+{
+ return 0 == memcmp(&a, &b, sizeof(mx25519_pubkey));
+}
+
+TEST(x25519, scmul_key_convergence)
+{
+ std::vector<const mx25519_impl*> available_impls = get_available_mx25519_impls();
+
+ ASSERT_GT(available_impls.size(), 0);
+
+ dump_mx25519_impls(available_impls);
+
+ std::vector<mx25519_privkey> scalars;
+ for (int i = 0; i <= 254; ++i)
+ {
+ for (unsigned char j = 0; j < 8; ++j)
+ {
+ // add 2^i + j (sometimes with duplicates, which is okay)
+ mx25519_privkey &s = scalars.emplace_back();
+ memset(s.data, 0, sizeof(mx25519_privkey));
+ const int msb_byte_index = i >> 3;
+ const int msb_bit_index = i & 7;
+ s.data[msb_byte_index] = 1 << msb_bit_index;
+ s.data[0] |= j;
+ }
+ }
+ // add l-1
+ scalars.push_back(hex2pod<mx25519_privkey>("ecd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010"));
+ // add p-1
+ scalars.push_back(hex2pod<mx25519_privkey>("ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f"));
+ // add random
+ const rct::key a = rct::skGen();
+ memcpy(scalars.emplace_back().data, &a, sizeof(mx25519_privkey));
+
+ std::vector<std::pair<rct::key, mx25519_pubkey>> points;
+ // add base point
+ points.push_back({rct::G, mx25519_pubkey{.data={9}}});
+ // add RFC 7784 test point
+ points.push_back({
+ hex2pod<rct::key>("8120f299c37ae1ca64a179f638a6c6fafde968f1c33705e28c413c7579d9884f"),
+ hex2pod<mx25519_pubkey>("8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a")
+ });
+ // add random point
+ const rct::key P_random = rct::pkGen();
+ mx25519_pubkey P_random_x;
+ edwards_bytes_to_x25519_vartime(P_random_x.data, P_random.bytes);
+ points.push_back({P_random, P_random_x});
+
+ for (const mx25519_privkey &scalar : scalars)
+ {
+ for (const auto &point : points)
+ {
+ // D1 = ConvertPointE(a * P_base)
+ ge_p3 P_ed;
+ ASSERT_EQ(0, ge_frombytes_vartime(&P_ed, point.first.bytes));
+ ge_p3 res_p3;
+ ge_scalarmult_p3(&res_p3, scalar.data, &P_ed);
+ mx25519_pubkey res;
+ ge_p3_to_x25519(res.data, &res_p3);
+
+ for (const mx25519_impl *impl : available_impls)
+ {
+ // D2 = a * D_base
+ mx25519_pubkey res_mx;
+ mx25519_scmul_key_unclamped(impl, &res_mx, &scalar, &point.second);
+
+ // D1 ?= D2
+ EXPECT_EQ(res, res_mx);
+ }
+ }
+ }
+}
+
+TEST(x25519, ConvertPointE_Base)
+{
+ const crypto::public_key G = crypto::get_G();
+ const mx25519_pubkey B_expected = {{9}};
+
+ mx25519_pubkey B_actual;
+ edwards_bytes_to_x25519_vartime(B_actual.data, to_bytes(G));
+
+ EXPECT_EQ(B_expected, B_actual);
+}
+
+TEST(x25519, ConvertPointE_EraseSign)
+{
+ // generate a random point P and test that ConvertPointE(P) == ConvertPointE(-P)
+
+ const rct::key P = rct::pkGen();
+ rct::key negP;
+ rct::subKeys(negP, rct::I, P);
+
+ mx25519_pubkey P_mont;
+ edwards_bytes_to_x25519_vartime(P_mont.data, P.bytes);
+
+ mx25519_pubkey negP_mont;
+ edwards_bytes_to_x25519_vartime(negP_mont.data, negP.bytes);
+
+ EXPECT_EQ(P_mont, negP_mont);
+}
+
+TEST(x25519, small_order_mul_eq_0)
+{
+ mx25519_privkey sk;
+ crypto::rand(sizeof(sk), sk.data);
+
+ // clamp 3 LSBs
+ sk.data[0] &= 0xf8;
+
+ const mx25519_pubkey x_eq_0{{0}};
+
+ const std::vector<const mx25519_impl*> available_mx25519_impls = get_available_mx25519_impls();
+
+ static constexpr size_t num_small_order_points = sizeof(x25519_small_order_points) /
+ sizeof(x25519_small_order_points[0]);
+ for (int i = 0; i < num_small_order_points; ++i)
+ {
+ for (const mx25519_impl* impl : available_mx25519_impls)
+ {
+ mx25519_pubkey Q;
+ mx25519_scmul_key_unclamped(impl, &Q, &sk, &x25519_small_order_points[i]);
+
+ EXPECT_EQ(x_eq_0, Q);
+ }
+ }
+}Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.