Merge pull request #1912

00cbf720 ringct: move ge_frombytes_vartime failure error to warning (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-03-23 11:47:26 +02:00
commit 16f12f0628
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -36,6 +36,8 @@ using namespace std;
#undef MONERO_DEFAULT_LOG_CATEGORY #undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "ringct" #define MONERO_DEFAULT_LOG_CATEGORY "ringct"
#define CHECK_AND_ASSERT_THROW_MES_L1(expr, message) {if(!(expr)) {MWARNING(message); throw std::runtime_error(message);}}
namespace rct { namespace rct {
//Various key initialization functions //Various key initialization functions
@ -175,7 +177,7 @@ namespace rct {
void scalarmultKey(key & aP, const key &P, const key &a) { void scalarmultKey(key & aP, const key &P, const key &a) {
ge_p3 A; ge_p3 A;
ge_p2 R; ge_p2 R;
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&A, P.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&A, P.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_scalarmult(&R, a.bytes, &A); ge_scalarmult(&R, a.bytes, &A);
ge_tobytes(aP.bytes, &R); ge_tobytes(aP.bytes, &R);
} }
@ -184,7 +186,7 @@ namespace rct {
key scalarmultKey(const key & P, const key & a) { key scalarmultKey(const key & P, const key & a) {
ge_p3 A; ge_p3 A;
ge_p2 R; ge_p2 R;
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&A, P.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&A, P.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_scalarmult(&R, a.bytes, &A); ge_scalarmult(&R, a.bytes, &A);
key aP; key aP;
ge_tobytes(aP.bytes, &R); ge_tobytes(aP.bytes, &R);
@ -196,7 +198,7 @@ namespace rct {
key scalarmultH(const key & a) { key scalarmultH(const key & a) {
ge_p3 A; ge_p3 A;
ge_p2 R; ge_p2 R;
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&A, H.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&A, H.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_scalarmult(&R, a.bytes, &A); ge_scalarmult(&R, a.bytes, &A);
key aP; key aP;
ge_tobytes(aP.bytes, &R); ge_tobytes(aP.bytes, &R);
@ -208,8 +210,8 @@ namespace rct {
//for curve points: AB = A + B //for curve points: AB = A + B
void addKeys(key &AB, const key &A, const key &B) { void addKeys(key &AB, const key &A, const key &B) {
ge_p3 B2, A2; ge_p3 B2, A2;
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&A2, A.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&A2, A.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_cached tmp2; ge_cached tmp2;
ge_p3_to_cached(&tmp2, &B2); ge_p3_to_cached(&tmp2, &B2);
ge_p1p1 tmp3; ge_p1p1 tmp3;
@ -231,7 +233,7 @@ namespace rct {
void addKeys2(key &aGbB, const key &a, const key &b, const key & B) { void addKeys2(key &aGbB, const key &a, const key &b, const key & B) {
ge_p2 rv; ge_p2 rv;
ge_p3 B2; ge_p3 B2;
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_double_scalarmult_base_vartime(&rv, b.bytes, &B2, a.bytes); ge_double_scalarmult_base_vartime(&rv, b.bytes, &B2, a.bytes);
ge_tobytes(aGbB.bytes, &rv); ge_tobytes(aGbB.bytes, &rv);
} }
@ -240,7 +242,7 @@ namespace rct {
// input B a curve point and output a ge_dsmp which has precomputation applied // input B a curve point and output a ge_dsmp which has precomputation applied
void precomp(ge_dsmp rv, const key & B) { void precomp(ge_dsmp rv, const key & B) {
ge_p3 B2; ge_p3 B2;
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_dsm_precomp(rv, &B2); ge_dsm_precomp(rv, &B2);
} }
@ -250,7 +252,7 @@ namespace rct {
void addKeys3(key &aAbB, const key &a, const key &A, const key &b, const ge_dsmp B) { void addKeys3(key &aAbB, const key &a, const key &A, const key &b, const ge_dsmp B) {
ge_p2 rv; ge_p2 rv;
ge_p3 A2; ge_p3 A2;
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&A2, A.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&A2, A.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_double_scalarmult_precomp_vartime(&rv, a.bytes, &A2, b.bytes, B); ge_double_scalarmult_precomp_vartime(&rv, a.bytes, &A2, b.bytes, B);
ge_tobytes(aAbB.bytes, &rv); ge_tobytes(aAbB.bytes, &rv);
} }
@ -260,8 +262,8 @@ namespace rct {
//AB = A - B where A, B are curve points //AB = A - B where A, B are curve points
void subKeys(key & AB, const key &A, const key &B) { void subKeys(key & AB, const key &A, const key &B) {
ge_p3 B2, A2; ge_p3 B2, A2;
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&A2, A.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&A2, A.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_cached tmp2; ge_cached tmp2;
ge_p3_to_cached(&tmp2, &B2); ge_p3_to_cached(&tmp2, &B2);
ge_p1p1 tmp3; ge_p1p1 tmp3;
@ -381,7 +383,7 @@ namespace rct {
ge_p2 point; ge_p2 point;
ge_p3 res; ge_p3 res;
key h = cn_fast_hash(hh); key h = cn_fast_hash(hh);
CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&res, h.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__)); CHECK_AND_ASSERT_THROW_MES_L1(ge_frombytes_vartime(&res, h.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
ge_p3_to_p2(&point, &res); ge_p3_to_p2(&point, &res);
ge_mul8(&point2, &point); ge_mul8(&point2, &point);
ge_p1p1_to_p3(&res, &point2); ge_p1p1_to_p3(&res, &point2);