albttx / ark-circom-tc

4 stars 1 forks source link

to_array32 error #1

Closed albttx closed 2 years ago

albttx commented 2 years ago

the function is failing with error

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value',
/home/albttx/.cargo/git/checkouts/ark-circom-1c15f1eba3004428/cac27e6/src/witness/witness_calculator.rs:47:43

here is the function

fn to_array32(s: &BigInt, size: usize) -> Vec<i32> {
    let mut res = vec![0; size as usize];
    let mut rem = s.clone();
    let radix = BigInt::from(0x100000000u64);
    let mut c = size - 1;
    while !rem.is_zero() {
        res[c] = (&rem % &radix).to_i32().unwrap();   // <-- error here
        rem /= &radix;
        c -= 1;
    }

    res
}