openvm/
utils.rs

1
2
3
4
5
6
7
8
9
10
11
12
#[cfg(not(target_os = "zkvm"))]
use num_bigint::BigUint;

#[inline]
#[cfg(not(target_os = "zkvm"))]
#[allow(dead_code)]
/// Convert a `BigUint` to a `[u8; NUM_LIMBS]` in little-endian format.
pub fn biguint_to_limbs<const NUM_LIMBS: usize>(x: &BigUint) -> [u8; NUM_LIMBS] {
    let mut sm = x.to_bytes_le();
    sm.resize(NUM_LIMBS, 0);
    sm.try_into().unwrap()
}