@solarity/zkit 0.3.0 → 0.3.2
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 +5 -4
- package/dist/core/CircuitZKit.d.ts +11 -4
- package/dist/core/CircuitZKit.d.ts.map +1 -1
- package/dist/core/CircuitZKit.js +14 -7
- package/dist/core/CircuitZKit.js.map +1 -1
- package/dist/core/protocols/AbstractImplementer.d.ts +2 -2
- package/dist/core/protocols/AbstractImplementer.d.ts.map +1 -1
- package/dist/core/protocols/AbstractImplementer.js +5 -4
- package/dist/core/protocols/AbstractImplementer.js.map +1 -1
- package/dist/core/templates/verifier_groth16.sol.ejs +3 -3
- package/dist/core/templates/verifier_groth16.vy.ejs +3 -0
- package/dist/core/templates/verifier_plonk.sol.ejs +5 -5
- package/dist/core/templates/verifier_plonk.vy.ejs +3 -0
- package/dist/types/protocols/index.d.ts +2 -2
- package/dist/types/protocols/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/CircuitZKit.ts +14 -7
- package/src/core/protocols/AbstractImplementer.ts +4 -4
- package/src/core/templates/verifier_groth16.sol.ejs +3 -3
- package/src/core/templates/verifier_groth16.vy.ejs +3 -0
- package/src/core/templates/verifier_plonk.sol.ejs +5 -5
- package/src/core/templates/verifier_plonk.vy.ejs +3 -0
- package/src/types/protocols/index.ts +1 -2
package/README.md
CHANGED
|
@@ -53,12 +53,13 @@ The `implementer` is the instance of a certain proving system. Currently `groth1
|
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
56
|
-
- **`async createVerifier("sol" | "vy")`**
|
|
56
|
+
- **`async createVerifier("sol" | "vy", verifierNameSuffix?: string)`**
|
|
57
57
|
|
|
58
|
-
Creates a Solidity | Vyper verifier contract on `verifierDirPath` path, which was specified in the config.
|
|
58
|
+
Creates a Solidity | Vyper verifier contract with the optional `verifierNameSuffix` on `verifierDirPath` path, which was specified in the config.
|
|
59
59
|
|
|
60
60
|
```typescript
|
|
61
61
|
await circuit.createVerifier("sol");
|
|
62
|
+
await circuit.createVerifier("sol", "_suffix_");
|
|
62
63
|
```
|
|
63
64
|
|
|
64
65
|
- **`async calculateWitness(inputs) -> bigint[]`**
|
|
@@ -101,12 +102,12 @@ const calldata = await circuit.generateCalldata(proof);
|
|
|
101
102
|
|
|
102
103
|
Returns the name of the circuit from the config.
|
|
103
104
|
|
|
104
|
-
- **`getVerifierName() -> string`**
|
|
105
|
+
- **`getVerifierName(verifierNameSuffix?: string) -> string`**
|
|
105
106
|
|
|
106
107
|
Returns the name of the verifier in the following form:
|
|
107
108
|
|
|
108
109
|
```typescript
|
|
109
|
-
<Circuit name><Proving system>Verifier
|
|
110
|
+
<Circuit name><Suffix><Proving system>Verifier
|
|
110
111
|
```
|
|
111
112
|
|
|
112
113
|
- **`getProvingSystemType() -> "groth16" | "plonk"`**
|
|
@@ -9,9 +9,13 @@ export declare class CircuitZKit<Type extends ProvingSystemType> {
|
|
|
9
9
|
private readonly _implementer;
|
|
10
10
|
constructor(_config: CircuitZKitConfig, _implementer: IProtocolImplementer<Type>);
|
|
11
11
|
/**
|
|
12
|
-
* Creates a verifier contract for the specified contract language.
|
|
12
|
+
* Creates a verifier contract for the specified contract language with optional name suffix.
|
|
13
|
+
* For more details regarding the structure of the contract verifier name, see {@link getVerifierName} description.
|
|
14
|
+
*
|
|
15
|
+
* @param {VerifierLanguageType} languageExtension - The verifier contract language extension.
|
|
16
|
+
* @param {string} verifierNameSuffix - The optional verifier name suffix.
|
|
13
17
|
*/
|
|
14
|
-
createVerifier(languageExtension: VerifierLanguageType): Promise<void>;
|
|
18
|
+
createVerifier(languageExtension: VerifierLanguageType, verifierNameSuffix?: string): Promise<void>;
|
|
15
19
|
/**
|
|
16
20
|
* Calculates a witness for the given inputs.
|
|
17
21
|
*
|
|
@@ -54,11 +58,14 @@ export declare class CircuitZKit<Type extends ProvingSystemType> {
|
|
|
54
58
|
*/
|
|
55
59
|
getCircuitName(): string;
|
|
56
60
|
/**
|
|
57
|
-
* Returns the verifier name. The verifier name
|
|
61
|
+
* Returns the verifier name. The verifier name has the next structure:
|
|
62
|
+
* `<template name><suffix><proving system>Verifier.<extension>`.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} verifierNameSuffix - The optional verifier name suffix.
|
|
58
65
|
*
|
|
59
66
|
* @returns {string} The verifier name.
|
|
60
67
|
*/
|
|
61
|
-
getVerifierName(): string;
|
|
68
|
+
getVerifierName(verifierNameSuffix?: string): string;
|
|
62
69
|
/**
|
|
63
70
|
* Returns the type of the proving protocol
|
|
64
71
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircuitZKit.d.ts","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAExH;;GAEG;AACH,qBAAa,WAAW,CAAC,IAAI,SAAS,iBAAiB;IAEnD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY;gBADZ,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,oBAAoB,CAAC,IAAI,CAAC;IAG3D
|
|
1
|
+
{"version":3,"file":"CircuitZKit.d.ts","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;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_implementer;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Creates a verifier contract for the specified contract language.
|
|
45
|
+
* Creates a verifier contract for the specified contract language with optional name suffix.
|
|
46
|
+
* For more details regarding the structure of the contract verifier name, see {@link getVerifierName} description.
|
|
47
|
+
*
|
|
48
|
+
* @param {VerifierLanguageType} languageExtension - The verifier contract language extension.
|
|
49
|
+
* @param {string} verifierNameSuffix - The optional verifier name suffix.
|
|
46
50
|
*/
|
|
47
|
-
async createVerifier(languageExtension) {
|
|
51
|
+
async createVerifier(languageExtension, verifierNameSuffix) {
|
|
48
52
|
const vKeyFilePath = this.mustGetArtifactsFilePath("vkey");
|
|
49
|
-
const verifierFilePath = path_1.default.join(this._config.verifierDirPath, `${this.
|
|
50
|
-
this._implementer.createVerifier(
|
|
53
|
+
const verifierFilePath = path_1.default.join(this._config.verifierDirPath, `${this.getVerifierName(verifierNameSuffix)}.${languageExtension}`);
|
|
54
|
+
this._implementer.createVerifier(vKeyFilePath, verifierFilePath, languageExtension);
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* Calculates a witness for the given inputs.
|
|
@@ -112,12 +116,15 @@ class CircuitZKit {
|
|
|
112
116
|
return this._config.circuitName;
|
|
113
117
|
}
|
|
114
118
|
/**
|
|
115
|
-
* Returns the verifier name. The verifier name
|
|
119
|
+
* Returns the verifier name. The verifier name has the next structure:
|
|
120
|
+
* `<template name><suffix><proving system>Verifier.<extension>`.
|
|
121
|
+
*
|
|
122
|
+
* @param {string} verifierNameSuffix - The optional verifier name suffix.
|
|
116
123
|
*
|
|
117
124
|
* @returns {string} The verifier name.
|
|
118
125
|
*/
|
|
119
|
-
getVerifierName() {
|
|
120
|
-
return this._implementer.getVerifierName(this._config.circuitName);
|
|
126
|
+
getVerifierName(verifierNameSuffix) {
|
|
127
|
+
return this._implementer.getVerifierName(this._config.circuitName, verifierNameSuffix);
|
|
121
128
|
}
|
|
122
129
|
/**
|
|
123
130
|
* Returns the type of the proving protocol
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircuitZKit.js","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,uCAAyB;AACzB,iDAAmC;AAMnC;;GAEG;AACH,MAAa,WAAW;IAEH;IACA;IAFnB,YACmB,OAA0B,EAC1B,YAAwC;QADxC,YAAO,GAAP,OAAO,CAAmB;QAC1B,iBAAY,GAAZ,YAAY,CAA4B;IACxD,CAAC;IAEJ
|
|
1
|
+
{"version":3,"file":"CircuitZKit.js","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,uCAAyB;AACzB,iDAAmC;AAMnC;;GAEG;AACH,MAAa,WAAW;IAEH;IACA;IAFnB,YACmB,OAA0B,EAC1B,YAAwC;QADxC,YAAO,GAAP,OAAO,CAAmB;QAC1B,iBAAY,GAAZ,YAAY,CAA4B;IACxD,CAAC;IAEJ;;;;;;OAMG;IACI,KAAK,CAAC,cAAc,CAAC,iBAAuC,EAAE,kBAA2B;QAC9F,MAAM,YAAY,GAAW,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAC;QACnE,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAChC,IAAI,CAAC,OAAO,CAAC,eAAe,EAC5B,GAAG,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,iBAAiB,EAAE,CACnE,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IACtF,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,gBAAgB,CAAC,MAAe;QAC3C,MAAM,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,E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AI,CAAC,YAAY,CAAC,eAAe,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/D,MAAM;YACR,KAAK,KAAK;gBACR,QAAQ,GAAG,GAAG,WAAW,MAAM,CAAC;gBAChC,MAAM;YACR,KAAK,MAAM;gBACT,QAAQ,GAAG,GAAG,WAAW,mBAAmB,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;AArLD,kCAqLC"}
|
|
@@ -2,13 +2,13 @@ import { Signals } from "../../types/proof-utils";
|
|
|
2
2
|
import { IProtocolImplementer, ProvingSystemType, ProofStructByProtocol, CalldataByProtocol } from "../../types/protocols";
|
|
3
3
|
import { VerifierLanguageType } from "../../types/circuit-zkit";
|
|
4
4
|
export declare abstract class AbstractProtocolImplementer<T extends ProvingSystemType> implements IProtocolImplementer<T> {
|
|
5
|
-
createVerifier(
|
|
5
|
+
createVerifier(vKeyFilePath: string, verifierFilePath: string, languageExtension: VerifierLanguageType): Promise<void>;
|
|
6
6
|
abstract generateProof(inputs: Signals, zKeyFilePath: string, wasmFilePath: string): Promise<ProofStructByProtocol<T>>;
|
|
7
7
|
abstract verifyProof(proof: ProofStructByProtocol<T>, vKeyFilePath: string): Promise<boolean>;
|
|
8
8
|
abstract generateCalldata(proof: ProofStructByProtocol<T>): Promise<CalldataByProtocol<T>>;
|
|
9
9
|
abstract getProvingSystemType(): ProvingSystemType;
|
|
10
10
|
getTemplate(languageExtension: VerifierLanguageType): string;
|
|
11
|
-
getVerifierName(circuitName: string): string;
|
|
11
|
+
getVerifierName(circuitName: string, verifierNameSuffix?: string): string;
|
|
12
12
|
getZKeyFileName(circuitName: string): string;
|
|
13
13
|
getVKeyFileName(circuitName: string): string;
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractImplementer.d.ts","sourceRoot":"","sources":["../../../src/core/protocols/AbstractImplementer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,8BAAsB,2BAA2B,CAAC,CAAC,SAAS,iBAAiB,CAAE,YAAW,oBAAoB,CAAC,CAAC,CAAC;IAClG,cAAc,CACzB,
|
|
1
|
+
{"version":3,"file":"AbstractImplementer.d.ts","sourceRoot":"","sources":["../../../src/core/protocols/AbstractImplementer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,8BAAsB,2BAA2B,CAAC,CAAC,SAAS,iBAAiB,CAAE,YAAW,oBAAoB,CAAC,CAAC,CAAC;IAClG,cAAc,CACzB,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,iBAAiB,EAAE,oBAAoB,GACtC,OAAO,CAAC,IAAI,CAAC;aAeA,aAAa,CAC3B,MAAM,EAAE,OAAO,EACf,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;aAEpB,WAAW,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;aAEpF,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;aAEjF,oBAAoB,IAAI,iBAAiB;IAElD,WAAW,CAAC,iBAAiB,EAAE,oBAAoB,GAAG,MAAM;IAO5D,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM;IAOzE,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAI5C,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;CAGpD"}
|
|
@@ -8,22 +8,23 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const ejs_1 = __importDefault(require("ejs"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
class AbstractProtocolImplementer {
|
|
11
|
-
async createVerifier(
|
|
11
|
+
async createVerifier(vKeyFilePath, verifierFilePath, languageExtension) {
|
|
12
12
|
const verifierTemplate = this.getTemplate(languageExtension);
|
|
13
13
|
if (!fs_1.default.existsSync(path_1.default.dirname(verifierFilePath))) {
|
|
14
14
|
fs_1.default.mkdirSync(path_1.default.dirname(verifierFilePath), { recursive: true });
|
|
15
15
|
}
|
|
16
16
|
const templateParams = JSON.parse(fs_1.default.readFileSync(vKeyFilePath, "utf-8"));
|
|
17
|
-
templateParams["verifier_id"] =
|
|
17
|
+
templateParams["verifier_id"] = path_1.default.parse(verifierFilePath).name;
|
|
18
18
|
const verifierCode = ejs_1.default.render(verifierTemplate, templateParams);
|
|
19
19
|
fs_1.default.writeFileSync(verifierFilePath, verifierCode, "utf-8");
|
|
20
20
|
}
|
|
21
21
|
getTemplate(languageExtension) {
|
|
22
22
|
return fs_1.default.readFileSync(path_1.default.join(__dirname, "..", "templates", `verifier_${this.getProvingSystemType()}.${languageExtension}.ejs`), "utf8");
|
|
23
23
|
}
|
|
24
|
-
getVerifierName(circuitName) {
|
|
24
|
+
getVerifierName(circuitName, verifierNameSuffix) {
|
|
25
25
|
const protocolType = this.getProvingSystemType();
|
|
26
|
-
|
|
26
|
+
const nameSuffix = verifierNameSuffix ?? "";
|
|
27
|
+
return `${circuitName}${nameSuffix}${protocolType.charAt(0).toUpperCase() + protocolType.slice(1)}Verifier`;
|
|
27
28
|
}
|
|
28
29
|
getZKeyFileName(circuitName) {
|
|
29
30
|
return `${circuitName}.${this.getProvingSystemType()}.zkey`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractImplementer.js","sourceRoot":"","sources":["../../../src/core/protocols/AbstractImplementer.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,8CAAsB;AACtB,gDAAwB;AAWxB,MAAsB,2BAA2B;IACxC,KAAK,CAAC,cAAc,CACzB,
|
|
1
|
+
{"version":3,"file":"AbstractImplementer.js","sourceRoot":"","sources":["../../../src/core/protocols/AbstractImplementer.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,8CAAsB;AACtB,gDAAwB;AAWxB,MAAsB,2BAA2B;IACxC,KAAK,CAAC,cAAc,CACzB,YAAoB,EACpB,gBAAwB,EACxB,iBAAuC;QAEvC,MAAM,gBAAgB,GAAW,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;QAErE,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;YACnD,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;QAC1E,cAAc,CAAC,aAAa,CAAC,GAAG,cAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC;QAElE,MAAM,YAAY,GAAG,aAAG,CAAC,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAElE,YAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAcM,WAAW,CAAC,iBAAuC;QACxD,OAAO,YAAE,CAAC,YAAY,CACpB,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,IAAI,CAAC,oBAAoB,EAAE,IAAI,iBAAiB,MAAM,CAAC,EAC3G,MAAM,CACP,CAAC;IACJ,CAAC;IAEM,eAAe,CAAC,WAAmB,EAAE,kBAA2B;QACrE,MAAM,YAAY,GAAsB,IAAI,CAAC,oBAAoB,EAAE,CAAC;QACpE,MAAM,UAAU,GAAW,kBAAkB,IAAI,EAAE,CAAC;QAEpD,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC;IAC9G,CAAC;IAEM,eAAe,CAAC,WAAmB;QACxC,OAAO,GAAG,WAAW,IAAI,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAC9D,CAAC;IAEM,eAAe,CAAC,WAAmB;QACxC,OAAO,GAAG,WAAW,IAAI,IAAI,CAAC,oBAAoB,EAAE,YAAY,CAAC;IACnE,CAAC;CACF;AArDD,kEAqDC"}
|
|
@@ -67,7 +67,7 @@ contract <%=verifier_id%> {
|
|
|
67
67
|
mstore(add(pointer_, 32), y_)
|
|
68
68
|
mstore(add(pointer_, 64), s_)
|
|
69
69
|
|
|
70
|
-
res_ := staticcall(
|
|
70
|
+
res_ := staticcall(6000, 7, pointer_, 96, pointer_, 64) // ecMul
|
|
71
71
|
res_ := and(res_, gt(returndatasize(), 0)) // check that multiplication succeeded
|
|
72
72
|
|
|
73
73
|
if iszero(res_) {
|
|
@@ -77,7 +77,7 @@ contract <%=verifier_id%> {
|
|
|
77
77
|
mstore(add(pointer_, 64), mload(pR_))
|
|
78
78
|
mstore(add(pointer_, 96), mload(add(pR_, 32)))
|
|
79
79
|
|
|
80
|
-
res_ := staticcall(
|
|
80
|
+
res_ := staticcall(150, 6, pointer_, 128, pR_, 64) // ecAdd
|
|
81
81
|
res_ := and(res_, gt(returndatasize(), 0)) // check that addition succeeded
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -136,7 +136,7 @@ contract <%=verifier_id%> {
|
|
|
136
136
|
mstore(add(pPairing_, 704), DELTA_Y1)
|
|
137
137
|
mstore(add(pPairing_, 736), DELTA_Y2)
|
|
138
138
|
|
|
139
|
-
res_ := staticcall(
|
|
139
|
+
res_ := staticcall(181000, 8, pPairing_, 768, pPairing_, 32) // ecPairing
|
|
140
140
|
res_ := and(res_, mload(pPairing_)) // check that pairing succeeded
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -53,6 +53,7 @@ def _g1MulAdd(pR: uint256[2], pP: uint256[2], s: uint256) -> (bool, uint256[2]):
|
|
|
53
53
|
success, response = raw_call(
|
|
54
54
|
EC_MUL_PRECOMPILED_ADDRESS,
|
|
55
55
|
abi_encode(pP, s),
|
|
56
|
+
gas=6000,
|
|
56
57
|
max_outsize=64,
|
|
57
58
|
is_static_call=True,
|
|
58
59
|
revert_on_failure=False
|
|
@@ -68,6 +69,7 @@ def _g1MulAdd(pR: uint256[2], pP: uint256[2], s: uint256) -> (bool, uint256[2]):
|
|
|
68
69
|
success, response = raw_call(
|
|
69
70
|
EC_ADD_PRECOMPILED_ADDRESS,
|
|
70
71
|
abi_encode(pR, pS),
|
|
72
|
+
gas=150,
|
|
71
73
|
max_outsize=64,
|
|
72
74
|
is_static_call=True,
|
|
73
75
|
revert_on_failure=False
|
|
@@ -107,6 +109,7 @@ def _checkPairing(pA: uint256[2], pB: uint256[2][2], pC: uint256[2], pubSignals:
|
|
|
107
109
|
pC,
|
|
108
110
|
DELTA_X1, DELTA_X2, DELTA_Y1, DELTA_Y2
|
|
109
111
|
),
|
|
112
|
+
gas=181000,
|
|
110
113
|
max_outsize=32,
|
|
111
114
|
is_static_call=True,
|
|
112
115
|
revert_on_failure=False
|
|
@@ -415,7 +415,7 @@ contract <%=verifier_id%> {
|
|
|
415
415
|
mstore(add(mIn,64), mload(pP_))
|
|
416
416
|
mstore(add(mIn,96), mload(add(pP_, 32)))
|
|
417
417
|
|
|
418
|
-
res_ := staticcall(
|
|
418
|
+
res_ := staticcall(150, 6, mIn, 128, pR_, 64)
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
function g1_mulAccC(pR_, x_, y_, s_) -> res_ {
|
|
@@ -424,7 +424,7 @@ contract <%=verifier_id%> {
|
|
|
424
424
|
mstore(add(mIn,32), y_)
|
|
425
425
|
mstore(add(mIn,64), s_)
|
|
426
426
|
|
|
427
|
-
res_ := staticcall(
|
|
427
|
+
res_ := staticcall(6000, 7, mIn, 96, mIn, 64)
|
|
428
428
|
|
|
429
429
|
if iszero(res_) {
|
|
430
430
|
leave
|
|
@@ -433,7 +433,7 @@ contract <%=verifier_id%> {
|
|
|
433
433
|
mstore(add(mIn,64), mload(pR_))
|
|
434
434
|
mstore(add(mIn,96), mload(add(pR_, 32)))
|
|
435
435
|
|
|
436
|
-
res_ := staticcall(
|
|
436
|
+
res_ := staticcall(150, 6, mIn, 128, pR_, 64)
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
function g1_mulSetC(pR_, x_, y_, s_) -> res_ {
|
|
@@ -442,7 +442,7 @@ contract <%=verifier_id%> {
|
|
|
442
442
|
mstore(add(mIn,32), y_)
|
|
443
443
|
mstore(add(mIn,64), s_)
|
|
444
444
|
|
|
445
|
-
res_ := staticcall(
|
|
445
|
+
res_ := staticcall(6000, 7, mIn, 96, pR_, 64)
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
function g1_mulSet(pR_, pP_, s_) -> res_ {
|
|
@@ -748,7 +748,7 @@ contract <%=verifier_id%> {
|
|
|
748
748
|
mstore(add(mIn,320), G2_Y2)
|
|
749
749
|
mstore(add(mIn,352), G2_Y1)
|
|
750
750
|
|
|
751
|
-
if iszero(staticcall(
|
|
751
|
+
if iszero(staticcall(113000, 8, mIn, 384, mIn, 0x20)) {
|
|
752
752
|
leave
|
|
753
753
|
}
|
|
754
754
|
|
|
@@ -149,6 +149,7 @@ def _ecadd(a: uint256[2], b: uint256[2]) -> (bool, uint256[2]):
|
|
|
149
149
|
success, response = raw_call(
|
|
150
150
|
EC_ADD_PRECOMPILED_ADDRESS,
|
|
151
151
|
abi_encode(a, b),
|
|
152
|
+
gas=150,
|
|
152
153
|
max_outsize=64,
|
|
153
154
|
is_static_call=True,
|
|
154
155
|
revert_on_failure=False
|
|
@@ -171,6 +172,7 @@ def _ecmul(p: uint256[2], s: uint256) -> (bool, uint256[2]):
|
|
|
171
172
|
success, response = raw_call(
|
|
172
173
|
EC_MUL_PRECOMPILED_ADDRESS,
|
|
173
174
|
abi_encode(p, s),
|
|
175
|
+
gas=6000,
|
|
174
176
|
max_outsize=64,
|
|
175
177
|
is_static_call=True,
|
|
176
178
|
revert_on_failure=False
|
|
@@ -639,6 +641,7 @@ def _checkPairing(p: uint256[P_TOTAL_SIZE], proof: uint256[24]) -> bool:
|
|
|
639
641
|
success, response = raw_call(
|
|
640
642
|
EC_PAIRING_PRECOMPILED_ADDRESS,
|
|
641
643
|
abi_encode(mIn),
|
|
644
|
+
gas=113000,
|
|
642
645
|
max_outsize=32,
|
|
643
646
|
is_static_call=True,
|
|
644
647
|
revert_on_failure=False
|
|
@@ -5,13 +5,13 @@ import { VerifierLanguageType } from "../circuit-zkit";
|
|
|
5
5
|
export * from "./groth16";
|
|
6
6
|
export * from "./plonk";
|
|
7
7
|
export interface IProtocolImplementer<T extends ProvingSystemType> {
|
|
8
|
-
createVerifier(
|
|
8
|
+
createVerifier(vKeyFilePath: string, verifierFilePath: string, languageExtension: VerifierLanguageType): Promise<void>;
|
|
9
9
|
generateProof(inputs: Signals, zKeyFilePath: string, wasmFilePath: string): Promise<ProofStructByProtocol<T>>;
|
|
10
10
|
verifyProof(proof: ProofStructByProtocol<T>, vKeyFilePath: string): Promise<boolean>;
|
|
11
11
|
generateCalldata(proof: ProofStructByProtocol<T>): Promise<CalldataByProtocol<T>>;
|
|
12
12
|
getProvingSystemType(): ProvingSystemType;
|
|
13
13
|
getTemplate(fileExtension: VerifierLanguageType): string;
|
|
14
|
-
getVerifierName(circuitName: string): string;
|
|
14
|
+
getVerifierName(circuitName: string, verifierNameSuffix?: string): string;
|
|
15
15
|
getZKeyFileName(circuitName: string): string;
|
|
16
16
|
getVKeyFileName(circuitName: string): string;
|
|
17
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AAExB,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,iBAAiB;IAC/D,cAAc,CACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,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;AAE7D,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,iBAAiB,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;AAC1G,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,iBAAiB,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/core/CircuitZKit.ts
CHANGED
|
@@ -17,16 +17,20 @@ export class CircuitZKit<Type extends ProvingSystemType> {
|
|
|
17
17
|
) {}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* Creates a verifier contract for the specified contract language.
|
|
20
|
+
* Creates a verifier contract for the specified contract language with optional name suffix.
|
|
21
|
+
* For more details regarding the structure of the contract verifier name, see {@link getVerifierName} description.
|
|
22
|
+
*
|
|
23
|
+
* @param {VerifierLanguageType} languageExtension - The verifier contract language extension.
|
|
24
|
+
* @param {string} verifierNameSuffix - The optional verifier name suffix.
|
|
21
25
|
*/
|
|
22
|
-
public async createVerifier(languageExtension: VerifierLanguageType): Promise<void> {
|
|
26
|
+
public async createVerifier(languageExtension: VerifierLanguageType, verifierNameSuffix?: string): Promise<void> {
|
|
23
27
|
const vKeyFilePath: string = this.mustGetArtifactsFilePath("vkey");
|
|
24
28
|
const verifierFilePath = path.join(
|
|
25
29
|
this._config.verifierDirPath,
|
|
26
|
-
`${this.
|
|
30
|
+
`${this.getVerifierName(verifierNameSuffix)}.${languageExtension}`,
|
|
27
31
|
);
|
|
28
32
|
|
|
29
|
-
this._implementer.createVerifier(
|
|
33
|
+
this._implementer.createVerifier(vKeyFilePath, verifierFilePath, languageExtension);
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
/**
|
|
@@ -104,12 +108,15 @@ export class CircuitZKit<Type extends ProvingSystemType> {
|
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
/**
|
|
107
|
-
* Returns the verifier name. The verifier name
|
|
111
|
+
* Returns the verifier name. The verifier name has the next structure:
|
|
112
|
+
* `<template name><suffix><proving system>Verifier.<extension>`.
|
|
113
|
+
*
|
|
114
|
+
* @param {string} verifierNameSuffix - The optional verifier name suffix.
|
|
108
115
|
*
|
|
109
116
|
* @returns {string} The verifier name.
|
|
110
117
|
*/
|
|
111
|
-
public getVerifierName(): string {
|
|
112
|
-
return this._implementer.getVerifierName(this._config.circuitName);
|
|
118
|
+
public getVerifierName(verifierNameSuffix?: string): string {
|
|
119
|
+
return this._implementer.getVerifierName(this._config.circuitName, verifierNameSuffix);
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
/**
|
|
@@ -13,7 +13,6 @@ import { VerifierLanguageType } from "../../types/circuit-zkit";
|
|
|
13
13
|
|
|
14
14
|
export abstract class AbstractProtocolImplementer<T extends ProvingSystemType> implements IProtocolImplementer<T> {
|
|
15
15
|
public async createVerifier(
|
|
16
|
-
circuitName: string,
|
|
17
16
|
vKeyFilePath: string,
|
|
18
17
|
verifierFilePath: string,
|
|
19
18
|
languageExtension: VerifierLanguageType,
|
|
@@ -25,7 +24,7 @@ export abstract class AbstractProtocolImplementer<T extends ProvingSystemType> i
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
const templateParams = JSON.parse(fs.readFileSync(vKeyFilePath, "utf-8"));
|
|
28
|
-
templateParams["verifier_id"] =
|
|
27
|
+
templateParams["verifier_id"] = path.parse(verifierFilePath).name;
|
|
29
28
|
|
|
30
29
|
const verifierCode = ejs.render(verifierTemplate, templateParams);
|
|
31
30
|
|
|
@@ -51,10 +50,11 @@ export abstract class AbstractProtocolImplementer<T extends ProvingSystemType> i
|
|
|
51
50
|
);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
public getVerifierName(circuitName: string): string {
|
|
53
|
+
public getVerifierName(circuitName: string, verifierNameSuffix?: string): string {
|
|
55
54
|
const protocolType: ProvingSystemType = this.getProvingSystemType();
|
|
55
|
+
const nameSuffix: string = verifierNameSuffix ?? "";
|
|
56
56
|
|
|
57
|
-
return `${circuitName}${protocolType.charAt(0).toUpperCase() + protocolType.slice(1)}Verifier`;
|
|
57
|
+
return `${circuitName}${nameSuffix}${protocolType.charAt(0).toUpperCase() + protocolType.slice(1)}Verifier`;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
public getZKeyFileName(circuitName: string): string {
|
|
@@ -67,7 +67,7 @@ contract <%=verifier_id%> {
|
|
|
67
67
|
mstore(add(pointer_, 32), y_)
|
|
68
68
|
mstore(add(pointer_, 64), s_)
|
|
69
69
|
|
|
70
|
-
res_ := staticcall(
|
|
70
|
+
res_ := staticcall(6000, 7, pointer_, 96, pointer_, 64) // ecMul
|
|
71
71
|
res_ := and(res_, gt(returndatasize(), 0)) // check that multiplication succeeded
|
|
72
72
|
|
|
73
73
|
if iszero(res_) {
|
|
@@ -77,7 +77,7 @@ contract <%=verifier_id%> {
|
|
|
77
77
|
mstore(add(pointer_, 64), mload(pR_))
|
|
78
78
|
mstore(add(pointer_, 96), mload(add(pR_, 32)))
|
|
79
79
|
|
|
80
|
-
res_ := staticcall(
|
|
80
|
+
res_ := staticcall(150, 6, pointer_, 128, pR_, 64) // ecAdd
|
|
81
81
|
res_ := and(res_, gt(returndatasize(), 0)) // check that addition succeeded
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -136,7 +136,7 @@ contract <%=verifier_id%> {
|
|
|
136
136
|
mstore(add(pPairing_, 704), DELTA_Y1)
|
|
137
137
|
mstore(add(pPairing_, 736), DELTA_Y2)
|
|
138
138
|
|
|
139
|
-
res_ := staticcall(
|
|
139
|
+
res_ := staticcall(181000, 8, pPairing_, 768, pPairing_, 32) // ecPairing
|
|
140
140
|
res_ := and(res_, mload(pPairing_)) // check that pairing succeeded
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -53,6 +53,7 @@ def _g1MulAdd(pR: uint256[2], pP: uint256[2], s: uint256) -> (bool, uint256[2]):
|
|
|
53
53
|
success, response = raw_call(
|
|
54
54
|
EC_MUL_PRECOMPILED_ADDRESS,
|
|
55
55
|
abi_encode(pP, s),
|
|
56
|
+
gas=6000,
|
|
56
57
|
max_outsize=64,
|
|
57
58
|
is_static_call=True,
|
|
58
59
|
revert_on_failure=False
|
|
@@ -68,6 +69,7 @@ def _g1MulAdd(pR: uint256[2], pP: uint256[2], s: uint256) -> (bool, uint256[2]):
|
|
|
68
69
|
success, response = raw_call(
|
|
69
70
|
EC_ADD_PRECOMPILED_ADDRESS,
|
|
70
71
|
abi_encode(pR, pS),
|
|
72
|
+
gas=150,
|
|
71
73
|
max_outsize=64,
|
|
72
74
|
is_static_call=True,
|
|
73
75
|
revert_on_failure=False
|
|
@@ -107,6 +109,7 @@ def _checkPairing(pA: uint256[2], pB: uint256[2][2], pC: uint256[2], pubSignals:
|
|
|
107
109
|
pC,
|
|
108
110
|
DELTA_X1, DELTA_X2, DELTA_Y1, DELTA_Y2
|
|
109
111
|
),
|
|
112
|
+
gas=181000,
|
|
110
113
|
max_outsize=32,
|
|
111
114
|
is_static_call=True,
|
|
112
115
|
revert_on_failure=False
|
|
@@ -415,7 +415,7 @@ contract <%=verifier_id%> {
|
|
|
415
415
|
mstore(add(mIn,64), mload(pP_))
|
|
416
416
|
mstore(add(mIn,96), mload(add(pP_, 32)))
|
|
417
417
|
|
|
418
|
-
res_ := staticcall(
|
|
418
|
+
res_ := staticcall(150, 6, mIn, 128, pR_, 64)
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
function g1_mulAccC(pR_, x_, y_, s_) -> res_ {
|
|
@@ -424,7 +424,7 @@ contract <%=verifier_id%> {
|
|
|
424
424
|
mstore(add(mIn,32), y_)
|
|
425
425
|
mstore(add(mIn,64), s_)
|
|
426
426
|
|
|
427
|
-
res_ := staticcall(
|
|
427
|
+
res_ := staticcall(6000, 7, mIn, 96, mIn, 64)
|
|
428
428
|
|
|
429
429
|
if iszero(res_) {
|
|
430
430
|
leave
|
|
@@ -433,7 +433,7 @@ contract <%=verifier_id%> {
|
|
|
433
433
|
mstore(add(mIn,64), mload(pR_))
|
|
434
434
|
mstore(add(mIn,96), mload(add(pR_, 32)))
|
|
435
435
|
|
|
436
|
-
res_ := staticcall(
|
|
436
|
+
res_ := staticcall(150, 6, mIn, 128, pR_, 64)
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
function g1_mulSetC(pR_, x_, y_, s_) -> res_ {
|
|
@@ -442,7 +442,7 @@ contract <%=verifier_id%> {
|
|
|
442
442
|
mstore(add(mIn,32), y_)
|
|
443
443
|
mstore(add(mIn,64), s_)
|
|
444
444
|
|
|
445
|
-
res_ := staticcall(
|
|
445
|
+
res_ := staticcall(6000, 7, mIn, 96, pR_, 64)
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
function g1_mulSet(pR_, pP_, s_) -> res_ {
|
|
@@ -748,7 +748,7 @@ contract <%=verifier_id%> {
|
|
|
748
748
|
mstore(add(mIn,320), G2_Y2)
|
|
749
749
|
mstore(add(mIn,352), G2_Y1)
|
|
750
750
|
|
|
751
|
-
if iszero(staticcall(
|
|
751
|
+
if iszero(staticcall(113000, 8, mIn, 384, mIn, 0x20)) {
|
|
752
752
|
leave
|
|
753
753
|
}
|
|
754
754
|
|
|
@@ -149,6 +149,7 @@ def _ecadd(a: uint256[2], b: uint256[2]) -> (bool, uint256[2]):
|
|
|
149
149
|
success, response = raw_call(
|
|
150
150
|
EC_ADD_PRECOMPILED_ADDRESS,
|
|
151
151
|
abi_encode(a, b),
|
|
152
|
+
gas=150,
|
|
152
153
|
max_outsize=64,
|
|
153
154
|
is_static_call=True,
|
|
154
155
|
revert_on_failure=False
|
|
@@ -171,6 +172,7 @@ def _ecmul(p: uint256[2], s: uint256) -> (bool, uint256[2]):
|
|
|
171
172
|
success, response = raw_call(
|
|
172
173
|
EC_MUL_PRECOMPILED_ADDRESS,
|
|
173
174
|
abi_encode(p, s),
|
|
175
|
+
gas=6000,
|
|
174
176
|
max_outsize=64,
|
|
175
177
|
is_static_call=True,
|
|
176
178
|
revert_on_failure=False
|
|
@@ -639,6 +641,7 @@ def _checkPairing(p: uint256[P_TOTAL_SIZE], proof: uint256[24]) -> bool:
|
|
|
639
641
|
success, response = raw_call(
|
|
640
642
|
EC_PAIRING_PRECOMPILED_ADDRESS,
|
|
641
643
|
abi_encode(mIn),
|
|
644
|
+
gas=113000,
|
|
642
645
|
max_outsize=32,
|
|
643
646
|
is_static_call=True,
|
|
644
647
|
revert_on_failure=False
|
|
@@ -9,7 +9,6 @@ export * from "./plonk";
|
|
|
9
9
|
|
|
10
10
|
export interface IProtocolImplementer<T extends ProvingSystemType> {
|
|
11
11
|
createVerifier(
|
|
12
|
-
circuitName: string,
|
|
13
12
|
vKeyFilePath: string,
|
|
14
13
|
verifierFilePath: string,
|
|
15
14
|
languageExtension: VerifierLanguageType,
|
|
@@ -25,7 +24,7 @@ export interface IProtocolImplementer<T extends ProvingSystemType> {
|
|
|
25
24
|
|
|
26
25
|
getTemplate(fileExtension: VerifierLanguageType): string;
|
|
27
26
|
|
|
28
|
-
getVerifierName(circuitName: string): string;
|
|
27
|
+
getVerifierName(circuitName: string, verifierNameSuffix?: string): string;
|
|
29
28
|
|
|
30
29
|
getZKeyFileName(circuitName: string): string;
|
|
31
30
|
|