Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic on to_array32 #20

Closed
albttx opened this issue Feb 8, 2022 · 3 comments
Closed

Panic on to_array32 #20

albttx opened this issue Feb 8, 2022 · 3 comments

Comments

@albttx
Copy link

albttx commented Feb 8, 2022

Hello,

i'm new with rust and circom but I'm doing my best to learn.

I'm trying to compile the tornado-cash circuit and use ark-circom to interact with it.
here are the circuits: https://github.com/tornadocash/tornado-core/tree/master/circuits they're using v1, but after 2 minor modifications it's compile. you can see my circuits here

I created a small and reproducible project to show my errors: https://github.com/albttx/ark-circom-tc and an issue albttx/ark-circom-tc#1

the function to_array32 panic

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

see the line here

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
}

Could you guys help ?

@albttx
Copy link
Author

albttx commented Feb 8, 2022

after hours of search, i decided to write the issue...

right after i discover: #19 which fix my problem..

i failed on

Constraint trace requires enabling `ConstraintLayer`

I'll create a new issue in case i still don't manage to find a solution

really sorry

@albttx albttx closed this as completed Feb 8, 2022
@philsippl
Copy link
Contributor

@albttx I've just pushed the missing test case, as soon as it is merged you can switch to master again, sorry for the delays. Did you figure out the other issue?

@albttx
Copy link
Author

albttx commented Feb 19, 2022

@philsippl Hello, thanks for your PR update.

yes I figure everything out.

i made a poc that is now working: https://github.com/albttx/ark-circom-tc in case you're interested :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants