88#define _SECP256K1_MODULE_BPP_RANGEPROOF_IMPL_
99
1010
11- #include "group.h"
12- #include "scalar.h"
13- #include "secp256k1.h"
14- #include "ecmult_const.h"
15- #include "field.h"
16- #include "include/secp256k1_bppp.h"
11+ #include "../../ group.h"
12+ #include "../../ scalar.h"
13+ #include "../../../include/ secp256k1.h"
14+ #include "../../ ecmult_const.h"
15+ #include "../../ field.h"
16+ #include "../../../ include/secp256k1_bppp.h"
1717
18- #include "modules /bppp/bppp_util.h"
19- #include "modules /bppp/bppp_transcript_impl.h"
20- #include "modules /bppp/bppp_norm_product_impl.h"
18+ #include ".. /bppp/bppp_util.h"
19+ #include ".. /bppp/bppp_transcript_impl.h"
20+ #include ".. /bppp/bppp_norm_product_impl.h"
2121
2222struct secp256k1_bppp_rangeproof_prover_context {
2323
@@ -72,7 +72,6 @@ static void secp256k1_bppp_rangeproof_prove_round1_impl(
7272) {
7373 size_t log_base = secp256k1_bppp_log2 (digit_base );
7474 size_t i , j ;
75- size_t log_num_digits = secp256k1_bppp_log2 (num_digits );
7675 size_t g_offset = digit_base > num_digits ? digit_base : num_digits ;
7776 secp256k1_gej d_commj , m_commj ;
7877 uint16_t multiplicities [64 ]; /* SECP256K1_BPP_MAX_BASE = 64. TODO: Check this in high level API */
@@ -91,7 +90,7 @@ static void secp256k1_bppp_rangeproof_prove_round1_impl(
9190 }
9291
9392 /* Commit to the vector d in gens */
94- secp256k1_ecmult_const (& d_commj , asset_genp , & prover_ctx -> r_d_0 , 256 );
93+ secp256k1_ecmult_const (& d_commj , asset_genp , & prover_ctx -> r_d_0 );
9594
9695 for (i = 0 ; i < num_digits ; i ++ ) {
9796 secp256k1_gej resj ;
@@ -103,7 +102,7 @@ static void secp256k1_bppp_rangeproof_prove_round1_impl(
103102 multiplicities [j ] += (j == digit );
104103 }
105104 secp256k1_scalar_set_int (& prover_ctx -> d [i ], digit );
106- secp256k1_ecmult_const (& resj , & gens -> gens [i ], & prover_ctx -> d [i ], log_base + 1 ); /* (I think ) there should there be +1 here? */
105+ secp256k1_ecmult_const (& resj , & gens -> gens [i ], & prover_ctx -> d [i ]); /* should be = log_base + 1 bits here */
107106 secp256k1_ge_set_gej (& d_comm , & d_commj );
108107 secp256k1_gej_add_ge (& d_commj , & resj , & d_comm ); /* d_comm cannot be zero */
109108 }
@@ -119,29 +118,29 @@ static void secp256k1_bppp_rangeproof_prove_round1_impl(
119118
120119 secp256k1_scalar_clear (& prover_ctx -> r_m_1_vec [3 ]); /* r_m_1_vec[3] = 0 */
121120 secp256k1_scalar_clear (& prover_ctx -> r_m_1_vec [6 ]); /* r_m_1_vec[6] = 0 */
122- secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + 2 ], & prover_ctx -> r_d_1_vec_2 , 256 );
121+ secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + 2 ], & prover_ctx -> r_d_1_vec_2 );
123122 secp256k1_ge_set_gej (& d_comm , & d_commj );
124123 secp256k1_gej_add_ge (& d_commj , & resj , & d_comm );
125- secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + 5 ], & prover_ctx -> r_d_1_vec_5 , 256 );
124+ secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + 5 ], & prover_ctx -> r_d_1_vec_5 );
126125 secp256k1_ge_set_gej (& d_comm , & d_commj );
127126 secp256k1_gej_add_ge (& d_commj , & resj , & d_comm );
128127 }
129128
130129 /* Compute the m vector as multiplicity of each digit */
131- secp256k1_ecmult_const (& m_commj , asset_genp , & prover_ctx -> r_m_0 , 256 );
130+ secp256k1_ecmult_const (& m_commj , asset_genp , & prover_ctx -> r_m_0 );
132131 for (i = 0 ; i < digit_base ; i ++ ) {
133132 secp256k1_gej resj ;
134133 secp256k1_ge m_comm ;
135134 secp256k1_scalar_set_int (& prover_ctx -> m [i ], multiplicities [i ]);
136- secp256k1_ecmult_const (& resj , & gens -> gens [i ], & prover_ctx -> m [i ], log_num_digits + 1 ); /* (I think ) there should there be +1 here? */
135+ secp256k1_ecmult_const (& resj , & gens -> gens [i ], & prover_ctx -> m [i ]); /* , log_num_digits + 1 (I think ) there should there be +1 here? */
137136 secp256k1_ge_set_gej (& m_comm , & m_commj );
138137 secp256k1_gej_add_ge (& m_commj , & resj , & m_comm ); /* m_comm cannot be zero*/
139138 }
140139
141140 for (i = 0 ; i < 8 ; i ++ ) {
142141 secp256k1_gej resj ;
143142 secp256k1_ge m_comm ;
144- secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + i ], & prover_ctx -> r_m_1_vec [i ], 256 );
143+ secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + i ], & prover_ctx -> r_m_1_vec [i ]);
145144 secp256k1_ge_set_gej (& m_comm , & m_commj );
146145 secp256k1_gej_add_ge (& m_commj , & resj , & m_comm ); /* m_comm cannot be zero */
147146 }
@@ -191,13 +190,13 @@ static void secp256k1_bppp_rangeproof_prove_round2_impl(
191190 secp256k1_scalar_chacha20 (& prover_ctx -> r_r_0 , & prover_ctx -> r_r_0 , nonce , 5 );
192191
193192 /* Commit to the vector d in gens */
194- secp256k1_ecmult_const (& r_commj , asset_genp , & prover_ctx -> r_r_0 , 256 );
193+ secp256k1_ecmult_const (& r_commj , asset_genp , & prover_ctx -> r_r_0 );
195194 for (i = 0 ; i < num_digits ; i ++ ) {
196195 secp256k1_gej resj ;
197196 secp256k1_ge r_comm ;
198197 secp256k1_scalar_add (& prover_ctx -> r [i ], & prover_ctx -> d [i ], & prover_ctx -> alpha );
199198 secp256k1_scalar_inverse (& prover_ctx -> r [i ], & prover_ctx -> r [i ]); /* r_i cannot be zero as it added by random value `alpha`*/
200- secp256k1_ecmult_const (& resj , & gens -> gens [i ], & prover_ctx -> r [i ], 256 );
199+ secp256k1_ecmult_const (& resj , & gens -> gens [i ], & prover_ctx -> r [i ]);
201200 secp256k1_ge_set_gej (& r_comm , & r_commj );
202201 secp256k1_gej_add_ge (& r_commj , & resj , & r_comm ); /* r_comm cannot be zero */
203202 }
@@ -211,12 +210,12 @@ static void secp256k1_bppp_rangeproof_prove_round2_impl(
211210 secp256k1_scalar tmp ;
212211
213212 secp256k1_scalar_negate (& tmp , & prover_ctx -> r_d_1_vec_2 );
214- secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + 1 ], & tmp , 256 );
213+ secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + 1 ], & tmp );
215214 secp256k1_ge_set_gej (& r_comm , & r_commj );
216215 secp256k1_gej_add_ge (& r_commj , & resj , & r_comm );
217216
218217 secp256k1_scalar_negate (& tmp , & prover_ctx -> r_d_1_vec_5 );
219- secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + 4 ], & tmp , 256 );
218+ secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + 4 ], & tmp );
220219 secp256k1_ge_set_gej (& r_comm , & r_commj );
221220 secp256k1_gej_add_ge (& r_commj , & resj , & r_comm );
222221 }
@@ -457,19 +456,19 @@ static void secp256k1_bppp_rangeproof_prove_round3_impl(
457456 secp256k1_scalar_negate (& prover_ctx -> r_s_1_vec [6 ], & w_w_q [TPOW (6 )]); /* T^7 */
458457 }
459458 /* Commit to the vector s in gens, with r_s_0 along asset and l in H_vec */
460- secp256k1_ecmult_const (& s_commj , asset_genp , & prover_ctx -> r_s_0 , 256 );
459+ secp256k1_ecmult_const (& s_commj , asset_genp , & prover_ctx -> r_s_0 );
461460 for (i = 0 ; i < g_offset ; i ++ ) {
462461 secp256k1_gej resj ;
463462 secp256k1_ge s_comm ;
464- secp256k1_ecmult_const (& resj , & gens -> gens [i ], & prover_ctx -> s [i ], 256 );
463+ secp256k1_ecmult_const (& resj , & gens -> gens [i ], & prover_ctx -> s [i ]);
465464 secp256k1_ge_set_gej (& s_comm , & s_commj );
466465 secp256k1_gej_add_ge (& s_commj , & resj , & s_comm ); /* s_comm cannot be 0 */
467466 }
468467
469468 for (i = 0 ; i < 7 ; i ++ ) {
470469 secp256k1_gej resj ;
471470 secp256k1_ge s_comm ;
472- secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + i ], & prover_ctx -> r_s_1_vec [i ], 256 );
471+ secp256k1_ecmult_const (& resj , & gens -> gens [g_offset + i ], & prover_ctx -> r_s_1_vec [i ]);
473472 secp256k1_ge_set_gej (& s_comm , & s_commj );
474473 secp256k1_gej_add_ge (& s_commj , & resj , & s_comm ); /* s_comm cannot be 0 */
475474 }
@@ -614,14 +613,14 @@ static int secp256k1_bppp_rangeproof_prove_impl(
614613 const secp256k1_context * ctx ,
615614 secp256k1_scratch_space * scratch ,
616615 const secp256k1_bppp_generators * gens ,
617- const secp256k1_ge * asset_genp ,
616+ secp256k1_ge * asset_genp ,
618617 unsigned char * proof ,
619618 size_t * proof_len ,
620619 const size_t n_bits ,
621620 const size_t digit_base ,
622621 const uint64_t value ,
623622 const uint64_t min_value ,
624- const secp256k1_ge * commitp ,
623+ secp256k1_ge * commitp ,
625624 const secp256k1_scalar * gamma ,
626625 const unsigned char * nonce ,
627626 const unsigned char * extra_commit ,
@@ -817,13 +816,13 @@ static int secp256k1_bppp_rangeproof_verify_impl(
817816 const secp256k1_context * ctx ,
818817 secp256k1_scratch_space * scratch ,
819818 const secp256k1_bppp_generators * gens ,
820- const secp256k1_ge * asset_genp ,
819+ secp256k1_ge * asset_genp ,
821820 const unsigned char * proof ,
822821 const size_t proof_len ,
823822 const size_t n_bits ,
824823 const size_t digit_base ,
825824 const uint64_t min_value ,
826- const secp256k1_ge * commitp ,
825+ secp256k1_ge * commitp ,
827826 const unsigned char * extra_commit ,
828827 size_t extra_commit_len
829828) {
0 commit comments