Plonk proof generation in the browser with snarkjs

This is a demonstration of Plonk proof generation in the browser using snarkjs. It uses a circuit with 426 R1CS constraints and 0 public inputs.

Demo

First, clone this repository and install dependencies:

git clone https://github.com/weijiekoh/snarkjs_plonk_in_browser.git && \
cd snarkjs_plonk_in_browser && \
npm i

Next, compile the test circuit, download the right .ptau file, generate the .zkey file, and export the verification key:

./setup.sh

Run a local HTTP server:

npx http-server

Open http://localhost:8080. Click on the "Create proof" button.

Benchmarks

R1CS Constraints Proving time (s)
426 3.3
2982 21.1

Example output

 Time taken: 2.517 seconds
 Valid?: true
 Proof: {
 "A": [
  "15665984145179725041910330430080579401248898527731361306197519054623956182252",
  "5265872380313457278958757208933531991001287034260621222837645154951506822026",
  "1"
 ],
 "B": [
  "11938644787607793125522866034003390469896390950202864503570276130909241500893",
  "6451279744603077427442017520598264612743948278672907894378285763659133239010",
  "1"
 ],
 "C": [
  "14185078313622722488241169008359203295372966136130153913395938757780564741841",
  "527214845043672529009478613937520412654038067641405106932122796653027102131",
  "1"
 ],
 "Z": [
  "21317513439232034141781857294775553016090674640736462939973241568714351254081",
  "20237205537689163943745385528596927747993019070994550178711452285288418418145",
  "1"
 ],
 "T1": [
  "14443761980739623542355187851274190918732415981764896141255618332136479841769",
  "4473673527094657155303880724685319790910778839179269262501090079615213956043",
  "1"
 ],
 "T2": [
  "13022561030150843591883509661711034952255434463518856315227185589675107741645",
  "8908274135800540725431291188808207830835393407754810296497043715138887128739",
  "1"
 ],
 "T3": [
  "4098807894467282887514503126264906640668605429273793180159711004323716909237",
  "6082419109110491449460933644839203450918471971825932482543513469434961939564",
  "1"
 ],
 "eval_a": "8628535747123098632139114311704879978090455268047166641248629222387671917005",
 "eval_b": "13630095352936267670665862744187525231990844902981063402056238180659693881299",
 "eval_c": "20609736107231292567270418494045834991871691636667172353051406453497416020510",
 "eval_s1": "16750881421793667976064707785779903355711314772459338550375715712605313993798",
 "eval_s2": "1300839786235323679846200507701110351324131872184257423092301005308146467239",
 "eval_zw": "17119531509877691600653135182188737943125683978338624976544533352503516390960",
 "eval_r": "19913688112601090205125778351826913351537292267999868690664926141717099679637",
 "Wxi": [
  "3347064175531134613855459502299165494771328611301555598351936725547922108012",
  "3230500163730866198851151332727093197758123106097605944839051998608799605504",
  "1"
 ],
 "Wxiw": [
  "7605830619912237845255294736914787021906313877467436983245442878177545978567",
  "6605657944107178224047129213246160811342563366780758304565361339154767275109",
  "1"
 ],
 "protocol": "plonk",
 "curve": "bn128"
}