This repository contains a boilerplate for full stack development of a Zero Knowledge decentralized application with the use of DSLs and tools such as Hardhat, Circom, Snarkjs, Nextjs etc.
ZERO KNOWLEDGE PROOFS: In cryptography, a zero-knowledge proof or zero-knowledge protocol is a method by which one party (the prover) can prove to another party (the verifier) that a given statement is true while the prover avoids conveying any additional information apart from the fact that the statement is indeed true. The most commonly used types are ZK-Snarks and ZK-Starks. For this boilerplate, we'd be utilizing ZK-Snarks.
ZK-Snarks: zk-SNARK is an acronym which stands for Zero Knowledge Succinct Non-Interactive Argument of Knowledge. All zk-SNARKs have these properties; they don’t leak information, they are tiny and easy to verify even if the notion being proven is complicated, they don’t require back and forth communication, and they are proofs of knowledge — the prover must actually know the thing being claimed, not just that it is true.
CIRCOM: Like most ZKPs, zk-SNARKs permits proving computational statements, but they cannot be applied to the computational problem directly, the statement first needs to be converted into the right form(Circuits). Circom is a novel domain-specific language (DSL) for defining arithmetic circuits that can be used to generate zero-knowledge proofs.
SNARKJs: Snarkjs is a JavaScript and Pure Web Assembly implementation of zkSNARK and PLONK schemes. It uses the Groth16 Protocol (3 point only and 3 pairings) and PLONK. You can read more about it in the official repo
NEXTJs: Nextjs is a React framework that lets you build server-side rendering and static web applications using React. We would be using Nextjs as opposed to React, as it helps you build production ready websites faster.
To get started:
- clone the repo using:
git clone [email protected]:Darlington02/circom-next-starter.git
- change directory into the hardhat folder and run:
npm install or yarn install
-
Follow the instructions in the Readme located in hardhat to compile, test and deploy your projects.
-
change directory into the ui folder and run:
npm install or yarn install
-
Follow the instructions in the Readme located in ui to run your ui locally.
-
Was the boilerplate helpful? Do give it a star.
The following graphic shows the structure of the most important elements of the boilerplate.
├── circuits
│ ├── circuit.circom
│
├── contracts
│ ├── contracts
│ │ ├── verifier.sol
├── ui
│ ├── public
│ │ ├── zkproof
│ │ │ ├── circuit.wasm
│ │ │ │── circuit_final.zkey
│ │ │
│ ├── zkproof
│ │ ├── snarkjsZkproof.js
│ │ ├
If you ever get stuck, and need a guide to reference, the guide written by Vivian Plasencia, "How to create a Zero Knowledge Dapp, from Zero to Production", is a great one, and where the inspiration for this boilerplate, was derived from. Find it HERE.