@solarity/zkit 0.3.7-rc.1 → 0.3.7-rc.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/dist/core/CircuitZKit.d.ts +1 -3
- package/dist/core/CircuitZKit.d.ts.map +1 -1
- package/dist/core/CircuitZKit.js.map +1 -1
- package/dist/core/protocols/AbstractImplementer.d.ts +1 -2
- package/dist/core/protocols/AbstractImplementer.d.ts.map +1 -1
- package/dist/core/protocols/Groth16Implementer.d.ts +1 -1
- package/dist/core/protocols/Groth16Implementer.d.ts.map +1 -1
- package/dist/core/protocols/PlonkImplementer.d.ts +1 -1
- package/dist/core/protocols/PlonkImplementer.d.ts.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/witness-utils.d.ts +8 -0
- package/dist/types/witness-utils.d.ts.map +1 -0
- package/dist/types/witness-utils.js +3 -0
- package/dist/types/witness-utils.js.map +1 -0
- package/dist/utils/witness-utils.d.ts +15 -5
- package/dist/utils/witness-utils.d.ts.map +1 -1
- package/dist/utils/witness-utils.js +34 -13
- package/dist/utils/witness-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/core/CircuitZKit.ts +12 -4
- package/src/core/protocols/AbstractImplementer.ts +2 -2
- package/src/core/protocols/Groth16Implementer.ts +1 -1
- package/src/core/protocols/PlonkImplementer.ts +1 -1
- package/src/index.ts +2 -3
- package/src/types/index.ts +4 -0
- package/src/types/witness-utils.ts +8 -0
- package/src/utils/witness-utils.ts +42 -19
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { ArtifactsFileType, CircuitZKitConfig, VerifierLanguageType } from "../types
|
|
2
|
-
import { Signals } from "../types/proof-utils";
|
|
3
|
-
import { CalldataByProtocol, IProtocolImplementer, ProofStructByProtocol, ProvingSystemType } from "../types/protocols";
|
|
1
|
+
import { ArtifactsFileType, CircuitZKitConfig, VerifierLanguageType, Signals, CalldataByProtocol, IProtocolImplementer, ProofStructByProtocol, ProvingSystemType } from "../types";
|
|
4
2
|
/**
|
|
5
3
|
* `CircuitZKit` represents a single circuit and provides a high-level API to work with it.
|
|
6
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircuitZKit.d.ts","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"CircuitZKit.d.ts","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EAElB,MAAM,UAAU,CAAC;AAKlB;;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;;;;;;;;;;;OAWG;IACU,cAAc,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBhH;;;;;;;;;;;OAWG;IACU,gBAAgB,CAAC,MAAM,EAAE,OAAO,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAmB5G;;;;;;;;;;;;;;OAcG;IACU,aAAa,CACxB,MAAM,EAAE,OAAO,EACf,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACxC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAuBvC;;;;;;;;OAQG;IACU,WAAW,CAAC,KAAK,EAAE,qBAAqB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAM9E;;;;;OAKG;IACU,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAIpG;;;;OAIG;IACI,cAAc,IAAI,MAAM;IAI/B;;;;;;;OAOG;IACI,eAAe,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM;IAI3D;;;;OAIG;IACI,oBAAoB,IAAI,iBAAiB;IAIhD;;;;OAIG;IACI,mBAAmB,CAAC,iBAAiB,EAAE,oBAAoB,GAAG,MAAM;IAI3E;;;;;;;OAOG;IACI,uBAAuB,IAAI,MAAM;IAIxC;;;;;OAKG;IACI,wBAAwB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM;IAUpE;;;;;OAKG;IACI,oBAAoB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM;CAgCjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircuitZKit.js","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,iDAAmC;AACnC,mCAAoC;
|
|
1
|
+
{"version":3,"file":"CircuitZKit.js","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,iDAAmC;AACnC,mCAAoC;AAcpC,4CAAoD;AACpD,oCAAkG;AAElG;;GAEG;AACH,MAAa,WAAW;IAEH;IACA;IAFnB,YACmB,OAA0B,EAC1B,YAAwC;QADxC,YAAO,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../../types
|
|
2
|
-
import { VerifierLanguageType } from "../../types/circuit-zkit";
|
|
1
|
+
import { IProtocolImplementer, ProvingSystemType, ProofStructByProtocol, CalldataByProtocol, VerifierLanguageType } from "../../types";
|
|
3
2
|
export declare abstract class AbstractProtocolImplementer<T extends ProvingSystemType> implements IProtocolImplementer<T> {
|
|
4
3
|
createVerifier(vKeyFilePath: string, verifierFilePath: string, languageExtension: VerifierLanguageType): Promise<void>;
|
|
5
4
|
abstract generateProof(zKeyFilePath: string, witnessFilePath: string): Promise<ProofStructByProtocol<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractImplementer.d.ts","sourceRoot":"","sources":["../../../src/core/protocols/AbstractImplementer.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"AbstractImplementer.d.ts","sourceRoot":"","sources":["../../../src/core/protocols/AbstractImplementer.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,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,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;aAE/F,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractProtocolImplementer } from "./AbstractImplementer";
|
|
2
|
-
import { Groth16ProofStruct, Groth16CalldataStruct, ProvingSystemType } from "../../types
|
|
2
|
+
import { Groth16ProofStruct, Groth16CalldataStruct, ProvingSystemType } from "../../types";
|
|
3
3
|
export declare class Groth16Implementer extends AbstractProtocolImplementer<"groth16"> {
|
|
4
4
|
generateProof(zKeyFilePath: string, witnessFilePath: string): Promise<Groth16ProofStruct>;
|
|
5
5
|
verifyProof(proof: Groth16ProofStruct, vKeyFilePath: string): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Groth16Implementer.d.ts","sourceRoot":"","sources":["../../../src/core/protocols/Groth16Implementer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Groth16Implementer.d.ts","sourceRoot":"","sources":["../../../src/core/protocols/Groth16Implementer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAI3F,qBAAa,kBAAmB,SAAQ,2BAA2B,CAAC,SAAS,CAAC;IAC/D,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQzF,WAAW,CAAC,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU9E,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAejF,oBAAoB,IAAI,iBAAiB;CAGjD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractProtocolImplementer } from "./AbstractImplementer";
|
|
2
|
-
import { PlonkProofStruct, PlonkCalldataStruct, ProvingSystemType } from "../../types
|
|
2
|
+
import { PlonkProofStruct, PlonkCalldataStruct, ProvingSystemType } from "../../types";
|
|
3
3
|
export declare class PlonkImplementer extends AbstractProtocolImplementer<"plonk"> {
|
|
4
4
|
generateProof(zKeyFilePath: string, witnessFilePath: string): Promise<PlonkProofStruct>;
|
|
5
5
|
verifyProof(proof: PlonkProofStruct, vKeyFilePath: string): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlonkImplementer.d.ts","sourceRoot":"","sources":["../../../src/core/protocols/PlonkImplementer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"PlonkImplementer.d.ts","sourceRoot":"","sources":["../../../src/core/protocols/PlonkImplementer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIvF,qBAAa,gBAAiB,SAAQ,2BAA2B,CAAC,OAAO,CAAC;IAC3D,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQvF,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU5E,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgB7E,oBAAoB,IAAI,iBAAiB;CAGjD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { CircuitZKit } from "./core/CircuitZKit";
|
|
2
2
|
export * from "./core/protocols";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./types
|
|
5
|
-
export * from "./types/protocols";
|
|
3
|
+
export * from "./utils";
|
|
4
|
+
export * from "./types";
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,cAAc,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AAExB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,6 @@ exports.CircuitZKit = void 0;
|
|
|
18
18
|
var CircuitZKit_1 = require("./core/CircuitZKit");
|
|
19
19
|
Object.defineProperty(exports, "CircuitZKit", { enumerable: true, get: function () { return CircuitZKit_1.CircuitZKit; } });
|
|
20
20
|
__exportStar(require("./core/protocols"), exports);
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./types
|
|
23
|
-
__exportStar(require("./types/protocols"), exports);
|
|
21
|
+
__exportStar(require("./utils"), exports);
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
24
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAiD;AAAxC,0GAAA,WAAW,OAAA;AACpB,mDAAiC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAiD;AAAxC,0GAAA,WAAW,OAAA;AACpB,mDAAiC;AACjC,0CAAwB;AAExB,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./circuit-zkit"), exports);
|
|
18
|
+
__exportStar(require("./proof-utils"), exports);
|
|
19
|
+
__exportStar(require("./witness-utils"), exports);
|
|
20
|
+
__exportStar(require("./protocols"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,gDAA8B;AAC9B,kDAAgC;AAChC,8CAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"witness-utils.d.ts","sourceRoot":"","sources":["../../src/types/witness-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,UAAU,CAAC;IACf,YAAY,EAAE,UAAU,CAAC;IACzB,WAAW,EAAE,UAAU,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"witness-utils.js","sourceRoot":"","sources":["../../src/types/witness-utils.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NumberLike, SignalInfo } from "../types";
|
|
1
2
|
/**
|
|
2
3
|
* Validates the provided witness overrides against the `.sym` file and returns the signal-to-index map.
|
|
3
4
|
*
|
|
@@ -8,11 +9,20 @@
|
|
|
8
9
|
* Signal names in `overrides` must be in their full form as represented in the `.sym` file, e.g.,
|
|
9
10
|
* `main.signal`, `main.component.signal`, or `main.component.signal[n][m]`.
|
|
10
11
|
*
|
|
11
|
-
* @param {string}
|
|
12
|
+
* @param {string} symFilePath - Path to the `.sym` file.
|
|
12
13
|
* @param {Record<string, bigint>} overrides - Map of signal names to new witness values.
|
|
13
|
-
* @returns {Promise<Record<string,
|
|
14
|
+
* @returns {Promise<Record<string, NumberLike>>} Map of signal names to their corresponding witness indices.
|
|
14
15
|
*/
|
|
15
|
-
export declare function checkWitnessOverrides(
|
|
16
|
+
export declare function checkWitnessOverrides(symFilePath: string, overrides: Record<string, bigint>): Promise<Record<string, NumberLike>>;
|
|
17
|
+
/**
|
|
18
|
+
* Iterates over signal entries in a `.sym` file line by line.
|
|
19
|
+
*
|
|
20
|
+
* Each line is parsed into a `SignalInfo` object which is passed to the provided callback.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} symFilePath - The full path to the `.sym` file to read.
|
|
23
|
+
* @param {(signalInfo: SignalInfo) => void} onSignal - Callback invoked for each signal line.
|
|
24
|
+
*/
|
|
25
|
+
export declare function iterateSymFile(symFilePath: string, onSignal: (signalInfo: SignalInfo) => void): Promise<void>;
|
|
16
26
|
/**
|
|
17
27
|
* Modifies specific signal values in a witness array.
|
|
18
28
|
* Substitutes signal from `overrides` in the witness array at positions defined in `signalIndexes`.
|
|
@@ -21,11 +31,11 @@ export declare function checkWitnessOverrides(symFile: string, overrides: Record
|
|
|
21
31
|
* `main.signal`, `main.component.signal`, or `main.component.signal[n][m]`.
|
|
22
32
|
*
|
|
23
33
|
* @param {bigint[]} witness - The original witness array.
|
|
24
|
-
* @param {Record<string,
|
|
34
|
+
* @param {Record<string, NumberLike>} signalIndexes - Map of signal names to their witness indices.
|
|
25
35
|
* @param {Record<string, bigint>} overrides - Map of signal names to new witness values.
|
|
26
36
|
* @returns {Promise<bigint[]>} The modified witness array.
|
|
27
37
|
*/
|
|
28
|
-
export declare function modifyWitnessArray(witness: bigint[], signalIndexes: Record<string,
|
|
38
|
+
export declare function modifyWitnessArray(witness: bigint[], signalIndexes: Record<string, NumberLike>, overrides: Record<string, bigint>): Promise<bigint[]>;
|
|
29
39
|
/**
|
|
30
40
|
* Writes a witness array to a `.wtns` binary file.
|
|
31
41
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"witness-utils.d.ts","sourceRoot":"","sources":["../../src/utils/witness-utils.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,
|
|
1
|
+
{"version":3,"file":"witness-utils.d.ts","sourceRoot":"","sources":["../../src/utils/witness-utils.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAkBrC;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,iBAkBnG;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,MAAM,EAAE,EACjB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACzC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,MAAM,EAAE,CAAC,CAQnB;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,iBAwB5E"}
|
|
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.checkWitnessOverrides = checkWitnessOverrides;
|
|
40
|
+
exports.iterateSymFile = iterateSymFile;
|
|
40
41
|
exports.modifyWitnessArray = modifyWitnessArray;
|
|
41
42
|
exports.writeWitnessFile = writeWitnessFile;
|
|
42
43
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -55,27 +56,47 @@ const binFileUtils = __importStar(require("@iden3/binfileutils"));
|
|
|
55
56
|
* Signal names in `overrides` must be in their full form as represented in the `.sym` file, e.g.,
|
|
56
57
|
* `main.signal`, `main.component.signal`, or `main.component.signal[n][m]`.
|
|
57
58
|
*
|
|
58
|
-
* @param {string}
|
|
59
|
+
* @param {string} symFilePath - Path to the `.sym` file.
|
|
59
60
|
* @param {Record<string, bigint>} overrides - Map of signal names to new witness values.
|
|
60
|
-
* @returns {Promise<Record<string,
|
|
61
|
+
* @returns {Promise<Record<string, NumberLike>>} Map of signal names to their corresponding witness indices.
|
|
61
62
|
*/
|
|
62
|
-
async function checkWitnessOverrides(
|
|
63
|
+
async function checkWitnessOverrides(symFilePath, overrides) {
|
|
63
64
|
const signalToWitnessIndex = {};
|
|
64
65
|
const missingSignals = new Set(Object.keys(overrides));
|
|
65
|
-
|
|
66
|
+
await iterateSymFile(symFilePath, (signalInfo) => {
|
|
67
|
+
if (BigInt(signalInfo.witnessIndex) >= 0) {
|
|
68
|
+
signalToWitnessIndex[signalInfo.signalName] = signalInfo.witnessIndex;
|
|
69
|
+
missingSignals.delete(signalInfo.signalName);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (missingSignals.size > 0) {
|
|
73
|
+
throw new Error(`Signals not found in .sym file: ${Array.from(missingSignals).join(", ")}`);
|
|
74
|
+
}
|
|
75
|
+
return signalToWitnessIndex;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Iterates over signal entries in a `.sym` file line by line.
|
|
79
|
+
*
|
|
80
|
+
* Each line is parsed into a `SignalInfo` object which is passed to the provided callback.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} symFilePath - The full path to the `.sym` file to read.
|
|
83
|
+
* @param {(signalInfo: SignalInfo) => void} onSignal - Callback invoked for each signal line.
|
|
84
|
+
*/
|
|
85
|
+
async function iterateSymFile(symFilePath, onSignal) {
|
|
86
|
+
const fileStream = fs_1.default.createReadStream(symFilePath, { encoding: "utf8" });
|
|
66
87
|
const signals = readline.createInterface({ input: fileStream, crlfDelay: Infinity });
|
|
67
88
|
for await (const signal of signals) {
|
|
68
89
|
const signalInfo = signal.split(",");
|
|
69
|
-
if (signalInfo.length != 4
|
|
90
|
+
if (signalInfo.length != 4) {
|
|
70
91
|
continue;
|
|
71
92
|
}
|
|
72
|
-
|
|
73
|
-
|
|
93
|
+
onSignal({
|
|
94
|
+
id: BigInt(signalInfo[0]),
|
|
95
|
+
witnessIndex: BigInt(signalInfo[1]),
|
|
96
|
+
componentId: BigInt(signalInfo[2]),
|
|
97
|
+
signalName: signalInfo[3],
|
|
98
|
+
});
|
|
74
99
|
}
|
|
75
|
-
if (missingSignals.size > 0) {
|
|
76
|
-
throw new Error(`Signals not found in .sym file: ${Array.from(missingSignals).join(", ")}`);
|
|
77
|
-
}
|
|
78
|
-
return signalToWitnessIndex;
|
|
79
100
|
}
|
|
80
101
|
/**
|
|
81
102
|
* Modifies specific signal values in a witness array.
|
|
@@ -85,13 +106,13 @@ async function checkWitnessOverrides(symFile, overrides) {
|
|
|
85
106
|
* `main.signal`, `main.component.signal`, or `main.component.signal[n][m]`.
|
|
86
107
|
*
|
|
87
108
|
* @param {bigint[]} witness - The original witness array.
|
|
88
|
-
* @param {Record<string,
|
|
109
|
+
* @param {Record<string, NumberLike>} signalIndexes - Map of signal names to their witness indices.
|
|
89
110
|
* @param {Record<string, bigint>} overrides - Map of signal names to new witness values.
|
|
90
111
|
* @returns {Promise<bigint[]>} The modified witness array.
|
|
91
112
|
*/
|
|
92
113
|
async function modifyWitnessArray(witness, signalIndexes, overrides) {
|
|
93
114
|
for (const [signal, value] of Object.entries(overrides)) {
|
|
94
|
-
const index = signalIndexes[signal];
|
|
115
|
+
const index = Number(signalIndexes[signal]);
|
|
95
116
|
witness[index] = value;
|
|
96
117
|
}
|
|
97
118
|
return witness;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"witness-utils.js","sourceRoot":"","sources":["../../src/utils/witness-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"witness-utils.js","sourceRoot":"","sources":["../../src/utils/witness-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,sDAqBC;AAUD,wCAkBC;AAcD,gDAYC;AAUD,4CAwBC;AAtID,4CAAoB;AAEpB,mDAAqC;AAErC,aAAa;AACb,+CAAsC;AACtC,aAAa;AACb,kEAAoD;AAIpD;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,qBAAqB,CACzC,WAAmB,EACnB,SAAiC;IAEjC,MAAM,oBAAoB,GAA+B,EAAE,CAAC;IAE5D,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAEvD,MAAM,cAAc,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE;QAC/C,IAAI,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YACzC,oBAAoB,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC;YAEtE,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,cAAc,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9F,CAAC;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAAC,WAAmB,EAAE,QAA0C;IAClG,MAAM,UAAU,GAAG,YAAE,CAAC,gBAAgB,CAAC,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EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACpD,MAAM,EAAE,CAAC,SAAS,EAAE,CAAC;IAErB,MAAM,YAAY,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IACtC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC;IAEjB,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
package/src/core/CircuitZKit.ts
CHANGED
|
@@ -3,9 +3,17 @@ import path from "path";
|
|
|
3
3
|
import * as snarkjs from "snarkjs";
|
|
4
4
|
import { createHash } from "crypto";
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import {
|
|
7
|
+
ArtifactsFileType,
|
|
8
|
+
CircuitZKitConfig,
|
|
9
|
+
VerifierLanguageType,
|
|
10
|
+
Signals,
|
|
11
|
+
CalldataByProtocol,
|
|
12
|
+
IProtocolImplementer,
|
|
13
|
+
ProofStructByProtocol,
|
|
14
|
+
ProvingSystemType,
|
|
15
|
+
NumberLike,
|
|
16
|
+
} from "../types";
|
|
9
17
|
|
|
10
18
|
import { MAX_FILE_NAME_LENGTH } from "../constants";
|
|
11
19
|
import { getTmpDir, modifyWitnessArray, checkWitnessOverrides, writeWitnessFile } from "../utils";
|
|
@@ -69,7 +77,7 @@ export class CircuitZKit<Type extends ProvingSystemType> {
|
|
|
69
77
|
const wtnsFile = this.getTemporaryWitnessPath();
|
|
70
78
|
const wasmFile = this.mustGetArtifactsFilePath("wasm");
|
|
71
79
|
|
|
72
|
-
let signalIndexes: Record<string,
|
|
80
|
+
let signalIndexes: Record<string, NumberLike> = {};
|
|
73
81
|
|
|
74
82
|
if (witnessOverrides) {
|
|
75
83
|
const symFile = this.mustGetArtifactsFilePath("sym");
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
ProvingSystemType,
|
|
8
8
|
ProofStructByProtocol,
|
|
9
9
|
CalldataByProtocol,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
VerifierLanguageType,
|
|
11
|
+
} from "../../types";
|
|
12
12
|
|
|
13
13
|
export abstract class AbstractProtocolImplementer<T extends ProvingSystemType> implements IProtocolImplementer<T> {
|
|
14
14
|
public async createVerifier(
|
|
@@ -3,7 +3,7 @@ import * as snarkjs from "snarkjs";
|
|
|
3
3
|
|
|
4
4
|
import { AbstractProtocolImplementer } from "./AbstractImplementer";
|
|
5
5
|
|
|
6
|
-
import { Groth16ProofStruct, Groth16CalldataStruct, ProvingSystemType } from "../../types
|
|
6
|
+
import { Groth16ProofStruct, Groth16CalldataStruct, ProvingSystemType } from "../../types";
|
|
7
7
|
|
|
8
8
|
import { terminateCurve } from "../../utils";
|
|
9
9
|
|
|
@@ -3,7 +3,7 @@ import * as snarkjs from "snarkjs";
|
|
|
3
3
|
|
|
4
4
|
import { AbstractProtocolImplementer } from "./AbstractImplementer";
|
|
5
5
|
|
|
6
|
-
import { PlonkProofStruct, PlonkCalldataStruct, ProvingSystemType } from "../../types
|
|
6
|
+
import { PlonkProofStruct, PlonkCalldataStruct, ProvingSystemType } from "../../types";
|
|
7
7
|
|
|
8
8
|
import { terminateCurve } from "../../utils";
|
|
9
9
|
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { Scalar } from "ffjavascript";
|
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import * as binFileUtils from "@iden3/binfileutils";
|
|
9
9
|
|
|
10
|
+
import { NumberLike, SignalInfo } from "../types";
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Validates the provided witness overrides against the `.sym` file and returns the signal-to-index map.
|
|
12
14
|
*
|
|
@@ -17,38 +19,59 @@ import * as binFileUtils from "@iden3/binfileutils";
|
|
|
17
19
|
* Signal names in `overrides` must be in their full form as represented in the `.sym` file, e.g.,
|
|
18
20
|
* `main.signal`, `main.component.signal`, or `main.component.signal[n][m]`.
|
|
19
21
|
*
|
|
20
|
-
* @param {string}
|
|
22
|
+
* @param {string} symFilePath - Path to the `.sym` file.
|
|
21
23
|
* @param {Record<string, bigint>} overrides - Map of signal names to new witness values.
|
|
22
|
-
* @returns {Promise<Record<string,
|
|
24
|
+
* @returns {Promise<Record<string, NumberLike>>} Map of signal names to their corresponding witness indices.
|
|
23
25
|
*/
|
|
24
26
|
export async function checkWitnessOverrides(
|
|
25
|
-
|
|
27
|
+
symFilePath: string,
|
|
26
28
|
overrides: Record<string, bigint>,
|
|
27
|
-
): Promise<Record<string,
|
|
28
|
-
const signalToWitnessIndex: Record<string,
|
|
29
|
+
): Promise<Record<string, NumberLike>> {
|
|
30
|
+
const signalToWitnessIndex: Record<string, NumberLike> = {};
|
|
29
31
|
|
|
30
32
|
const missingSignals = new Set(Object.keys(overrides));
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
await iterateSymFile(symFilePath, (signalInfo) => {
|
|
35
|
+
if (BigInt(signalInfo.witnessIndex) >= 0) {
|
|
36
|
+
signalToWitnessIndex[signalInfo.signalName] = signalInfo.witnessIndex;
|
|
37
|
+
|
|
38
|
+
missingSignals.delete(signalInfo.signalName);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (missingSignals.size > 0) {
|
|
43
|
+
throw new Error(`Signals not found in .sym file: ${Array.from(missingSignals).join(", ")}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return signalToWitnessIndex;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Iterates over signal entries in a `.sym` file line by line.
|
|
51
|
+
*
|
|
52
|
+
* Each line is parsed into a `SignalInfo` object which is passed to the provided callback.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} symFilePath - The full path to the `.sym` file to read.
|
|
55
|
+
* @param {(signalInfo: SignalInfo) => void} onSignal - Callback invoked for each signal line.
|
|
56
|
+
*/
|
|
57
|
+
export async function iterateSymFile(symFilePath: string, onSignal: (signalInfo: SignalInfo) => void) {
|
|
58
|
+
const fileStream = fs.createReadStream(symFilePath, { encoding: "utf8" });
|
|
33
59
|
const signals = readline.createInterface({ input: fileStream, crlfDelay: Infinity });
|
|
34
60
|
|
|
35
61
|
for await (const signal of signals) {
|
|
36
62
|
const signalInfo = signal.split(",");
|
|
37
63
|
|
|
38
|
-
if (signalInfo.length != 4
|
|
64
|
+
if (signalInfo.length != 4) {
|
|
39
65
|
continue;
|
|
40
66
|
}
|
|
41
67
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
onSignal({
|
|
69
|
+
id: BigInt(signalInfo[0]),
|
|
70
|
+
witnessIndex: BigInt(signalInfo[1]),
|
|
71
|
+
componentId: BigInt(signalInfo[2]),
|
|
72
|
+
signalName: signalInfo[3],
|
|
73
|
+
});
|
|
45
74
|
}
|
|
46
|
-
|
|
47
|
-
if (missingSignals.size > 0) {
|
|
48
|
-
throw new Error(`Signals not found in .sym file: ${Array.from(missingSignals).join(", ")}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return signalToWitnessIndex;
|
|
52
75
|
}
|
|
53
76
|
|
|
54
77
|
/**
|
|
@@ -59,17 +82,17 @@ export async function checkWitnessOverrides(
|
|
|
59
82
|
* `main.signal`, `main.component.signal`, or `main.component.signal[n][m]`.
|
|
60
83
|
*
|
|
61
84
|
* @param {bigint[]} witness - The original witness array.
|
|
62
|
-
* @param {Record<string,
|
|
85
|
+
* @param {Record<string, NumberLike>} signalIndexes - Map of signal names to their witness indices.
|
|
63
86
|
* @param {Record<string, bigint>} overrides - Map of signal names to new witness values.
|
|
64
87
|
* @returns {Promise<bigint[]>} The modified witness array.
|
|
65
88
|
*/
|
|
66
89
|
export async function modifyWitnessArray(
|
|
67
90
|
witness: bigint[],
|
|
68
|
-
signalIndexes: Record<string,
|
|
91
|
+
signalIndexes: Record<string, NumberLike>,
|
|
69
92
|
overrides: Record<string, bigint>,
|
|
70
93
|
): Promise<bigint[]> {
|
|
71
94
|
for (const [signal, value] of Object.entries(overrides)) {
|
|
72
|
-
const index = signalIndexes[signal];
|
|
95
|
+
const index = Number(signalIndexes[signal]);
|
|
73
96
|
|
|
74
97
|
witness[index] = value;
|
|
75
98
|
}
|