@proto-kit/common 0.1.1-develop.1661 → 0.1.1-develop.1688
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.1.1-develop.
|
|
6
|
+
"version": "0.1.1-develop.1688+a8257e42",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc -p tsconfig.json",
|
|
9
9
|
"dev": "tsc -p tsconfig.json --watch",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"typescript-memoize": "^1.1.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"o1js": "^
|
|
27
|
+
"o1js": "^2.10.0",
|
|
28
28
|
"tsyringe": "^4.10.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@jest/globals": "^29.5.0",
|
|
32
32
|
"@types/lodash": "^4.14.194"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "a8257e428f8cda2b7252ead17e29482d2fdb0575"
|
|
35
35
|
}
|
|
@@ -33,7 +33,10 @@ export interface Compile {
|
|
|
33
33
|
(): Promise<CompileArtifact>;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export interface PlainZkProgram<
|
|
36
|
+
export interface PlainZkProgram<
|
|
37
|
+
PublicInput = undefined,
|
|
38
|
+
PublicOutput = undefined,
|
|
39
|
+
> {
|
|
37
40
|
name: string;
|
|
38
41
|
compile: Compile;
|
|
39
42
|
verify: Verify<PublicInput, PublicOutput>;
|
|
@@ -45,11 +48,17 @@ export interface PlainZkProgram<PublicInput = undefined, PublicOutput = void> {
|
|
|
45
48
|
>;
|
|
46
49
|
methods: Record<
|
|
47
50
|
string,
|
|
48
|
-
| ((...args: any) => Promise<
|
|
51
|
+
| ((...args: any) => Promise<{
|
|
52
|
+
proof: Proof<PublicInput, PublicOutput>;
|
|
53
|
+
auxiliaryOutput: any;
|
|
54
|
+
}>)
|
|
49
55
|
| ((
|
|
50
56
|
publicInput: PublicInput,
|
|
51
57
|
...args: any
|
|
52
|
-
) => Promise<
|
|
58
|
+
) => Promise<{
|
|
59
|
+
proof: Proof<PublicInput, PublicOutput>;
|
|
60
|
+
auxiliaryOutput: any;
|
|
61
|
+
}>)
|
|
53
62
|
>;
|
|
54
63
|
analyzeMethods: () => Promise<
|
|
55
64
|
Record<string, Awaited<ReturnType<typeof Provable.constraintSystem>>>
|
|
@@ -38,7 +38,9 @@ export function toProver(
|
|
|
38
38
|
|
|
39
39
|
if (areProofsEnabled) {
|
|
40
40
|
const programProvableMethod = zkProgram.methods[methodName];
|
|
41
|
-
|
|
41
|
+
const result = await Reflect.apply(programProvableMethod, this, args);
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
43
|
+
return result.proof as Proof<any, any>;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
// create a mock proof by simulating method> execution in JS
|
|
@@ -49,8 +51,18 @@ export function toProver(
|
|
|
49
51
|
|
|
50
52
|
// TODO: provide undefined if public input is not used
|
|
51
53
|
publicInput: isFirstParameterPublicInput ? args[0] : undefined,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
55
|
+
publicOutput: (() => {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
57
|
+
if (!publicOutput || typeof publicOutput !== "object") {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
if ("publicOutput" in publicOutput) {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
62
|
+
return (publicOutput as any).publicOutput;
|
|
63
|
+
}
|
|
64
|
+
return publicOutput;
|
|
65
|
+
})(),
|
|
54
66
|
/**
|
|
55
67
|
* We set this to the max possible number, to avoid having
|
|
56
68
|
* to manually count in-circuit proof verifications
|
|
@@ -42,18 +42,22 @@ class TestProgrammable extends ZkProgrammable<
|
|
|
42
42
|
@provableMethod()
|
|
43
43
|
public async foo(publicInput: TestPublicInput, bar: Balance) {
|
|
44
44
|
// expose the private input as public output again for testing purposes
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
return {
|
|
46
|
+
publicOutput: new TestPublicOutput({
|
|
47
|
+
bar,
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
@provableMethod()
|
|
51
53
|
public async fail(publicInput: TestPublicInput) {
|
|
52
54
|
publicInput.foo.assertEquals(1, failErrorMessage);
|
|
53
55
|
|
|
54
|
-
return
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
return {
|
|
57
|
+
publicOutput: new TestPublicOutput({
|
|
58
|
+
bar: Field(0),
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
public zkProgramFactory() {
|
|
@@ -272,7 +276,7 @@ describe("zkProgrammable", () => {
|
|
|
272
276
|
// proof bar
|
|
273
277
|
const otherTestProof = await executionContext
|
|
274
278
|
.current()
|
|
275
|
-
.result.prove<Proof<undefined,
|
|
279
|
+
.result.prove<Proof<undefined, undefined>>();
|
|
276
280
|
const otherTestProofVerified =
|
|
277
281
|
await otherTestProgrammable.zkProgram[0].verify(otherTestProof);
|
|
278
282
|
|