Giter Club home page Giter Club logo

circom-witness-rs's Issues

index out of bounds: the len is 4 but the index is 4

Hi,
When I build with the multiplier circuit

pragma circom 2.1.4;

/*This circuit template checks that c is the multiplication of a and b.*/  

template Multiplier2 () {  

   // Declaration of signals.  
   signal input a;  
   signal input b;  
   signal output c;  

   // Constraints.  
   c <== a * b;  
}

component main { public [ a ] } = Multiplier2();

It shows the error

error: failed to run custom build command for `wtest v0.1.0 (/Users/zhengyawen/Documents/GitHub/semaphore-witness-example)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/Users/zhengyawen/Documents/GitHub/semaphore-witness-example/target/debug/build/wtest-d40a5b9cdeee7289/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at /Users/zhengyawen/.cargo/git/checkouts/circom-witness-rs-68138715c9db01bf/1de8315/src/generate.rs:218:22:
  index out of bounds: the len is 4 but the index is 4
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
     1: core::panicking::panic_fmt
               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
     2: core::panicking::panic_bounds_check
               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:180:5
     3: <usize as core::slice::index::SliceIndex<[T]>>::index_mut
     4: <alloc::vec::Vec<T,A> as core::ops::index::IndexMut<I>>::index_mut
     5: witness::generate::build_witness
     6: build_script_build::main
     7: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Do you have any idea about how this happened?

`Fr_toInt` overflows

Circuit:

Anon-adhaar verifier: https://github.com/oskarth/mopro/blob/b84d4423bd5c0b3d11292b5587d20124229fd630/mopro-core/examples/circom/anonAadhaar/aadhaar-verifier.circom#L111

Error message

Total input length: 1607
Total signal length: 1602
Main input signal no: 5
thread 'main' panicked at witness/src/field.rs:247:26:
called `Result::unwrap()` on an `Err` value: Overflow(256, 4891460686036598784, 18446744073709551615)
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
   1: core::panicking::panic_fmt
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/result.rs:1652:5
   3: witness::field::Fr_toInt
   4: _cxxbridge1$Fr_toInt
   5: _Z19BigLessThan_119_runjP14Circom_CalcWit
             at /Users/zhengyawen/Documents/GitHub/mopro/witness/src/circuit.cc:202103:28
   6: _Z22RSAVerify65537_124_runjP14Circom_CalcWit
             at /Users/zhengyawen/Documents/GitHub/mopro/witness/src/circuit.cc:203339:1
   7: _Z23AadhaarVerifier_366_runjP14Circom_CalcWit
             at /Users/zhengyawen/Documents/GitHub/mopro/witness/src/circuit.cc:1509527:1
   8: _Z3runP14Circom_CalcWit
             at /Users/zhengyawen/Documents/GitHub/mopro/witness/src/circuit.cc:1509835:1
   9: cxxbridge1$run
             at /Users/zhengyawen/Documents/GitHub/mopro/target/release/build/witness-bc43ce4e137812d3/out/cxxbridge/sources/witness/src/generate.rs.cc:878:3
  10: witness::generate::build_witness
  11: generate_witness::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
libc++abi: terminating due to uncaught foreign exception
./scripts/prepare.sh: line 29: 51257 Abort trap: 6           RUST_BACKTRACE=1 WITNESS_CPP="$CIRCOM_DIR/$circuit_dir/$circuit_file" cargo run --package witness --bin generate-witness --release --features=build-witness

values[a].try_into().unwrap()

ref: circuit.cc

Unclosed "{" in circuit.cc

My generated circuit.cc has unclosed "{" so that at some point of compilation I get

a function-definition is not allowed here before '{' token

Maybe it is due to replace.sh file? How can I debug that?

supported prime numbers

I use circom with a specific prime number (secq256k1). Are all primes supported for a drop-in replacement of witness generation or need to expand this library to support different primes?

NotFound, message: "No such file or directory"

Launching it this way
WITNESS_CPP=[absolute path to my circom circuit] cargo build --release

build.rs has this

fn main() {
    witness::generate::build_witness()
}

However, I get

called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }

Any hint why this may be happenning? Am I using the correct system variable?

Missing ops

My circuit requires:
Fr_element2str
Fr_neg
Fr_div
Fr_band
Fr_shr

I am happy to help implementing those if you could provide a bit of guidance. Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.