From d43993724deb5fdc1d2162f7423f8e8398103dd5 Mon Sep 17 00:00:00 2001 From: siv2r Date: Sat, 2 Oct 2021 15:52:05 +0530 Subject: [PATCH] tests: remove `secp256k1_fe_verify` from tests.c and modify `secp256k1_fe_from_storage` to call `secp256k1_fe_verify` 1. secp256k1_fe_verify is removed from tests since, it throws an error if VERIFY is not defined during compilation. (Ex: ./configure --enable-coverage) 2. `secp256k1_fe_from_storage` calls `secp256k1_fe_verify` in the VERIFY build to check for invalid field element. --- src/field_10x26_impl.h | 1 + src/field_5x52_impl.h | 1 + src/tests.c | 4 ---- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/field_10x26_impl.h b/src/field_10x26_impl.h index 7a38c11..7244749 100644 --- a/src/field_10x26_impl.h +++ b/src/field_10x26_impl.h @@ -1162,6 +1162,7 @@ static SECP256K1_INLINE void secp256k1_fe_from_storage(secp256k1_fe *r, const se #ifdef VERIFY r->magnitude = 1; r->normalized = 1; + secp256k1_fe_verify(r); #endif } diff --git a/src/field_5x52_impl.h b/src/field_5x52_impl.h index 60ded92..ed52297 100644 --- a/src/field_5x52_impl.h +++ b/src/field_5x52_impl.h @@ -496,6 +496,7 @@ static SECP256K1_INLINE void secp256k1_fe_from_storage(secp256k1_fe *r, const se #ifdef VERIFY r->magnitude = 1; r->normalized = 1; + secp256k1_fe_verify(r); #endif } diff --git a/src/tests.c b/src/tests.c index 8dc4a32..a7c37ed 100644 --- a/src/tests.c +++ b/src/tests.c @@ -3435,8 +3435,6 @@ void test_pre_g_table(const secp256k1_ge_storage * pre_g, size_t n) { CHECK(0 < n); secp256k1_ge_from_storage(&p, &pre_g[0]); - secp256k1_fe_verify(&p.x); - secp256k1_fe_verify(&p.y); CHECK(secp256k1_ge_is_valid_var(&p)); secp256k1_gej_set_ge(&g2, &p); @@ -3449,8 +3447,6 @@ void test_pre_g_table(const secp256k1_ge_storage * pre_g, size_t n) { CHECK(!secp256k1_fe_normalizes_to_zero_var(&dpx) || !secp256k1_fe_normalizes_to_zero_var(&dpy)); secp256k1_ge_from_storage(&q, &pre_g[i]); - secp256k1_fe_verify(&q.x); - secp256k1_fe_verify(&q.y); CHECK(secp256k1_ge_is_valid_var(&q)); secp256k1_fe_negate(&dqx, &q.x, 1); secp256k1_fe_add(&dqx, &gg.x); secp256k1_fe_normalize_weak(&dqx);