This commit is contained in:
Jason Rhinelander 2020-12-03 12:54:51 -04:00
parent 51786d398f
commit fcdd8c0dc8
4 changed files with 3 additions and 13 deletions

View File

@ -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

View File

@ -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<const unsigned char *>(&h));

View File

@ -1608,7 +1608,7 @@ bool gen_trezor_live_refresh::generate(std::vector<test_event_entry>& 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);

View File

@ -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);