-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit db8796b
Showing
27 changed files
with
666 additions
and
0 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,11 @@ | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
insert_final_newline = true | ||
[*.ts] | ||
indent_size = 2 | ||
max_line_length = 120 | ||
[*.sol] | ||
indent_size = 4 | ||
max_line_length = 99 |
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,30 @@ | ||
name: Bug Report | ||
description: File a bug report | ||
labels: ['bug'] | ||
assignees: | ||
- | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: Thanks for taking the time to fill out this bug report! | ||
- type: input | ||
id: version | ||
attributes: | ||
label: "Project version" | ||
placeholder: "1.2.3" | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: what-happened | ||
attributes: | ||
label: What happened? | ||
description: A brief description of what happened and what you expected to happen | ||
validations: | ||
required: true | ||
- type: textarea | ||
id: reproduction-steps | ||
attributes: | ||
label: "Minimal reproduction steps" | ||
description: "The minimal steps needed to reproduce the bug" | ||
validations: | ||
required: true |
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,13 @@ | ||
name: Feature request | ||
description: Suggest a new feature | ||
labels: ['feature'] | ||
assignees: | ||
- | ||
body: | ||
- type: textarea | ||
id: feature-description | ||
attributes: | ||
label: "Describe the feature" | ||
description: "A description of what you would like to see in the project" | ||
validations: | ||
required: true |
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,4 @@ | ||
--- | ||
name: Other issue | ||
about: Other kind of issue | ||
--- |
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,13 @@ | ||
name: setup | ||
|
||
description: setup | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup Bun | ||
uses: oven-sh/setup-bun@v2 | ||
|
||
- name: Install packages | ||
run: bun install | ||
shell: bash |
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,25 @@ | ||
name: "checks" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
|
||
- uses: oven-sh/setup-bun@v2 | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
|
||
- name: Run tests | ||
run: bun run test |
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 @@ | ||
node_modules | ||
.env | ||
.DS_Store | ||
|
||
# Hardhat files | ||
cache | ||
artifacts | ||
coverage.json | ||
coverage | ||
abi | ||
zkit | ||
|
||
# Typechain generated files | ||
generated-types | ||
|
||
# Hardhat migrate | ||
.storage.json | ||
circuits/test | ||
|
||
IdentityAuth.witness.json | ||
IdentityAuth.wtns |
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 @@ | ||
npm run lint-fix && git add -u |
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,5 @@ | ||
{ | ||
"require": ["ts-node/register", "./test/setup.ts"], | ||
"extension": ["ts"], | ||
"spec": "test/**/*.spec.ts" | ||
} |
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 @@ | ||
node_modules | ||
.env | ||
.DS_Store | ||
package-lock.json | ||
|
||
# Hardhat files | ||
cache | ||
artifacts | ||
coverage.json | ||
coverage | ||
zkit | ||
|
||
# Typechain generated files | ||
generated-types | ||
|
||
# Hardhat migrate | ||
.storage.json |
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 @@ | ||
{ | ||
"overrides": [ | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"printWidth": 99, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"singleQuote": false, | ||
"bracketSpacing": false | ||
} | ||
}, | ||
{ | ||
"files": "*.ts", | ||
"options": { | ||
"printWidth": 120, | ||
"tabWidth": 2 | ||
} | ||
} | ||
] | ||
} |
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) 2025 ZKDL Camp | ||
|
||
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 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,7 @@ | ||
# Hardhat Zkit template | ||
|
||
## Usage | ||
|
||
This project is using [bun](https://bun.sh/) JS runtime. If you do not have it installed follow the instructions [here](https://bun.sh/docs/installation). | ||
|
||
Otherwise, you can delete the `bun.lockb` lock file and run `npm install` to install the dependencies. |
Binary file not shown.
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,6 @@ | ||
// LICENSE: MIT | ||
pragma circom 2.1.6; | ||
|
||
include "templates/Math.circom"; | ||
|
||
component main = Math(); |
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,18 @@ | ||
// LICENSE: MIT | ||
pragma circom 2.1.6; | ||
|
||
template Math() { | ||
signal output r; | ||
|
||
signal input x1; | ||
|
||
signal input x2; | ||
signal input x3; | ||
|
||
x1 * x1 === x1; | ||
|
||
signal mult <== x2 * x3; | ||
signal selectMult <== x1 * mult; | ||
|
||
(1 - x1) * (x2 + x3) + selectMult ==> r; | ||
} |
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,158 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
/* AUTOGENERATED FILE BY HARDHAT-ZKIT. DO NOT EDIT. */ | ||
|
||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
contract MathVerifier { | ||
/// @dev base field size | ||
uint256 public constant BASE_FIELD_SIZE = | ||
21888242871839275222246405745257275088696311157297823662689037894645226208583; | ||
|
||
/// @dev verification key data | ||
uint256 public constant ALPHA_X = | ||
20491192805390485299153009773594534940189261866228447918068658471970481763042; | ||
uint256 public constant ALPHA_Y = | ||
9383485363053290200918347156157836566562967994039712273449902621266178545958; | ||
uint256 public constant BETA_X1 = | ||
4252822878758300859123897981450591353533073413197771768651442665752259397132; | ||
uint256 public constant BETA_X2 = | ||
6375614351688725206403948262868962793625744043794305715222011528459656738731; | ||
uint256 public constant BETA_Y1 = | ||
21847035105528745403288232691147584728191162732299865338377159692350059136679; | ||
uint256 public constant BETA_Y2 = | ||
10505242626370262277552901082094356697409835680220590971873171140371331206856; | ||
uint256 public constant GAMMA_X1 = | ||
11559732032986387107991004021392285783925812861821192530917403151452391805634; | ||
uint256 public constant GAMMA_X2 = | ||
10857046999023057135944570762232829481370756359578518086990519993285655852781; | ||
uint256 public constant GAMMA_Y1 = | ||
4082367875863433681332203403145435568316851327593401208105741076214120093531; | ||
uint256 public constant GAMMA_Y2 = | ||
8495653923123431417604973247489272438418190587263600148770280649306958101930; | ||
uint256 public constant DELTA_X1 = | ||
11559732032986387107991004021392285783925812861821192530917403151452391805634; | ||
uint256 public constant DELTA_X2 = | ||
10857046999023057135944570762232829481370756359578518086990519993285655852781; | ||
uint256 public constant DELTA_Y1 = | ||
4082367875863433681332203403145435568316851327593401208105741076214120093531; | ||
uint256 public constant DELTA_Y2 = | ||
8495653923123431417604973247489272438418190587263600148770280649306958101930; | ||
|
||
uint256 public constant IC0_X = | ||
7246450750923962100077445566644177421429507238279338753215624391282583293394; | ||
uint256 public constant IC0_Y = | ||
19778601966845352785929137625645717352315842481501201420677797211475501180673; | ||
uint256 public constant IC1_X = | ||
21489871966673422990912038207381382789455440732690519161907414590243298309365; | ||
uint256 public constant IC1_Y = | ||
6950355566631655764010982136442430243610621295051493732978619100549291270591; | ||
|
||
/// @dev memory pointer sizes | ||
uint16 public constant P_PUBLIC_SIGNALS_ACCUMULATOR_SIZE = 128; | ||
uint16 public constant P_TOTAL_SIZE = 896; | ||
|
||
function verifyProof( | ||
uint256[2] memory pointA_, | ||
uint256[2][2] memory pointB_, | ||
uint256[2] memory pointC_, | ||
uint256[1] memory publicSignals_ | ||
) public view returns (bool verified_) { | ||
assembly { | ||
function checkField(signal_) -> res_ { | ||
res_ := lt(signal_, BASE_FIELD_SIZE) | ||
} | ||
|
||
function g1MulAdd(pR_, x_, y_, s_) -> res_ { | ||
let pointer_ := mload(64) // free pointer | ||
|
||
mstore(pointer_, x_) | ||
mstore(add(pointer_, 32), y_) | ||
mstore(add(pointer_, 64), s_) | ||
|
||
res_ := staticcall(sub(gas(), 2000), 7, pointer_, 96, pointer_, 64) // ecMul | ||
res_ := and(res_, gt(returndatasize(), 0)) // check that multiplication succeeded | ||
|
||
if iszero(res_) { | ||
leave | ||
} | ||
|
||
mstore(add(pointer_, 64), mload(pR_)) | ||
mstore(add(pointer_, 96), mload(add(pR_, 32))) | ||
|
||
res_ := staticcall(sub(gas(), 2000), 6, pointer_, 128, pR_, 64) // ecAdd | ||
res_ := and(res_, gt(returndatasize(), 0)) // check that addition succeeded | ||
} | ||
|
||
function checkPairing(pA_, pB_, pC_, pubSignals_, pointer_) -> res_ { | ||
let pPairing_ := add(pointer_, P_PUBLIC_SIGNALS_ACCUMULATOR_SIZE) | ||
|
||
mstore(pointer_, IC0_X) | ||
mstore(add(pointer_, 32), IC0_Y) | ||
|
||
/// @dev compute the linear combination of public signals | ||
if iszero(g1MulAdd(pointer_, IC1_X, IC1_Y, mload(add(pubSignals_, 0)))) { | ||
leave | ||
} | ||
|
||
/// @dev -A | ||
mstore(pPairing_, mload(pA_)) | ||
mstore( | ||
add(pPairing_, 32), | ||
mod(sub(BASE_FIELD_SIZE, mload(add(pA_, 32))), BASE_FIELD_SIZE) | ||
) | ||
|
||
/// @dev B | ||
mstore(add(pPairing_, 64), mload(mload(pB_))) | ||
mstore(add(pPairing_, 96), mload(add(mload(pB_), 32))) | ||
mstore(add(pPairing_, 128), mload(mload(add(pB_, 32)))) | ||
mstore(add(pPairing_, 160), mload(add(mload(add(pB_, 32)), 32))) | ||
|
||
/// @dev alpha1 | ||
mstore(add(pPairing_, 192), ALPHA_X) | ||
mstore(add(pPairing_, 224), ALPHA_Y) | ||
|
||
/// @dev beta2 | ||
mstore(add(pPairing_, 256), BETA_X1) | ||
mstore(add(pPairing_, 288), BETA_X2) | ||
mstore(add(pPairing_, 320), BETA_Y1) | ||
mstore(add(pPairing_, 352), BETA_Y2) | ||
|
||
/// @dev public signals | ||
mstore(add(pPairing_, 384), mload(pointer_)) | ||
mstore(add(pPairing_, 416), mload(add(pointer_, 32))) | ||
|
||
/// @dev gamma2 | ||
mstore(add(pPairing_, 448), GAMMA_X1) | ||
mstore(add(pPairing_, 480), GAMMA_X2) | ||
mstore(add(pPairing_, 512), GAMMA_Y1) | ||
mstore(add(pPairing_, 544), GAMMA_Y2) | ||
|
||
/// @dev C | ||
mstore(add(pPairing_, 576), mload(pC_)) | ||
mstore(add(pPairing_, 608), mload(add(pC_, 32))) | ||
|
||
/// @dev delta2 | ||
mstore(add(pPairing_, 640), DELTA_X1) | ||
mstore(add(pPairing_, 672), DELTA_X2) | ||
mstore(add(pPairing_, 704), DELTA_Y1) | ||
mstore(add(pPairing_, 736), DELTA_Y2) | ||
|
||
res_ := staticcall(sub(gas(), 2000), 8, pPairing_, 768, pPairing_, 32) // ecPairing | ||
res_ := and(res_, mload(pPairing_)) // check that pairing succeeded | ||
} | ||
|
||
let pointer_ := mload(64) // free pointer | ||
mstore(64, add(pointer_, P_TOTAL_SIZE)) | ||
|
||
/// @dev check that all public signals are in F | ||
verified_ := 1 | ||
verified_ := and(verified_, checkField(mload(add(publicSignals_, 0)))) | ||
|
||
/// @dev check pairings | ||
if not(iszero(verified_)) { | ||
verified_ := checkPairing(pointA_, pointB_, pointC_, publicSignals_, pointer_) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.