consensus-specs
consensus-specs copied to clipboard
`reverse_bits_limited` helper for `polynomial-commitments-sampling.md`
There's potential for a new helper function, which doesn't add much complexity, that could improve efficiency in a few spots, like here. Something like the following method might be a useful addition. Rather than BRP the list of roots, you can just compute the index/indices that you need.
def reverse_bits_limited(num_bits: int, value: int):
reversed_bits = 0
for _ in range(32): # 32-bit value
reversed_bits = (reversed_bits << 1) | (value & 1)
value >>= 1
unused_bit_len = 32 - int(math.log2(num_bits))
return reversed_bits >> unused_bit_len
Originally posted by @jtraglia in https://github.com/ethereum/consensus-specs/pull/3557#discussion_r1416551306
I will try to make a PR for this later! This isn't a high priority addition IMO.
I am closing this issue because it seems stale. Please, do not hesitate to reopen it if this is a mistake