|
1 | 1 | # CIRCOMJS |
2 | | -CircomJS is a development framework for automating the proof generation of ZK-circuit using circom. |
| 2 | +CircomJS is a javascript framework for automating and easing workflow around developing in the [Circom](https://docs.circom.io) DSL. |
3 | 3 |
|
4 | | -### Development |
5 | | -Repo supports conditional logging based on `log` package. |
| 4 | +**We would suggest getting started with this [gitbook](https://zefi.gitbook.io/circomjs), and you should also checkout our [blog post](todo) on why we made CircomJS.** |
| 5 | + |
| 6 | +The framework operates on a simple [circuit.config.js](https://zefi.gitbook.io/circomjs/circuit-config-file/circuit-config-file) file, which is a configuration file for circomJS. |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +You can also take a look at [CircomJS starter](https://github.com/getZeFi/circomjs-starter) repository for reference. |
| 11 | + |
| 12 | +CircomJS gives you the following capabilities in Javascript! |
| 13 | + |
| 14 | +### Compile your circuits |
| 15 | + |
| 16 | +```javascript |
| 17 | +const {CircomJS} = require("circomjs") |
| 18 | + |
| 19 | +const main = async() => { |
| 20 | + const circomjs = new CircomJS() |
| 21 | + const circuit = circomjs.getCircuit("mul") |
| 22 | + |
| 23 | + // it will build the circuit with cID mul |
| 24 | + await circuit.compile() |
| 25 | +} |
| 26 | + |
| 27 | +main() |
6 | 28 | ``` |
7 | | -$ LOG_LEVEL=info ts-node src/index.ts |
| 29 | + |
| 30 | +### Generate Proofs |
| 31 | + |
| 32 | +```javascript |
| 33 | +const {CircomJS} = require("circomjs") |
| 34 | + |
| 35 | +const main = async() => { |
| 36 | + const circomjs = new CircomJS() |
| 37 | + const circuit = circomjs.getCircuit("mul") |
| 38 | + |
| 39 | + // important to await compilation, before running circuit.genProof() |
| 40 | + await circuit.compile() |
| 41 | + |
| 42 | + const input = { |
| 43 | + x: 3, |
| 44 | + y: 5 |
| 45 | + } |
| 46 | + |
| 47 | + const proof = await circuit.genProof(input); |
| 48 | + console.log("proof verification result ----->",await circuit.verifyProof(proof)) |
| 49 | +} |
| 50 | + |
| 51 | +main() |
8 | 52 | ``` |
9 | 53 |
|
10 | | -### Usage |
11 | | -// TODO |
| 54 | +### Verify proofs |
| 55 | + |
| 56 | +```javascript |
| 57 | +const {CircomJS} = require("circomjs") |
| 58 | + |
| 59 | +const main = async() => { |
| 60 | + const circomjs = new CircomJS() |
| 61 | + const circuit = circomjs.getCircuit("mul") |
| 62 | + |
| 63 | + // important to await compilation, before running circuit.genProof() |
| 64 | + await circuit.compile() |
| 65 | + |
| 66 | + const input = { |
| 67 | + x: 3, |
| 68 | + y: 5 |
| 69 | + } |
| 70 | + |
| 71 | + const proof = await circuit.genProof(input); |
| 72 | + console.log("proof verification result ----->",await circuit.verifyProof(proof)) |
| 73 | +} |
| 74 | + |
| 75 | +main() |
| 76 | +``` |
| 77 | + |
| 78 | +### and much more! |
| 79 | +You can do a lot more than this: |
| 80 | +- calculate witness |
| 81 | +- calculate total constraints |
| 82 | +- check constraints on a generated witness |
| 83 | +- export solidity smart contract verifier { coming-soon } |
| 84 | +- export solidity call-data { coming-soon } |
| 85 | + |
| 86 | +### Upcoming features |
| 87 | + |
| 88 | +We are working towards adding new features to the framework, some of which include: |
| 89 | +- Support for C compilation of circuits { witness generation programs } |
| 90 | +- Automatic download of ideal power of tau file |
| 91 | +- Parallel build of ZK Circuits |
| 92 | +- Integration with Ethersjs to deploy smart contract verifiers |
| 93 | +- Using sha-256 hashing to only build circuits when source code changes |
| 94 | + |
| 95 | +We at zefi are open to ideas around the project and would love to interact with the community and see contributions comings its way, feel free to join our [telegram group ](https://t.me/+7JPXv-RoXJk0MTVl) and say hi, also feel free to write to us at [[email protected]](mailto:[email protected]). |
0 commit comments