File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ static int secp256k1_rangeproof_header_set_for_value(
113
113
secp256k1_rangeproof_header * header ,
114
114
uint64_t * proven_value ,
115
115
const uint64_t min_value ,
116
- const uint64_t min_bits ,
116
+ uint64_t min_bits ,
117
117
const int exp ,
118
118
const uint64_t value
119
119
) {
@@ -149,9 +149,17 @@ static int secp256k1_rangeproof_header_set_for_value(
149
149
*/
150
150
header -> exp = 0 ;
151
151
}
152
+ /* Reduce min_bits to keep within a uint64_t's range (essentially copied from 2015 code) */
153
+ {
154
+ const unsigned int max_bits = min_value ? secp256k1_clz64_var (min_value ) : 64 ;
155
+ if (min_bits > max_bits ) {
156
+ header -> mantissa = max_bits ;
157
+ min_bits = max_bits ;
158
+ }
159
+ }
152
160
{
153
161
/* If the user has asked for more bits of proof then there is room for in the exponent, reduce the exponent. */
154
- uint64_t max = min_bits ? (UINT64_MAX >> (64 - min_bits )) : 0 ;
162
+ uint64_t max = min_bits ? (UINT64_MAX >> (64 - header -> mantissa )) : 0 ;
155
163
int i ;
156
164
for (i = 0 ; i < header -> exp && max <= UINT64_MAX / 10 ; i ++ ) {
157
165
max *= 10 ;
You can’t perform that action at this time.
0 commit comments