Make sure that bppp_log2 isn't called with value 0
Author: Jonas Nick <jonasd.nick@gmail.com> Date: Thu Feb 9 21:31:43 2023 +0000
This commit is contained in:
@@ -45,9 +45,10 @@ static int secp256k1_is_power_of_two(size_t n) {
|
||||
return n > 0 && (n & (n - 1)) == 0;
|
||||
}
|
||||
|
||||
/* Compute the log2 of n. If n is not a power of two, it returns the largest
|
||||
* `k` such that 2^k <= n. Assumes n < 2^64. In Bulletproofs, this is bounded
|
||||
* by len of input vectors which can be safely assumed to be less than 2^64.
|
||||
/* Compute the log2 of n. n must NOT be 0. If n is not a power of two, it
|
||||
* returns the largest `k` such that 2^k <= n. Assumes 0 < n < 2^64. In
|
||||
* Bulletproofs, this is bounded by len of input vectors which can be safely
|
||||
* assumed to be less than 2^64.
|
||||
*/
|
||||
static size_t secp256k1_bppp_log2(size_t n) {
|
||||
return 64 - 1 - secp256k1_clz64_var((uint64_t)n);
|
||||
|
||||
Reference in New Issue
Block a user