circom-compat
circom-compat copied to clipboard
How to `push_input` for a 3d array input?
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?
@gakonst Please help us with it.
Doing it this way doesn't work as well:
(1..=7)
.for_each(|d| builder.push_input(format!("digits[{d}]"), d));
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.
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.
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?
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() ); ...