{"id":13619901,"url":"https://github.com/BitVM/bitvm-circom-example","last_synced_at":"2025-04-14T18:32:42.344Z","repository":{"id":231972190,"uuid":"783018077","full_name":"BitVM/bitvm-circom-example","owner":"BitVM","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-22T13:40:51.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-08T06:39:18.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BitVM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-06T17:55:58.000Z","updated_at":"2024-05-17T11:30:47.000Z","dependencies_parsed_at":"2024-04-09T04:21:40.271Z","dependency_job_id":"b02ac6d0-1c7e-4f34-92f8-5397a4c598e1","html_url":"https://github.com/BitVM/bitvm-circom-example","commit_stats":null,"previous_names":["weikengchen/circom-bitvm-exp","bitvm/bitvm-circom-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitVM%2Fbitvm-circom-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitVM%2Fbitvm-circom-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitVM%2Fbitvm-circom-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BitVM%2Fbitvm-circom-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BitVM","download_url":"https://codeload.github.com/BitVM/bitvm-circom-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248936967,"owners_count":21186134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:00:50.000Z","updated_at":"2025-04-14T18:32:42.038Z","avatar_url":"https://github.com/BitVM.png","language":"Solidity","funding_links":[],"categories":["Libraries"],"sub_categories":["Potential Use Case"],"readme":"This repository contains an example circom circuit that is used to test the Bitcoin script for a fflonk verifier.\n\n## Dependencies\n\nWe use circom, snarkjs, and circomlib. \n- follow instructions [here](https://docs.circom.io/getting-started/installation/#installing-snarkjs) to install circom and snarkjs.\n- circomlib has been included as a git submodule. One can do `git submodule update --init --remote --recursive`.\n\n## Instructions\n\n### Step 1: obtain the setup parameters\n\nWe use the KZG setup ceremony that Polygon Hermez has done. More information can be found [here](https://github.com/iden3/snarkjs).\n\n```console\nwget https://storage.googleapis.com/zkevm/ptau/powersOfTau28_hez_final_21.ptau\n```\n\n### Step 2: compile the circuit\n\nWe use circom to compile the circuit.\n\n```console\ncircom test_circuit.circom --r1cs --wasm --sym\n```\n\n### Step 3: perform the witness generation\n\nThen, we use the witness generator that circom creates to compute the witness.\n\n```console\ncd test_circuit_js\nnode generate_witness.js test_circuit.wasm ../input.json ../witness.wtns\ncd ../\n```\n\nYou can test if the witness is correct.\n```console\nsnarkjs wtns check test_circuit.r1cs witness.wtns\n```\n\n### Step 4: preprocess the keys\n\nNow, we use snarkjs to preprocess the keys, which creates the proving key file `circuit.zkey`\n\n```console\nsnarkjs fflonk setup test_circuit.r1cs powersOfTau28_hez_final_21.ptau circuit.zkey\n```\n\n### Step 5: export the verification key\n\nWe can derive the verifying key out of the proving key.\n\n```console\nsnarkjs zkey export verificationkey circuit.zkey verification_key.json\n```\n\n### Step 6: create the proof\n\nWe can now run the proof generation.\n\n```console\nsnarkjs fflonk prove circuit.zkey witness.wtns proof.json public.json\n```\n\nFor testing purposes, however, it is more common to use fixed randomness.\n\n\n```console\nUSE_FIXED_RANDOMNESS=1 snarkjs fflonk prove circuit.zkey witness.wtns proof.json public.json\n```\n\nAnd if one wants to save the console output to a file, use `|\u0026 tee a.txt`.\n\nTo check if the verifier will accept this proof, do:\n\n```console\nsnarkjs fflonk verify verification_key.json public.json proof.json\n```\n\n### Step 7: export the Solidity verifier contract\n\nA very convenient feature of snarkjs is that it can generate a highly efficient and fully preprocessed Solidity smart contract that exactly represents the verifier. \n\n```console\nsnarkjs zkey export solidityverifier circuit.zkey verifier.sol\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBitVM%2Fbitvm-circom-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBitVM%2Fbitvm-circom-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBitVM%2Fbitvm-circom-example/lists"}