@proto-kit/common 0.1.1-develop.190 → 0.1.1-develop.2024
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/compiling/AtomicCompileHelper.d.ts +13 -0
- package/dist/compiling/AtomicCompileHelper.d.ts.map +1 -0
- package/dist/compiling/AtomicCompileHelper.js +40 -0
- package/dist/compiling/AtomicCompileHelper.js.map +1 -0
- package/dist/compiling/CompilableModule.d.ts +6 -0
- package/dist/compiling/CompilableModule.d.ts.map +1 -0
- package/dist/compiling/CompilableModule.js +2 -0
- package/dist/compiling/CompilableModule.js.map +1 -0
- package/dist/compiling/CompileRegistry.d.ts +26 -0
- package/dist/compiling/CompileRegistry.d.ts.map +1 -0
- package/dist/compiling/CompileRegistry.js +67 -0
- package/dist/compiling/CompileRegistry.js.map +1 -0
- package/dist/compiling/services/ChildVerificationKeyService.d.ts +10 -0
- package/dist/compiling/services/ChildVerificationKeyService.d.ts.map +1 -0
- package/dist/compiling/services/ChildVerificationKeyService.js +27 -0
- package/dist/compiling/services/ChildVerificationKeyService.js.map +1 -0
- package/dist/config/ChildContainerCreatable.d.ts +5 -0
- package/dist/config/ChildContainerCreatable.d.ts.map +1 -0
- package/dist/config/ChildContainerCreatable.js +2 -0
- package/dist/config/ChildContainerCreatable.js.map +1 -0
- package/dist/config/ChildContainerProvider.d.ts +5 -0
- package/dist/config/ChildContainerProvider.d.ts.map +1 -0
- package/dist/config/ChildContainerProvider.js +2 -0
- package/dist/config/ChildContainerProvider.js.map +1 -0
- package/dist/config/ConfigurableModule.d.ts +6 -2
- package/dist/config/ConfigurableModule.d.ts.map +1 -1
- package/dist/config/ConfigurableModule.js +5 -0
- package/dist/config/ConfigurableModule.js.map +1 -0
- package/dist/config/ModuleContainer.d.ts +70 -23
- package/dist/config/ModuleContainer.d.ts.map +1 -1
- package/dist/config/ModuleContainer.js +164 -31
- package/dist/config/ModuleContainer.js.map +1 -0
- package/dist/config/Startable.d.ts +4 -0
- package/dist/config/Startable.d.ts.map +1 -0
- package/dist/config/Startable.js +2 -0
- package/dist/config/Startable.js.map +1 -0
- package/dist/config/injectAlias.d.ts +18 -0
- package/dist/config/injectAlias.d.ts.map +1 -0
- package/dist/config/injectAlias.js +47 -0
- package/dist/config/injectAlias.js.map +1 -0
- package/dist/dependencyFactory/DependencyFactory.d.ts +14 -9
- package/dist/dependencyFactory/DependencyFactory.d.ts.map +1 -1
- package/dist/dependencyFactory/DependencyFactory.js +2 -96
- package/dist/dependencyFactory/DependencyFactory.js.map +1 -0
- package/dist/dependencyFactory/injectOptional.d.ts +16 -0
- package/dist/dependencyFactory/injectOptional.d.ts.map +1 -0
- package/dist/dependencyFactory/injectOptional.js +40 -0
- package/dist/dependencyFactory/injectOptional.js.map +1 -0
- package/dist/dummyVerificationKey.d.ts +3 -0
- package/dist/dummyVerificationKey.d.ts.map +1 -0
- package/dist/dummyVerificationKey.js +8 -0
- package/dist/dummyVerificationKey.js.map +1 -0
- package/dist/events/EventEmitter.d.ts +19 -0
- package/dist/events/EventEmitter.d.ts.map +1 -0
- package/dist/events/EventEmitter.js +35 -0
- package/dist/events/EventEmitter.js.map +1 -0
- package/dist/events/EventEmitterProxy.d.ts +18 -0
- package/dist/events/EventEmitterProxy.d.ts.map +1 -0
- package/dist/events/EventEmitterProxy.js +35 -0
- package/dist/events/EventEmitterProxy.js.map +1 -0
- package/dist/events/EventEmittingComponent.d.ts +9 -0
- package/dist/events/EventEmittingComponent.d.ts.map +1 -0
- package/dist/events/EventEmittingComponent.js +2 -0
- package/dist/events/EventEmittingComponent.js.map +1 -0
- package/dist/events/ReplayingSingleUseEventEmitter.d.ts +17 -0
- package/dist/events/ReplayingSingleUseEventEmitter.d.ts.map +1 -0
- package/dist/events/ReplayingSingleUseEventEmitter.js +34 -0
- package/dist/events/ReplayingSingleUseEventEmitter.js.map +1 -0
- package/dist/index.d.ts +23 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -2
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +37 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +117 -0
- package/dist/log.js.map +1 -0
- package/dist/trees/InMemoryLinkedLeafStore.d.ts +21 -0
- package/dist/trees/InMemoryLinkedLeafStore.d.ts.map +1 -0
- package/dist/trees/InMemoryLinkedLeafStore.js +26 -0
- package/dist/trees/InMemoryLinkedLeafStore.js.map +1 -0
- package/dist/trees/InMemoryLinkedMerkleLeafStore.d.ts +7 -0
- package/dist/trees/InMemoryLinkedMerkleLeafStore.d.ts.map +1 -0
- package/dist/trees/InMemoryLinkedMerkleLeafStore.js +6 -0
- package/dist/trees/InMemoryLinkedMerkleLeafStore.js.map +1 -0
- package/dist/trees/InMemoryMerkleTreeStorage.d.ts +11 -0
- package/dist/trees/InMemoryMerkleTreeStorage.d.ts.map +1 -0
- package/dist/trees/InMemoryMerkleTreeStorage.js +13 -0
- package/dist/trees/InMemoryMerkleTreeStorage.js.map +1 -0
- package/dist/trees/LinkedMerkleTree.d.ts +345 -0
- package/dist/trees/LinkedMerkleTree.d.ts.map +1 -0
- package/dist/trees/LinkedMerkleTree.js +337 -0
- package/dist/trees/LinkedMerkleTree.js.map +1 -0
- package/dist/trees/LinkedMerkleTreeStore.d.ts +24 -0
- package/dist/trees/LinkedMerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/LinkedMerkleTreeStore.js +2 -0
- package/dist/trees/LinkedMerkleTreeStore.js.map +1 -0
- package/dist/trees/MerkleTreeStore.d.ts +5 -0
- package/dist/trees/MerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/MerkleTreeStore.js +2 -0
- package/dist/trees/MerkleTreeStore.js.map +1 -0
- package/dist/trees/MockAsyncMerkleStore.d.ts +9 -0
- package/dist/trees/MockAsyncMerkleStore.d.ts.map +1 -0
- package/dist/trees/MockAsyncMerkleStore.js +20 -0
- package/dist/trees/MockAsyncMerkleStore.js.map +1 -0
- package/dist/trees/RollupMerkleTree.d.ts +147 -0
- package/dist/trees/RollupMerkleTree.d.ts.map +1 -0
- package/dist/trees/RollupMerkleTree.js +218 -0
- package/dist/trees/RollupMerkleTree.js.map +1 -0
- package/dist/trees/VirtualMerkleTreeStore.d.ts +13 -0
- package/dist/trees/VirtualMerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/VirtualMerkleTreeStore.js +18 -0
- package/dist/trees/VirtualMerkleTreeStore.js.map +1 -0
- package/dist/trees/lmt/AbstractLinkedMerkleTree.d.ts +288 -0
- package/dist/trees/lmt/AbstractLinkedMerkleTree.d.ts.map +1 -0
- package/dist/trees/lmt/AbstractLinkedMerkleTree.js +22 -0
- package/dist/trees/lmt/AbstractLinkedMerkleTree.js.map +1 -0
- package/dist/trees/lmt/InMemoryLinkedLeafStore.d.ts +21 -0
- package/dist/trees/lmt/InMemoryLinkedLeafStore.d.ts.map +1 -0
- package/dist/trees/lmt/InMemoryLinkedLeafStore.js +26 -0
- package/dist/trees/lmt/InMemoryLinkedLeafStore.js.map +1 -0
- package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.d.ts +7 -0
- package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.d.ts.map +1 -0
- package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.js +6 -0
- package/dist/trees/lmt/InMemoryLinkedMerkleLeafStore.js.map +1 -0
- package/dist/trees/lmt/LinkedLeafStore.d.ts +16 -0
- package/dist/trees/lmt/LinkedLeafStore.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedLeafStore.js +2 -0
- package/dist/trees/lmt/LinkedLeafStore.js.map +1 -0
- package/dist/trees/lmt/LinkedLinkedStore.d.ts +16 -0
- package/dist/trees/lmt/LinkedLinkedStore.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedLinkedStore.js +2 -0
- package/dist/trees/lmt/LinkedLinkedStore.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTree.d.ts +11 -0
- package/dist/trees/lmt/LinkedMerkleTree.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTree.js +241 -0
- package/dist/trees/lmt/LinkedMerkleTree.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.d.ts +113 -0
- package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.js +113 -0
- package/dist/trees/lmt/LinkedMerkleTreeCircuitOps.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeDatabase.d.ts +7 -0
- package/dist/trees/lmt/LinkedMerkleTreeDatabase.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeDatabase.js +2 -0
- package/dist/trees/lmt/LinkedMerkleTreeDatabase.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeStore.d.ts +16 -0
- package/dist/trees/lmt/LinkedMerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeStore.js +2 -0
- package/dist/trees/lmt/LinkedMerkleTreeStore.js.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeTypes.d.ts +74 -0
- package/dist/trees/lmt/LinkedMerkleTreeTypes.d.ts.map +1 -0
- package/dist/trees/lmt/LinkedMerkleTreeTypes.js +50 -0
- package/dist/trees/lmt/LinkedMerkleTreeTypes.js.map +1 -0
- package/dist/trees/sparse/InMemoryMerkleTreeStorage.d.ts +11 -0
- package/dist/trees/sparse/InMemoryMerkleTreeStorage.d.ts.map +1 -0
- package/dist/trees/sparse/InMemoryMerkleTreeStorage.js +13 -0
- package/dist/trees/sparse/InMemoryMerkleTreeStorage.js.map +1 -0
- package/dist/trees/sparse/MerkleTreeStore.d.ts +5 -0
- package/dist/trees/sparse/MerkleTreeStore.d.ts.map +1 -0
- package/dist/trees/sparse/MerkleTreeStore.js +2 -0
- package/dist/trees/sparse/MerkleTreeStore.js.map +1 -0
- package/dist/trees/sparse/MockAsyncMerkleStore.d.ts +9 -0
- package/dist/trees/sparse/MockAsyncMerkleStore.d.ts.map +1 -0
- package/dist/trees/sparse/MockAsyncMerkleStore.js +20 -0
- package/dist/trees/sparse/MockAsyncMerkleStore.js.map +1 -0
- package/dist/trees/sparse/RollupMerkleTree.d.ts +158 -0
- package/dist/trees/sparse/RollupMerkleTree.d.ts.map +1 -0
- package/dist/trees/sparse/RollupMerkleTree.js +330 -0
- package/dist/trees/sparse/RollupMerkleTree.js.map +1 -0
- package/dist/types.d.ts +62 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -1
- package/dist/types.js.map +1 -0
- package/dist/union/union.d.ts +177 -0
- package/dist/union/union.d.ts.map +1 -0
- package/dist/union/union.js +35 -0
- package/dist/union/union.js.map +1 -0
- package/dist/utils.d.ts +64 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +165 -3
- package/dist/utils.js.map +1 -0
- package/dist/zkProgrammable/ProvableMethodExecutionContext.d.ts +4 -3
- package/dist/zkProgrammable/ProvableMethodExecutionContext.d.ts.map +1 -1
- package/dist/zkProgrammable/ProvableMethodExecutionContext.js +2 -3
- package/dist/zkProgrammable/ProvableMethodExecutionContext.js.map +1 -0
- package/dist/zkProgrammable/ZkProgrammable.d.ts +23 -9
- package/dist/zkProgrammable/ZkProgrammable.d.ts.map +1 -1
- package/dist/zkProgrammable/ZkProgrammable.js +34 -15
- package/dist/zkProgrammable/ZkProgrammable.js.map +1 -0
- package/dist/zkProgrammable/provableMethod.d.ts +8 -5
- package/dist/zkProgrammable/provableMethod.d.ts.map +1 -1
- package/dist/zkProgrammable/provableMethod.js +30 -15
- package/dist/zkProgrammable/provableMethod.js.map +1 -0
- package/jest.config.cjs +12 -1
- package/package.json +8 -7
- package/src/compiling/AtomicCompileHelper.ts +62 -0
- package/src/compiling/CompilableModule.ts +6 -0
- package/src/compiling/CompileRegistry.ts +74 -0
- package/src/compiling/services/ChildVerificationKeyService.ts +26 -0
- package/src/config/ChildContainerCreatable.ts +5 -0
- package/src/config/ChildContainerProvider.ts +5 -0
- package/src/config/ConfigurableModule.ts +15 -2
- package/src/config/ModuleContainer.ts +286 -58
- package/src/config/Startable.ts +3 -0
- package/src/config/injectAlias.ts +70 -0
- package/src/dependencyFactory/DependencyFactory.ts +34 -109
- package/src/dummyVerificationKey.ts +10 -0
- package/src/events/EventEmitter.ts +61 -0
- package/src/events/EventEmitterProxy.ts +81 -0
- package/src/events/EventEmittingComponent.ts +11 -0
- package/src/events/ReplayingSingleUseEventEmitter.ts +42 -0
- package/src/index.ts +23 -2
- package/src/log.ts +145 -0
- package/src/trees/lmt/AbstractLinkedMerkleTree.ts +102 -0
- package/src/trees/lmt/InMemoryLinkedLeafStore.ts +42 -0
- package/src/trees/lmt/LinkedLeafStore.ts +13 -0
- package/src/trees/lmt/LinkedMerkleTree.ts +335 -0
- package/src/trees/lmt/LinkedMerkleTreeCircuitOps.ts +188 -0
- package/src/trees/lmt/LinkedMerkleTreeTypes.ts +53 -0
- package/src/trees/sparse/InMemoryMerkleTreeStorage.ts +17 -0
- package/src/trees/sparse/MerkleTreeStore.ts +5 -0
- package/src/trees/sparse/MockAsyncMerkleStore.ts +30 -0
- package/src/trees/sparse/RollupMerkleTree.ts +512 -0
- package/src/types.ts +53 -2
- package/src/utils.ts +298 -3
- package/src/zkProgrammable/ProvableMethodExecutionContext.ts +6 -6
- package/src/zkProgrammable/ZkProgrammable.ts +72 -31
- package/src/zkProgrammable/provableMethod.ts +53 -24
- package/test/config/ContainerEvents.test.ts +65 -0
- package/test/config/ModuleContainer.test.ts +146 -15
- package/test/config/injectAlias.test.ts +28 -0
- package/test/trees/LinkedMerkleTree.test.ts +124 -0
- package/test/trees/LinkedMerkleTreeCircuitOps.test.ts +147 -0
- package/test/trees/MerkleTree.test.ts +251 -0
- package/test/tsconfig.json +5 -2
- package/test/zkProgrammable/ZkProgrammable.test.ts +145 -119
- package/tsconfig.json +1 -1
- package/LICENSE.md +0 -201
- package/tsconfig.test.json +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProvableMethodExecutionContext.d.ts","sourceRoot":"","sources":["../../src/zkProgrammable/ProvableMethodExecutionContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ProvableMethodExecutionContext.d.ts","sourceRoot":"","sources":["../../src/zkProgrammable/ProvableMethodExecutionContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAIlC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAWtD,qBAAa,6BAA6B;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,IAAI,CAAC,EAAE,aAAa,CAAC;IAErB,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAE1C,KAAK,CAChB,SAAS,SAAS,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KACtC,OAAO,CAAC,SAAS,CAAC;CAaxB;AAED;;;;GAIG;AACH,qBACa,8BAA8B;IAClC,EAAE,SAAc;IAEhB,OAAO,EAAE,MAAM,EAAE,CAAM;IAEvB,MAAM,EAAE,6BAA6B,CACN;IAGtC;;;;;;OAMG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAI/D;;;;;OAKG;IACI,YAAY,CACjB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa;IAYrB;;;;OAIG;IACI,WAAW;IAIlB,IAAW,UAAU,YAEpB;IAED,IAAW,UAAU,YAEpB;IAED;;OAEG;IACI,OAAO;;;;IAOd;;OAEG;IACI,KAAK;CAGb"}
|
|
@@ -29,13 +29,12 @@ export class ProvableMethodExecutionResult {
|
|
|
29
29
|
* allowing them to post relevant information (such as execution status)
|
|
30
30
|
* into the context without any unnecessary 'prop drilling'.
|
|
31
31
|
*/
|
|
32
|
-
let ProvableMethodExecutionContext = class ProvableMethodExecutionContext {
|
|
32
|
+
export let ProvableMethodExecutionContext = class ProvableMethodExecutionContext {
|
|
33
33
|
constructor() {
|
|
34
34
|
this.id = uniqueId();
|
|
35
35
|
this.methods = [];
|
|
36
36
|
this.result = new ProvableMethodExecutionResult();
|
|
37
37
|
}
|
|
38
|
-
// eslint-disable-next-line no-warning-comments,max-len
|
|
39
38
|
// TODO See if we should make this class generic, bc I think we can persist the type
|
|
40
39
|
/**
|
|
41
40
|
* Adds a method prover to the current execution context,
|
|
@@ -95,4 +94,4 @@ let ProvableMethodExecutionContext = class ProvableMethodExecutionContext {
|
|
|
95
94
|
ProvableMethodExecutionContext = __decorate([
|
|
96
95
|
singleton()
|
|
97
96
|
], ProvableMethodExecutionContext);
|
|
98
|
-
|
|
97
|
+
//# sourceMappingURL=ProvableMethodExecutionContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProvableMethodExecutionContext.js","sourceRoot":"","sources":["../../src/zkProgrammable/ProvableMethodExecutionContext.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAIvC,MAAM,MAAM,GAAG;IACb,wBAAwB,EAAE,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,+BAA+B,CAAC;IAE1E,YAAY,EAAE,CAAC,UAAkB,EAAE,UAAkB,EAAE,EAAE,CACvD,IAAI,KAAK,CACP,uBAAuB,UAAU,IAAI,UAAU,4CAA4C,CAC5F;CACJ,CAAC;AAEF,MAAM,OAAO,6BAA6B;IASjC,KAAK,CAAC,KAAK;QAGhB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,yEAAyE;YACzE,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;gBACxC,MAAM,MAAM,CAAC,wB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IAAI,CAAC,UAAU;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK;QACV,IAAI,CAAC,MAAM,GAAG,IAAI,6BAA6B,EAAE,CAAC;IACpD,CAAC;CACF,CAAA;AA1EY,8BAA8B;IAD1C,SAAS,EAAE;GACC,8BAA8B,CA0E1C"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZkProgram, FlexibleProvablePure, Proof, Field, Provable } from "o1js";
|
|
2
|
+
import type { CompileRegistry } from "../compiling/CompileRegistry";
|
|
2
3
|
export interface CompileArtifact {
|
|
3
|
-
verificationKey:
|
|
4
|
+
verificationKey: {
|
|
5
|
+
data: string;
|
|
6
|
+
hash: Field;
|
|
7
|
+
};
|
|
4
8
|
}
|
|
5
9
|
export interface AreProofsEnabled {
|
|
6
10
|
areProofsEnabled: boolean;
|
|
@@ -12,19 +16,29 @@ export interface Verify<PublicInput, PublicOutput> {
|
|
|
12
16
|
export interface Compile {
|
|
13
17
|
(): Promise<CompileArtifact>;
|
|
14
18
|
}
|
|
15
|
-
export interface PlainZkProgram<PublicInput = undefined, PublicOutput =
|
|
19
|
+
export interface PlainZkProgram<PublicInput = undefined, PublicOutput = undefined> {
|
|
20
|
+
name: string;
|
|
16
21
|
compile: Compile;
|
|
17
22
|
verify: Verify<PublicInput, PublicOutput>;
|
|
18
|
-
Proof: ReturnType<typeof
|
|
19
|
-
methods: Record<string, ((...args: any) => Promise<
|
|
23
|
+
Proof: ReturnType<typeof ZkProgram.Proof<FlexibleProvablePure<PublicInput>, FlexibleProvablePure<PublicOutput>>>;
|
|
24
|
+
methods: Record<string, ((...args: any) => Promise<{
|
|
25
|
+
proof: Proof<PublicInput, PublicOutput>;
|
|
26
|
+
auxiliaryOutput: any;
|
|
27
|
+
}>) | ((publicInput: PublicInput, ...args: any) => Promise<{
|
|
28
|
+
proof: Proof<PublicInput, PublicOutput>;
|
|
29
|
+
auxiliaryOutput: any;
|
|
30
|
+
}>)>;
|
|
31
|
+
analyzeMethods: () => Promise<Record<string, Awaited<ReturnType<typeof Provable.constraintSystem>>>>;
|
|
20
32
|
}
|
|
21
33
|
export declare function verifyToMockable<PublicInput, PublicOutput>(verify: Verify<PublicInput, PublicOutput>, { areProofsEnabled }: AreProofsEnabled): (proof: Proof<PublicInput, PublicOutput>) => Promise<boolean>;
|
|
22
|
-
export declare const
|
|
34
|
+
export declare const MOCK_VERIFICATION_KEY: import("o1js/dist/node/lib/proof-system/verification-key").VerificationKey;
|
|
23
35
|
export declare function compileToMockable(compile: Compile, { areProofsEnabled }: AreProofsEnabled): () => Promise<CompileArtifact>;
|
|
24
36
|
export declare abstract class ZkProgrammable<PublicInput = undefined, PublicOutput = void> {
|
|
25
|
-
abstract get
|
|
26
|
-
abstract zkProgramFactory(): PlainZkProgram<PublicInput, PublicOutput
|
|
27
|
-
|
|
37
|
+
abstract get areProofsEnabled(): AreProofsEnabled | undefined;
|
|
38
|
+
abstract zkProgramFactory(): PlainZkProgram<PublicInput, PublicOutput>[];
|
|
39
|
+
private zkProgramSingleton?;
|
|
40
|
+
get zkProgram(): PlainZkProgram<PublicInput, PublicOutput>[];
|
|
41
|
+
compile(registry: CompileRegistry): Promise<Record<string, CompileArtifact>>;
|
|
28
42
|
}
|
|
29
43
|
export interface WithZkProgrammable<PublicInput = undefined, PublicOutput = void> {
|
|
30
44
|
zkProgrammable: ZkProgrammable<PublicInput, PublicOutput>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZkProgrammable.d.ts","sourceRoot":"","sources":["../../src/zkProgrammable/ZkProgrammable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ZkProgrammable.d.ts","sourceRoot":"","sources":["../../src/zkProgrammable/ZkProgrammable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,KAAK,EAAE,KAAK,EA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;QACxC,eAAe,EAAE,GAAG,CAAC;KACtB,CAAC,CAAC,CACN,CAAC;IACF,cAAc,EAAE,MAAM,OAAO,CAC3B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CACtE,CAAC;CACH;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,YAAY,EACxD,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,YAAY,CAAC,EACzC,EAAE,gBAAgB,EAAE,EAAE,gBAAgB,WAEjB,MAAM,WAAW,EAAE,YAAY,CAAC,sBAiBtD;AAED,eAAO,MAAM,qBAAqB,4EAAyB,CAAC;AAE5D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,EAAE,gBAAgB,EAAE,EAAE,gBAAgB,GACrC,MAAM,OAAO,CAAC,eAAe,CAAC,CAUhC;AAED,8BAAsB,cAAc,CAClC,WAAW,GAAG,SAAS,EACvB,YAAY,GAAG,IAAI;IAEnB,aAAoB,gBAAgB,IAAI,gBAAgB,GAAG,SAAS,CAAC;aAErD,gBAAgB,IAAI,cAAc,CAChD,WAAW,EACX,YAAY,CACb,EAAE;IAEH,OAAO,CAAC,kBAAkB,CAAC,CAA8C;IAEzE,IACW,SAAS,IAAI,cAAc,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,CAelE;IAEY,OAAO,CAAC,QAAQ,EAAE,eAAe;CAc/C;AAED,MAAM,WAAW,kBAAkB,CACjC,WAAW,GAAG,SAAS,EACvB,YAAY,GAAG,IAAI;IAEnB,cAAc,EAAE,cAAc,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;CAC3D"}
|
|
@@ -8,9 +8,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { Memoize } from "typescript-memoize";
|
|
11
|
-
import {
|
|
11
|
+
import { log } from "../log";
|
|
12
|
+
import { dummyVerificationKey } from "../dummyVerificationKey";
|
|
13
|
+
import { reduceSequential } from "../utils";
|
|
14
|
+
import { MOCK_PROOF } from "./provableMethod";
|
|
12
15
|
const errors = {
|
|
13
|
-
|
|
16
|
+
areProofsEnabledNotSet: (name) => new Error(`AreProofsEnabled was not injected for: ${name}`),
|
|
14
17
|
};
|
|
15
18
|
export function verifyToMockable(verify, { areProofsEnabled }) {
|
|
16
19
|
return async (proof) => {
|
|
@@ -21,40 +24,56 @@ export function verifyToMockable(verify, { areProofsEnabled }) {
|
|
|
21
24
|
}
|
|
22
25
|
catch (error) {
|
|
23
26
|
// silently fail verification
|
|
24
|
-
|
|
27
|
+
log.error(error);
|
|
25
28
|
verified = false;
|
|
26
29
|
}
|
|
27
30
|
return verified;
|
|
28
31
|
}
|
|
29
|
-
return proof.proof ===
|
|
32
|
+
return proof.proof === MOCK_PROOF;
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
|
-
export const
|
|
35
|
+
export const MOCK_VERIFICATION_KEY = dummyVerificationKey();
|
|
33
36
|
export function compileToMockable(compile, { areProofsEnabled }) {
|
|
34
37
|
return async () => {
|
|
35
38
|
if (areProofsEnabled) {
|
|
36
39
|
return await compile();
|
|
37
40
|
}
|
|
38
41
|
return {
|
|
39
|
-
verificationKey:
|
|
42
|
+
verificationKey: MOCK_VERIFICATION_KEY,
|
|
40
43
|
};
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
46
|
export class ZkProgrammable {
|
|
44
47
|
get zkProgram() {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
throw errors.appChainNotSet(this.constructor.name);
|
|
48
|
+
if (this.zkProgramSingleton === undefined) {
|
|
49
|
+
this.zkProgramSingleton = this.zkProgramFactory();
|
|
48
50
|
}
|
|
49
|
-
return {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
return this.zkProgramSingleton.map((bucket) => {
|
|
52
|
+
if (!this.areProofsEnabled) {
|
|
53
|
+
throw errors.areProofsEnabledNotSet(this.constructor.name);
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...bucket,
|
|
57
|
+
verify: verifyToMockable(bucket.verify, this.areProofsEnabled),
|
|
58
|
+
compile: compileToMockable(bucket.compile, this.areProofsEnabled),
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async compile(registry) {
|
|
63
|
+
return await reduceSequential(this.zkProgram, async (acc, program) => {
|
|
64
|
+
const result = await registry.compile(program);
|
|
65
|
+
return {
|
|
66
|
+
...acc,
|
|
67
|
+
[program.name]: result,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
71
|
+
{});
|
|
54
72
|
}
|
|
55
73
|
}
|
|
56
74
|
__decorate([
|
|
57
75
|
Memoize(),
|
|
58
|
-
__metadata("design:type",
|
|
76
|
+
__metadata("design:type", Array),
|
|
59
77
|
__metadata("design:paramtypes", [])
|
|
60
78
|
], ZkProgrammable.prototype, "zkProgram", null);
|
|
79
|
+
//# sourceMappingURL=ZkProgrammable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZkProgrammable.js","sourceRoot":"","sources":["../../src/zkProgrammable/ZkProgrammable.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,MAAM,GAAG;IACb,sBAAsB,EAAE,CAAC,IAAY,EAAE,EAAE,CACvC,IAAI,KAAK,CAAC,0CAA0C,IAAI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EAAE,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC;gBAC9D,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,CAAC;aAClE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAyB;QAC5C,OAAO,MAAM,gBAAgB,CAC3B,IAAI,CAAC,SAAS,EACd,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;YACrB,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC/C,OAAO;gBACL,GAAG,GAAG;gBACN,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM;aACvB,CAAC;QACJ,CAAC;QACD,yEAAyE;QACzE,EAAqC,CACtC,CAAC;IACJ,CAAC;CACF;AAhCC;IAAC,OAAO,EAAE;;;+CAgBT"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { Proof, DynamicProof } from "o1js";
|
|
1
2
|
import { ProvableMethodExecutionContext } from "./ProvableMethodExecutionContext";
|
|
2
|
-
import type { ZkProgrammable } from "./ZkProgrammable";
|
|
3
|
-
export type
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
import type { WithZkProgrammable, ZkProgrammable } from "./ZkProgrammable";
|
|
4
|
+
export type O1JSPrimitive = object | string | boolean | number;
|
|
5
|
+
export type ArgumentTypes = (O1JSPrimitive | Proof<unknown, unknown> | DynamicProof<unknown, unknown>)[];
|
|
6
|
+
export type DecoratedMethod = (...args: ArgumentTypes) => Promise<unknown>;
|
|
7
|
+
export declare const MOCK_PROOF = "mock-proof";
|
|
8
|
+
export declare function toProver(methodName: string, simulatedMethod: DecoratedMethod, isFirstParameterPublicInput: boolean, ...args: ArgumentTypes): (this: ZkProgrammable<any, any>) => Promise<Proof<any, any>>;
|
|
6
9
|
/**
|
|
7
10
|
* Decorates a provable method on a 'prover class', depending on
|
|
8
11
|
* if proofs are enabled or not, either runs the respective zkProgram prover,
|
|
@@ -12,5 +15,5 @@ export declare function toProver(methodName: string, simulatedMethod: DecoratedM
|
|
|
12
15
|
* @param executionContext
|
|
13
16
|
* @returns
|
|
14
17
|
*/
|
|
15
|
-
export declare function provableMethod(isFirstParameterPublicInput?: boolean, executionContext?: ProvableMethodExecutionContext): <Target extends ZkProgrammable<any, any>>(target: Target, methodName: string, descriptor:
|
|
18
|
+
export declare function provableMethod(isFirstParameterPublicInput?: boolean, executionContext?: ProvableMethodExecutionContext): <Target extends ZkProgrammable<any, any> | WithZkProgrammable<any, any>>(target: Target, methodName: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any> | any>) => TypedPropertyDescriptor<(...args: any[]) => Promise<any> | any>;
|
|
16
19
|
//# sourceMappingURL=provableMethod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provableMethod.d.ts","sourceRoot":"","sources":["../../src/zkProgrammable/provableMethod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provableMethod.d.ts","sourceRoot":"","sources":["../../src/zkProgrammable/provableMethod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAG3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG3E,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAC/D,MAAM,MAAM,aAAa,GAAG,CACxB,aAAa,GACb,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,GACvB,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,CACjC,EAAE,CAAC;AAEJ,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE3E,eAAO,MAAM,UAAU,eAAe,CAAC;AAGvC,wBAAgB,QAAQ,CACtB,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,eAAe,EAChC,2BAA2B,EAAE,OAAO,EACpC,GAAG,IAAI,EAAE,aAAa,UAEa,eAAe,GAAG,EAAE,GAAG,CAAC,8BA+C5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,2BAA2B,UAAO,EAClC,gBAAgB,GAAE,8BAEjB,wGAMa,MAAM,gDAC4B,GAAG,EAAE,KAAK,QAAQ,GAAG,CAAC,GAAG,GAAG,wCAA5B,GAAG,EAAE,KAAK,QAAQ,GAAG,CAAC,GAAG,GAAG,EA2C7E"}
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
import { container } from "tsyringe";
|
|
2
2
|
import { ProvableMethodExecutionContext } from "./ProvableMethodExecutionContext";
|
|
3
|
-
export const
|
|
3
|
+
export const MOCK_PROOF = "mock-proof";
|
|
4
|
+
// (await Proof.dummy(Field(0), Field(0), 2)).proof as string;
|
|
4
5
|
export function toProver(methodName, simulatedMethod, isFirstParameterPublicInput, ...args) {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
6
|
return async function prover() {
|
|
7
|
-
const areProofsEnabled = this.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const { areProofsEnabled } = this.areProofsEnabled;
|
|
8
|
+
const zkProgram = this.zkProgram.find((prog) => Object.keys(prog.methods).includes(methodName));
|
|
9
|
+
if (zkProgram === undefined) {
|
|
10
|
+
throw new Error(`Correct ZkProgram not found (searching for method ${methodName})`);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if (areProofsEnabled) {
|
|
13
|
+
const programProvableMethod = zkProgram.methods[methodName];
|
|
14
|
+
const result = await Reflect.apply(programProvableMethod, this, args);
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
16
|
+
return result.proof;
|
|
17
|
+
}
|
|
18
|
+
// create a mock proof by simulating method> execution in JS
|
|
19
|
+
const publicOutput = await Reflect.apply(simulatedMethod, this, args);
|
|
20
|
+
return new zkProgram.Proof({
|
|
21
|
+
proof: MOCK_PROOF,
|
|
17
22
|
// TODO: provide undefined if public input is not used
|
|
18
23
|
publicInput: isFirstParameterPublicInput ? args[0] : undefined,
|
|
19
|
-
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
25
|
+
publicOutput: (() => {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
27
|
+
if (!publicOutput || typeof publicOutput !== "object") {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
if ("publicOutput" in publicOutput) {
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
32
|
+
return publicOutput.publicOutput;
|
|
33
|
+
}
|
|
34
|
+
return publicOutput;
|
|
35
|
+
})(),
|
|
20
36
|
/**
|
|
21
37
|
* We set this to the max possible number, to avoid having
|
|
22
38
|
* to manually count in-circuit proof verifications
|
|
@@ -35,11 +51,10 @@ export function toProver(methodName, simulatedMethod, isFirstParameterPublicInpu
|
|
|
35
51
|
* @returns
|
|
36
52
|
*/
|
|
37
53
|
export function provableMethod(isFirstParameterPublicInput = true, executionContext = container.resolve(ProvableMethodExecutionContext)) {
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
54
|
return (target, methodName, descriptor) => {
|
|
40
55
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
41
56
|
const simulatedMethod = descriptor.value;
|
|
42
|
-
descriptor.value = function value(...args) {
|
|
57
|
+
descriptor.value = async function value(...args) {
|
|
43
58
|
const prover = toProver(methodName, simulatedMethod, isFirstParameterPublicInput, ...args);
|
|
44
59
|
executionContext.beforeMethod(this.constructor.name, methodName, args);
|
|
45
60
|
/**
|
|
@@ -54,7 +69,6 @@ export function provableMethod(isFirstParameterPublicInput = true, executionCont
|
|
|
54
69
|
* or not, execute its simulated (Javascript) version and
|
|
55
70
|
* return the result.
|
|
56
71
|
*/
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
58
72
|
let result;
|
|
59
73
|
try {
|
|
60
74
|
result = Reflect.apply(simulatedMethod, this, args);
|
|
@@ -67,3 +81,4 @@ export function provableMethod(isFirstParameterPublicInput = true, executionCont
|
|
|
67
81
|
return descriptor;
|
|
68
82
|
};
|
|
69
83
|
}
|
|
84
|
+
//# sourceMappingURL=provableMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provableMethod.js","sourceRoot":"","sources":["../../src/zkProgrammable/provableMethod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAalF,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AACvC,8DAA8D;AAE9D,MAAM,UAAU,QAAQ,CACtB,UAAkB,EAClB,eAAgC,EAChC,2BAAoC,EACpC,GAAG,IAAmB;IAEtB,OAAO,KAAK,UAAU,MAAM;QAC1B,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,gBAAiB,CAAC;QAEpD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAC7C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC/C,CAAC;QAEF,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,MAAM,IAAI,KAAK,CACb,qDAAqD,UAAU,GAAG,CACnE,CAAC;SACH;QAED,IAAI,gBAAgB,EAAE;YACpB,MAAM,qBAAqB,GAAG,SAAS,C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AAU,EACV,eAAe,EACf,2BAA2B,EAC3B,GAAG,IAAI,CACR,CAAC;YAEF,gBAAgB,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;YAEvE;;;eAGG;YACH,IAAI,gBAAgB,CAAC,UAAU,EAAE;gBAC/B,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;aAC/C;YAED;;;;eAIG;YACH,IAAI,MAAe,CAAC;YACpB,IAAI;gBACF,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;aACrD;oBAAS;gBACR,gBAAgB,CAAC,WAAW,EAAE,CAAC;aAChC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
package/jest.config.cjs
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
const config = require("../../jest.config.cjs");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
...config,
|
|
6
|
+
collectCoverageFrom: [
|
|
7
|
+
"packages/common/src/**",
|
|
8
|
+
"!**/node_modules/**",
|
|
9
|
+
"!**/dist/**",
|
|
10
|
+
],
|
|
11
|
+
coverageDirectory: "coverage/common",
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.1.1-develop.
|
|
6
|
+
"version": "0.1.1-develop.2024+5a945075",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc -p tsconfig.json",
|
|
9
9
|
"dev": "tsc -p tsconfig.json --watch",
|
|
10
10
|
"lint": "eslint ./src ./test",
|
|
11
|
-
"test:file": "node --experimental-vm-modules --experimental-wasm-modules
|
|
12
|
-
"test": "npm run test:file -- ./
|
|
13
|
-
"test:watch": "npm run test:file -- ./
|
|
11
|
+
"test:file": "node --experimental-vm-modules --experimental-wasm-modules ../../node_modules/jest/bin/jest.js",
|
|
12
|
+
"test": "npm run test:file -- ./test/**",
|
|
13
|
+
"test:watch": "npm run test:file -- ./test/** --watch"
|
|
14
14
|
},
|
|
15
15
|
"main": "dist/index.js",
|
|
16
16
|
"publishConfig": {
|
|
@@ -20,15 +20,16 @@
|
|
|
20
20
|
"lodash": "^4.17.21",
|
|
21
21
|
"loglevel": "^1.8.1",
|
|
22
22
|
"reflect-metadata": "^0.1.13",
|
|
23
|
+
"ts-mixer": "^6.0.3",
|
|
23
24
|
"typescript-memoize": "^1.1.1"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"tsyringe": "^4.
|
|
27
|
+
"o1js": "^2.10.0",
|
|
28
|
+
"tsyringe": "^4.10.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@jest/globals": "^29.5.0",
|
|
31
32
|
"@types/lodash": "^4.14.194"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "5a945075ca3572f50ea9a686224c2eccab1421b0"
|
|
34
35
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AreProofsEnabled,
|
|
3
|
+
CompileArtifact,
|
|
4
|
+
MOCK_VERIFICATION_KEY,
|
|
5
|
+
} from "../zkProgrammable/ZkProgrammable";
|
|
6
|
+
import { isSubtypeOfName } from "../utils";
|
|
7
|
+
import { TypedClass } from "../types";
|
|
8
|
+
import { log } from "../log";
|
|
9
|
+
|
|
10
|
+
export type ArtifactRecord = Record<string, CompileArtifact>;
|
|
11
|
+
|
|
12
|
+
export type CompileTarget = {
|
|
13
|
+
name: string;
|
|
14
|
+
compile: () => Promise<CompileArtifact>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export class AtomicCompileHelper {
|
|
18
|
+
public constructor(private readonly areProofsEnabled: AreProofsEnabled) {}
|
|
19
|
+
|
|
20
|
+
private compilationPromises: {
|
|
21
|
+
[key: string]: Promise<CompileArtifact>;
|
|
22
|
+
} = {};
|
|
23
|
+
|
|
24
|
+
public async compileContract(
|
|
25
|
+
contract: CompileTarget,
|
|
26
|
+
overrideProofsEnabled?: boolean
|
|
27
|
+
): Promise<CompileArtifact> {
|
|
28
|
+
let newPromise = false;
|
|
29
|
+
const { name } = contract;
|
|
30
|
+
if (this.compilationPromises[name] === undefined) {
|
|
31
|
+
const proofsEnabled =
|
|
32
|
+
overrideProofsEnabled ?? this.areProofsEnabled.areProofsEnabled;
|
|
33
|
+
|
|
34
|
+
// We only care about proofs enabled here if it's a contract, because
|
|
35
|
+
// in all other cases, ZkProgrammable already handles this switch, and we
|
|
36
|
+
// want to preserve the artifact layout (which might be more than one
|
|
37
|
+
// entry for ZkProgrammables)
|
|
38
|
+
if (
|
|
39
|
+
proofsEnabled ||
|
|
40
|
+
!isSubtypeOfName(
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
42
|
+
contract as unknown as TypedClass<any>,
|
|
43
|
+
"SmartContract"
|
|
44
|
+
)
|
|
45
|
+
) {
|
|
46
|
+
log.time(`Compiling ${name}`);
|
|
47
|
+
this.compilationPromises[name] = contract.compile();
|
|
48
|
+
newPromise = true;
|
|
49
|
+
} else {
|
|
50
|
+
log.debug(`Compiling ${name} - mock`);
|
|
51
|
+
this.compilationPromises[name] = Promise.resolve({
|
|
52
|
+
verificationKey: MOCK_VERIFICATION_KEY,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const result = await this.compilationPromises[name];
|
|
57
|
+
if (newPromise) {
|
|
58
|
+
log.timeEnd.info(`Compiling ${name}`);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { inject, injectable, singleton } from "tsyringe";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AreProofsEnabled,
|
|
5
|
+
CompileArtifact,
|
|
6
|
+
} from "../zkProgrammable/ZkProgrammable";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ArtifactRecord,
|
|
10
|
+
AtomicCompileHelper,
|
|
11
|
+
CompileTarget,
|
|
12
|
+
} from "./AtomicCompileHelper";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The CompileRegistry compiles "compilable modules"
|
|
16
|
+
* (i.e. zkprograms, contracts or contractmodules)
|
|
17
|
+
* while making sure they don't get compiled twice in the same process in parallel.
|
|
18
|
+
*/
|
|
19
|
+
@injectable()
|
|
20
|
+
@singleton()
|
|
21
|
+
export class CompileRegistry {
|
|
22
|
+
public constructor(
|
|
23
|
+
@inject("AreProofsEnabled")
|
|
24
|
+
private readonly areProofsEnabled: AreProofsEnabled
|
|
25
|
+
) {
|
|
26
|
+
this.compiler = new AtomicCompileHelper(this.areProofsEnabled);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private compiler: AtomicCompileHelper;
|
|
30
|
+
|
|
31
|
+
private artifacts: ArtifactRecord = {};
|
|
32
|
+
|
|
33
|
+
private inForceProverBlock = false;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* This function forces compilation even if the artifact itself is in the registry.
|
|
37
|
+
* Basically the statement is: The artifact along is not enough, we need to
|
|
38
|
+
* actually have the prover compiled.
|
|
39
|
+
* This is true for non-sideloaded circuit dependencies.
|
|
40
|
+
*/
|
|
41
|
+
public async forceProverExists<R>(
|
|
42
|
+
f: (registry: CompileRegistry) => Promise<R>
|
|
43
|
+
): Promise<R> {
|
|
44
|
+
this.inForceProverBlock = true;
|
|
45
|
+
const result = await f(this);
|
|
46
|
+
this.inForceProverBlock = false;
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async compile(target: CompileTarget, nameOverride?: string) {
|
|
51
|
+
const name = nameOverride ?? target.name;
|
|
52
|
+
if (this.artifacts[name] === undefined || this.inForceProverBlock) {
|
|
53
|
+
const artifact = await this.compiler.compileContract(target);
|
|
54
|
+
this.artifacts[name] = artifact;
|
|
55
|
+
return artifact;
|
|
56
|
+
}
|
|
57
|
+
return this.artifacts[name];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public getArtifact(name: string): CompileArtifact | undefined {
|
|
61
|
+
return this.artifacts[name];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public addArtifactsRaw(artifacts: ArtifactRecord) {
|
|
65
|
+
this.artifacts = {
|
|
66
|
+
...this.artifacts,
|
|
67
|
+
...artifacts,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public getAllArtifacts() {
|
|
72
|
+
return this.artifacts;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { injectable, Lifecycle, scoped } from "tsyringe";
|
|
2
|
+
|
|
3
|
+
import { CompileRegistry } from "../CompileRegistry";
|
|
4
|
+
|
|
5
|
+
@injectable()
|
|
6
|
+
@scoped(Lifecycle.ContainerScoped)
|
|
7
|
+
export class ChildVerificationKeyService {
|
|
8
|
+
private compileRegistry?: CompileRegistry;
|
|
9
|
+
|
|
10
|
+
public setCompileRegistry(registry: CompileRegistry) {
|
|
11
|
+
this.compileRegistry = registry;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public getVerificationKey(name: string) {
|
|
15
|
+
if (this.compileRegistry === undefined) {
|
|
16
|
+
throw new Error("CompileRegistry hasn't been set yet");
|
|
17
|
+
}
|
|
18
|
+
const artifact = this.compileRegistry.getArtifact(name);
|
|
19
|
+
if (artifact === undefined) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
`Verification Key for child program ${name} not found in registry`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return artifact.verificationKey;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { noop } from "../utils";
|
|
2
|
+
|
|
3
|
+
import { ChildContainerProvider } from "./ChildContainerProvider";
|
|
4
|
+
import type { BaseModuleInstanceType } from "./ModuleContainer";
|
|
5
|
+
|
|
1
6
|
const errors = {
|
|
2
7
|
configNotSet: (moduleName: string) =>
|
|
3
8
|
new Error(
|
|
@@ -6,7 +11,7 @@ const errors = {
|
|
|
6
11
|
};
|
|
7
12
|
|
|
8
13
|
// defines how presets can be provided, either a function or a record
|
|
9
|
-
export type Preset<Config> = Config | ((...args:
|
|
14
|
+
export type Preset<Config> = Config | ((...args: unknown[]) => Config);
|
|
10
15
|
export type Presets<Config> = Record<string, Preset<Config>>;
|
|
11
16
|
|
|
12
17
|
// describes the interface of a configurable module
|
|
@@ -14,10 +19,14 @@ export interface Configurable<Config> {
|
|
|
14
19
|
config: Config;
|
|
15
20
|
}
|
|
16
21
|
|
|
22
|
+
export type NoConfig = Record<never, never>;
|
|
23
|
+
|
|
17
24
|
/**
|
|
18
25
|
* Used by various module sub-types that may need to be configured
|
|
19
26
|
*/
|
|
20
|
-
export class ConfigurableModule<Config
|
|
27
|
+
export class ConfigurableModule<Config = NoConfig>
|
|
28
|
+
implements BaseModuleInstanceType
|
|
29
|
+
{
|
|
21
30
|
/**
|
|
22
31
|
* Store the config separately, so that we can apply additional
|
|
23
32
|
* checks when retrieving it via the getter
|
|
@@ -36,6 +45,10 @@ export class ConfigurableModule<Config> implements Configurable<Config> {
|
|
|
36
45
|
public set config(config: Config) {
|
|
37
46
|
this.currentConfig = config;
|
|
38
47
|
}
|
|
48
|
+
|
|
49
|
+
public create(childContainerProvider: ChildContainerProvider): void {
|
|
50
|
+
noop();
|
|
51
|
+
}
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
// Helps ensure that the target class implements static presets
|