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

Passing > 1145 public inputs causes RangeError #147

Closed
themighty1 opened this issue May 6, 2022 · 0 comments · Fixed by #1334
Closed

Passing > 1145 public inputs causes RangeError #147

themighty1 opened this issue May 6, 2022 · 0 comments · Fixed by #1334
Labels
bug Something isn't working move-to-js Refactor parts of the OCaml portion to JS

Comments

@themighty1
Copy link

This simple repro works with 1145, but not with 1146 elements
The error is


generating keypair...
/home/default2/Desktop/poseidon/snarkyjs/dist/server/node_bindings/snarky_js_node.bc.js:28740
      function symbol_bind(t,f){return caml_call2(_DU_,t,f)}
                                       ^

RangeError: Maximum call stack size exceeded
    at symbol_bind (/home/default2/Desktop/poseidon/snarkyjs/dist/server/node_bindings/snarky_js_node.bc.js:28740:40)
    at caml_call2 (/home/default2/Desktop/poseidon/snarkyjs/dist/server/node_bindings/snarky_js_node.bc.js:24686:28)
    at all_unit (/home/default2/Desktop/poseidon/snarkyjs/dist/server/node_bindings/snarky_js_node.bc.js:28772:18)
...

The code is


import {
    Field,
    Circuit,
    circuitMain,
    public_,
    isReady,
    CircuitValue,
    arrayProp,
  } from 'snarkyjs';
  
  // works with 1145 on my machine
   const count = 1146;

  class PublicInputs extends CircuitValue {
    @arrayProp(Field, count) fields: Field[];
  
    constructor(fields: Field[]) {
      super();
      this.fields = fields;
    }
  }

    class Main extends Circuit {
      @circuitMain
        static main(priv: Field, @public_ pub: PublicInputs) {
            // do something
      }
    }
      
  await isReady;
  
  const pub = new PublicInputs([...Array(count).fill(Field.one)]);

  console.log('generating keypair...');
  console.time('genKey');
  const kp = Main.generateKeypair();
  console.timeEnd('genKey');

  console.log('prove...');
  console.time('prove');
  const pi = Main.prove([Field.one], [pub], kp);
  console.timeEnd('prove');
  console.log('proof', pi);
  
  console.log('verify...');
  let ok = Main.verify([pub], kp.verificationKey(), pi);
  console.log('ok?', ok);
  
@mitschabaude mitschabaude added bug Something isn't working move-to-js Refactor parts of the OCaml portion to JS labels Jan 4, 2023
gabrielbosio pushed a commit to lambdaclass/o1js that referenced this issue Nov 22, 2023
…ledge

Update bindings for chunked zero-knowledge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working move-to-js Refactor parts of the OCaml portion to JS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants