openvm_mod_circuit_builder/
utils.rs

1use num_bigint::BigUint;
2
3// Use this when num_limbs is not a constant.
4// little endian.
5// Warning: This function only returns the last NUM_LIMBS bytes of
6//          the input, while the input can have more than that.
7#[inline(always)]
8pub fn biguint_to_limbs_vec(x: &BigUint, num_limbs: usize) -> Vec<u8> {
9    x.to_bytes_le()
10        .into_iter()
11        .chain(std::iter::repeat(0u8))
12        .take(num_limbs)
13        .collect()
14}