@solarity/zkit 0.3.4 → 0.3.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 +3 -2
- package/dist/core/CircuitZKit.js +17 -7
- package/dist/core/CircuitZKit.js.map +1 -1
- package/dist/core/protocols/Groth16Implementer.d.ts +2 -2
- package/dist/core/protocols/Groth16Implementer.d.ts.map +1 -1
- package/dist/core/protocols/Groth16Implementer.js +26 -9
- package/dist/core/protocols/Groth16Implementer.js.map +1 -1
- package/dist/core/protocols/PlonkImplementer.d.ts +2 -2
- package/dist/core/protocols/PlonkImplementer.d.ts.map +1 -1
- package/dist/core/protocols/PlonkImplementer.js +24 -8
- package/dist/core/protocols/PlonkImplementer.js.map +1 -1
- package/dist/types/protocols/groth16.d.ts +9 -15
- package/dist/types/protocols/groth16.d.ts.map +1 -1
- package/dist/types/protocols/index.d.ts +5 -5
- package/dist/types/protocols/index.d.ts.map +1 -1
- package/dist/types/protocols/plonk.d.ts +7 -1
- package/dist/types/protocols/plonk.d.ts.map +1 -1
- package/dist/utils.js +17 -7
- package/dist/utils.js.map +1 -1
- package/package.json +3 -2
- package/src/core/protocols/Groth16Implementer.ts +14 -5
- package/src/core/protocols/PlonkImplementer.ts +11 -4
- package/src/types/protocols/groth16.ts +10 -6
- package/src/types/protocols/index.ts +5 -5
- package/src/types/protocols/plonk.ts +8 -1
package/README.md
CHANGED
|
@@ -91,10 +91,11 @@ const isValidProof = await circuit.verifyProof(proof);
|
|
|
91
91
|
|
|
92
92
|
- **`async generateCalldata(proof) -> calldata`**
|
|
93
93
|
|
|
94
|
-
Generates
|
|
94
|
+
Generates `Calldata` struct by proof for the Solidity | Vyper verifier's `verifyProof()` method.
|
|
95
95
|
|
|
96
96
|
```typescript
|
|
97
|
-
/// You can use this calldata
|
|
97
|
+
/// You can use this `calldata` sturct in the circuit verifier contract.
|
|
98
|
+
/// calldata: { proofPoints: { a, b, c }, publicSignals: [6] }
|
|
98
99
|
const calldata = await circuit.generateCalldata(proof);
|
|
99
100
|
```
|
|
100
101
|
|
package/dist/core/CircuitZKit.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircuitZKit.js","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CircuitZKit.js","sourceRoot":"","sources":["../../src/core/CircuitZKit.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,uCAAyB;AACzB,iDAAmC;AACn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C;gBAC/D,MAAM;YACR,KAAK,MAAM;gBACT,QAAQ,GAAG,GAAG,IAAI,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;AAtMD,kCAsMC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AbstractProtocolImplementer } from "./AbstractImplementer";
|
|
2
2
|
import { Signals } from "../../types/proof-utils";
|
|
3
|
-
import { Groth16ProofStruct,
|
|
3
|
+
import { Groth16ProofStruct, Groth16CalldataStruct, ProvingSystemType } from "../../types/protocols";
|
|
4
4
|
export declare class Groth16Implementer extends AbstractProtocolImplementer<"groth16"> {
|
|
5
5
|
generateProof(inputs: Signals, zKeyFilePath: string, wasmFilePath: string): Promise<Groth16ProofStruct>;
|
|
6
6
|
verifyProof(proof: Groth16ProofStruct, vKeyFilePath: string): Promise<boolean>;
|
|
7
|
-
generateCalldata(proof: Groth16ProofStruct): Promise<
|
|
7
|
+
generateCalldata(proof: Groth16ProofStruct): Promise<Groth16CalldataStruct>;
|
|
8
8
|
getProvingSystemType(): ProvingSystemType;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=Groth16Implementer.d.ts.map
|
|
@@ -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,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,
|
|
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,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAIrG,qBAAa,kBAAmB,SAAQ,2BAA2B,CAAC,SAAS,CAAC;IAC/D,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQvG,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"}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -44,8 +54,15 @@ class Groth16Implementer extends AbstractImplementer_1.AbstractProtocolImplement
|
|
|
44
54
|
return proofVerification;
|
|
45
55
|
}
|
|
46
56
|
async generateCalldata(proof) {
|
|
47
|
-
const
|
|
48
|
-
return
|
|
57
|
+
const calldataRawArray = JSON.parse(`[${await snarkjs.groth16.exportSolidityCallData(proof.proof, proof.publicSignals)}]`);
|
|
58
|
+
return {
|
|
59
|
+
proofPoints: {
|
|
60
|
+
a: calldataRawArray[0],
|
|
61
|
+
b: calldataRawArray[1],
|
|
62
|
+
c: calldataRawArray[2],
|
|
63
|
+
},
|
|
64
|
+
publicSignals: calldataRawArray[3],
|
|
65
|
+
};
|
|
49
66
|
}
|
|
50
67
|
getProvingSystemType() {
|
|
51
68
|
return "groth16";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Groth16Implementer.js","sourceRoot":"","sources":["../../../src/core/protocols/Groth16Implementer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Groth16Implementer.js","sourceRoot":"","sources":["../../../src/core/protocols/Groth16Implementer.ts"],"names":[],"mappings":";;;;;;;;;;;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O,SAAS,CAAC;IACnB,CAAC;CACF;AArCD,gDAqCC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AbstractProtocolImplementer } from "./AbstractImplementer";
|
|
2
2
|
import { Signals } from "../../types/proof-utils";
|
|
3
|
-
import {
|
|
3
|
+
import { PlonkProofStruct, PlonkCalldataStruct, ProvingSystemType } from "../../types/protocols";
|
|
4
4
|
export declare class PlonkImplementer extends AbstractProtocolImplementer<"plonk"> {
|
|
5
5
|
generateProof(inputs: Signals, zKeyFilePath: string, wasmFilePath: string): Promise<PlonkProofStruct>;
|
|
6
6
|
verifyProof(proof: PlonkProofStruct, vKeyFilePath: string): Promise<boolean>;
|
|
7
|
-
generateCalldata(proof: PlonkProofStruct): Promise<
|
|
7
|
+
generateCalldata(proof: PlonkProofStruct): Promise<PlonkCalldataStruct>;
|
|
8
8
|
getProvingSystemType(): ProvingSystemType;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=PlonkImplementer.d.ts.map
|
|
@@ -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,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,
|
|
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,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAIjG,qBAAa,gBAAiB,SAAQ,2BAA2B,CAAC,OAAO,CAAC;IAC3D,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQrG,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"}
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
@@ -46,7 +56,13 @@ class PlonkImplementer extends AbstractImplementer_1.AbstractProtocolImplementer
|
|
|
46
56
|
async generateCalldata(proof) {
|
|
47
57
|
const calldata = await snarkjs.plonk.exportSolidityCallData(proof.proof, proof.publicSignals);
|
|
48
58
|
const proofArrEndIndex = calldata.indexOf("]") + 1;
|
|
49
|
-
|
|
59
|
+
const calldataRawArray = JSON.parse(`[${calldata.slice(0, proofArrEndIndex)},${calldata.slice(proofArrEndIndex, calldata.length)}]`);
|
|
60
|
+
return {
|
|
61
|
+
proofPoints: {
|
|
62
|
+
proofData: calldataRawArray[0],
|
|
63
|
+
},
|
|
64
|
+
publicSignals: calldataRawArray[1],
|
|
65
|
+
};
|
|
50
66
|
}
|
|
51
67
|
getProvingSystemType() {
|
|
52
68
|
return "plonk";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlonkImplementer.js","sourceRoot":"","sources":["../../../src/core/protocols/PlonkImplementer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlonkImplementer.js","sourceRoot":"","sources":["../../../src/core/protocols/PlonkImplementer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoB;AACpB,iDAAmC;AAEnC,+DAAoE;AAKpE,uCAA6C;AAE7C,MAAa,gBAAiB,SAAQ,iDAAoC;IACjE,KAAK,CAAC,aAAa,CAAC,MAAe,EAAE,YAAoB,EAAE,YAAoB;QACpF,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QAEpF,MAAM,IAAA,sBAAc,GAAE,CAAC;QAEvB,OAAO,SAA6B,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,KAAuB,EAAE,YAAoB;QACpE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEtE,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAEjG,MAAM,IAAA,sBAAc,GAAE,CAAC;QAEvB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,KAAuB;QACnD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,sBAAsB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;QAC9F,MAAM,gBAAgB,GAAW,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE3D,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CACjC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,gBAAgB,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,CAChG,CAAC;QAEF,OAAO;YACL,WAAW,EAAE;gBACX,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC;aAC/B;YACD,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;SACnC,CAAC;IACJ,CAAC;IAEM,oBAAoB;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAtCD,4CAsCC"}
|
|
@@ -10,19 +10,13 @@ export interface Groth16ProofStruct {
|
|
|
10
10
|
proof: Groth16Proof;
|
|
11
11
|
publicSignals: PublicSignals;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
[
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
[
|
|
23
|
-
NumericString,
|
|
24
|
-
NumericString
|
|
25
|
-
],
|
|
26
|
-
PublicSignals
|
|
27
|
-
];
|
|
13
|
+
export interface Groth16CalldataStruct {
|
|
14
|
+
proofPoints: Groth16ProofPoints;
|
|
15
|
+
publicSignals: PublicSignals;
|
|
16
|
+
}
|
|
17
|
+
export interface Groth16ProofPoints {
|
|
18
|
+
a: [NumericString, NumericString];
|
|
19
|
+
b: [[NumericString, NumericString], [NumericString, NumericString]];
|
|
20
|
+
c: [NumericString, NumericString];
|
|
21
|
+
}
|
|
28
22
|
//# sourceMappingURL=groth16.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"groth16.d.ts","sourceRoot":"","sources":["../../../src/types/protocols/groth16.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;IACvE,IAAI,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,YAAY,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,
|
|
1
|
+
{"version":3,"file":"groth16.d.ts","sourceRoot":"","sources":["../../../src/types/protocols/groth16.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;IACvE,IAAI,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,YAAY,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,kBAAkB,CAAC;IAChC,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC;IACpE,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;CACnC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Groth16ProofStruct,
|
|
2
|
-
import { PlonkProofStruct,
|
|
1
|
+
import { Groth16ProofStruct, Groth16CalldataStruct } from "./groth16";
|
|
2
|
+
import { PlonkProofStruct, PlonkCalldataStruct } from "./plonk";
|
|
3
3
|
import { Signals } from "../proof-utils";
|
|
4
4
|
import { VerifierLanguageType } from "../circuit-zkit";
|
|
5
5
|
export * from "./groth16";
|
|
@@ -18,14 +18,14 @@ export interface IProtocolImplementer<T extends ProvingSystemType> {
|
|
|
18
18
|
export interface ProvingSystemStructMap {
|
|
19
19
|
groth16: {
|
|
20
20
|
proofStruct: Groth16ProofStruct;
|
|
21
|
-
|
|
21
|
+
calldataStruct: Groth16CalldataStruct;
|
|
22
22
|
};
|
|
23
23
|
plonk: {
|
|
24
24
|
proofStruct: PlonkProofStruct;
|
|
25
|
-
|
|
25
|
+
calldataStruct: PlonkCalldataStruct;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
export type ProvingSystemType = keyof ProvingSystemStructMap;
|
|
29
29
|
export type ProofStructByProtocol<T extends ProvingSystemType> = ProvingSystemStructMap[T]["proofStruct"];
|
|
30
|
-
export type CalldataByProtocol<T extends ProvingSystemType> = ProvingSystemStructMap[T]["
|
|
30
|
+
export type CalldataByProtocol<T extends ProvingSystemType> = ProvingSystemStructMap[T]["calldataStruct"];
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/protocols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEhE,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,YAAY,EAAE,MAAM,EACpB,gBAAgB,EAAE,MAAM,EACxB,iBAAiB,EAAE,oBAAoB,GACtC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9G,WAAW,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAErF,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;IAElF,oBAAoB,IAAI,iBAAiB,CAAC;IAE1C,WAAW,CAAC,aAAa,EAAE,oBAAoB,GAAG,MAAM,CAAC;IAEzD,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1E,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAE7C,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;CAC9C;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE;QACP,WAAW,EAAE,kBAAkB,CAAC;QAChC,cAAc,EAAE,qBAAqB,CAAC;KACvC,CAAC;IACF,KAAK,EAAE;QACL,WAAW,EAAE,gBAAgB,CAAC;QAC9B,cAAc,EAAE,mBAAmB,CAAC;KACrC,CAAC;CACH;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,sBAAsB,CAAC;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,gBAAgB,CAAC,CAAC"}
|
|
@@ -22,5 +22,11 @@ export interface PlonkProofStruct {
|
|
|
22
22
|
proof: PlonkProof;
|
|
23
23
|
publicSignals: PublicSignals;
|
|
24
24
|
}
|
|
25
|
-
export
|
|
25
|
+
export interface PlonkCalldataStruct {
|
|
26
|
+
proofPoints: PlonkProofPoints;
|
|
27
|
+
publicSignals: PublicSignals;
|
|
28
|
+
}
|
|
29
|
+
export interface PlonkProofPoints {
|
|
30
|
+
proofData: NumericString[];
|
|
31
|
+
}
|
|
26
32
|
//# sourceMappingURL=plonk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plonk.d.ts","sourceRoot":"","sources":["../../../src/types/protocols/plonk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,E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,CAAC,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAClC,EAAE,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACnC,EAAE,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACnC,EAAE,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACnC,GAAG,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACpC,IAAI,EAAE,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACrC,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B"}
|
package/dist/utils.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.terminateCurve = terminateCurve;
|
|
27
37
|
const snarkjs = __importStar(require("snarkjs"));
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wCAEC;AALD,iDAAmC;AACnC,2CAA+C;AAExC,KAAK,UAAU,cAAc;IAClC,MAAM,CAAC,MAAO,OAAe,CAAC,MAAM,CAAC,gBAAgB,CAAC,4BAAgB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AACvF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solarity/zkit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Distributed Lab",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@nomicfoundation/hardhat-ethers": "3.0.5",
|
|
46
46
|
"@nomiclabs/hardhat-vyper": "^3.0.7",
|
|
47
|
+
"@solarity/solidity-lib": "3.0.0-rc.3",
|
|
47
48
|
"@types/chai": "^4.3.12",
|
|
48
49
|
"@types/chai-as-promised": "^7.1.8",
|
|
49
50
|
"@types/ejs": "^3.1.5",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"@types/snarkjs": "^0.7.8",
|
|
52
53
|
"chai": "^4.4.1",
|
|
53
54
|
"chai-as-promised": "^7.1.1",
|
|
54
|
-
"ethers": "6.11.1",
|
|
55
|
+
"ethers": "^6.11.1",
|
|
55
56
|
"hardhat": "2.22.7",
|
|
56
57
|
"husky": "^9.0.11",
|
|
57
58
|
"mocha": "^10.3.0",
|
|
@@ -4,7 +4,7 @@ import * as snarkjs from "snarkjs";
|
|
|
4
4
|
import { AbstractProtocolImplementer } from "./AbstractImplementer";
|
|
5
5
|
|
|
6
6
|
import { Signals } from "../../types/proof-utils";
|
|
7
|
-
import { Groth16ProofStruct,
|
|
7
|
+
import { Groth16ProofStruct, Groth16CalldataStruct, ProvingSystemType } from "../../types/protocols";
|
|
8
8
|
|
|
9
9
|
import { terminateCurve } from "../../utils";
|
|
10
10
|
|
|
@@ -27,10 +27,19 @@ export class Groth16Implementer extends AbstractProtocolImplementer<"groth16"> {
|
|
|
27
27
|
return proofVerification;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
public async generateCalldata(proof: Groth16ProofStruct): Promise<
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
public async generateCalldata(proof: Groth16ProofStruct): Promise<Groth16CalldataStruct> {
|
|
31
|
+
const calldataRawArray = JSON.parse(
|
|
32
|
+
`[${await snarkjs.groth16.exportSolidityCallData(proof.proof, proof.publicSignals)}]`,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
proofPoints: {
|
|
37
|
+
a: calldataRawArray[0],
|
|
38
|
+
b: calldataRawArray[1],
|
|
39
|
+
c: calldataRawArray[2],
|
|
40
|
+
},
|
|
41
|
+
publicSignals: calldataRawArray[3],
|
|
42
|
+
};
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
public getProvingSystemType(): ProvingSystemType {
|
|
@@ -4,7 +4,7 @@ import * as snarkjs from "snarkjs";
|
|
|
4
4
|
import { AbstractProtocolImplementer } from "./AbstractImplementer";
|
|
5
5
|
|
|
6
6
|
import { Signals } from "../../types/proof-utils";
|
|
7
|
-
import {
|
|
7
|
+
import { PlonkProofStruct, PlonkCalldataStruct, ProvingSystemType } from "../../types/protocols";
|
|
8
8
|
|
|
9
9
|
import { terminateCurve } from "../../utils";
|
|
10
10
|
|
|
@@ -27,13 +27,20 @@ export class PlonkImplementer extends AbstractProtocolImplementer<"plonk"> {
|
|
|
27
27
|
return proofVerification;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
public async generateCalldata(proof: PlonkProofStruct): Promise<
|
|
30
|
+
public async generateCalldata(proof: PlonkProofStruct): Promise<PlonkCalldataStruct> {
|
|
31
31
|
const calldata = await snarkjs.plonk.exportSolidityCallData(proof.proof, proof.publicSignals);
|
|
32
32
|
const proofArrEndIndex: number = calldata.indexOf("]") + 1;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
const calldataRawArray = JSON.parse(
|
|
35
35
|
`[${calldata.slice(0, proofArrEndIndex)},${calldata.slice(proofArrEndIndex, calldata.length)}]`,
|
|
36
|
-
)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
proofPoints: {
|
|
40
|
+
proofData: calldataRawArray[0],
|
|
41
|
+
},
|
|
42
|
+
publicSignals: calldataRawArray[1],
|
|
43
|
+
};
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
public getProvingSystemType(): ProvingSystemType {
|
|
@@ -13,9 +13,13 @@ export interface Groth16ProofStruct {
|
|
|
13
13
|
publicSignals: PublicSignals;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
export interface Groth16CalldataStruct {
|
|
17
|
+
proofPoints: Groth16ProofPoints;
|
|
18
|
+
publicSignals: PublicSignals;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Groth16ProofPoints {
|
|
22
|
+
a: [NumericString, NumericString];
|
|
23
|
+
b: [[NumericString, NumericString], [NumericString, NumericString]];
|
|
24
|
+
c: [NumericString, NumericString];
|
|
25
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Groth16ProofStruct,
|
|
2
|
-
import { PlonkProofStruct,
|
|
1
|
+
import { Groth16ProofStruct, Groth16CalldataStruct } from "./groth16";
|
|
2
|
+
import { PlonkProofStruct, PlonkCalldataStruct } from "./plonk";
|
|
3
3
|
|
|
4
4
|
import { Signals } from "../proof-utils";
|
|
5
5
|
import { VerifierLanguageType } from "../circuit-zkit";
|
|
@@ -34,15 +34,15 @@ export interface IProtocolImplementer<T extends ProvingSystemType> {
|
|
|
34
34
|
export interface ProvingSystemStructMap {
|
|
35
35
|
groth16: {
|
|
36
36
|
proofStruct: Groth16ProofStruct;
|
|
37
|
-
|
|
37
|
+
calldataStruct: Groth16CalldataStruct;
|
|
38
38
|
};
|
|
39
39
|
plonk: {
|
|
40
40
|
proofStruct: PlonkProofStruct;
|
|
41
|
-
|
|
41
|
+
calldataStruct: PlonkCalldataStruct;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export type ProvingSystemType = keyof ProvingSystemStructMap;
|
|
46
46
|
|
|
47
47
|
export type ProofStructByProtocol<T extends ProvingSystemType> = ProvingSystemStructMap[T]["proofStruct"];
|
|
48
|
-
export type CalldataByProtocol<T extends ProvingSystemType> = ProvingSystemStructMap[T]["
|
|
48
|
+
export type CalldataByProtocol<T extends ProvingSystemType> = ProvingSystemStructMap[T]["calldataStruct"];
|
|
@@ -25,4 +25,11 @@ export interface PlonkProofStruct {
|
|
|
25
25
|
publicSignals: PublicSignals;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export
|
|
28
|
+
export interface PlonkCalldataStruct {
|
|
29
|
+
proofPoints: PlonkProofPoints;
|
|
30
|
+
publicSignals: PublicSignals;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface PlonkProofPoints {
|
|
34
|
+
proofData: NumericString[];
|
|
35
|
+
}
|