@solarity/zkit 0.2.5 → 0.2.6
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 +8 -8
- package/dist/core/CircuitZKit.d.ts +11 -10
- package/dist/core/CircuitZKit.d.ts.map +1 -1
- package/dist/core/CircuitZKit.js +16 -15
- package/dist/core/CircuitZKit.js.map +1 -1
- package/dist/core/templates/verifier_groth16.vy.ejs +118 -0
- package/dist/types/circuit-zkit.d.ts +3 -2
- package/dist/types/circuit-zkit.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/core/CircuitZKit.ts +18 -16
- package/src/core/templates/verifier_groth16.vy.ejs +118 -0
- package/src/types/circuit-zkit.ts +3 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
**A zero knowledge kit that helps you interact with Circom circuits.**
|
|
7
7
|
|
|
8
8
|
- Generate and verify ZK proofs with a single line of code.
|
|
9
|
-
- Render optimized Solidity verifiers.
|
|
9
|
+
- Render optimized Solidity | Vyper verifiers.
|
|
10
10
|
- Build and work with ZK witnesses.
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
@@ -33,7 +33,7 @@ CircuitZKitConfig = {
|
|
|
33
33
|
circuitName: string;
|
|
34
34
|
circuitArtifactsPath: string;
|
|
35
35
|
verifierDirPath: string;
|
|
36
|
-
|
|
36
|
+
provingSystem?: VerifierProvingSystem;
|
|
37
37
|
};
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -41,23 +41,23 @@ This config contains all the information required to work with the circuit, name
|
|
|
41
41
|
|
|
42
42
|
- `circuitName` - Name of the circuit file without extension
|
|
43
43
|
- `circuitArtifactsPath` - Full path to compilation artifacts for the desired circuit
|
|
44
|
-
- `verifierDirPath` - Full path to the directory where Solidity verifier file will be generated
|
|
45
|
-
- `
|
|
44
|
+
- `verifierDirPath` - Full path to the directory where Solidity | Vyper verifier file will be generated
|
|
45
|
+
- `provingSystem` - The proving system that will be used to generate the verifier contract. Right now only `groth16` is supported
|
|
46
46
|
|
|
47
47
|
#### getTemplate()
|
|
48
48
|
|
|
49
49
|
Static `CircuitZKit` function that returns the contents of a template file by the passed type.
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
|
-
const templateContent = CircuitZKit.getTemplate("groth16");
|
|
52
|
+
const templateContent = CircuitZKit.getTemplate("groth16", "sol");
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
#### createVerifier()
|
|
56
56
|
|
|
57
|
-
Creates a Solidity verifier contract on `verifierDirPath` path, which was specified in the config.
|
|
57
|
+
Creates a Solidity | Vyper verifier contract on `verifierDirPath` path, which was specified in the config.
|
|
58
58
|
|
|
59
59
|
```typescript
|
|
60
|
-
await multiplier.createVerifier();
|
|
60
|
+
await multiplier.createVerifier("sol");
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
#### calculateWitness()
|
|
@@ -89,7 +89,7 @@ const isValidProof = await multiplier.verifyProof(proof);
|
|
|
89
89
|
|
|
90
90
|
#### generateCalldata()
|
|
91
91
|
|
|
92
|
-
Generates calldata by proof for the Solidity verifier's `verifyProof()` method.
|
|
92
|
+
Generates calldata by proof for the Solidity | Vyper verifier's `verifyProof()` method.
|
|
93
93
|
|
|
94
94
|
```typescript
|
|
95
95
|
/// You can use this calldata to call the verifier contract
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArtifactsFileType, Calldata, CircuitZKitConfig, Signals, ProofStruct,
|
|
1
|
+
import { ArtifactsFileType, Calldata, CircuitZKitConfig, Signals, ProofStruct, VerifierProvingSystem, VerifierLanguageType } from "../types/circuit-zkit";
|
|
2
2
|
/**
|
|
3
3
|
* `CircuitZKit` represents a single circuit and provides a high-level API to work with it.
|
|
4
4
|
*/
|
|
@@ -6,16 +6,17 @@ export declare class CircuitZKit {
|
|
|
6
6
|
private readonly _config;
|
|
7
7
|
constructor(_config: CircuitZKitConfig);
|
|
8
8
|
/**
|
|
9
|
-
* Returns the
|
|
9
|
+
* Returns the verifier template for the specified proving system and contract language.
|
|
10
10
|
*
|
|
11
|
-
* @param {
|
|
12
|
-
* @
|
|
11
|
+
* @param {VerifierProvingSystem} provingSystem - The template proving system.
|
|
12
|
+
* @param {VerifierLanguageType} fileExtension - The file extension.
|
|
13
|
+
* @returns {string} The verifier template.
|
|
13
14
|
*/
|
|
14
|
-
static getTemplate(
|
|
15
|
+
static getTemplate(provingSystem: VerifierProvingSystem, fileExtension: VerifierLanguageType): string;
|
|
15
16
|
/**
|
|
16
|
-
* Creates a
|
|
17
|
+
* Creates a verifier contract for the specified contract language.
|
|
17
18
|
*/
|
|
18
|
-
createVerifier(): Promise<void>;
|
|
19
|
+
createVerifier(languageExtension: VerifierLanguageType): Promise<void>;
|
|
19
20
|
/**
|
|
20
21
|
* Calculates a witness for the given inputs.
|
|
21
22
|
*
|
|
@@ -64,11 +65,11 @@ export declare class CircuitZKit {
|
|
|
64
65
|
*/
|
|
65
66
|
getVerifierName(): string;
|
|
66
67
|
/**
|
|
67
|
-
* Returns the
|
|
68
|
+
* Returns the proving system of verifier template that was stored in the config
|
|
68
69
|
*
|
|
69
|
-
* @returns {
|
|
70
|
+
* @returns {VerifierProvingSystem} The verifier proving system.
|
|
70
71
|
*/
|
|
71
|
-
|
|
72
|
+
getProvingSystem(): VerifierProvingSystem;
|
|
72
73
|
/**
|
|
73
74
|
* Returns the path to the file of the given type inside artifacts directory. Throws an error if the file doesn't exist.
|
|
74
75
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircuitZKit.d.ts","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,iBAAiB;IAEvD
|
|
1
|
+
{"version":3,"file":"CircuitZKit.d.ts","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EACjB,OAAO,EACP,WAAW,EACX,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,iBAAiB;IAEvD;;;;;;OAMG;WACW,WAAW,CAAC,aAAa,EAAE,qBAAqB,EAAE,aAAa,EAAE,oBAAoB,GAAG,MAAM;IAS5G;;OAEG;IACU,cAAc,CAAC,iBAAiB,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBnF;;;;;OAKG;IACU,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAejE;;;;;;;;OAQG;IACU,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;IAOjE;;;;;;;;OAQG;IACU,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ9D;;;;;;OAMG;IACU,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAMpE;;;;OAIG;IACI,cAAc,IAAI,MAAM;IAI/B;;;;OAIG;IACI,eAAe,IAAI,MAAM;IAIhC;;;;OAIG;IACI,gBAAgB,IAAI,qBAAqB;IAIhD;;;;;OAKG;IACI,wBAAwB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM;IAUpE;;;;;OAKG;IACI,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM;CAgCjE"}
|
package/dist/core/CircuitZKit.js
CHANGED
|
@@ -41,26 +41,27 @@ class CircuitZKit {
|
|
|
41
41
|
this._config = _config;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
|
-
* Returns the
|
|
44
|
+
* Returns the verifier template for the specified proving system and contract language.
|
|
45
45
|
*
|
|
46
|
-
* @param {
|
|
47
|
-
* @
|
|
46
|
+
* @param {VerifierProvingSystem} provingSystem - The template proving system.
|
|
47
|
+
* @param {VerifierLanguageType} fileExtension - The file extension.
|
|
48
|
+
* @returns {string} The verifier template.
|
|
48
49
|
*/
|
|
49
|
-
static getTemplate(
|
|
50
|
-
switch (
|
|
50
|
+
static getTemplate(provingSystem, fileExtension) {
|
|
51
|
+
switch (provingSystem) {
|
|
51
52
|
case "groth16":
|
|
52
|
-
return fs_1.default.readFileSync(path_1.default.join(__dirname, "templates",
|
|
53
|
+
return fs_1.default.readFileSync(path_1.default.join(__dirname, "templates", `verifier_groth16.${fileExtension}.ejs`), "utf8");
|
|
53
54
|
default:
|
|
54
|
-
throw new Error(`Ambiguous
|
|
55
|
+
throw new Error(`Ambiguous proving system: ${provingSystem}.`);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
|
-
* Creates a
|
|
59
|
+
* Creates a verifier contract for the specified contract language.
|
|
59
60
|
*/
|
|
60
|
-
async createVerifier() {
|
|
61
|
+
async createVerifier(languageExtension) {
|
|
61
62
|
const vKeyFilePath = this.mustGetArtifactsFilePath("vkey");
|
|
62
|
-
const verifierFilePath = path_1.default.join(this._config.verifierDirPath, `${this.getVerifierName()}
|
|
63
|
-
const verifierTemplate = CircuitZKit.getTemplate(this.
|
|
63
|
+
const verifierFilePath = path_1.default.join(this._config.verifierDirPath, `${this.getVerifierName()}.${languageExtension}`);
|
|
64
|
+
const verifierTemplate = CircuitZKit.getTemplate(this.getProvingSystem(), languageExtension);
|
|
64
65
|
if (!fs_1.default.existsSync(this._config.verifierDirPath)) {
|
|
65
66
|
fs_1.default.mkdirSync(this._config.verifierDirPath, { recursive: true });
|
|
66
67
|
}
|
|
@@ -141,12 +142,12 @@ class CircuitZKit {
|
|
|
141
142
|
return `${this._config.circuitName}Verifier`;
|
|
142
143
|
}
|
|
143
144
|
/**
|
|
144
|
-
* Returns the
|
|
145
|
+
* Returns the proving system of verifier template that was stored in the config
|
|
145
146
|
*
|
|
146
|
-
* @returns {
|
|
147
|
+
* @returns {VerifierProvingSystem} The verifier proving system.
|
|
147
148
|
*/
|
|
148
|
-
|
|
149
|
-
return this._config.
|
|
149
|
+
getProvingSystem() {
|
|
150
|
+
return this._config.provingSystem ?? "groth16";
|
|
150
151
|
}
|
|
151
152
|
/**
|
|
152
153
|
* Returns the path to the file of the given type inside artifacts directory. Throws an error if the file doesn't exist.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircuitZKit.js","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,4CAAoB;AACpB,uCAAyB;AACzB,gDAAwB;AACxB,iDAAmC;
|
|
1
|
+
{"version":3,"file":"CircuitZKit.js","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,4CAAoB;AACpB,uCAAyB;AACzB,gDAAwB;AACxB,iDAAmC;AAYnC;;GAEG;AACH,MAAa,WAAW;IACO;IAA7B,YAA6B,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAE3D;;;;;;OAMG;IACI,MAAM,CAAC,WAAW,CAAC,aAAoC,EAAE,aAAmC;QACjG,QAAQ,aAAa,EAAE,CAAC;YACtB,KAAK,SAAS;gBACZ,OAAO,YAAE,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,oBAAoB,aAAa,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;YAC7G;gBACE,MAAM,IAAI,KAAK,CAAC,6BAA6B,aAAa,GAAG,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED;;OAEG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BAAmB,CAAC;gBAC7C,MAAM;YACR,KAAK,MAAM;gBACT,QAAQ,GAAG,GAAG,WAAW,OAAO,CAAC;gBACjC,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,WAAW,KAAK,CAAC,CAAC;gBAClD,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,GAAG,CAAC,CAAC;QACzD,CAAC;QAED,OAAO,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;CACF;AA5LD,kCA4LC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# pragma version ~=0.4.0
|
|
2
|
+
|
|
3
|
+
# AUTOGENERATED FILE BY HARDHAT-ZKIT. DO NOT EDIT.
|
|
4
|
+
|
|
5
|
+
# @dev base field size
|
|
6
|
+
BASE_FIELD_SIZE: constant(uint256) = 21888242871839275222246405745257275088696311157297823662689037894645226208583
|
|
7
|
+
|
|
8
|
+
# @dev verification key data
|
|
9
|
+
ALPHA_X: constant(uint256) = <%=vk_alpha_1[0]%>
|
|
10
|
+
ALPHA_Y: constant(uint256) = <%=vk_alpha_1[1]%>
|
|
11
|
+
BETA_X1: constant(uint256) = <%=vk_beta_2[0][1]%>
|
|
12
|
+
BETA_X2: constant(uint256) = <%=vk_beta_2[0][0]%>
|
|
13
|
+
BETA_Y1: constant(uint256) = <%=vk_beta_2[1][1]%>
|
|
14
|
+
BETA_Y2: constant(uint256) = <%=vk_beta_2[1][0]%>
|
|
15
|
+
GAMMA_X1: constant(uint256) = <%=vk_gamma_2[0][1]%>
|
|
16
|
+
GAMMA_X2: constant(uint256) = <%=vk_gamma_2[0][0]%>
|
|
17
|
+
GAMMA_Y1: constant(uint256) = <%=vk_gamma_2[1][1]%>
|
|
18
|
+
GAMMA_Y2: constant(uint256) = <%=vk_gamma_2[1][0]%>
|
|
19
|
+
DELTA_X1: constant(uint256) = <%=vk_delta_2[0][1]%>
|
|
20
|
+
DELTA_X2: constant(uint256) = <%=vk_delta_2[0][0]%>
|
|
21
|
+
DELTA_Y1: constant(uint256) = <%=vk_delta_2[1][1]%>
|
|
22
|
+
DELTA_Y2: constant(uint256) = <%=vk_delta_2[1][0] -%>
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
IC: constant(uint256[<%=IC.length%>][2]) = [
|
|
26
|
+
<% IC.forEach(function(innerArray, index) { %> [
|
|
27
|
+
<%= innerArray[0] %>,
|
|
28
|
+
<%= innerArray[1] %>
|
|
29
|
+
]<%= index < IC.length - 1 ? ',' : '' %>
|
|
30
|
+
<% }); %>]
|
|
31
|
+
|
|
32
|
+
EC_ADD_PRECOMPILED_ADDRESS: constant(address) = 0x0000000000000000000000000000000000000006
|
|
33
|
+
EC_MUL_PRECOMPILED_ADDRESS: constant(address) = 0x0000000000000000000000000000000000000007
|
|
34
|
+
EC_PAIRING_PRECOMPILED_ADDRESS: constant(address) = 0x0000000000000000000000000000000000000008
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@view
|
|
38
|
+
@external
|
|
39
|
+
def verifyProof(pointA: uint256[2], pointB: uint256[2][2], pointC: uint256[2], publicSignals: uint256[<%=IC.length-1%>]) -> bool:
|
|
40
|
+
# @dev check that all public signals are in F
|
|
41
|
+
for signal: uint256 in publicSignals:
|
|
42
|
+
if signal >= BASE_FIELD_SIZE:
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
return self._checkPairing(pointA, pointB, pointC, publicSignals)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@view
|
|
49
|
+
@internal
|
|
50
|
+
def _g1MulAdd(pR: uint256[2], pP: uint256[2], s: uint256) -> (bool, uint256[2]):
|
|
51
|
+
success: bool = True
|
|
52
|
+
response: Bytes[64] = b""
|
|
53
|
+
success, response = raw_call(
|
|
54
|
+
EC_MUL_PRECOMPILED_ADDRESS,
|
|
55
|
+
abi_encode(pP, s),
|
|
56
|
+
max_outsize=64,
|
|
57
|
+
is_static_call=True,
|
|
58
|
+
revert_on_failure=False
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
if not success or len(response) != 64:
|
|
62
|
+
return (False, [0, 0])
|
|
63
|
+
|
|
64
|
+
x: uint256 = convert(slice(response, 0, 32), uint256)
|
|
65
|
+
y: uint256 = convert(slice(response, 32, 32), uint256)
|
|
66
|
+
pS: uint256[2] = [x, y]
|
|
67
|
+
|
|
68
|
+
success, response = raw_call(
|
|
69
|
+
EC_ADD_PRECOMPILED_ADDRESS,
|
|
70
|
+
abi_encode(pR, pS),
|
|
71
|
+
max_outsize=64,
|
|
72
|
+
is_static_call=True,
|
|
73
|
+
revert_on_failure=False
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
if not success or len(response) != 64:
|
|
77
|
+
return (False, [0, 0])
|
|
78
|
+
|
|
79
|
+
x = convert(slice(response, 0, 32), uint256)
|
|
80
|
+
y = convert(slice(response, 32, 32), uint256)
|
|
81
|
+
|
|
82
|
+
return (True, [x, y])
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@view
|
|
86
|
+
@internal
|
|
87
|
+
def _checkPairing(pA: uint256[2], pB: uint256[2][2], pC: uint256[2], pubSignals: uint256[<%=IC.length-1%>]) -> bool:
|
|
88
|
+
success: bool = True
|
|
89
|
+
mulAddResult: uint256[2] = IC[0]
|
|
90
|
+
|
|
91
|
+
# @dev compute the linear combination of public signals
|
|
92
|
+
for i: uint256 in range(1, <%=IC.length%>):
|
|
93
|
+
success, mulAddResult = self._g1MulAdd(mulAddResult, IC[i], pubSignals[i - 1])
|
|
94
|
+
if not success:
|
|
95
|
+
return False
|
|
96
|
+
|
|
97
|
+
response: Bytes[32] = b""
|
|
98
|
+
success, response = raw_call(
|
|
99
|
+
EC_PAIRING_PRECOMPILED_ADDRESS,
|
|
100
|
+
abi_encode(
|
|
101
|
+
pA[0], (BASE_FIELD_SIZE - pA[1]) % BASE_FIELD_SIZE,
|
|
102
|
+
pB,
|
|
103
|
+
ALPHA_X, ALPHA_Y,
|
|
104
|
+
BETA_X1, BETA_X2, BETA_Y1, BETA_Y2,
|
|
105
|
+
mulAddResult,
|
|
106
|
+
GAMMA_X1, GAMMA_X2, GAMMA_Y1, GAMMA_Y2,
|
|
107
|
+
pC,
|
|
108
|
+
DELTA_X1, DELTA_X2, DELTA_Y1, DELTA_Y2
|
|
109
|
+
),
|
|
110
|
+
max_outsize=32,
|
|
111
|
+
is_static_call=True,
|
|
112
|
+
revert_on_failure=False
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if not success:
|
|
116
|
+
return False
|
|
117
|
+
|
|
118
|
+
return convert(response, bool)
|
|
@@ -31,11 +31,12 @@ export type ArrayLike = NumberLike[] | ArrayLike[];
|
|
|
31
31
|
export type Signal = NumberLike | ArrayLike;
|
|
32
32
|
export type Signals = Record<string, Signal>;
|
|
33
33
|
export type ArtifactsFileType = "r1cs" | "zkey" | "vkey" | "sym" | "json" | "wasm";
|
|
34
|
-
export type
|
|
34
|
+
export type VerifierProvingSystem = "groth16";
|
|
35
|
+
export type VerifierLanguageType = "sol" | "vy";
|
|
35
36
|
export type CircuitZKitConfig = {
|
|
36
37
|
circuitName: string;
|
|
37
38
|
circuitArtifactsPath: string;
|
|
38
39
|
verifierDirPath: string;
|
|
39
|
-
|
|
40
|
+
provingSystem?: VerifierProvingSystem;
|
|
40
41
|
};
|
|
41
42
|
//# sourceMappingURL=circuit-zkit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"circuit-zkit.d.ts","sourceRoot":"","sources":["../../src/types/circuit-zkit.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;AAEjD,MAAM,MAAM,aAAa,GAAG,aAAa,EAAE,CAAC;AAE5C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,aAAa,EAA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
|
"name": "@solarity/zkit",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Distributed Lab",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -43,18 +43,19 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@nomicfoundation/hardhat-ethers": "3.0.5",
|
|
46
|
-
"@
|
|
47
|
-
"@types/snarkjs": "^0.7.8",
|
|
46
|
+
"@nomiclabs/hardhat-vyper": "^3.0.7",
|
|
48
47
|
"@types/chai": "^4.3.12",
|
|
49
48
|
"@types/chai-as-promised": "^7.1.8",
|
|
49
|
+
"@types/ejs": "^3.1.5",
|
|
50
50
|
"@types/mocha": "^10.0.6",
|
|
51
|
+
"@types/snarkjs": "^0.7.8",
|
|
51
52
|
"chai": "^4.4.1",
|
|
52
53
|
"chai-as-promised": "^7.1.1",
|
|
53
|
-
"mocha": "^10.3.0",
|
|
54
|
-
"nyc": "^15.1.0",
|
|
55
54
|
"ethers": "6.11.1",
|
|
56
|
-
"hardhat": "2.
|
|
55
|
+
"hardhat": "2.22.7",
|
|
57
56
|
"husky": "^9.0.11",
|
|
57
|
+
"mocha": "^10.3.0",
|
|
58
|
+
"nyc": "^15.1.0",
|
|
58
59
|
"prettier": "^3.2.5",
|
|
59
60
|
"ts-node": "^10.9.2",
|
|
60
61
|
"typescript": "^5.4.5"
|
package/src/core/CircuitZKit.ts
CHANGED
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
CircuitZKitConfig,
|
|
11
11
|
Signals,
|
|
12
12
|
ProofStruct,
|
|
13
|
-
|
|
13
|
+
VerifierProvingSystem,
|
|
14
|
+
VerifierLanguageType,
|
|
14
15
|
} from "../types/circuit-zkit";
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -20,28 +21,29 @@ export class CircuitZKit {
|
|
|
20
21
|
constructor(private readonly _config: CircuitZKitConfig) {}
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
* Returns the
|
|
24
|
+
* Returns the verifier template for the specified proving system and contract language.
|
|
24
25
|
*
|
|
25
|
-
* @param {
|
|
26
|
-
* @
|
|
26
|
+
* @param {VerifierProvingSystem} provingSystem - The template proving system.
|
|
27
|
+
* @param {VerifierLanguageType} fileExtension - The file extension.
|
|
28
|
+
* @returns {string} The verifier template.
|
|
27
29
|
*/
|
|
28
|
-
public static getTemplate(
|
|
29
|
-
switch (
|
|
30
|
+
public static getTemplate(provingSystem: VerifierProvingSystem, fileExtension: VerifierLanguageType): string {
|
|
31
|
+
switch (provingSystem) {
|
|
30
32
|
case "groth16":
|
|
31
|
-
return fs.readFileSync(path.join(__dirname, "templates",
|
|
33
|
+
return fs.readFileSync(path.join(__dirname, "templates", `verifier_groth16.${fileExtension}.ejs`), "utf8");
|
|
32
34
|
default:
|
|
33
|
-
throw new Error(`Ambiguous
|
|
35
|
+
throw new Error(`Ambiguous proving system: ${provingSystem}.`);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/**
|
|
38
|
-
* Creates a
|
|
40
|
+
* Creates a verifier contract for the specified contract language.
|
|
39
41
|
*/
|
|
40
|
-
public async createVerifier(): Promise<void> {
|
|
42
|
+
public async createVerifier(languageExtension: VerifierLanguageType): Promise<void> {
|
|
41
43
|
const vKeyFilePath: string = this.mustGetArtifactsFilePath("vkey");
|
|
42
|
-
const verifierFilePath = path.join(this._config.verifierDirPath, `${this.getVerifierName()}
|
|
44
|
+
const verifierFilePath = path.join(this._config.verifierDirPath, `${this.getVerifierName()}.${languageExtension}`);
|
|
43
45
|
|
|
44
|
-
const verifierTemplate: string = CircuitZKit.getTemplate(this.
|
|
46
|
+
const verifierTemplate: string = CircuitZKit.getTemplate(this.getProvingSystem(), languageExtension);
|
|
45
47
|
|
|
46
48
|
if (!fs.existsSync(this._config.verifierDirPath)) {
|
|
47
49
|
fs.mkdirSync(this._config.verifierDirPath, { recursive: true });
|
|
@@ -141,12 +143,12 @@ export class CircuitZKit {
|
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
/**
|
|
144
|
-
* Returns the
|
|
146
|
+
* Returns the proving system of verifier template that was stored in the config
|
|
145
147
|
*
|
|
146
|
-
* @returns {
|
|
148
|
+
* @returns {VerifierProvingSystem} The verifier proving system.
|
|
147
149
|
*/
|
|
148
|
-
public
|
|
149
|
-
return this._config.
|
|
150
|
+
public getProvingSystem(): VerifierProvingSystem {
|
|
151
|
+
return this._config.provingSystem ?? "groth16";
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
/**
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# pragma version ~=0.4.0
|
|
2
|
+
|
|
3
|
+
# AUTOGENERATED FILE BY HARDHAT-ZKIT. DO NOT EDIT.
|
|
4
|
+
|
|
5
|
+
# @dev base field size
|
|
6
|
+
BASE_FIELD_SIZE: constant(uint256) = 21888242871839275222246405745257275088696311157297823662689037894645226208583
|
|
7
|
+
|
|
8
|
+
# @dev verification key data
|
|
9
|
+
ALPHA_X: constant(uint256) = <%=vk_alpha_1[0]%>
|
|
10
|
+
ALPHA_Y: constant(uint256) = <%=vk_alpha_1[1]%>
|
|
11
|
+
BETA_X1: constant(uint256) = <%=vk_beta_2[0][1]%>
|
|
12
|
+
BETA_X2: constant(uint256) = <%=vk_beta_2[0][0]%>
|
|
13
|
+
BETA_Y1: constant(uint256) = <%=vk_beta_2[1][1]%>
|
|
14
|
+
BETA_Y2: constant(uint256) = <%=vk_beta_2[1][0]%>
|
|
15
|
+
GAMMA_X1: constant(uint256) = <%=vk_gamma_2[0][1]%>
|
|
16
|
+
GAMMA_X2: constant(uint256) = <%=vk_gamma_2[0][0]%>
|
|
17
|
+
GAMMA_Y1: constant(uint256) = <%=vk_gamma_2[1][1]%>
|
|
18
|
+
GAMMA_Y2: constant(uint256) = <%=vk_gamma_2[1][0]%>
|
|
19
|
+
DELTA_X1: constant(uint256) = <%=vk_delta_2[0][1]%>
|
|
20
|
+
DELTA_X2: constant(uint256) = <%=vk_delta_2[0][0]%>
|
|
21
|
+
DELTA_Y1: constant(uint256) = <%=vk_delta_2[1][1]%>
|
|
22
|
+
DELTA_Y2: constant(uint256) = <%=vk_delta_2[1][0] -%>
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
IC: constant(uint256[<%=IC.length%>][2]) = [
|
|
26
|
+
<% IC.forEach(function(innerArray, index) { %> [
|
|
27
|
+
<%= innerArray[0] %>,
|
|
28
|
+
<%= innerArray[1] %>
|
|
29
|
+
]<%= index < IC.length - 1 ? ',' : '' %>
|
|
30
|
+
<% }); %>]
|
|
31
|
+
|
|
32
|
+
EC_ADD_PRECOMPILED_ADDRESS: constant(address) = 0x0000000000000000000000000000000000000006
|
|
33
|
+
EC_MUL_PRECOMPILED_ADDRESS: constant(address) = 0x0000000000000000000000000000000000000007
|
|
34
|
+
EC_PAIRING_PRECOMPILED_ADDRESS: constant(address) = 0x0000000000000000000000000000000000000008
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@view
|
|
38
|
+
@external
|
|
39
|
+
def verifyProof(pointA: uint256[2], pointB: uint256[2][2], pointC: uint256[2], publicSignals: uint256[<%=IC.length-1%>]) -> bool:
|
|
40
|
+
# @dev check that all public signals are in F
|
|
41
|
+
for signal: uint256 in publicSignals:
|
|
42
|
+
if signal >= BASE_FIELD_SIZE:
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
return self._checkPairing(pointA, pointB, pointC, publicSignals)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@view
|
|
49
|
+
@internal
|
|
50
|
+
def _g1MulAdd(pR: uint256[2], pP: uint256[2], s: uint256) -> (bool, uint256[2]):
|
|
51
|
+
success: bool = True
|
|
52
|
+
response: Bytes[64] = b""
|
|
53
|
+
success, response = raw_call(
|
|
54
|
+
EC_MUL_PRECOMPILED_ADDRESS,
|
|
55
|
+
abi_encode(pP, s),
|
|
56
|
+
max_outsize=64,
|
|
57
|
+
is_static_call=True,
|
|
58
|
+
revert_on_failure=False
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
if not success or len(response) != 64:
|
|
62
|
+
return (False, [0, 0])
|
|
63
|
+
|
|
64
|
+
x: uint256 = convert(slice(response, 0, 32), uint256)
|
|
65
|
+
y: uint256 = convert(slice(response, 32, 32), uint256)
|
|
66
|
+
pS: uint256[2] = [x, y]
|
|
67
|
+
|
|
68
|
+
success, response = raw_call(
|
|
69
|
+
EC_ADD_PRECOMPILED_ADDRESS,
|
|
70
|
+
abi_encode(pR, pS),
|
|
71
|
+
max_outsize=64,
|
|
72
|
+
is_static_call=True,
|
|
73
|
+
revert_on_failure=False
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
if not success or len(response) != 64:
|
|
77
|
+
return (False, [0, 0])
|
|
78
|
+
|
|
79
|
+
x = convert(slice(response, 0, 32), uint256)
|
|
80
|
+
y = convert(slice(response, 32, 32), uint256)
|
|
81
|
+
|
|
82
|
+
return (True, [x, y])
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@view
|
|
86
|
+
@internal
|
|
87
|
+
def _checkPairing(pA: uint256[2], pB: uint256[2][2], pC: uint256[2], pubSignals: uint256[<%=IC.length-1%>]) -> bool:
|
|
88
|
+
success: bool = True
|
|
89
|
+
mulAddResult: uint256[2] = IC[0]
|
|
90
|
+
|
|
91
|
+
# @dev compute the linear combination of public signals
|
|
92
|
+
for i: uint256 in range(1, <%=IC.length%>):
|
|
93
|
+
success, mulAddResult = self._g1MulAdd(mulAddResult, IC[i], pubSignals[i - 1])
|
|
94
|
+
if not success:
|
|
95
|
+
return False
|
|
96
|
+
|
|
97
|
+
response: Bytes[32] = b""
|
|
98
|
+
success, response = raw_call(
|
|
99
|
+
EC_PAIRING_PRECOMPILED_ADDRESS,
|
|
100
|
+
abi_encode(
|
|
101
|
+
pA[0], (BASE_FIELD_SIZE - pA[1]) % BASE_FIELD_SIZE,
|
|
102
|
+
pB,
|
|
103
|
+
ALPHA_X, ALPHA_Y,
|
|
104
|
+
BETA_X1, BETA_X2, BETA_Y1, BETA_Y2,
|
|
105
|
+
mulAddResult,
|
|
106
|
+
GAMMA_X1, GAMMA_X2, GAMMA_Y1, GAMMA_Y2,
|
|
107
|
+
pC,
|
|
108
|
+
DELTA_X1, DELTA_X2, DELTA_Y1, DELTA_Y2
|
|
109
|
+
),
|
|
110
|
+
max_outsize=32,
|
|
111
|
+
is_static_call=True,
|
|
112
|
+
revert_on_failure=False
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if not success:
|
|
116
|
+
return False
|
|
117
|
+
|
|
118
|
+
return convert(response, bool)
|
|
@@ -28,11 +28,12 @@ export type Signal = NumberLike | ArrayLike;
|
|
|
28
28
|
export type Signals = Record<string, Signal>;
|
|
29
29
|
|
|
30
30
|
export type ArtifactsFileType = "r1cs" | "zkey" | "vkey" | "sym" | "json" | "wasm";
|
|
31
|
-
export type
|
|
31
|
+
export type VerifierProvingSystem = "groth16";
|
|
32
|
+
export type VerifierLanguageType = "sol" | "vy";
|
|
32
33
|
|
|
33
34
|
export type CircuitZKitConfig = {
|
|
34
35
|
circuitName: string;
|
|
35
36
|
circuitArtifactsPath: string;
|
|
36
37
|
verifierDirPath: string;
|
|
37
|
-
|
|
38
|
+
provingSystem?: VerifierProvingSystem;
|
|
38
39
|
};
|