Coder Social home page Coder Social logo

circom_test's Introduction

circom 0.5.23 vs circom 0.0.34

The witness calcuation of circuit_bad.circom works with circom v0.0.34, but now with v0.5.21.

circuit_works.circom works with v0.5.21.

To run the code, clone this repository, cd into it, and use:

npm i
npm run build
node ./build/index.js

The reason may lie in the way signals are assigned. In circuit_bad.circom, the output signals of selectors[i] are wired to the input signals of hasher[i]. The output signal of hasher[i], however, is only wired to selectors[i].input_elem later on in a for loop.

This makes sense if one imagines that the compiler does some kind of lazy evaluation - just wire the signals first, and execute the program later. This, however, does not seem to be the case with circom 0.5.21.

See circuit_simple.circom as well. The basic structure of the circuits is as such:

0 ==> S0.in[0] 
1 ==> S0.in[1]
      S0.in[2] <== 3
        S0.out[0] ==> A0.left
        S0.out[1] ==> A0.right
                      A0.out ==||
                               ||
1 ==> S1.in[0]                 ||
2 ==> S1.in[1]                 ||
      S1.in[2] <===============//
        S1.out[0] ==> A1.left
        S1.out[1] ==> A1.right
                      A1.out ==> out

S0 and S1 are selectors and A0 and A1 are hashers (which we also call Adders; it doesn't matter).

It seems that the compiler prefers this following structure, which uses intermediate signals (L0, L1, and L2) instead.

L0 <== 3
||
||
\\==> S0.in[0]
0 ==> S0.in[1]
      S0.out[0] ==> A0.left
      S0.out[1] ==> A0.right
L1 <=============== A0.out
||
||
\\==> S1.in[0]
1 ==> S1.in[1]
      S1.out[0] ==> A1.left
      S0.out[1] ==> A1.right
L2 <=============== A1.out
||
||
\\==> out

circom_test's People

Contributors

weijiekoh avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jbaylina

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.