| 24 | |
| 25 | impl<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! { |