@fatsolutions/privacy-pools-core-circuits 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/artifacts/commitment.vkey +109 -0
- package/artifacts/commitment.wasm +0 -0
- package/artifacts/commitment.zkey +0 -0
- package/artifacts/withdraw.vkey +129 -0
- package/artifacts/withdraw.wasm +0 -0
- package/artifacts/withdraw.zkey +0 -0
- package/dist/circuits.d.ts +25 -0
- package/dist/circuits.d.ts.map +1 -0
- package/dist/circuits.js +92 -0
- package/dist/circuits.js.map +1 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +14 -0
- package/dist/errors.js.map +1 -0
- package/dist/fetchArtifacts.d.ts +2 -0
- package/dist/fetchArtifacts.d.ts.map +1 -0
- package/dist/fetchArtifacts.esm.d.ts +2 -0
- package/dist/fetchArtifacts.esm.d.ts.map +1 -0
- package/dist/fetchArtifacts.esm.js +10 -0
- package/dist/fetchArtifacts.esm.js.map +1 -0
- package/dist/fetchArtifacts.js +9 -0
- package/dist/fetchArtifacts.js.map +1 -0
- package/dist/fetchArtifacts.node.d.ts +2 -0
- package/dist/fetchArtifacts.node.d.ts.map +1 -0
- package/dist/fetchArtifacts.node.js +23 -0
- package/dist/fetchArtifacts.node.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Privacy Pool Circuits
|
|
2
|
+
|
|
3
|
+
This package contains the zero-knowledge circuit implementations for the Privacy Pool protocol. The circuits are written in Circom and are designed to work together to enable private withdrawals with membership proofs.
|
|
4
|
+
|
|
5
|
+
## Circuit Architecture
|
|
6
|
+
|
|
7
|
+
The protocol implements three main circuits that work together:
|
|
8
|
+
|
|
9
|
+
### Withdrawal Circuit
|
|
10
|
+
|
|
11
|
+
The withdrawal circuit verifies that a user can privately withdraw funds from the protocol. It takes as input:
|
|
12
|
+
|
|
13
|
+
- The withdrawal amount and details
|
|
14
|
+
- The unique related commitments identifier (label)
|
|
15
|
+
- A state root and ASP (Association Set Provider) root
|
|
16
|
+
- A proof of inclusion in the state tree
|
|
17
|
+
- A proof of inclusion in the ASP tree
|
|
18
|
+
- Nullifier and commitment secrets
|
|
19
|
+
|
|
20
|
+
The circuit ensures the withdrawal is valid by verifying:
|
|
21
|
+
|
|
22
|
+
- The user knows the preimage of the commitment
|
|
23
|
+
- The commitment exists in the state tree
|
|
24
|
+
- The comimtment label is included in the ASP tree
|
|
25
|
+
- The withdrawal amount is valid and matches the commitment
|
|
26
|
+
|
|
27
|
+
### LeanIMT Circuit
|
|
28
|
+
|
|
29
|
+
The LeanIMT (Lean Incremental Merkle Tree) circuit handles merkle tree operations. It implements an optimized merkle tree that:
|
|
30
|
+
|
|
31
|
+
- Supports dynamic depth
|
|
32
|
+
- Optimizes node computations by propagating single child values
|
|
33
|
+
- Verifies inclusion proofs efficiently
|
|
34
|
+
|
|
35
|
+
### Commitment Circuit
|
|
36
|
+
|
|
37
|
+
The commitment circuit manages the hashing and verification of commitments. It:
|
|
38
|
+
|
|
39
|
+
- Computes commitment hashes from input values and secrets
|
|
40
|
+
- Generates nullifier hashes for preventing double-spending
|
|
41
|
+
- Creates precommitment hashes for privacy preservation
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
### Prerequisites
|
|
46
|
+
|
|
47
|
+
- Node.js 20+
|
|
48
|
+
- Yarn
|
|
49
|
+
- circom 2.2.0+
|
|
50
|
+
|
|
51
|
+
### Building
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Compile circuits
|
|
55
|
+
yarn compile
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Testing
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Run circuit tests
|
|
62
|
+
yarn test
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Generating Groth16 Solidity verifiers
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Generate verifier for the withdrawal circuit
|
|
69
|
+
yarn gencontract:withdraw
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Generate verifier for the commitment circuit
|
|
74
|
+
yarn gencontract:commitment
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Directory Structure
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
circuits/
|
|
81
|
+
├── circuits/
|
|
82
|
+
│ ├── commitment.circom # Commitment circuit
|
|
83
|
+
│ ├── merkleTree.circom # LeanIMT circuit
|
|
84
|
+
│ └── withdraw.circom # Withdrawal circuit
|
|
85
|
+
└── tests/ # Circuit tests
|
|
86
|
+
```
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "groth16",
|
|
3
|
+
"curve": "bn128",
|
|
4
|
+
"nPublic": 4,
|
|
5
|
+
"vk_alpha_1": [
|
|
6
|
+
"16428432848801857252194528405604668803277877773566238944394625302971855135431",
|
|
7
|
+
"16846502678714586896801519656441059708016666274385668027902869494772365009666",
|
|
8
|
+
"1"
|
|
9
|
+
],
|
|
10
|
+
"vk_beta_2": [
|
|
11
|
+
[
|
|
12
|
+
"16348171800823588416173124589066524623406261996681292662100840445103873053252",
|
|
13
|
+
"3182164110458002340215786955198810119980427837186618912744689678939861918171"
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
"19687132236965066906216944365591810874384658708175106803089633851114028275753",
|
|
17
|
+
"4920802715848186258981584729175884379674325733638798907835771393452862684714"
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
"1",
|
|
21
|
+
"0"
|
|
22
|
+
]
|
|
23
|
+
],
|
|
24
|
+
"vk_gamma_2": [
|
|
25
|
+
[
|
|
26
|
+
"10857046999023057135944570762232829481370756359578518086990519993285655852781",
|
|
27
|
+
"11559732032986387107991004021392285783925812861821192530917403151452391805634"
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
|
|
31
|
+
"4082367875863433681332203403145435568316851327593401208105741076214120093531"
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
"1",
|
|
35
|
+
"0"
|
|
36
|
+
]
|
|
37
|
+
],
|
|
38
|
+
"vk_delta_2": [
|
|
39
|
+
[
|
|
40
|
+
"21776852187814503669288941195438703300133533055551110414135507755772009048755",
|
|
41
|
+
"14071349277984160738769650232570048842420599174481891079570637520850148195985"
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
"14829896038465638754619183039629777804281009075842360651276603555963792313589",
|
|
45
|
+
"17768817325504614104442767796226297300876042529701251019410487903768062418156"
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
"1",
|
|
49
|
+
"0"
|
|
50
|
+
]
|
|
51
|
+
],
|
|
52
|
+
"vk_alphabeta_12": [
|
|
53
|
+
[
|
|
54
|
+
[
|
|
55
|
+
"5275725312362878540782176211860327475781113689246818544623830805017503247034",
|
|
56
|
+
"700769043921060225711174322502145319612473365595920873303028146383045646735"
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
"16577533945604560505206253312979863148043263406037367789711279754781525822966",
|
|
60
|
+
"9408338099405950952721388539539775335199747835458172188116297223654842340186"
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"12663399896275491035004982800573482669934131767886952660443268164480899034271",
|
|
64
|
+
"4432711152773877173921024337047412943791122852326272337530740732443732395954"
|
|
65
|
+
]
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
[
|
|
69
|
+
"13121778684901402722679281862736806628725205381360313795132945954337708567513",
|
|
70
|
+
"9534744673358550231812045647241180985734073058548683258847806241019905135720"
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
"21329152369227346659770815132468371951064045353268189088026893413117512652875",
|
|
74
|
+
"17209195434408943681049655974234541356066884378594227002358272904159790622854"
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"5346467096835895366917814311591075634165750361894629082277248282132405045579",
|
|
78
|
+
"15508364027636868967189209273443690126627947943852338696115233789046842639684"
|
|
79
|
+
]
|
|
80
|
+
]
|
|
81
|
+
],
|
|
82
|
+
"IC": [
|
|
83
|
+
[
|
|
84
|
+
"19389685603863983493459600466245000912176323935722089191442216924893875659471",
|
|
85
|
+
"21368310947604120084615976168620713319957912144314383367152441982584687704754",
|
|
86
|
+
"1"
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
"20480370908727861268768811690351970824724320271007139967515539994552383745448",
|
|
90
|
+
"6543788534290546924704177190532160218635019071447323280686282609769447108534",
|
|
91
|
+
"1"
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
"6221997045242061390626775825094098886891157777390462309437733708122892686303",
|
|
95
|
+
"2977171917149158683110905238240269877054732203916711132834349252293157981665",
|
|
96
|
+
"1"
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"17383678627611548606682427983617497767432126302933563182026534678391392668921",
|
|
100
|
+
"3215629258564266791517073142612182991488671524212271597007691057737644736842",
|
|
101
|
+
"1"
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
"8279881556386467131443125483794142587933910369215858657040335636659378561647",
|
|
105
|
+
"13829047140424789745087385395711127297752590615995160902909738061982036826097",
|
|
106
|
+
"1"
|
|
107
|
+
]
|
|
108
|
+
]
|
|
109
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "groth16",
|
|
3
|
+
"curve": "bn128",
|
|
4
|
+
"nPublic": 8,
|
|
5
|
+
"vk_alpha_1": [
|
|
6
|
+
"16428432848801857252194528405604668803277877773566238944394625302971855135431",
|
|
7
|
+
"16846502678714586896801519656441059708016666274385668027902869494772365009666",
|
|
8
|
+
"1"
|
|
9
|
+
],
|
|
10
|
+
"vk_beta_2": [
|
|
11
|
+
[
|
|
12
|
+
"16348171800823588416173124589066524623406261996681292662100840445103873053252",
|
|
13
|
+
"3182164110458002340215786955198810119980427837186618912744689678939861918171"
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
"19687132236965066906216944365591810874384658708175106803089633851114028275753",
|
|
17
|
+
"4920802715848186258981584729175884379674325733638798907835771393452862684714"
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
"1",
|
|
21
|
+
"0"
|
|
22
|
+
]
|
|
23
|
+
],
|
|
24
|
+
"vk_gamma_2": [
|
|
25
|
+
[
|
|
26
|
+
"10857046999023057135944570762232829481370756359578518086990519993285655852781",
|
|
27
|
+
"11559732032986387107991004021392285783925812861821192530917403151452391805634"
|
|
28
|
+
],
|
|
29
|
+
[
|
|
30
|
+
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
|
|
31
|
+
"4082367875863433681332203403145435568316851327593401208105741076214120093531"
|
|
32
|
+
],
|
|
33
|
+
[
|
|
34
|
+
"1",
|
|
35
|
+
"0"
|
|
36
|
+
]
|
|
37
|
+
],
|
|
38
|
+
"vk_delta_2": [
|
|
39
|
+
[
|
|
40
|
+
"11377546232269146885719711323617440487334358631817944307305954377320021081609",
|
|
41
|
+
"355730187017390060257088699243557931444743893437609284639879195946356391671"
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
"14925671126934765953425446845541707408298799882358491896288696759849089416456",
|
|
45
|
+
"14828571047823507951936654719331566168682863576761372686128260593891040163007"
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
"1",
|
|
49
|
+
"0"
|
|
50
|
+
]
|
|
51
|
+
],
|
|
52
|
+
"vk_alphabeta_12": [
|
|
53
|
+
[
|
|
54
|
+
[
|
|
55
|
+
"5275725312362878540782176211860327475781113689246818544623830805017503247034",
|
|
56
|
+
"700769043921060225711174322502145319612473365595920873303028146383045646735"
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
"16577533945604560505206253312979863148043263406037367789711279754781525822966",
|
|
60
|
+
"9408338099405950952721388539539775335199747835458172188116297223654842340186"
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"12663399896275491035004982800573482669934131767886952660443268164480899034271",
|
|
64
|
+
"4432711152773877173921024337047412943791122852326272337530740732443732395954"
|
|
65
|
+
]
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
[
|
|
69
|
+
"13121778684901402722679281862736806628725205381360313795132945954337708567513",
|
|
70
|
+
"9534744673358550231812045647241180985734073058548683258847806241019905135720"
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
"21329152369227346659770815132468371951064045353268189088026893413117512652875",
|
|
74
|
+
"17209195434408943681049655974234541356066884378594227002358272904159790622854"
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"5346467096835895366917814311591075634165750361894629082277248282132405045579",
|
|
78
|
+
"15508364027636868967189209273443690126627947943852338696115233789046842639684"
|
|
79
|
+
]
|
|
80
|
+
]
|
|
81
|
+
],
|
|
82
|
+
"IC": [
|
|
83
|
+
[
|
|
84
|
+
"20917852783971662989037834579922189207796850157455689196836407829693273058181",
|
|
85
|
+
"14309172700509163829827835936087829189193823544006124999667589607573555153317",
|
|
86
|
+
"1"
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
"4002318554163308338961115195600756325669504095744400749661836505711747131480",
|
|
90
|
+
"19388553801400869339697580180794985615392396320851212290435880306887322433262",
|
|
91
|
+
"1"
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
"4254123736274716305094004322466639736349000292613093104635160011340821139688",
|
|
95
|
+
"19581123507269704428735684612376263280905609143077051758684797548075203355862",
|
|
96
|
+
"1"
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"12829149822163537636941647022474968478908625676617259064999683111486877280191",
|
|
100
|
+
"11906986527782177454913261933143777359684553833291705890148735374364062300950",
|
|
101
|
+
"1"
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
"14959519196996577022953934863461427249996916985368164934760550902108247251314",
|
|
105
|
+
"17153998018818455451015682095753537372058398415644924731407055981674255991568",
|
|
106
|
+
"1"
|
|
107
|
+
],
|
|
108
|
+
[
|
|
109
|
+
"386592992276936501107132673378759567169940445750810516666781824566579325489",
|
|
110
|
+
"6545363418535856048783449340812901581000301323807547677423370106415935030419",
|
|
111
|
+
"1"
|
|
112
|
+
],
|
|
113
|
+
[
|
|
114
|
+
"14405334651179970829248032802453416652902403107461697011217734903378819167500",
|
|
115
|
+
"5941867495000526980426755384727509338287954936978959436019043816230884260430",
|
|
116
|
+
"1"
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
"6593325309923573421969784559603844408437482353554868263039840702125354704945",
|
|
120
|
+
"19710681365262161445645108505967116609968223704683705865914938644210040221046",
|
|
121
|
+
"1"
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
"13832774438085654502815602896317109691851791928314457690314578958243235503172",
|
|
125
|
+
"2034154171145211628085643224823864015412822036123513499722451852634747199812",
|
|
126
|
+
"1"
|
|
127
|
+
]
|
|
128
|
+
]
|
|
129
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Binaries, CircuitArtifacts, CircuitNameString, CircuitsInterface, VersionString } from "./types.js";
|
|
2
|
+
interface CircuitOptions {
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
browser?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class Circuits implements CircuitsInterface {
|
|
7
|
+
protected initialized: boolean;
|
|
8
|
+
protected version: VersionString;
|
|
9
|
+
protected binaries: Binaries;
|
|
10
|
+
protected baseUrl: string;
|
|
11
|
+
protected readonly browser: boolean;
|
|
12
|
+
constructor(options?: CircuitOptions);
|
|
13
|
+
_browser(): boolean;
|
|
14
|
+
protected _initialize(binaries: Binaries, version: VersionString): void;
|
|
15
|
+
protected _handleInitialization(version?: VersionString): Promise<void>;
|
|
16
|
+
_fetchVersionedArtifact(artifactPath: string): Promise<Uint8Array>;
|
|
17
|
+
_downloadCircuitArtifacts(circuitName: CircuitNameString): Promise<CircuitArtifacts>;
|
|
18
|
+
downloadArtifacts(_version: VersionString): Promise<Binaries>;
|
|
19
|
+
initArtifacts(version: VersionString): Promise<void>;
|
|
20
|
+
getVerificationKey(circuitName: CircuitNameString, version?: VersionString): Promise<Uint8Array>;
|
|
21
|
+
getProvingKey(circuitName: CircuitNameString, version?: VersionString): Promise<Uint8Array>;
|
|
22
|
+
getWasm(circuitName: CircuitNameString, version?: VersionString): Promise<Uint8Array>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=circuits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuits.d.ts","sourceRoot":"","sources":["../lib/circuits.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,gBAAgB,EAEhB,iBAAiB,EACjB,iBAAiB,EAGjB,aAAa,EACd,MAAM,YAAY,CAAC;AAGpB,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,QAAS,YAAW,iBAAiB;IAChD,SAAS,CAAC,WAAW,EAAE,OAAO,CAAS;IACvC,SAAS,CAAC,OAAO,EAAE,aAAa,CAAkB;IAClD,SAAS,CAAC,QAAQ,EAAG,QAAQ,CAAC;IAC9B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAwC;IACjE,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAQ;gBAE/B,OAAO,CAAC,EAAE,cAAc;IASpC,QAAQ,IAAI,OAAO;IAInB,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa;cAMhD,qBAAqB,CACnC,OAAO,GAAE,aAA8B;IAgBnC,uBAAuB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAQlE,yBAAyB,CAC7B,WAAW,EAAE,iBAAiB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAUtB,iBAAiB,CACrB,QAAQ,EAAE,aAAa,GACtB,OAAO,CAAC,QAAQ,CAAC;IAQd,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD,kBAAkB,CACtB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE,aAA8B,GACtC,OAAO,CAAC,UAAU,CAAC;IAWhB,aAAa,CACjB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE,aAA8B,GACtC,OAAO,CAAC,UAAU,CAAC;IAWhB,OAAO,CACX,WAAW,EAAE,iBAAiB,EAC9B,OAAO,GAAE,aAA8B,GACtC,OAAO,CAAC,UAAU,CAAC;CAUvB"}
|
package/dist/circuits.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CircuitInitialization, FetchArtifact } from "./errors.js";
|
|
2
|
+
import { CircuitName, circuitToAsset, Version, } from "./types.js";
|
|
3
|
+
import { importFetchVersionedArtifact } from "./fetchArtifacts.js";
|
|
4
|
+
export class Circuits {
|
|
5
|
+
initialized = false;
|
|
6
|
+
version = Version.Latest;
|
|
7
|
+
binaries;
|
|
8
|
+
baseUrl = new URL("../", import.meta.url).href;
|
|
9
|
+
browser = true;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
if (options?.baseUrl) {
|
|
12
|
+
this.baseUrl = options.baseUrl;
|
|
13
|
+
}
|
|
14
|
+
if (options?.browser !== undefined) {
|
|
15
|
+
this.browser = options.browser;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
_browser() {
|
|
19
|
+
return typeof window !== "undefined";
|
|
20
|
+
}
|
|
21
|
+
_initialize(binaries, version) {
|
|
22
|
+
this.binaries = binaries;
|
|
23
|
+
this.version = version;
|
|
24
|
+
this.initialized = true;
|
|
25
|
+
}
|
|
26
|
+
async _handleInitialization(version = Version.Latest) {
|
|
27
|
+
if (!this.initialized || this.binaries === undefined) {
|
|
28
|
+
try {
|
|
29
|
+
await this.initArtifacts(version);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
if (e instanceof FetchArtifact) {
|
|
33
|
+
throw new CircuitInitialization(`${e.name}: ${e.message}`);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.error(e);
|
|
37
|
+
throw new CircuitInitialization(`UnknownError: ${e}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async _fetchVersionedArtifact(artifactPath) {
|
|
43
|
+
const artifactUrl = new URL(artifactPath, this.baseUrl);
|
|
44
|
+
const { fetchVersionedArtifact } = await importFetchVersionedArtifact(this.browser);
|
|
45
|
+
return fetchVersionedArtifact(artifactUrl);
|
|
46
|
+
}
|
|
47
|
+
async _downloadCircuitArtifacts(circuitName) {
|
|
48
|
+
const assetName = circuitToAsset[circuitName];
|
|
49
|
+
const [wasm, vkey, zkey] = await Promise.all([
|
|
50
|
+
this._fetchVersionedArtifact(["artifacts", assetName.wasm].join("/")),
|
|
51
|
+
this._fetchVersionedArtifact(["artifacts", assetName.vkey].join("/")),
|
|
52
|
+
this._fetchVersionedArtifact(["artifacts", assetName.zkey].join("/")),
|
|
53
|
+
]);
|
|
54
|
+
return { wasm, vkey, zkey };
|
|
55
|
+
}
|
|
56
|
+
async downloadArtifacts(_version) {
|
|
57
|
+
const [commitment, withdraw] = await Promise.all([
|
|
58
|
+
this._downloadCircuitArtifacts(CircuitName.Commitment),
|
|
59
|
+
this._downloadCircuitArtifacts(CircuitName.Withdraw),
|
|
60
|
+
]);
|
|
61
|
+
return { commitment, withdraw };
|
|
62
|
+
}
|
|
63
|
+
async initArtifacts(version) {
|
|
64
|
+
const binaries = await this.downloadArtifacts(version);
|
|
65
|
+
this._initialize(binaries, version);
|
|
66
|
+
}
|
|
67
|
+
async getVerificationKey(circuitName, version = Version.Latest) {
|
|
68
|
+
await this._handleInitialization(version);
|
|
69
|
+
const artifacts = this.binaries[circuitName];
|
|
70
|
+
if (!artifacts) {
|
|
71
|
+
throw new CircuitInitialization(`Circuit artifacts not found for ${circuitName}`);
|
|
72
|
+
}
|
|
73
|
+
return artifacts.vkey;
|
|
74
|
+
}
|
|
75
|
+
async getProvingKey(circuitName, version = Version.Latest) {
|
|
76
|
+
await this._handleInitialization(version);
|
|
77
|
+
const artifacts = this.binaries[circuitName];
|
|
78
|
+
if (!artifacts) {
|
|
79
|
+
throw new CircuitInitialization(`Circuit artifacts not found for ${circuitName}`);
|
|
80
|
+
}
|
|
81
|
+
return artifacts.zkey;
|
|
82
|
+
}
|
|
83
|
+
async getWasm(circuitName, version = Version.Latest) {
|
|
84
|
+
await this._handleInitialization(version);
|
|
85
|
+
const artifacts = this.binaries[circuitName];
|
|
86
|
+
if (!artifacts) {
|
|
87
|
+
throw new CircuitInitialization(`Circuit artifacts not found for ${circuitName}`);
|
|
88
|
+
}
|
|
89
|
+
return artifacts.wasm;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=circuits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circuits.js","sourceRoot":"","sources":["../lib/circuits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAGL,WAAW,EAGX,cAAc,EACd,OAAO,GAER,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAOnE,MAAM,OAAO,QAAQ;IACT,WAAW,GAAY,KAAK,CAAC;IAC7B,OAAO,GAAkB,OAAO,CAAC,MAAM,CAAC;IACxC,QAAQ,CAAY;IACpB,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|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,QAAQ,EAAE,GAAG;CAK1B;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class FetchArtifact extends Error {
|
|
2
|
+
constructor(artifact) {
|
|
3
|
+
const message = `Encountered error while loading artifact at ${artifact.toString()}.`;
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "FetchArtifact";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class CircuitInitialization extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(`There was an error initializing the circuits: ${message}`);
|
|
11
|
+
this.name = "CircuitInitialization";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,QAAa;QACvB,MAAM,OAAO,GAAG,+CAA+C,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;QACtF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,iDAAiD,OAAO,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.d.ts","sourceRoot":"","sources":["../lib/fetchArtifacts.ts"],"names":[],"mappings":"AAAA,wBAAsB,4BAA4B,CAAC,SAAS,EAAE,OAAO,qDAMpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.esm.d.ts","sourceRoot":"","sources":["../lib/fetchArtifacts.esm.ts"],"names":[],"mappings":"AAEA,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,GAAG,GACf,OAAO,CAAC,UAAU,CAAC,CAOrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FetchArtifact } from "./errors.js";
|
|
2
|
+
export async function fetchVersionedArtifact(artifactUrl) {
|
|
3
|
+
const res = await fetch(artifactUrl);
|
|
4
|
+
if (res.status !== 200) {
|
|
5
|
+
throw new FetchArtifact(artifactUrl);
|
|
6
|
+
}
|
|
7
|
+
const aBuf = await res.arrayBuffer();
|
|
8
|
+
return new Uint8Array(aBuf);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=fetchArtifacts.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.esm.js","sourceRoot":"","sources":["../lib/fetchArtifacts.esm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,WAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,CAAC;IACrC,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC;IACrC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.js","sourceRoot":"","sources":["../lib/fetchArtifacts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAAC,SAAkB;IACnE,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAC3C,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.node.d.ts","sourceRoot":"","sources":["../lib/fetchArtifacts.node.ts"],"names":[],"mappings":"AAEA,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,GAAG,GACf,OAAO,CAAC,UAAU,CAAC,CAkBrB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FetchArtifact } from "./errors.js";
|
|
2
|
+
export async function fetchVersionedArtifact(artifactUrl) {
|
|
3
|
+
try {
|
|
4
|
+
const fs = (await import("fs")).default;
|
|
5
|
+
const readPromise = new Promise((resolve, reject) => {
|
|
6
|
+
fs.readFile(artifactUrl.pathname, (err, data) => {
|
|
7
|
+
if (err) {
|
|
8
|
+
reject(err);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
resolve(data);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
const buf = await readPromise;
|
|
16
|
+
return new Uint8Array(buf);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error(error);
|
|
20
|
+
throw new FetchArtifact(artifactUrl);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=fetchArtifacts.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.node.js","sourceRoot":"","sources":["../lib/fetchArtifacts.node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,WAAgB;IAEhB,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;QACxC,MAAM,WAAW,GAAoB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC9C,IAAI,GAAG,EAAE,CAAC;oBACR,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC;QAC9B,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Circuits } from "./circuits.js";
|
|
2
|
+
export { CircuitName, Version, circuitToAsset, } from "./types.js";
|
|
3
|
+
export type { CircuitsInterface, CircuitNameString, VersionString, CircuitArtifacts, Binaries, Circ2Asset, } from "./types.js";
|
|
4
|
+
export { FetchArtifact, CircuitInitialization } from "./errors.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,WAAW,EACX,OAAO,EACP,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,WAAW,EACX,OAAO,EACP,cAAc,GACf,MAAM,YAAY,CAAC;AASpB,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare enum Version {
|
|
2
|
+
Latest = "latest"
|
|
3
|
+
}
|
|
4
|
+
export type VersionString = `${Version}`;
|
|
5
|
+
export declare enum CircuitName {
|
|
6
|
+
Commitment = "commitment",
|
|
7
|
+
Withdraw = "withdraw"
|
|
8
|
+
}
|
|
9
|
+
export type CircuitNameString = `${CircuitName}`;
|
|
10
|
+
export interface CircuitArtifacts {
|
|
11
|
+
wasm: Uint8Array;
|
|
12
|
+
vkey: Uint8Array;
|
|
13
|
+
zkey: Uint8Array;
|
|
14
|
+
}
|
|
15
|
+
export type Circ2Asset = {
|
|
16
|
+
[key in CircuitName]: {
|
|
17
|
+
wasm: string;
|
|
18
|
+
vkey: string;
|
|
19
|
+
zkey: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare const circuitToAsset: Circ2Asset;
|
|
23
|
+
export interface Binaries {
|
|
24
|
+
commitment: CircuitArtifacts;
|
|
25
|
+
withdraw: CircuitArtifacts;
|
|
26
|
+
}
|
|
27
|
+
export interface CircuitsInterface {
|
|
28
|
+
downloadArtifacts(version: VersionString): Promise<Binaries>;
|
|
29
|
+
initArtifacts(version: VersionString): Promise<void>;
|
|
30
|
+
getVerificationKey(circuitName: CircuitNameString, version?: VersionString): Promise<Uint8Array>;
|
|
31
|
+
getProvingKey(circuitName: CircuitNameString, version?: VersionString): Promise<Uint8Array>;
|
|
32
|
+
getWasm(circuitName: CircuitNameString, version?: VersionString): Promise<Uint8Array>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,aAAa,GAAG,GAAG,OAAO,EAAE,CAAC;AAEzC,oBAAY,WAAW;IACrB,UAAU,eAAe;IACzB,QAAQ,aAAa;CACtB;AAED,MAAM,MAAM,iBAAiB,GAAG,GAAG,WAAW,EAAE,CAAC;AAEjD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG;KACtB,GAAG,IAAI,WAAW,GAAG;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd;CACF,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,UAWnB,CAAC;AAEX,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7D,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,kBAAkB,CAChB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,aAAa,CACX,WAAW,EAAE,iBAAiB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB,OAAO,CACL,WAAW,EAAE,iBAAiB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export var Version;
|
|
2
|
+
(function (Version) {
|
|
3
|
+
Version["Latest"] = "latest";
|
|
4
|
+
})(Version || (Version = {}));
|
|
5
|
+
export var CircuitName;
|
|
6
|
+
(function (CircuitName) {
|
|
7
|
+
CircuitName["Commitment"] = "commitment";
|
|
8
|
+
CircuitName["Withdraw"] = "withdraw";
|
|
9
|
+
})(CircuitName || (CircuitName = {}));
|
|
10
|
+
export const circuitToAsset = {
|
|
11
|
+
[CircuitName.Commitment]: {
|
|
12
|
+
wasm: "commitment.wasm",
|
|
13
|
+
vkey: "commitment.vkey",
|
|
14
|
+
zkey: "commitment.zkey",
|
|
15
|
+
},
|
|
16
|
+
[CircuitName.Withdraw]: {
|
|
17
|
+
wasm: "withdraw.wasm",
|
|
18
|
+
vkey: "withdraw.vkey",
|
|
19
|
+
zkey: "withdraw.zkey",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,OAEX;AAFD,WAAY,OAAO;IACjB,4BAAiB,CAAA;AACnB,CAAC,EAFW,OAAO,KAAP,OAAO,QAElB;AAID,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,oCAAqB,CAAA;AACvB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAkBD,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE;QACxB,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,iBAAiB;KACxB;IACD,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QACtB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,eAAe;KACtB;CACO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fatsolutions/privacy-pools-core-circuits",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Circom circuits and pre-built artifacts for the Privacy Pool protocol",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/0xbow-io/privacy-pools-core.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"author": "Wonderland",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./artifacts/*": "./artifacts/*"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"artifacts"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build:lib": "tsc -p tsconfig.build.json",
|
|
28
|
+
"stage-artifacts": "sh ./scripts/present.sh",
|
|
29
|
+
"compile": "npx ts-node -P tsconfig.json ./src/index.ts",
|
|
30
|
+
"test": "npx mocha",
|
|
31
|
+
"test:merkle": "npx mocha --ignore tests/commitment.test.ts --ignore tests/withdrawal.test.ts",
|
|
32
|
+
"test:withdraw": "npx mocha --ignore tests/commitment.test.ts --ignore tests/lean-imt.test.ts",
|
|
33
|
+
"test:commitment": "npx mocha --ignore tests/withdrawal.test.ts --ignore tests/lean-imt.test.ts",
|
|
34
|
+
"circomspect": "circomspect -L ../../node_modules/circomlib/circuits/comparators.circom -L ../../node_modules/circomlib/circuits/mux1.circom -L ../../node_modules/circomlib/circuits/poseidon.circom ./circuits/*",
|
|
35
|
+
"info:withdraw": "npx circomkit info withdraw",
|
|
36
|
+
"info:commitment": "npx circomkit info commitment",
|
|
37
|
+
"setup:ptau": "npx circomkit ptau withdraw",
|
|
38
|
+
"setup:all": "yarn setup:ptau && yarn setup:withdraw && yarn setup:merkle && yarn setup:commitment",
|
|
39
|
+
"setup:withdraw": "npx circomkit setup withdraw ptau/powersOfTau28_hez_final_16.ptau",
|
|
40
|
+
"setup:commitment": "npx circomkit setup commitment ptau/powersOfTau28_hez_final_16.ptau",
|
|
41
|
+
"setup:merkle": "npx circomkit setup merkleTree ptau/powersOfTau28_hez_final_16.ptau",
|
|
42
|
+
"present": "sh ./scripts/present.sh",
|
|
43
|
+
"prove:withdraw": "npx circomkit prove withdraw default",
|
|
44
|
+
"prove:commitment": "npx circomkit prove commitment default",
|
|
45
|
+
"verify:withdraw": "npx circomkit verify withdraw default",
|
|
46
|
+
"verify:commitment": "npx circomkit verify commitment default",
|
|
47
|
+
"gencontract:withdraw": "npx snarkjs zkey export solidityverifier trusted-setup/final-keys/withdraw.zkey WithdrawalVerifier.sol",
|
|
48
|
+
"gencontract:commitment": "npx snarkjs zkey export solidityverifier trusted-setup/final-keys/commitment.zkey CommitmentVerifier.sol"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/mocha": "^10.0.1",
|
|
52
|
+
"@types/node": "20.3.1",
|
|
53
|
+
"@zk-kit/lean-imt": "2.2.2",
|
|
54
|
+
"chai": "5.1.2",
|
|
55
|
+
"circomkit": "0.3.2",
|
|
56
|
+
"circomlib": "2.0.5",
|
|
57
|
+
"maci-circuits": "2.5.0",
|
|
58
|
+
"maci-crypto": "2.5.0",
|
|
59
|
+
"mocha": "^10.2.0",
|
|
60
|
+
"snarkjs": "0.7.5",
|
|
61
|
+
"ts-node": "^10.9.1",
|
|
62
|
+
"typescript": "5.5.4",
|
|
63
|
+
"viem": "2.21.57"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public",
|
|
67
|
+
"registry": "https://registry.npmjs.org"
|
|
68
|
+
}
|
|
69
|
+
}
|