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

Getting started tutorial doesn't seem to work anymore #296

Open
michal-wrzosek opened this issue Sep 20, 2024 · 0 comments
Open

Getting started tutorial doesn't seem to work anymore #296

michal-wrzosek opened this issue Sep 20, 2024 · 0 comments

Comments

@michal-wrzosek
Copy link

michal-wrzosek commented Sep 20, 2024

Hi,
I tried to follow the "Getting started" tutorial but no matter what I do to my circuit when proving I end up with [ERROR] snarkJS: Error: Scalar size does not match.

Do I miss something here?

Here's a Dockerfile to be able to reproduce the issue and all the steps:

FROM node:20

RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y

ENV PATH="/root/.cargo/bin:${PATH}"

RUN git clone https://github.com/iden3/circom.git

WORKDIR /circom

RUN git checkout v2.1.9

RUN cargo build --release

RUN cargo install --path circom

RUN npm install -g [email protected]

WORKDIR /circuits

RUN cat <<EOF > ./multiplier.circom
pragma circom 2.0.0;

template Multiplier2() {
  signal input a;
  signal input b;
  signal output c;
  c <== a*b;
}

component main = Multiplier2();
EOF

RUN cat <<EOF > ./multiplier-input.json
{ "a": "2", "b": "3" }
EOF

# This is super slow to build in docker so I'm going to use the prebuilt one
# RUN snarkjs powersoftau new bn128 12 ./pot12_0000.ptau
# RUN snarkjs powersoftau contribute ./pot12_0000.ptau ./pot12_0001.ptau --name="First contribution"

RUN curl -O https://hermez.s3-eu-west-1.amazonaws.com/powersOfTau28_hez_final_08.ptau

RUN mkdir ./multiplier

RUN circom ./multiplier.circom \
  --wasm \
  --r1cs \
  --O0 \
  --sym \
  --inspect \
  -o ./multiplier

RUN snarkjs r1cs info \
  ./multiplier/multiplier.r1cs

RUN node ./multiplier/multiplier_js/generate_witness.js \
  ./multiplier/multiplier_js/multiplier.wasm \
  ./multiplier-input.json \
  ./multiplier/multiplier.wtns

RUN snarkjs powersoftau prepare phase2 \
  ./powersOfTau28_hez_final_08.ptau \
  ./multiplier/multiplier.ptau

RUN snarkjs groth16 setup \
  ./multiplier/multiplier.r1cs \
  ./multiplier/multiplier.ptau \
  ./multiplier/multiplier-0000.zkey

RUN snarkjs zkey contribute \
  ./multiplier/multiplier-0000.zkey \
  ./multiplier/multiplier.zkey \
  --name="John Doe" \
  -e="Random entropy"

RUN snarkjs zkey export verificationkey \
  ./multiplier/multiplier.zkey \
  ./multiplier/multiplier-verification-key.json

RUN snarkjs groth16 prove \
  ./multiplier/multiplier.zkey \
  ./multiplier/multiplier.wtns \
  ./multiplier/multiplier-proof.json \
  ./multiplier/multiplier-public.json

CMD snarkjs groth16 verify \
  ./multiplier/multiplier-verification-key.json \
  ./multiplier/multiplier-proof.json \
  ./multiplier/multiplier-public.json

Save this as "Dockerfile" file then build and run like this:

docker build -t zk-proofs .
docker run zk-proofs

Interestingly, running the prove/verify part from within the node script (not through CLI) works just fine.

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

1 participant