From 94e7f0585cc2993a3395af0ff3198e46d7448fde Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sat, 13 Aug 2022 15:16:47 +0000 Subject: [PATCH] rangeproof: rename create_value and verify_value to create_exact and verify_exact --- include/secp256k1_rangeproof.h | 6 ++-- src/modules/rangeproof/main_impl.h | 4 +-- src/modules/rangeproof/tests_impl.h | 44 ++++++++++++++--------------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/secp256k1_rangeproof.h b/include/secp256k1_rangeproof.h index 9f8112590..aaf233446 100644 --- a/include/secp256k1_rangeproof.h +++ b/include/secp256k1_rangeproof.h @@ -288,7 +288,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_rangeproof_info( ) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5); /** Verify a rangeproof with a single-value range. Useful as a "proof of value" - * of a Pedersen commitment. Such proofs can be created with `secp256k1_rangeproof_create_value`, + * of a Pedersen commitment. Such proofs can be created with `secp256k1_rangeproof_create_exact`, * or with `secp256k1_rangeproof_sign` by passing an `exp` parameter of -1 and the * target value as both `value` and `min_value`. (In this case `min_bits` is ignored * and may take any value, but for clarity it's best to pass zero.) @@ -301,7 +301,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_rangeproof_info( * commit: the Pedersen commitment whose value is being verified * gen: additional generator 'h' */ -SECP256K1_API int secp256k1_rangeproof_verify_value( +SECP256K1_API int secp256k1_rangeproof_verify_exact( const secp256k1_context* ctx, const unsigned char* proof, size_t plen, @@ -322,7 +322,7 @@ SECP256K1_API int secp256k1_rangeproof_verify_value( * commit: the Pedersen commitment whose value is being proven * gen: additional generator 'h' */ -SECP256K1_API int secp256k1_rangeproof_create_value( +SECP256K1_API int secp256k1_rangeproof_create_exact( const secp256k1_context* ctx, unsigned char* proof, size_t* plen, diff --git a/src/modules/rangeproof/main_impl.h b/src/modules/rangeproof/main_impl.h index fb3aff28a..5300c3d17 100644 --- a/src/modules/rangeproof/main_impl.h +++ b/src/modules/rangeproof/main_impl.h @@ -304,7 +304,7 @@ int secp256k1_rangeproof_sign(const secp256k1_context* ctx, unsigned char *proof proof, plen, min_value, &commitp, blind, nonce, exp, min_bits, value, message, msg_len, extra_commit, extra_commit_len, &genp); } -int secp256k1_rangeproof_verify_value(const secp256k1_context* ctx, const unsigned char* proof, size_t plen, uint64_t value, const secp256k1_pedersen_commitment* commit, const secp256k1_generator* gen) { +int secp256k1_rangeproof_verify_exact(const secp256k1_context* ctx, const unsigned char* proof, size_t plen, uint64_t value, const secp256k1_pedersen_commitment* commit, const secp256k1_generator* gen) { secp256k1_ge commitp; secp256k1_ge genp; secp256k1_gej tmpj; @@ -397,7 +397,7 @@ int secp256k1_rangeproof_verify_value(const secp256k1_context* ctx, const unsign return !secp256k1_memcmp_var(tmpch, &proof[offset], 32); } -int secp256k1_rangeproof_create_value(const secp256k1_context* ctx, unsigned char* proof, size_t* plen, uint64_t value, const unsigned char* blind, const secp256k1_pedersen_commitment* commit, const secp256k1_generator* gen) { +int secp256k1_rangeproof_create_exact(const secp256k1_context* ctx, unsigned char* proof, size_t* plen, uint64_t value, const unsigned char* blind, const secp256k1_pedersen_commitment* commit, const secp256k1_generator* gen) { secp256k1_ge commitp; secp256k1_ge genp; secp256k1_gej tmpj; diff --git a/src/modules/rangeproof/tests_impl.h b/src/modules/rangeproof/tests_impl.h index 79c3a6d39..3a0b1cb9b 100644 --- a/src/modules/rangeproof/tests_impl.h +++ b/src/modules/rangeproof/tests_impl.h @@ -229,43 +229,43 @@ static void test_rangeproof_api(const secp256k1_context *none, const secp256k1_c { *ecount = 0; len = sizeof(proof); - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, val, blind, &commit, secp256k1_generator_h) == 1); - CHECK(secp256k1_rangeproof_create_value(none, NULL, &len, val, blind, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, val, blind, &commit, secp256k1_generator_h) == 1); + CHECK(secp256k1_rangeproof_create_exact(none, NULL, &len, val, blind, &commit, secp256k1_generator_h) == 0); CHECK(*ecount == 1); - CHECK(secp256k1_rangeproof_create_value(none, proof, NULL, val, blind, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, NULL, val, blind, &commit, secp256k1_generator_h) == 0); CHECK(*ecount == 2); - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, val, NULL, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, val, NULL, &commit, secp256k1_generator_h) == 0); CHECK(*ecount == 3); - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, val, blind, NULL, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, val, blind, NULL, secp256k1_generator_h) == 0); CHECK(*ecount == 4); - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, val, blind, &commit, NULL) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, val, blind, &commit, NULL) == 0); CHECK(*ecount == 5); len = 0; - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, 0, blind, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, 0, blind, &commit, secp256k1_generator_h) == 0); len = 64; - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, 0, blind, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, 0, blind, &commit, secp256k1_generator_h) == 0); len = 65; - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, 0, blind, &commit, secp256k1_generator_h) == 1); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, 0, blind, &commit, secp256k1_generator_h) == 1); len = 65; - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, 1, blind, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, 1, blind, &commit, secp256k1_generator_h) == 0); len = 72; - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, 1, blind, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, 1, blind, &commit, secp256k1_generator_h) == 0); len = 73; - CHECK(secp256k1_rangeproof_create_value(none, proof, &len, val, blind, &commit, secp256k1_generator_h) == 1); + CHECK(secp256k1_rangeproof_create_exact(none, proof, &len, val, blind, &commit, secp256k1_generator_h) == 1); CHECK(*ecount == 5); *ecount = 0; - CHECK(secp256k1_rangeproof_verify_value(none, proof, len, val, &commit, secp256k1_generator_h) == 1); + CHECK(secp256k1_rangeproof_verify_exact(none, proof, len, val, &commit, secp256k1_generator_h) == 1); CHECK(*ecount == 0); - CHECK(secp256k1_rangeproof_verify_value(none, NULL, len, val, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_verify_exact(none, NULL, len, val, &commit, secp256k1_generator_h) == 0); CHECK(*ecount == 1); - CHECK(secp256k1_rangeproof_verify_value(none, proof, len, val, NULL, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_verify_exact(none, proof, len, val, NULL, secp256k1_generator_h) == 0); CHECK(*ecount == 2); - CHECK(secp256k1_rangeproof_verify_value(none, proof, len, val, &commit, NULL) == 0); + CHECK(secp256k1_rangeproof_verify_exact(none, proof, len, val, &commit, NULL) == 0); CHECK(*ecount == 3); - CHECK(secp256k1_rangeproof_verify_value(none, proof, 0, val, &commit, secp256k1_generator_h) == 0); - CHECK(secp256k1_rangeproof_verify_value(none, proof, len - 1, val, &commit, secp256k1_generator_h) == 0); - CHECK(secp256k1_rangeproof_verify_value(none, proof, len, val ^ 1, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_verify_exact(none, proof, 0, val, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_verify_exact(none, proof, len - 1, val, &commit, secp256k1_generator_h) == 0); + CHECK(secp256k1_rangeproof_verify_exact(none, proof, len, val ^ 1, &commit, secp256k1_generator_h) == 0); CHECK(*ecount == 3); } } @@ -680,7 +680,7 @@ static void test_single_value_proof(uint64_t val) { plen = sizeof(proof); } if (using_exact_value) { - CHECK(secp256k1_rangeproof_create_value(ctx, proof, &plen, val, blind, &commit, secp256k1_generator_h) == 1); + CHECK(secp256k1_rangeproof_create_exact(ctx, proof, &plen, val, blind, &commit, secp256k1_generator_h) == 1); } else { CHECK(secp256k1_rangeproof_sign( ctx, @@ -739,7 +739,7 @@ static void test_single_value_proof(uint64_t val) { CHECK(message_out[m_len_out] == 0); } } - CHECK(secp256k1_rangeproof_verify_value(ctx, proof, plen, val, &commit, secp256k1_generator_h)); + CHECK(secp256k1_rangeproof_verify_exact(ctx, proof, plen, val, &commit, secp256k1_generator_h)); } #define MAX_N_GENS 30 @@ -1028,7 +1028,7 @@ void test_rangeproof_fixed_vectors(void) { CHECK(max_value == UINT64_MAX); CHECK(m_len == 0); - CHECK(secp256k1_rangeproof_verify_value(ctx, vector_3, sizeof(vector_3), UINT64_MAX, &pc, secp256k1_generator_h)); + CHECK(secp256k1_rangeproof_verify_exact(ctx, vector_3, sizeof(vector_3), UINT64_MAX, &pc, secp256k1_generator_h)); } }