Skip to content

Commit 2c63d17

Browse files
committed
bppp: align terminology with paper (gamma)
e -> gamma
1 parent dbf2e4d commit 2c63d17

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/modules/bppp/bppp_norm_product_impl.h

+22-22
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static int secp256k1_bppp_rangeproof_norm_product_prove(
267267
secp256k1_scalar mu_sq, rho_inv, c0_l1, c1_l0, x_v, c1_l1, r_v;
268268
secp256k1_gej rj, xj;
269269
secp256k1_ge r_ge, x_ge;
270-
secp256k1_scalar e;
270+
secp256k1_scalar gamma;
271271

272272
secp256k1_scalar_inverse_var(&rho_inv, &rho_f);
273273
secp256k1_scalar_sqr(&mu_sq, &mu_f);
@@ -314,22 +314,22 @@ static int secp256k1_bppp_rangeproof_norm_product_prove(
314314
secp256k1_bppp_serialize_points(&proof[proof_idx], &x_ge, &r_ge);
315315
proof_idx += 65;
316316

317-
/* Obtain challenge e for the the next round */
317+
/* Obtain challenge gamma for the the next round */
318318
secp256k1_sha256_write(transcript, &proof[proof_idx - 65], 65);
319-
secp256k1_bppp_challenge_scalar(&e, transcript, 0);
319+
secp256k1_bppp_challenge_scalar(&gamma, transcript, 0);
320320

321321
if (g_len > 1) {
322322
for (i = 0; i < g_len; i = i + 2) {
323323
secp256k1_scalar nl, nr;
324324
secp256k1_gej gl, gr;
325325
secp256k1_scalar_mul(&nl, &n_vec[i], &rho_inv);
326-
secp256k1_scalar_mul(&nr, &n_vec[i + 1], &e);
326+
secp256k1_scalar_mul(&nr, &n_vec[i + 1], &gamma);
327327
secp256k1_scalar_add(&n_vec[i/2], &nl, &nr);
328328

329329
secp256k1_gej_set_ge(&gl, &g_vec[i]);
330330
secp256k1_ecmult(&gl, &gl, &rho_f, NULL);
331331
secp256k1_gej_set_ge(&gr, &g_vec[i + 1]);
332-
secp256k1_ecmult(&gr, &gr, &e, NULL);
332+
secp256k1_ecmult(&gr, &gr, &gamma, NULL);
333333
secp256k1_gej_add_var(&gl, &gl, &gr, NULL);
334334
secp256k1_ge_set_gej_var(&g_vec[i/2], &gl);
335335
}
@@ -339,14 +339,14 @@ static int secp256k1_bppp_rangeproof_norm_product_prove(
339339
for (i = 0; i < h_len; i = i + 2) {
340340
secp256k1_scalar temp1;
341341
secp256k1_gej grj;
342-
secp256k1_scalar_mul(&temp1, &c_vec[i + 1], &e);
342+
secp256k1_scalar_mul(&temp1, &c_vec[i + 1], &gamma);
343343
secp256k1_scalar_add(&c_vec[i/2], &c_vec[i], &temp1);
344344

345-
secp256k1_scalar_mul(&temp1, &l_vec[i + 1], &e);
345+
secp256k1_scalar_mul(&temp1, &l_vec[i + 1], &gamma);
346346
secp256k1_scalar_add(&l_vec[i/2], &l_vec[i], &temp1);
347347

348348
secp256k1_gej_set_ge(&grj, &g_vec[G_GENS_LEN + i + 1]);
349-
secp256k1_ecmult(&grj, &grj, &e, NULL);
349+
secp256k1_ecmult(&grj, &grj, &gamma, NULL);
350350
secp256k1_gej_add_ge_var(&grj, &grj, &g_vec[G_GENS_LEN + i], NULL);
351351
secp256k1_ge_set_gej_var(&g_vec[G_GENS_LEN + i/2], &grj);
352352
}
@@ -367,7 +367,7 @@ static int secp256k1_bppp_rangeproof_norm_product_prove(
367367
typedef struct ec_mult_verify_cb_data1 {
368368
const unsigned char *proof;
369369
const secp256k1_ge *commit;
370-
const secp256k1_scalar *challenges;
370+
const secp256k1_scalar *gammas;
371371
} ec_mult_verify_cb_data1;
372372

373373
static int ec_mult_verify_cb1(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx, void *cbdata) {
@@ -381,7 +381,7 @@ static int ec_mult_verify_cb1(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx
381381
if (idx % 2 == 0) {
382382
unsigned char pk_buf[33];
383383
idx /= 2;
384-
*sc = data->challenges[idx];
384+
*sc = data->gammas[idx];
385385
pk_buf[0] = 2 | (data->proof[65*idx] >> 1);
386386
memcpy(&pk_buf[1], &data->proof[65*idx + 1], 32);
387387
if (!secp256k1_eckey_pubkey_parse(pt, pk_buf, sizeof(pk_buf))) {
@@ -393,7 +393,7 @@ static int ec_mult_verify_cb1(secp256k1_scalar *sc, secp256k1_ge *pt, size_t idx
393393
idx /= 2;
394394
secp256k1_scalar_set_int(&neg_one, 1);
395395
secp256k1_scalar_negate(&neg_one, &neg_one);
396-
*sc = data->challenges[idx];
396+
*sc = data->gammas[idx];
397397
secp256k1_scalar_sqr(sc, sc);
398398
secp256k1_scalar_add(sc, sc, &neg_one);
399399
pk_buf[0] = 2 | data->proof[65*idx];
@@ -440,7 +440,7 @@ static int secp256k1_bppp_rangeproof_norm_product_verify(
440440
const secp256k1_ge* commit
441441
) {
442442
secp256k1_scalar rho_f, mu_f, v, n, l, rho_inv, h_c;
443-
secp256k1_scalar *es, *s_g, *s_h, *rho_inv_pows;
443+
secp256k1_scalar *gammas, *s_g, *s_h, *rho_inv_pows;
444444
secp256k1_gej res1, res2;
445445
size_t i = 0, scratch_checkpoint;
446446
int overflow;
@@ -469,13 +469,13 @@ static int secp256k1_bppp_rangeproof_norm_product_verify(
469469
if (overflow) return 0;
470470
if (secp256k1_scalar_is_zero(rho)) return 0;
471471

472-
/* Collect the challenges in a new vector */
472+
/* Collect the gammas in a new vector */
473473
scratch_checkpoint = secp256k1_scratch_checkpoint(&ctx->error_callback, scratch);
474-
es = (secp256k1_scalar*)secp256k1_scratch_alloc(&ctx->error_callback, scratch, n_rounds * sizeof(secp256k1_scalar));
474+
gammas = (secp256k1_scalar*)secp256k1_scratch_alloc(&ctx->error_callback, scratch, n_rounds * sizeof(secp256k1_scalar));
475475
s_g = (secp256k1_scalar*)secp256k1_scratch_alloc(&ctx->error_callback, scratch, g_len * sizeof(secp256k1_scalar));
476476
s_h = (secp256k1_scalar*)secp256k1_scratch_alloc(&ctx->error_callback, scratch, h_len * sizeof(secp256k1_scalar));
477477
rho_inv_pows = (secp256k1_scalar*)secp256k1_scratch_alloc(&ctx->error_callback, scratch, log_g_len * sizeof(secp256k1_scalar));
478-
if (es == NULL || s_g == NULL || s_h == NULL || rho_inv_pows == NULL) {
478+
if (gammas == NULL || s_g == NULL || s_h == NULL || rho_inv_pows == NULL) {
479479
secp256k1_scratch_apply_checkpoint(&ctx->error_callback, scratch, scratch_checkpoint);
480480
return 0;
481481
}
@@ -491,10 +491,10 @@ static int secp256k1_bppp_rangeproof_norm_product_verify(
491491
}
492492

493493
for (i = 0; i < n_rounds; i++) {
494-
secp256k1_scalar e;
494+
secp256k1_scalar gamma;
495495
secp256k1_sha256_write(transcript, &proof[i * 65], 65);
496-
secp256k1_bppp_challenge_scalar(&e, transcript, 0);
497-
es[i] = e;
496+
secp256k1_bppp_challenge_scalar(&gamma, transcript, 0);
497+
gammas[i] = gamma;
498498
}
499499
/* s_g[0] = n * \prod_{j=0}^{log_g_len - 1} rho^(2^j)
500500
* = n * rho^(2^log_g_len - 1)
@@ -504,19 +504,19 @@ static int secp256k1_bppp_rangeproof_norm_product_verify(
504504
for (i = 1; i < g_len; i++) {
505505
size_t log_i = secp256k1_bppp_log2(i);
506506
size_t nearest_pow_of_two = (size_t)1 << log_i;
507-
/* This combines the two multiplications of challenges and rho_invs in a
507+
/* This combines the two multiplications of gammas and rho_invs in a
508508
* single loop.
509509
* s_g[i] = s_g[i - nearest_pow_of_two]
510510
* * e[log_i] * rho_inv^(2^log_i) */
511-
secp256k1_scalar_mul(&s_g[i], &s_g[i - nearest_pow_of_two], &es[log_i]);
511+
secp256k1_scalar_mul(&s_g[i], &s_g[i - nearest_pow_of_two], &gammas[log_i]);
512512
secp256k1_scalar_mul(&s_g[i], &s_g[i], &rho_inv_pows[log_i]);
513513
}
514514
s_h[0] = l;
515515
secp256k1_scalar_set_int(&h_c, 0);
516516
for (i = 1; i < h_len; i++) {
517517
size_t log_i = secp256k1_bppp_log2(i);
518518
size_t nearest_pow_of_two = (size_t)1 << log_i;
519-
secp256k1_scalar_mul(&s_h[i], &s_h[i - nearest_pow_of_two], &es[log_i]);
519+
secp256k1_scalar_mul(&s_h[i], &s_h[i - nearest_pow_of_two], &gammas[log_i]);
520520
}
521521
secp256k1_scalar_inner_product(&h_c, c_vec, 0 /* a_offset */ , s_h, 0 /* b_offset */, 1 /* step */, h_len);
522522
/* Compute v = n*n*mu_f + l*h_c where mu_f = rho_f^2 */
@@ -529,7 +529,7 @@ static int secp256k1_bppp_rangeproof_norm_product_verify(
529529
ec_mult_verify_cb_data1 data;
530530
data.proof = proof;
531531
data.commit = commit;
532-
data.challenges = es;
532+
data.gammas = gammas;
533533

534534
if (!secp256k1_ecmult_multi_var(&ctx->error_callback, scratch, &res1, NULL, ec_mult_verify_cb1, &data, 2*n_rounds + 1)) {
535535
secp256k1_scratch_apply_checkpoint(&ctx->error_callback, scratch, scratch_checkpoint);

0 commit comments

Comments
 (0)