-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(circuits): new setup with circomkit
re #73
- Loading branch information
Showing
17 changed files
with
261 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
diff --git a/dist/utils/instantiate.js b/dist/utils/instantiate.js | ||
index 33cdff152e8b23d6853eb475097bda8c02712e01..418f57072c9c0ebf3778c8a9a50d379728128e5f 100644 | ||
--- a/dist/utils/instantiate.js | ||
+++ b/dist/utils/instantiate.js | ||
@@ -1,15 +1,17 @@ | ||
-"use strict"; | ||
-Object.defineProperty(exports, "__esModule", { value: true }); | ||
-exports.instantiate = void 0; | ||
-const fs_1 = require("fs"); | ||
+"use strict" | ||
+Object.defineProperty(exports, "__esModule", { value: true }) | ||
+exports.instantiate = void 0 | ||
+const fs_1 = require("fs") | ||
/** Circuit builder, kinda like `ejs.render`. **Be very careful when editing this file.** */ | ||
const makeCircuit = (config) => `// auto-generated by circomkit | ||
pragma circom ${config.version}; | ||
|
||
include "../${config.file}.circom"; | ||
|
||
-component main${config.pubs.length === 0 ? '' : ' {public[' + config.pubs.join(', ') + ']}'} = ${config.template}(${config.params.join(', ')}); | ||
-`; | ||
+component main${config.pubs.length === 0 ? "" : " {public[" + config.pubs.join(", ") + "]}"} = ${ | ||
+ config.template | ||
+}(${config.params.join(", ")}); | ||
+` | ||
/** | ||
* Programmatically generate the `main` component of a circuit | ||
* @param name name of the circuit to be generated | ||
@@ -18,31 +20,32 @@ component main${config.pubs.length === 0 ? '' : ' {public[' + config.pubs.join(' | ||
*/ | ||
function instantiate(name, circuitConfig) { | ||
// directory to output the file | ||
- const directory = circuitConfig.dir || 'test'; | ||
+ const directory = circuitConfig.dir || "test" | ||
// add "../" to the filename in include, one for each "/" in directory name | ||
// if none, the prefix becomes empty string | ||
- const filePrefixMatches = directory.match(/\//g); | ||
- let file = circuitConfig.file; | ||
+ const filePrefixMatches = directory.match(/\//g) | ||
+ let file = circuitConfig.file | ||
if (filePrefixMatches !== null) { | ||
- file = '../'.repeat(filePrefixMatches.length) + file; | ||
+ file = "../".repeat(filePrefixMatches.length) + file | ||
} | ||
const circuitCode = makeCircuit({ | ||
file: file, | ||
template: circuitConfig.template, | ||
- version: circuitConfig.version || '2.0.0', | ||
+ version: circuitConfig.version || "2.0.0", | ||
dir: directory, | ||
pubs: circuitConfig.pubs || [], | ||
- params: circuitConfig.params || [], | ||
- }); | ||
- const targetDir = `./circuits/${directory}`; | ||
+ params: circuitConfig.params || [] | ||
+ }) | ||
+ const targetDir = `./circom/${directory}` | ||
if (!(0, fs_1.existsSync)(targetDir)) { | ||
- (0, fs_1.mkdirSync)(targetDir, { | ||
- recursive: true, | ||
- }); | ||
+ ;(0, fs_1.mkdirSync)(targetDir, { | ||
+ recursive: true | ||
+ }) | ||
} | ||
- const targetPath = `${targetDir}/${name}.circom`; | ||
- (0, fs_1.writeFileSync)(targetPath, circuitCode); | ||
- return targetPath; | ||
+ const targetPath = `${targetDir}/${name}.circom` | ||
+ ;(0, fs_1.writeFileSync)(targetPath, circuitCode) | ||
+ return targetPath | ||
} | ||
-exports.instantiate = instantiate; | ||
+exports.instantiate = instantiate | ||
//# sourceMappingURL=instantiate.js.map | ||
+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,7 @@ | |
"circom" | ||
], | ||
"workspaces": [ | ||
"packages/*", | ||
"packages/circuits/templates" | ||
"packages/*" | ||
], | ||
"packageManager": "[email protected]", | ||
"devDependencies": { | ||
|
@@ -76,5 +75,8 @@ | |
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
}, | ||
"resolutions": { | ||
"[email protected]": "patch:circomkit@npm:0.0.18#.yarn/patches/circomkit-npm-0.0.18-e33b63f27f.patch" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
ptau | ||
main | ||
*.r1cs | ||
*.wasm |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Ethereum Foundation | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<p align="center"> | ||
<h1 align="center"> | ||
ZK-kit circuits | ||
</h1> | ||
<p align="center">A comprehensive library of general-purpose zero-knowledge circuits.</p> | ||
</p> | ||
|
||
<p align="center"> | ||
<a href="https://github.com/privacy-scaling-explorations/zk-kit"> | ||
<img src="https://img.shields.io/badge/project-zk--kit-blue.svg?style=flat-square"> | ||
</a> | ||
<a href="https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/circuits.sol/LICENSE"> | ||
<img alt="Github license" src="https://img.shields.io/github/license/privacy-scaling-explorations/zk-kit.svg?style=flat-square"> | ||
</a> | ||
<a href="https://www.npmjs.com/package/@zk-kit/circuits"> | ||
<img alt="NPM version" src="https://img.shields.io/npm/v/@zk-kit/circuits?style=flat-square" /> | ||
</a> | ||
<a href="https://npmjs.org/package/@zk-kit/circuits"> | ||
<img alt="Downloads" src="https://img.shields.io/npm/dm/@zk-kit/circuits.svg?style=flat-square" /> | ||
</a> | ||
<a href="https://bundlephobia.com/package/@zk-kit/circuits"> | ||
<img alt="npm bundle size (scoped)" src="https://img.shields.io/bundlephobia/minzip/@zk-kit/circuits" /> | ||
</a> | ||
</p> | ||
|
||
<div align="center"> | ||
<h4> | ||
<a href="https://appliedzkp.org/discord"> | ||
🗣️ Chat & Support | ||
</a> | ||
</h4> | ||
</div> | ||
|
||
--- | ||
|
||
## 🛠 Install | ||
|
||
### npm or yarn | ||
|
||
Install the `@zk-kit/circuits` package with npm: | ||
|
||
```bash | ||
npm i @zk-kit/circuits --save | ||
``` | ||
|
||
or yarn: | ||
|
||
```bash | ||
yarn add @zk-kit/circuits | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"poseidon-proof": { | ||
"file": "poseidon-proof", | ||
"template": "PoseidonProof" | ||
}, | ||
"binary-merkle-root": { | ||
"file": "binary-merkle-root", | ||
"template": "BinaryMerkleRoot", | ||
"params": [20] | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"protocol": "groth16", | ||
"prime": "bn128", | ||
"version": "2.1.5", | ||
"circuits": "./circom/circuits.json", | ||
"dirPtau": "./ptau", | ||
"dirCircuits": "./circom", | ||
"dirInputs": "./inputs", | ||
"dirBuild": "./build", | ||
"optimization": 1, | ||
"inspect": true, | ||
"include": ["../../node_modules/circomlib/circuits"], | ||
"groth16numContributions": 1, | ||
"groth16askForEntropy": false, | ||
"logLevel": "INFO", | ||
"verbose": true | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,27 @@ | ||
{ | ||
"name": "circuits", | ||
"private": true, | ||
"description": "A comprehensive library of general-purpose Circom circuits.", | ||
"name": "@zk-kit/circuits", | ||
"version": "0.2.0", | ||
"description": "A comprehensive library of general-purpose zero-knowledge circuits.", | ||
"license": "MIT", | ||
"files": [ | ||
"circom", | ||
"noir", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"repository": "[email protected]:privacy-scaling-explorations/zk-kit.git", | ||
"homepage": "https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/circuits.sol", | ||
"scripts": { | ||
"compile": "circom --r1cs -l ../../node_modules/circomlib/circuits" | ||
"circom:compile": "circomkit compile", | ||
"circom:setup": "circomkit setup" | ||
}, | ||
"dependencies": { | ||
"circomlib": "^2.0.5" | ||
}, | ||
"devDependencies": { | ||
"circomkit": "^0.0.18" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.