1package plonky2_verifier
2
3import (
4 "fmt"
5 "math/bits"
6)
7
8// Computes `log_2(n)`, panicking if `n` is not a power of two.
9func log2Strict(n uint) int {
10 res := bits.TrailingZeros(n)
11 if n>>res != 1 {
12 panic(fmt.Sprintf("Not a power of two: %d", n))
13 }
14 return res
15}