MCPcopy Create free account
hub / github.com/BitVM/BitVM / bigint_to_limbs

Function bigint_to_limbs

bitvm/src/chunk/helpers.rs:141–155  ·  view source on GitHub ↗
(n: num_bigint::BigInt, n_bits: u32)

Source from the content-addressed store, hash-verified

139
140 let r: ark_ff::BigInt<4> = BigInt::from_bits_be(&bit_array);
141 fn bigint_to_limbs(n: num_bigint::BigInt, n_bits: u32) -> Vec<u32> {
142 let mut limbs = vec![];
143 let mut limb: u32 = 0;
144 for i in 0..n_bits as u64 {
145 if i > 0 && i % (LIMB_SIZE as u64) == 0 {
146 limbs.push(limb);
147 limb = 0;
148 }
149 if n.bit(i) {
150 limb += 1 << (i % (LIMB_SIZE as u64));
151 }
152 }
153 limbs.push(limb);
154 limbs
155 }
156
157 let mut limbs = bigint_to_limbs(r.into(), 256);
158 limbs.reverse();

Callers 1

extern_nibbles_to_limbsFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected