Skip to content

Commit 8822988

Browse files
committed
commitment and bulletproof: fix a bunch of typos and stuff (thanks Tim Ruffing)
1 parent df8e037 commit 8822988

File tree

3 files changed

+23
-26
lines changed

3 files changed

+23
-26
lines changed

include/secp256k1_bulletproofs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ typedef struct secp256k1_bulletproof_generators secp256k1_bulletproof_generators
1616
#define SECP256K1_BULLETPROOF_CIRCUIT_VERSION 1
1717

1818
/* Maximum depth of 31 lets us validate an aggregate of 2^25 64-bit proofs */
19-
#define SECP256K1_BULLETPROOF_MAX_DEPTH 60
19+
#define SECP256K1_BULLETPROOF_MAX_DEPTH 31
2020

2121
/* Size of a hypothetical 31-depth rangeproof, in bytes */
22-
#define SECP256K1_BULLETPROOF_MAX_PROOF (160 + 66*32 + 7)
22+
#define SECP256K1_BULLETPROOF_MAX_PROOF (160 + 36*32 + 7)
2323

2424
/* Maximum memory, in bytes, that may be allocated to store a circuit representation */
2525
#define SECP256K1_BULLETPROOF_MAX_CIRCUIT (1024 * 1024 * 1024)

include/secp256k1_commitment.h

+14-17
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ extern "C" {
1717
* however guaranteed to be 33 bytes in size, and can be safely copied/moved.
1818
* If you need to convert to a format suitable for storage or transmission, use
1919
* secp256k1_pedersen_commitment_serialize and secp256k1_pedersen_commitment_parse.
20-
*
21-
* Furthermore, it is guaranteed to identical signatures will have identical
22-
* representation, so they can be memcmp'ed.
2320
*/
2421
typedef struct {
2522
unsigned char data[33];
@@ -55,7 +52,7 @@ SECP256K1_API int secp256k1_pedersen_commitment_serialize(
5552
/** Initialize a context for usage with Pedersen commitments. */
5653
void secp256k1_pedersen_context_initialize(secp256k1_context* ctx);
5754

58-
/** Generate a pedersen commitment.
55+
/** Generate a Pedersen commitment.
5956
* Returns 1: Commitment successfully created.
6057
* 0: Error. The blinding factor is larger than the group order
6158
* (probability for random 32 byte number < 2^-127) or results in the
@@ -86,7 +83,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_pedersen_commit(
8683
* In: ctx: pointer to a context object (cannot be NULL)
8784
* blinds: pointer to pointers to 32-byte character arrays for blinding factors. (cannot be NULL)
8885
* n: number of factors pointed to by blinds.
89-
* npositive: how many of the initial factors should be treated with a positive sign.
86+
* npositive: how many of the input factors should be treated with a positive sign.
9087
* Out: blind_out: pointer to a 32-byte array for the sum (cannot be NULL)
9188
*/
9289
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_pedersen_blind_sum(
@@ -97,28 +94,28 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_pedersen_blind_sum(
9794
size_t npositive
9895
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
9996

100-
/** Verify a tally of pedersen commitments
97+
/** Verify a tally of Pedersen commitments
10198
* Returns 1: commitments successfully sum to zero.
10299
* 0: Commitments do not sum to zero or other error.
103-
* In: ctx: pointer to a context object (cannot be NULL)
104-
* commits: pointer to array of pointers to the commitments. (cannot be NULL if pcnt is non-zero)
105-
* pcnt: number of commitments pointed to by commits.
106-
* ncommits: pointer to array of pointers to the negative commitments. (cannot be NULL if ncnt is non-zero)
107-
* ncnt: number of commitments pointed to by ncommits.
100+
* In: ctx: pointer to a context object (cannot be NULL)
101+
* pos: pointer to array of pointers to the commitments. (cannot be NULL if `n_pos` is non-zero)
102+
* n_pos: number of commitments pointed to by `pos`.
103+
* neg: pointer to array of pointers to the negative commitments. (cannot be NULL if `n_neg` is non-zero)
104+
* n_neg: number of commitments pointed to by `neg`.
108105
*
109-
* This computes sum(commit[0..pcnt)) - sum(ncommit[0..ncnt)) == 0.
106+
* This computes sum(pos[0..n_pos)) - sum(neg[0..n_neg)) == 0.
110107
*
111-
* A pedersen commitment is xG + vA where G and A are generators for the secp256k1 group and x is a blinding factor,
108+
* A Pedersen commitment is xG + vA where G and A are generators for the secp256k1 group and x is a blinding factor,
112109
* while v is the committed value. For a collection of commitments to sum to zero, for each distinct generator
113110
* A all blinding factors and all values must sum to zero.
114111
*
115112
*/
116113
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_pedersen_verify_tally(
117114
const secp256k1_context* ctx,
118-
const secp256k1_pedersen_commitment * const* commits,
119-
size_t pcnt,
120-
const secp256k1_pedersen_commitment * const* ncommits,
121-
size_t ncnt
115+
const secp256k1_pedersen_commitment * const* pos,
116+
size_t n_pos,
117+
const secp256k1_pedersen_commitment * const* neg,
118+
size_t n_neg
122119
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(4);
123120

124121
/** Sets the final Pedersen blinding factor correctly when the generators themselves

src/modules/commitment/main_impl.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,22 @@ int secp256k1_pedersen_blind_sum(const secp256k1_context* ctx, unsigned char *bl
108108
}
109109

110110
/* Takes two lists of commitments and sums the first set and subtracts the second and verifies that they sum to excess. */
111-
int secp256k1_pedersen_verify_tally(const secp256k1_context* ctx, const secp256k1_pedersen_commitment * const* commits, size_t pcnt, const secp256k1_pedersen_commitment * const* ncommits, size_t ncnt) {
111+
int secp256k1_pedersen_verify_tally(const secp256k1_context* ctx, const secp256k1_pedersen_commitment * const* pos, size_t n_pos, const secp256k1_pedersen_commitment * const* neg, size_t n_neg) {
112112
secp256k1_gej accj;
113113
secp256k1_ge add;
114114
size_t i;
115115
VERIFY_CHECK(ctx != NULL);
116-
ARG_CHECK(!pcnt || (commits != NULL));
117-
ARG_CHECK(!ncnt || (ncommits != NULL));
116+
ARG_CHECK(!n_pos || (pos != NULL));
117+
ARG_CHECK(!n_neg || (neg != NULL));
118118
(void) ctx;
119119
secp256k1_gej_set_infinity(&accj);
120-
for (i = 0; i < ncnt; i++) {
121-
secp256k1_pedersen_commitment_load(&add, ncommits[i]);
120+
for (i = 0; i < n_pos; i++) {
121+
secp256k1_pedersen_commitment_load(&add, neg[i]);
122122
secp256k1_gej_add_ge_var(&accj, &accj, &add, NULL);
123123
}
124124
secp256k1_gej_neg(&accj, &accj);
125-
for (i = 0; i < pcnt; i++) {
126-
secp256k1_pedersen_commitment_load(&add, commits[i]);
125+
for (i = 0; i < n_neg; i++) {
126+
secp256k1_pedersen_commitment_load(&add, pos[i]);
127127
secp256k1_gej_add_ge_var(&accj, &accj, &add, NULL);
128128
}
129129
return secp256k1_gej_is_infinity(&accj);

0 commit comments

Comments
 (0)