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

How to push_input for a 3d array input? #34

Open
0xbok opened this issue Jan 4, 2023 · 7 comments
Open

How to push_input for a 3d array input? #34

0xbok opened this issue Jan 4, 2023 · 7 comments

Comments

@0xbok
Copy link

0xbok commented Jan 4, 2023

No description provided.

@0xbok 0xbok changed the title How to push_input for a 3d array input How to push_input for a 3d array input? Jan 4, 2023
@jymchng
Copy link

jymchng commented May 12, 2023

I have a similar question, but for an array input.

In my circuit, main.circom, I have:
signal input digits[7];

In main.rs, I have:

let mut builder = CircomBuilder::new(cfg);
builder.push_input("digits", &[1, 2, 3, 4, 5, 6, 7]);

The error encountered is:

error[E0277]: the trait bound `num_bigint::bigint::BigInt: From<&[{integer}; 7]>` is not satisfied
  --> src\main.rs:18:34
   |
18 |     builder.push_input("digits", &[1, 2, 3, 4, 5, 6, 7]);
   |             ----------           ^^^^^^^^^^^^^^^^^^^^^^ the trait `From<&[{integer}; 7]>` is not implemented for `num_bigint::bigint::BigInt`
   |             |
   |             required by a bound introduced by this call

The error is easy to understand because

pub fn push_input<T: Into<BigInt>>(&mut self, name: impl ToString, val: T) {
        let values = self.inputs.entry(name.to_string()).or_insert_with(Vec::new);
        values.push(val.into());
    }

T must implement Into<BigInt>.

So how do we pass array inputs to circom circuits via rust?

@jymchng
Copy link

jymchng commented May 12, 2023

@gakonst Please help us with it.

@jymchng
Copy link

jymchng commented May 12, 2023

Doing it this way doesn't work as well:

(1..=7)
        .for_each(|d| builder.push_input(format!("digits[{d}]"), d));

@gakonst
Copy link
Collaborator

gakonst commented May 12, 2023

Hey - I hadn't figured out how to make this work when I was working on this. It's currently not supported, and I don't have bandwidth to figure this out unfortunately.

@jymchng
Copy link

jymchng commented May 13, 2023

Hey - I hadn't figured out how to make this work when I was working on this. It's currently not supported, and I don't have bandwidth to figure this out unfortunately.

@gakonst Hi, thank you for your response. Lol, I'll guess a funny workaround will be to split the input array into individual signals and push_input one by one.

@RajeshRk18
Copy link
Contributor

Hey - I hadn't figured out how to make this work when I was working on this. It's currently not supported, and I don't have bandwidth to figure this out unfortunately.

@gakonst Hi, thank you for your response. Lol, I'll guess a funny workaround will be to split the input array into individual signals and push_input one by one.

@jymchng Are you working on this issue?

@ivabe
Copy link

ivabe commented Jun 26, 2024

I think that if you try to push different BigInt values one by one into the same signal, it should work. Push_input seems to append values to the vector. Try something as follows:

builder.push_input("digits", ToBigInt::to_bigint(&1).unwrap() );
builder.push_input("digits", ToBigInt::to_bigint(&2).unwrap() );
...

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

6 participants
@0xbok @gakonst @jymchng @RajeshRk18 @ivabe and others