def bits_of
import bend-collections@1.0.0.0/src/crypto/secp256k1/limbs.bend as Limbsimport Base
207# the k low bits of x, most significant first
208def bits_of(k: Nat, +x: Nat) -> List<&2, Nat>:
209 match k:
210 case 0n: Nil{}
211 case 1n+j: List.append(&2, Nat, bits_of(j, Nat.div(x, 2n)), [Nat.mod(x, 2n)])