From fcdd8c0dc83edb0dd8f7f85a78c47f49dd99f922 Mon Sep 17 00:00:00 2001 From: Jason Rhinelander Date: Thu, 3 Dec 2020 12:54:51 -0400 Subject: [PATCH] fix --- tests/crypto/crypto-tests.h | 2 -- tests/crypto/crypto.cpp | 8 -------- tests/trezor/trezor_tests.cpp | 2 +- tests/unit_tests/random.cpp | 4 ++-- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/tests/crypto/crypto-tests.h b/tests/crypto/crypto-tests.h index d910a845c..83d88ab17 100644 --- a/tests/crypto/crypto-tests.h +++ b/tests/crypto/crypto-tests.h @@ -42,8 +42,6 @@ void setup_random(void); } bool check_scalar(const crypto::ec_scalar &scalar); -void random_scalar(crypto::ec_scalar &res); -void hash_to_scalar(const void *data, std::size_t length, crypto::ec_scalar &res); void hash_to_point(const crypto::hash &h, crypto::ec_point &res); void hash_to_ec(const crypto::public_key &key, crypto::ec_point &res); #endif diff --git a/tests/crypto/crypto.cpp b/tests/crypto/crypto.cpp index 6a1dd1b29..d68265806 100644 --- a/tests/crypto/crypto.cpp +++ b/tests/crypto/crypto.cpp @@ -36,14 +36,6 @@ bool check_scalar(const crypto::ec_scalar &scalar) { return crypto::sc_check(crypto::operator &(scalar)) == 0; } -void random_scalar(crypto::ec_scalar &res) { - crypto::random_scalar(res); -} - -void hash_to_scalar(const void *data, std::size_t length, crypto::ec_scalar &res) { - crypto::hash_to_scalar(data, length, res); -} - void hash_to_point(const crypto::hash &h, crypto::ec_point &res) { crypto::ge_p2 point; crypto::ge_fromfe_frombytes_vartime(&point, reinterpret_cast(&h)); diff --git a/tests/trezor/trezor_tests.cpp b/tests/trezor/trezor_tests.cpp index 65e8edf9b..d5a45f0dc 100644 --- a/tests/trezor/trezor_tests.cpp +++ b/tests/trezor/trezor_tests.cpp @@ -1608,7 +1608,7 @@ bool gen_trezor_live_refresh::generate(std::vector& events) ::crypto::public_key pub_ver; ::crypto::key_image ki; - ::crypto::random32_unbiased((unsigned char*)r.data); + ::crypto::random_scalar((unsigned char*)r.data); ::crypto::secret_key_to_public_key(r, R); memcpy(D.data, rct::scalarmultKey(rct::pk2rct(R), rct::sk2rct(m_alice_account.get_keys().m_view_secret_key)).bytes, 32); diff --git a/tests/unit_tests/random.cpp b/tests/unit_tests/random.cpp index 7653453cd..12aea75f6 100644 --- a/tests/unit_tests/random.cpp +++ b/tests/unit_tests/random.cpp @@ -34,12 +34,12 @@ extern "C" { #include "crypto/crypto-ops.h" } -TEST(random32_unbiased, less_than_order) +TEST(random_scalar, less_than_order) { unsigned char tmp[32], tmp2[32]; for (int i = 0; i < 1000; ++i) { - crypto::random32_unbiased(tmp); + crypto::random_scalar(tmp); memcpy(tmp2, tmp, 32); sc_reduce32(tmp2); ASSERT_EQ(memcmp(tmp, tmp2, 32), 0);