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

Method biguint_to_limbs

bitvm/src/bigint/std.rs:26–37  ·  view source on GitHub ↗
(x: BigUint)

Source from the content-addressed store, hash-verified

24
25impl<const N_BITS: u32, const LIMB_SIZE: u32> BigIntImpl<N_BITS, LIMB_SIZE> {
26 pub fn biguint_to_limbs(x: BigUint) -> Vec<u32> {
27 let mut limbs = vec![];
28 let bits: Vec<bool> = (0..N_BITS).map(|i| x.bit(i as u64)).collect();
29 for chunk in bits.chunks(LIMB_SIZE as usize) {
30 let mut limb_value = 0u32;
31 for (i, bit_value) in chunk.into_iter().enumerate() {
32 limb_value += (*bit_value as u32) << i;
33 }
34 limbs.push(limb_value);
35 }
36 limbs
37 }
38
39 pub fn push_biguint(x: BigUint) -> Script {
40 script! {

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected