From b2d23b189efaafe89082a9f14e376c2cbad42f40 Mon Sep 17 00:00:00 2001 From: stoffu Date: Mon, 5 Mar 2018 17:20:36 +0900 Subject: [PATCH] crypto: revert odd namespace changes made in #3303 --- src/crypto/crypto.cpp | 2 +- src/crypto/crypto.h | 9 --------- tests/crypto/crypto.cpp | 12 ++++++------ 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp index 0c70b9eeb..494027560 100644 --- a/src/crypto/crypto.cpp +++ b/src/crypto/crypto.cpp @@ -436,7 +436,7 @@ namespace crypto { return sc_isnonzero(&c2) == 0; } - void crypto_ops::hash_to_ec(const public_key &key, ge_p3 &res) { + static void hash_to_ec(const public_key &key, ge_p3 &res) { hash h; ge_p2 point; ge_p1p1 point2; diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index 9d0e5066b..81ebfb9e2 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -46,9 +46,6 @@ #include "hex.h" #include "span.h" #include "hash.h" -extern "C" { - #include "crypto-ops.h" -} namespace crypto { @@ -116,9 +113,6 @@ namespace crypto { void operator=(const crypto_ops &); ~crypto_ops(); - static void hash_to_ec(const public_key &key, ge_p3 &res) ; - friend void hash_to_ec(const public_key &key, ge_p3 &res) ; - static secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key& recovery_key = secret_key(), bool recover = false); friend secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key& recovery_key, bool recover); static bool check_key(const public_key &); @@ -172,9 +166,6 @@ namespace crypto { return res; } - inline void hash_to_ec(const public_key &key, ge_p3 &res) { - crypto_ops::hash_to_ec(key,res); - } /* Generate a new key pair */ inline secret_key generate_keys(public_key &pub, secret_key &sec, const secret_key& recovery_key = secret_key(), bool recover = false) { diff --git a/tests/crypto/crypto.cpp b/tests/crypto/crypto.cpp index 90212bd0b..6a1dd1b29 100644 --- a/tests/crypto/crypto.cpp +++ b/tests/crypto/crypto.cpp @@ -33,7 +33,7 @@ #include "crypto-tests.h" bool check_scalar(const crypto::ec_scalar &scalar) { - return sc_check(crypto::operator &(scalar)) == 0; + return crypto::sc_check(crypto::operator &(scalar)) == 0; } void random_scalar(crypto::ec_scalar &res) { @@ -45,13 +45,13 @@ 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) { - ge_p2 point; - ge_fromfe_frombytes_vartime(&point, reinterpret_cast(&h)); - ge_tobytes(crypto::operator &(res), &point); + crypto::ge_p2 point; + crypto::ge_fromfe_frombytes_vartime(&point, reinterpret_cast(&h)); + crypto::ge_tobytes(crypto::operator &(res), &point); } void hash_to_ec(const crypto::public_key &key, crypto::ec_point &res) { - ge_p3 tmp; + crypto::ge_p3 tmp; crypto::hash_to_ec(key, tmp); - ge_p3_tobytes(crypto::operator &(res), &tmp); + crypto::ge_p3_tobytes(crypto::operator &(res), &tmp); }