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

Circom Public Inputs Example not working, Snarkjs 0.7.4, Circom 2.1.9 #293

Open
jonas089 opened this issue Sep 9, 2024 · 1 comment
Open

Comments

@jonas089
Copy link

jonas089 commented Sep 9, 2024

[ERROR] snarkJS: Error: Scalar size does not match
    at _multiExp (/opt/homebrew/lib/node_modules/snarkjs/node_modules/ffjavascript/build/main.cjs:4978:19)
    at WasmCurve.multiExpAffine (/opt/homebrew/lib/node_modules/snarkjs/node_modules/ffjavascript/build/main.cjs:5015:22)
    at groth16Prove$1 (/opt/homebrew/lib/node_modules/snarkjs/build/cli.cjs:5768:33)
    at async Object.groth16Prove [as action] (/opt/homebrew/lib/node_modules/snarkjs/build/cli.cjs:12975:36)
    at async clProcessor (/opt/homebrew/lib/node_modules/snarkjs/build/cli.cjs:481:27)

for circuit:

pragma circom 2.0.0;

template Multiplier2(){
   //Declaration of signals
   signal input in1;
   signal input in2;
   signal output out;
   out <== in1 * in2;
}

component main {public [in1,in2]} = Multiplier2();

with inputs:

{"in1": "3", "in2": "11"}

Is this a known issue? I followed the tutorial exactly yet it does not generate a proof. If I make either of the inputs private it works e.g. component main {public [in1]} = Multiplier2(); is ok.

Screenshot 2024-09-09 at 22 45 55

See example for reference:
https://docs.circom.io/circom-language/signals/

I suspect this might be due to the two inputs forming a quadratic constraint. When I introduce a third input and make it public it works again.

@Arvolear
Copy link
Contributor

Arvolear commented Sep 30, 2024

Sad to see this mistake in the official circom docs. This is a common issue though. When a circuit has 0 constraints, snarkjs throws this exact error.

In the example, all the signals (both outputs and inputs) are public and ZK proof results into hiding nothing, becoming meaningless. Sometimes this error may also occur due to weird circom optimizations that "remove" constraints.

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

2 participants