@proto-kit/common 0.1.1-develop.153
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/LICENSE.md +201 -0
- package/dist/Constants.d.ts +4 -0
- package/dist/Constants.d.ts.map +1 -0
- package/dist/Constants.js +3 -0
- package/dist/config/ConfigurableModule.d.ts +21 -0
- package/dist/config/ConfigurableModule.d.ts.map +1 -0
- package/dist/config/ConfigurableModule.js +19 -0
- package/dist/config/ConfigurationAggregator.d.ts +10 -0
- package/dist/config/ConfigurationAggregator.d.ts.map +1 -0
- package/dist/config/ConfigurationAggregator.js +35 -0
- package/dist/config/ConfigurationReceiver.d.ts +25 -0
- package/dist/config/ConfigurationReceiver.d.ts.map +1 -0
- package/dist/config/ConfigurationReceiver.js +36 -0
- package/dist/config/ModuleContainer.d.ts +103 -0
- package/dist/config/ModuleContainer.d.ts.map +1 -0
- package/dist/config/ModuleContainer.js +163 -0
- package/dist/config/types.d.ts +2 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/model/MethodPublicInput.d.ts +51 -0
- package/dist/model/MethodPublicInput.d.ts.map +1 -0
- package/dist/model/MethodPublicInput.js +11 -0
- package/dist/model/Option.d.ts +89 -0
- package/dist/model/Option.d.ts.map +1 -0
- package/dist/model/Option.js +86 -0
- package/dist/model/Path.d.ts +31 -0
- package/dist/model/Path.d.ts.map +1 -0
- package/dist/model/Path.js +44 -0
- package/dist/model/StateTransition.d.ts +85 -0
- package/dist/model/StateTransition.d.ts.map +1 -0
- package/dist/model/StateTransition.js +58 -0
- package/dist/model/StateTransitionProvableBatch.d.ts +56 -0
- package/dist/model/StateTransitionProvableBatch.d.ts.map +1 -0
- package/dist/model/StateTransitionProvableBatch.js +20 -0
- package/dist/prover/block/BlockProver.d.ts +199 -0
- package/dist/prover/block/BlockProver.d.ts.map +1 -0
- package/dist/prover/block/BlockProver.js +119 -0
- package/dist/prover/block/BlockScopedModule.d.ts +3 -0
- package/dist/prover/block/BlockScopedModule.d.ts.map +1 -0
- package/dist/prover/block/BlockScopedModule.js +6 -0
- package/dist/prover/statetransition/StateTransitionProver.d.ts +92 -0
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -0
- package/dist/prover/statetransition/StateTransitionProver.js +127 -0
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts +16 -0
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts.map +1 -0
- package/dist/prover/statetransition/StateTransitionWitnessProvider.js +17 -0
- package/dist/src/model/Option.d.ts +158 -0
- package/dist/src/model/Option.d.ts.map +1 -0
- package/dist/src/model/Option.js +53 -0
- package/dist/src/model/Path.d.ts +35 -0
- package/dist/src/model/Path.d.ts.map +1 -0
- package/dist/src/model/Path.js +51 -0
- package/dist/src/model/StateTransition.d.ts +201 -0
- package/dist/src/model/StateTransition.d.ts.map +1 -0
- package/dist/src/model/StateTransition.js +43 -0
- package/dist/src/utils/PrefixedHashList.d.ts +15 -0
- package/dist/src/utils/PrefixedHashList.d.ts.map +1 -0
- package/dist/src/utils/PrefixedHashList.js +28 -0
- package/dist/src/utils/ProvableHashList.d.ts +30 -0
- package/dist/src/utils/ProvableHashList.d.ts.map +1 -0
- package/dist/src/utils/ProvableHashList.js +43 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils/PrefixedHashList.d.ts +14 -0
- package/dist/utils/PrefixedHashList.d.ts.map +1 -0
- package/dist/utils/PrefixedHashList.js +12 -0
- package/dist/utils/PrefixedProvableHashList.d.ts +8 -0
- package/dist/utils/PrefixedProvableHashList.d.ts.map +1 -0
- package/dist/utils/PrefixedProvableHashList.js +12 -0
- package/dist/utils/ProvableHashList.d.ts +26 -0
- package/dist/utils/ProvableHashList.d.ts.map +1 -0
- package/dist/utils/ProvableHashList.js +35 -0
- package/dist/utils/Utils.d.ts +22 -0
- package/dist/utils/Utils.d.ts.map +1 -0
- package/dist/utils/Utils.js +41 -0
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts +26 -0
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts.map +1 -0
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.js +79 -0
- package/dist/utils/merkletree/RollupMerkleTree.d.ts +143 -0
- package/dist/utils/merkletree/RollupMerkleTree.d.ts.map +1 -0
- package/dist/utils/merkletree/RollupMerkleTree.js +246 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +7 -0
- package/dist/zkProgrammable/ProvableMethodExecutionContext.d.ts +53 -0
- package/dist/zkProgrammable/ProvableMethodExecutionContext.d.ts.map +1 -0
- package/dist/zkProgrammable/ProvableMethodExecutionContext.js +98 -0
- package/dist/zkProgrammable/ZkProgrammable.d.ts +32 -0
- package/dist/zkProgrammable/ZkProgrammable.d.ts.map +1 -0
- package/dist/zkProgrammable/ZkProgrammable.js +60 -0
- package/dist/zkProgrammable/provableMethod.d.ts +16 -0
- package/dist/zkProgrammable/provableMethod.d.ts.map +1 -0
- package/dist/zkProgrammable/provableMethod.js +69 -0
- package/jest.config.cjs +1 -0
- package/package.json +35 -0
- package/src/config/ConfigurableModule.ts +44 -0
- package/src/config/ModuleContainer.ts +265 -0
- package/src/index.ts +9 -0
- package/src/types.ts +17 -0
- package/src/utils.ts +10 -0
- package/src/zkProgrammable/ProvableMethodExecutionContext.ts +122 -0
- package/src/zkProgrammable/ZkProgrammable.ts +119 -0
- package/src/zkProgrammable/provableMethod.ts +109 -0
- package/test/config/ModuleContainer.test.ts +82 -0
- package/test/tsconfig.json +4 -0
- package/test/zkProgrammable/ZkProgrammable.test.ts +283 -0
- package/tsconfig.json +8 -0
- package/tsconfig.test.json +9 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Field, type Proof, SelfProof } from "snarkyjs";
|
|
2
|
+
import { StateTransitionProver, type StateTransitionProverPublicInput } from "../statetransition/StateTransitionProver.js";
|
|
3
|
+
import { MethodPublicInput } from "../../model/MethodPublicInput";
|
|
4
|
+
import { Subclass } from "../../utils/utils";
|
|
5
|
+
export interface BlockProverState {
|
|
6
|
+
stateRoot: Field;
|
|
7
|
+
/**
|
|
8
|
+
* The current commitment of the transaction-list which
|
|
9
|
+
* will at the end equal the bundle hash
|
|
10
|
+
*/
|
|
11
|
+
transactionsHash: Field;
|
|
12
|
+
}
|
|
13
|
+
declare const BlockProverPublicInput_base: (new (value: {
|
|
14
|
+
fromTransactionsHash: Field;
|
|
15
|
+
toTransactionsHash: Field;
|
|
16
|
+
fromStateRoot: Field;
|
|
17
|
+
toStateRoot: Field;
|
|
18
|
+
}) => {
|
|
19
|
+
fromTransactionsHash: Field;
|
|
20
|
+
toTransactionsHash: Field;
|
|
21
|
+
fromStateRoot: Field;
|
|
22
|
+
toStateRoot: Field;
|
|
23
|
+
}) & {
|
|
24
|
+
_isStruct: true;
|
|
25
|
+
} & import("snarkyjs/dist/node/snarky.js").ProvablePure<{
|
|
26
|
+
fromTransactionsHash: Field;
|
|
27
|
+
toTransactionsHash: Field;
|
|
28
|
+
fromStateRoot: Field;
|
|
29
|
+
toStateRoot: Field;
|
|
30
|
+
}> & {
|
|
31
|
+
toInput: (x: {
|
|
32
|
+
fromTransactionsHash: Field;
|
|
33
|
+
toTransactionsHash: Field;
|
|
34
|
+
fromStateRoot: Field;
|
|
35
|
+
toStateRoot: Field;
|
|
36
|
+
}) => {
|
|
37
|
+
fields?: Field[] | undefined;
|
|
38
|
+
packed?: [Field, number][] | undefined;
|
|
39
|
+
};
|
|
40
|
+
toJSON: (x: {
|
|
41
|
+
fromTransactionsHash: Field;
|
|
42
|
+
toTransactionsHash: Field;
|
|
43
|
+
fromStateRoot: Field;
|
|
44
|
+
toStateRoot: Field;
|
|
45
|
+
}) => {
|
|
46
|
+
fromTransactionsHash: string;
|
|
47
|
+
toTransactionsHash: string;
|
|
48
|
+
fromStateRoot: string;
|
|
49
|
+
toStateRoot: string;
|
|
50
|
+
};
|
|
51
|
+
fromJSON: (x: {
|
|
52
|
+
fromTransactionsHash: string;
|
|
53
|
+
toTransactionsHash: string;
|
|
54
|
+
fromStateRoot: string;
|
|
55
|
+
toStateRoot: string;
|
|
56
|
+
}) => {
|
|
57
|
+
fromTransactionsHash: Field;
|
|
58
|
+
toTransactionsHash: Field;
|
|
59
|
+
fromStateRoot: Field;
|
|
60
|
+
toStateRoot: Field;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare class BlockProverPublicInput extends BlockProverPublicInput_base {
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* BlockProver class, which aggregates a AppChainProof and
|
|
67
|
+
* a StateTransitionProof into a single BlockProof, that can
|
|
68
|
+
* then be merged to be committed to the base-layer contract
|
|
69
|
+
*/
|
|
70
|
+
export declare class BlockProver {
|
|
71
|
+
private readonly stateTransitionProver;
|
|
72
|
+
constructor(stateTransitionProver: StateTransitionProver);
|
|
73
|
+
/**
|
|
74
|
+
* Applies and checks the two proofs and applies the corresponding state
|
|
75
|
+
* changes to the given state
|
|
76
|
+
*
|
|
77
|
+
* @param state The from-state of the BlockProver
|
|
78
|
+
* @param stateTransitionProof
|
|
79
|
+
* @param appProof
|
|
80
|
+
* @returns The new BlockProver-state to be used as public output
|
|
81
|
+
*/
|
|
82
|
+
applyTransaction(state: BlockProverState, stateTransitionProof: Proof<StateTransitionProverPublicInput>, appProof: Proof<MethodPublicInput>): BlockProverState;
|
|
83
|
+
proveTransaction(publicInput: BlockProverPublicInput, stateProof: Proof<StateTransitionProverPublicInput>, appProof: Proof<MethodPublicInput>): void;
|
|
84
|
+
merge(publicInput: BlockProverPublicInput, proof1: SelfProof<BlockProverPublicInput>, proof2: SelfProof<BlockProverPublicInput>): void;
|
|
85
|
+
/**
|
|
86
|
+
* Creates the BlockProver ZkProgram.
|
|
87
|
+
* Recursive linking of proofs is done via the previously
|
|
88
|
+
* injected StateTransitionProver and the required AppChainProof class
|
|
89
|
+
*/
|
|
90
|
+
createZkProgram(AppChainProof: Subclass<typeof Proof<MethodPublicInput>>): {
|
|
91
|
+
name: string;
|
|
92
|
+
compile: () => Promise<{
|
|
93
|
+
verificationKey: string;
|
|
94
|
+
}>;
|
|
95
|
+
verify: (proof: Proof<BlockProverPublicInput>) => Promise<boolean>;
|
|
96
|
+
digest: () => string;
|
|
97
|
+
analyzeMethods: () => {
|
|
98
|
+
rows: number;
|
|
99
|
+
digest: string;
|
|
100
|
+
result: unknown;
|
|
101
|
+
/**
|
|
102
|
+
* Creates the BlockProver ZkProgram.
|
|
103
|
+
* Recursive linking of proofs is done via the previously
|
|
104
|
+
* injected StateTransitionProver and the required AppChainProof class
|
|
105
|
+
*/
|
|
106
|
+
gates: import("snarkyjs/dist/node/snarky.js").Gate[];
|
|
107
|
+
publicInputSize: number;
|
|
108
|
+
}[];
|
|
109
|
+
publicInputType: typeof BlockProverPublicInput;
|
|
110
|
+
} & {
|
|
111
|
+
proveTransaction: import("snarkyjs/dist/node/lib/proof_system.js").Prover<BlockProverPublicInput, [(new (...args: any) => Proof<StateTransitionProverPublicInput>) & {
|
|
112
|
+
prototype: Proof<any>;
|
|
113
|
+
publicInputType: import("snarkyjs/dist/node/lib/circuit_value.js").FlexibleProvablePure<any>;
|
|
114
|
+
tag: () => {
|
|
115
|
+
name: string;
|
|
116
|
+
};
|
|
117
|
+
fromJSON: typeof Proof.fromJSON;
|
|
118
|
+
} & {
|
|
119
|
+
prototype: Proof<StateTransitionProverPublicInput>;
|
|
120
|
+
} & {
|
|
121
|
+
publicInputType: import("../../utils/utils").TypedClassConstructor<StateTransitionProverPublicInput>;
|
|
122
|
+
}, Subclass<{
|
|
123
|
+
new ({ proof, publicInput, maxProofsVerified, }: {
|
|
124
|
+
proof: unknown;
|
|
125
|
+
publicInput: MethodPublicInput;
|
|
126
|
+
maxProofsVerified: 0 | 2 | 1;
|
|
127
|
+
}): Proof<MethodPublicInput>;
|
|
128
|
+
publicInputType: import("snarkyjs/dist/node/lib/circuit_value.js").FlexibleProvablePure<any>;
|
|
129
|
+
tag: () => {
|
|
130
|
+
name: string;
|
|
131
|
+
};
|
|
132
|
+
fromJSON<S extends (new (...args: any) => Proof<unknown>) & {
|
|
133
|
+
prototype: Proof<any>;
|
|
134
|
+
publicInputType: import("snarkyjs/dist/node/lib/circuit_value.js").FlexibleProvablePure<any>;
|
|
135
|
+
tag: () => {
|
|
136
|
+
name: string;
|
|
137
|
+
};
|
|
138
|
+
fromJSON: typeof Proof.fromJSON;
|
|
139
|
+
} & {
|
|
140
|
+
prototype: Proof<unknown>;
|
|
141
|
+
}>(this: S, { maxProofsVerified, proof: proofString, publicInput: publicInputJson, }: {
|
|
142
|
+
publicInput: string[];
|
|
143
|
+
maxProofsVerified: 0 | 2 | 1;
|
|
144
|
+
proof: string;
|
|
145
|
+
}): Proof<import("snarkyjs/dist/node/lib/circuit_value.js").InferProvable<S["publicInputType"]>>;
|
|
146
|
+
}>]>;
|
|
147
|
+
merge: import("snarkyjs/dist/node/lib/proof_system.js").Prover<BlockProverPublicInput, [{
|
|
148
|
+
new ({ proof, publicInput, maxProofsVerified, }: {
|
|
149
|
+
proof: unknown;
|
|
150
|
+
publicInput: BlockProverPublicInput;
|
|
151
|
+
maxProofsVerified: 0 | 2 | 1;
|
|
152
|
+
}): SelfProof<BlockProverPublicInput>;
|
|
153
|
+
publicInputType: import("snarkyjs/dist/node/lib/circuit_value.js").FlexibleProvablePure<any>;
|
|
154
|
+
tag: () => {
|
|
155
|
+
name: string;
|
|
156
|
+
};
|
|
157
|
+
fromJSON<S extends (new (...args: any) => Proof<unknown>) & {
|
|
158
|
+
prototype: Proof<any>;
|
|
159
|
+
publicInputType: import("snarkyjs/dist/node/lib/circuit_value.js").FlexibleProvablePure<any>;
|
|
160
|
+
tag: () => {
|
|
161
|
+
name: string;
|
|
162
|
+
};
|
|
163
|
+
fromJSON: typeof Proof.fromJSON;
|
|
164
|
+
} & {
|
|
165
|
+
prototype: Proof<unknown>;
|
|
166
|
+
}>(this: S, { maxProofsVerified, proof: proofString, publicInput: publicInputJson, }: {
|
|
167
|
+
publicInput: string[];
|
|
168
|
+
maxProofsVerified: 0 | 2 | 1;
|
|
169
|
+
proof: string;
|
|
170
|
+
}): Proof<import("snarkyjs/dist/node/lib/circuit_value.js").InferProvable<S["publicInputType"]>>;
|
|
171
|
+
}, {
|
|
172
|
+
new ({ proof, publicInput, maxProofsVerified, }: {
|
|
173
|
+
proof: unknown;
|
|
174
|
+
publicInput: BlockProverPublicInput;
|
|
175
|
+
maxProofsVerified: 0 | 2 | 1;
|
|
176
|
+
}): SelfProof<BlockProverPublicInput>;
|
|
177
|
+
publicInputType: import("snarkyjs/dist/node/lib/circuit_value.js").FlexibleProvablePure<any>;
|
|
178
|
+
tag: () => {
|
|
179
|
+
name: string;
|
|
180
|
+
};
|
|
181
|
+
fromJSON<S extends (new (...args: any) => Proof<unknown>) & {
|
|
182
|
+
prototype: Proof<any>;
|
|
183
|
+
publicInputType: import("snarkyjs/dist/node/lib/circuit_value.js").FlexibleProvablePure<any>;
|
|
184
|
+
tag: () => {
|
|
185
|
+
name: string;
|
|
186
|
+
};
|
|
187
|
+
fromJSON: typeof Proof.fromJSON;
|
|
188
|
+
} & {
|
|
189
|
+
prototype: Proof<unknown>;
|
|
190
|
+
}>(this: S, { maxProofsVerified, proof: proofString, publicInput: publicInputJson, }: {
|
|
191
|
+
publicInput: string[];
|
|
192
|
+
maxProofsVerified: 0 | 2 | 1;
|
|
193
|
+
proof: string;
|
|
194
|
+
}): Proof<import("snarkyjs/dist/node/lib/circuit_value.js").InferProvable<S["publicInputType"]>>;
|
|
195
|
+
}]>;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export {};
|
|
199
|
+
//# sourceMappingURL=BlockProver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockProver.d.ts","sourceRoot":"","sources":["../../../src/prover/block/BlockProver.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,EACL,KAAK,KAAK,EACV,SAAS,EAEV,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,qBAAqB,EACrB,KAAK,gCAAgC,EACtC,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiB7C,MAAM,WAAW,gBAAgB;IAE/B,SAAS,EAAE,KAAK,CAAC;IAEjB;;;OAGG;IACH,gBAAgB,EAAE,KAAK,CAAC;CACzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,qBAAa,sBAAuB,SAAQ,2BAK1C;CAAG;AAEL;;;;GAIG;AACH,qBACa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,qBAAqB;gBAArB,qBAAqB,EAAE,qBAAqB;IAG/D;;;;;;;;OAQG;IACI,gBAAgB,CACrB,KAAK,EAAE,gBAAgB,EACvB,oBAAoB,EAAE,KAAK,CAAC,gCAAgC,CAAC,EAC7D,QAAQ,EAAE,KAAK,CAAC,iBAAiB,CAAC,GACjC,gBAAgB;IA0CZ,gBAAgB,CACrB,WAAW,EAAE,sBAAsB,EACnC,UAAU,EAAE,KAAK,CAAC,gCAAgC,CAAC,EACnD,QAAQ,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAmB7B,KAAK,CACV,WAAW,EAAE,sBAAsB,EACnC,MAAM,EAAE,SAAS,CAAC,sBAAsB,CAAC,EACzC,MAAM,EAAE,SAAS,CAAC,sBAAsB,CAAC;IAkC3C;;;;OAIG;IACI,eAAe,CACpB,aAAa,EAAE,QAAQ,CAAC,OAAO,KAAK,CAAC,iBAAiB,CAAC,CAAC;;;;;;;;;;;YAN1D;;;;eAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyCJ"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Circuit, Experimental, Field, SelfProof, Struct, } from "snarkyjs";
|
|
11
|
+
import { injectable } from "tsyringe";
|
|
12
|
+
import { StateTransitionProver, } from "../statetransition/StateTransitionProver.js";
|
|
13
|
+
import { DefaultProvableHashList } from "../../utils/ProvableHashList";
|
|
14
|
+
const errors = {
|
|
15
|
+
stateProofNotStartingAtZero: () => "StateProof not starting ST-commitment at zero",
|
|
16
|
+
stateTransitionsHashNotEqual: () => "StateTransition list commitments are not equal",
|
|
17
|
+
propertyNotMatching: (propertyName) => `${propertyName} not matching`,
|
|
18
|
+
stateRootNotMatching: (step) => `StateRoots not matching ${step}`,
|
|
19
|
+
transactionsHashNotMatching: (step) => `transactions hash not matching ${step}`,
|
|
20
|
+
};
|
|
21
|
+
export class BlockProverPublicInput extends Struct({
|
|
22
|
+
fromTransactionsHash: Field,
|
|
23
|
+
toTransactionsHash: Field,
|
|
24
|
+
fromStateRoot: Field,
|
|
25
|
+
toStateRoot: Field,
|
|
26
|
+
}) {
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* BlockProver class, which aggregates a AppChainProof and
|
|
30
|
+
* a StateTransitionProof into a single BlockProof, that can
|
|
31
|
+
* then be merged to be committed to the base-layer contract
|
|
32
|
+
*/
|
|
33
|
+
let BlockProver = class BlockProver {
|
|
34
|
+
constructor(stateTransitionProver) {
|
|
35
|
+
this.stateTransitionProver = stateTransitionProver;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Applies and checks the two proofs and applies the corresponding state
|
|
39
|
+
* changes to the given state
|
|
40
|
+
*
|
|
41
|
+
* @param state The from-state of the BlockProver
|
|
42
|
+
* @param stateTransitionProof
|
|
43
|
+
* @param appProof
|
|
44
|
+
* @returns The new BlockProver-state to be used as public output
|
|
45
|
+
*/
|
|
46
|
+
applyTransaction(state, stateTransitionProof, appProof) {
|
|
47
|
+
appProof.verify();
|
|
48
|
+
stateTransitionProof.verify();
|
|
49
|
+
const stateTo = { ...state };
|
|
50
|
+
// Checks for the stateTransitionProof and appProof matching
|
|
51
|
+
stateTransitionProof.publicInput.fromStateTransitionsHash.assertEquals(Field(0), errors.stateProofNotStartingAtZero());
|
|
52
|
+
appProof.publicInput.stateTransitionsHash.assertEquals(stateTransitionProof.publicInput.toStateTransitionsHash, errors.stateTransitionsHashNotEqual());
|
|
53
|
+
// Apply state if status success
|
|
54
|
+
state.stateRoot.assertEquals(stateTransitionProof.publicInput.fromStateRoot, errors.propertyNotMatching("from state root"));
|
|
55
|
+
stateTo.stateRoot = Circuit.if(appProof.publicInput.status, stateTransitionProof.publicInput.toStateRoot, stateTransitionProof.publicInput.fromStateRoot);
|
|
56
|
+
// Append tx to transaction list
|
|
57
|
+
const transactionList = new DefaultProvableHashList(Field, state.transactionsHash);
|
|
58
|
+
const { transactionHash } = appProof.publicInput;
|
|
59
|
+
transactionList.push(transactionHash);
|
|
60
|
+
stateTo.transactionsHash = transactionList.commitment;
|
|
61
|
+
return stateTo;
|
|
62
|
+
}
|
|
63
|
+
proveTransaction(publicInput, stateProof, appProof) {
|
|
64
|
+
const state = {
|
|
65
|
+
transactionsHash: publicInput.fromTransactionsHash,
|
|
66
|
+
stateRoot: publicInput.fromStateRoot,
|
|
67
|
+
};
|
|
68
|
+
this.applyTransaction(state, stateProof, appProof);
|
|
69
|
+
publicInput.toStateRoot.assertEquals(state.stateRoot, errors.propertyNotMatching("to state root"));
|
|
70
|
+
publicInput.toTransactionsHash.assertEquals(state.transactionsHash, errors.propertyNotMatching("to transactions hash and computed hash"));
|
|
71
|
+
}
|
|
72
|
+
merge(publicInput, proof1, proof2) {
|
|
73
|
+
proof1.verify();
|
|
74
|
+
proof2.verify();
|
|
75
|
+
// Check state
|
|
76
|
+
publicInput.fromStateRoot.assertEquals(proof1.publicInput.fromStateRoot, errors.stateRootNotMatching("publicInput.from -> proof1.from"));
|
|
77
|
+
proof1.publicInput.toStateRoot.assertEquals(proof2.publicInput.fromStateRoot, errors.stateRootNotMatching("proof1.to -> proof2.from"));
|
|
78
|
+
proof2.publicInput.toStateRoot.assertEquals(publicInput.toStateRoot, errors.stateRootNotMatching("proof2.to -> publicInput.to"));
|
|
79
|
+
// Check transaction list
|
|
80
|
+
publicInput.fromTransactionsHash.assertEquals(proof1.publicInput.fromTransactionsHash, errors.transactionsHashNotMatching("publicInput.from -> proof1.from"));
|
|
81
|
+
proof1.publicInput.toTransactionsHash.assertEquals(proof2.publicInput.fromTransactionsHash, errors.transactionsHashNotMatching("proof1.to -> proof2.from"));
|
|
82
|
+
proof2.publicInput.toTransactionsHash.assertEquals(publicInput.fromTransactionsHash, errors.transactionsHashNotMatching("proof2.to -> publicInput.to"));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates the BlockProver ZkProgram.
|
|
86
|
+
* Recursive linking of proofs is done via the previously
|
|
87
|
+
* injected StateTransitionProver and the required AppChainProof class
|
|
88
|
+
*/
|
|
89
|
+
createZkProgram(AppChainProof) {
|
|
90
|
+
const ZkProgramProof = this.stateTransitionProver.getProofType();
|
|
91
|
+
const proveTransaction = this.proveTransaction.bind(this);
|
|
92
|
+
const merge = this.merge.bind(this);
|
|
93
|
+
return Experimental.ZkProgram({
|
|
94
|
+
publicInput: BlockProverPublicInput,
|
|
95
|
+
methods: {
|
|
96
|
+
proveTransaction: {
|
|
97
|
+
privateInputs: [ZkProgramProof, AppChainProof],
|
|
98
|
+
method(publicInput, stateProof, appProof) {
|
|
99
|
+
proveTransaction(publicInput, stateProof, appProof);
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
merge: {
|
|
103
|
+
privateInputs: [
|
|
104
|
+
(SelfProof),
|
|
105
|
+
(SelfProof),
|
|
106
|
+
],
|
|
107
|
+
method(publicInput, proof1, proof2) {
|
|
108
|
+
merge(publicInput, proof1, proof2);
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
BlockProver = __decorate([
|
|
116
|
+
injectable(),
|
|
117
|
+
__metadata("design:paramtypes", [StateTransitionProver])
|
|
118
|
+
], BlockProver);
|
|
119
|
+
export { BlockProver };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockScopedModule.d.ts","sourceRoot":"","sources":["../../../src/prover/block/BlockScopedModule.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,OAAO,IAAI,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Field, Proof, SelfProof } from "snarkyjs";
|
|
2
|
+
import { ProvableHashList } from "../../utils/ProvableHashList";
|
|
3
|
+
import { ProvableStateTransition } from "../../model/StateTransition";
|
|
4
|
+
import { StateTransitionProvableBatch } from "../../model/StateTransitionProvableBatch";
|
|
5
|
+
import { Subclass, TypedClassConstructor, ZkProgramType } from "../../utils/utils";
|
|
6
|
+
import { StateTransitionWitnessProvider } from "./StateTransitionWitnessProvider.js";
|
|
7
|
+
interface StateTransitionProverState {
|
|
8
|
+
stateRoot: Field;
|
|
9
|
+
stateTransitionList: ProvableHashList<ProvableStateTransition>;
|
|
10
|
+
}
|
|
11
|
+
declare const StateTransitionProverPublicInput_base: (new (value: {
|
|
12
|
+
fromStateTransitionsHash: Field;
|
|
13
|
+
toStateTransitionsHash: Field;
|
|
14
|
+
fromStateRoot: Field;
|
|
15
|
+
toStateRoot: Field;
|
|
16
|
+
}) => {
|
|
17
|
+
fromStateTransitionsHash: Field;
|
|
18
|
+
toStateTransitionsHash: Field;
|
|
19
|
+
fromStateRoot: Field;
|
|
20
|
+
toStateRoot: Field;
|
|
21
|
+
}) & {
|
|
22
|
+
_isStruct: true;
|
|
23
|
+
} & import("snarkyjs/dist/node/snarky.js").ProvablePure<{
|
|
24
|
+
fromStateTransitionsHash: Field;
|
|
25
|
+
toStateTransitionsHash: Field;
|
|
26
|
+
fromStateRoot: Field;
|
|
27
|
+
toStateRoot: Field;
|
|
28
|
+
}> & {
|
|
29
|
+
toInput: (x: {
|
|
30
|
+
fromStateTransitionsHash: Field;
|
|
31
|
+
toStateTransitionsHash: Field;
|
|
32
|
+
fromStateRoot: Field;
|
|
33
|
+
toStateRoot: Field;
|
|
34
|
+
}) => {
|
|
35
|
+
fields?: Field[] | undefined;
|
|
36
|
+
packed?: [Field, number][] | undefined;
|
|
37
|
+
};
|
|
38
|
+
toJSON: (x: {
|
|
39
|
+
fromStateTransitionsHash: Field;
|
|
40
|
+
toStateTransitionsHash: Field;
|
|
41
|
+
fromStateRoot: Field;
|
|
42
|
+
toStateRoot: Field;
|
|
43
|
+
}) => {
|
|
44
|
+
fromStateTransitionsHash: string;
|
|
45
|
+
toStateTransitionsHash: string;
|
|
46
|
+
fromStateRoot: string;
|
|
47
|
+
toStateRoot: string;
|
|
48
|
+
};
|
|
49
|
+
fromJSON: (x: {
|
|
50
|
+
fromStateTransitionsHash: string;
|
|
51
|
+
toStateTransitionsHash: string;
|
|
52
|
+
fromStateRoot: string;
|
|
53
|
+
toStateRoot: string;
|
|
54
|
+
}) => {
|
|
55
|
+
fromStateTransitionsHash: Field;
|
|
56
|
+
toStateTransitionsHash: Field;
|
|
57
|
+
fromStateRoot: Field;
|
|
58
|
+
toStateRoot: Field;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare class StateTransitionProverPublicInput extends StateTransitionProverPublicInput_base {
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* StateTransitionProver is the prover that proves the application of some state
|
|
65
|
+
* transitions and checks and updates their merkle-tree entries
|
|
66
|
+
*/
|
|
67
|
+
export declare class StateTransitionProver {
|
|
68
|
+
private readonly witnessProvider;
|
|
69
|
+
private readonly program;
|
|
70
|
+
constructor(witnessProvider: StateTransitionWitnessProvider);
|
|
71
|
+
/**
|
|
72
|
+
* Applies the state transitions to the current stateRoot
|
|
73
|
+
* and returns the new prover state
|
|
74
|
+
*/
|
|
75
|
+
applyTransitions(stateRoot: Field, stateTransitionCommitmentFrom: Field, transitionBatch: StateTransitionProvableBatch): StateTransitionProverState;
|
|
76
|
+
/**
|
|
77
|
+
* Applies a single state transition to the given state
|
|
78
|
+
* and mutates it in place
|
|
79
|
+
*/
|
|
80
|
+
applyTransition(state: StateTransitionProverState, transition: ProvableStateTransition, index?: number): void;
|
|
81
|
+
/**
|
|
82
|
+
* Applies a whole batch of StateTransitions at once
|
|
83
|
+
*/
|
|
84
|
+
runBatch(publicInput: StateTransitionProverPublicInput, batch: StateTransitionProvableBatch): void;
|
|
85
|
+
merge(publicInput: StateTransitionProverPublicInput, proof1: SelfProof<StateTransitionProverPublicInput>, proof2: SelfProof<StateTransitionProverPublicInput>): void;
|
|
86
|
+
getZkProgram(): ZkProgramType<StateTransitionProverPublicInput>;
|
|
87
|
+
getProofType(): Subclass<typeof Proof<StateTransitionProverPublicInput>> & {
|
|
88
|
+
publicInputType: TypedClassConstructor<StateTransitionProverPublicInput>;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=StateTransitionProver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateTransitionProver.d.ts","sourceRoot":"","sources":["../../../src/prover/statetransition/StateTransitionProver.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,EACL,KAAK,EACL,SAAS,EAEV,MAAM,UAAU,CAAC;AAOlB,OAAO,EAEL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EACL,QAAQ,EACR,qBAAqB,EACrB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAcrF,UAAU,0BAA0B;IAClC,SAAS,EAAE,KAAK,CAAC;IACjB,mBAAmB,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;CAChE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACD,qBAAa,gCAAiC,SAAQ,qCAKpD;CAAG;AAEL;;;GAGG;AACH,qBACa,qBAAqB;IAqC9B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAnClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CA+BZ;gBAIO,eAAe,EAAE,8BAA8B;IAGlE;;;OAGG;IACI,gBAAgB,CACrB,SAAS,EAAE,KAAK,EAChB,6BAA6B,EAAE,KAAK,EACpC,eAAe,EAAE,4BAA4B,GAC5C,0BAA0B;IAsB7B;;;OAGG;IACI,eAAe,CACpB,KAAK,EAAE,0BAA0B,EACjC,UAAU,EAAE,uBAAuB,EACnC,KAAK,SAAI;IA4BX;;OAEG;IACI,QAAQ,CACb,WAAW,EAAE,gCAAgC,EAC7C,KAAK,EAAE,4BAA4B;IAkB9B,KAAK,CACV,WAAW,EAAE,gCAAgC,EAC7C,MAAM,EAAE,SAAS,CAAC,gCAAgC,CAAC,EACnD,MAAM,EAAE,SAAS,CAAC,gCAAgC,CAAC;IAkC9C,YAAY,IAAI,aAAa,CAAC,gCAAgC,CAAC;IAI/D,YAAY,IAAI,QAAQ,CAC7B,OAAO,KAAK,CAAC,gCAAgC,CAAC,CAC/C,GAAG;QACF,eAAe,EAAE,qBAAqB,CAAC,gCAAgC,CAAC,CAAC;KAC1E;CAQF"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Circuit, Experimental, Field, Proof, SelfProof, Struct, } from "snarkyjs";
|
|
14
|
+
import { inject, injectable } from "tsyringe";
|
|
15
|
+
import { MerkleTreeUtils, RollupMerkleWitness, } from "../../utils/merkletree/RollupMerkleTree.js";
|
|
16
|
+
import { DefaultProvableHashList, } from "../../utils/ProvableHashList";
|
|
17
|
+
import { ProvableStateTransition } from "../../model/StateTransition";
|
|
18
|
+
import { StateTransitionProvableBatch } from "../../model/StateTransitionProvableBatch";
|
|
19
|
+
import { constants } from "../../Constants";
|
|
20
|
+
const errors = {
|
|
21
|
+
stateRootNotMatching: (step) => `StateRoots not matching ${step}`,
|
|
22
|
+
stateTransitionsHashNotMatching: (step) => `State transitions hash not matching ${step}`,
|
|
23
|
+
merkleWitnessNotCorrect: (index) => `MerkleWitness not valid for StateTransition (${index})`,
|
|
24
|
+
propertyNotMatching: (propertyName) => `${propertyName} not matching`,
|
|
25
|
+
};
|
|
26
|
+
export class StateTransitionProverPublicInput extends Struct({
|
|
27
|
+
fromStateTransitionsHash: Field,
|
|
28
|
+
toStateTransitionsHash: Field,
|
|
29
|
+
fromStateRoot: Field,
|
|
30
|
+
toStateRoot: Field,
|
|
31
|
+
}) {
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* StateTransitionProver is the prover that proves the application of some state
|
|
35
|
+
* transitions and checks and updates their merkle-tree entries
|
|
36
|
+
*/
|
|
37
|
+
let StateTransitionProver = class StateTransitionProver {
|
|
38
|
+
constructor(witnessProvider) {
|
|
39
|
+
this.witnessProvider = witnessProvider;
|
|
40
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
41
|
+
this.program = ((instance) => Experimental.ZkProgram({
|
|
42
|
+
publicInput: StateTransitionProverPublicInput,
|
|
43
|
+
methods: {
|
|
44
|
+
proveBatch: {
|
|
45
|
+
privateInputs: [StateTransitionProvableBatch],
|
|
46
|
+
method(publicInput, batch) {
|
|
47
|
+
instance.runBatch(publicInput, batch);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
merge: {
|
|
51
|
+
privateInputs: [
|
|
52
|
+
(SelfProof),
|
|
53
|
+
(SelfProof),
|
|
54
|
+
],
|
|
55
|
+
method(publicInput, proof1, proof2) {
|
|
56
|
+
instance.merge(publicInput, proof1, proof2);
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
}))(this);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Applies the state transitions to the current stateRoot
|
|
64
|
+
* and returns the new prover state
|
|
65
|
+
*/
|
|
66
|
+
applyTransitions(stateRoot, stateTransitionCommitmentFrom, transitionBatch) {
|
|
67
|
+
const state = {
|
|
68
|
+
stateRoot,
|
|
69
|
+
stateTransitionList: new DefaultProvableHashList(ProvableStateTransition, stateTransitionCommitmentFrom),
|
|
70
|
+
};
|
|
71
|
+
const transitions = transitionBatch.batch;
|
|
72
|
+
for (let index = 0; index < constants.stateTransitionProverBatchSize; index++) {
|
|
73
|
+
this.applyTransition(state, transitions[index], index);
|
|
74
|
+
}
|
|
75
|
+
return state;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Applies a single state transition to the given state
|
|
79
|
+
* and mutates it in place
|
|
80
|
+
*/
|
|
81
|
+
applyTransition(state, transition, index = 0) {
|
|
82
|
+
const treeWitness = Circuit.witness(RollupMerkleWitness, () => this.witnessProvider.getWitness(transition.path));
|
|
83
|
+
const membershipValid = MerkleTreeUtils.checkMembership(treeWitness, state.stateRoot, transition.path, transition.from.value);
|
|
84
|
+
membershipValid
|
|
85
|
+
.or(transition.from.isSome.not())
|
|
86
|
+
.assertTrue(errors.merkleWitnessNotCorrect(index));
|
|
87
|
+
const newRoot = MerkleTreeUtils.computeRoot(treeWitness, transition.to.value);
|
|
88
|
+
state.stateRoot = Circuit.if(transition.to.isSome, newRoot, state.stateRoot);
|
|
89
|
+
state.stateTransitionList.push(transition);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Applies a whole batch of StateTransitions at once
|
|
93
|
+
*/
|
|
94
|
+
runBatch(publicInput, batch) {
|
|
95
|
+
const result = this.applyTransitions(publicInput.fromStateRoot, publicInput.fromStateTransitionsHash, batch);
|
|
96
|
+
publicInput.toStateRoot.assertEquals(result.stateRoot, errors.propertyNotMatching("resulting state-root"));
|
|
97
|
+
publicInput.toStateTransitionsHash.assertEquals(result.stateTransitionList.commitment, errors.propertyNotMatching("resulting state transition commitment"));
|
|
98
|
+
}
|
|
99
|
+
merge(publicInput, proof1, proof2) {
|
|
100
|
+
proof1.verify();
|
|
101
|
+
proof2.verify();
|
|
102
|
+
// Check state
|
|
103
|
+
publicInput.fromStateRoot.assertEquals(proof1.publicInput.fromStateRoot, errors.stateRootNotMatching("publicInput.from -> proof1.from"));
|
|
104
|
+
proof1.publicInput.toStateRoot.assertEquals(proof2.publicInput.fromStateRoot, errors.stateRootNotMatching("proof1.to -> proof2.from"));
|
|
105
|
+
proof2.publicInput.toStateRoot.assertEquals(publicInput.toStateRoot, errors.stateRootNotMatching("proof2.to -> publicInput.to"));
|
|
106
|
+
// Check ST list
|
|
107
|
+
publicInput.fromStateTransitionsHash.assertEquals(proof1.publicInput.fromStateTransitionsHash, errors.stateTransitionsHashNotMatching("publicInput.from -> proof1.from"));
|
|
108
|
+
proof1.publicInput.toStateTransitionsHash.assertEquals(proof2.publicInput.fromStateTransitionsHash, errors.stateTransitionsHashNotMatching("proof1.to -> proof2.from"));
|
|
109
|
+
proof2.publicInput.toStateTransitionsHash.assertEquals(publicInput.toStateTransitionsHash, errors.stateTransitionsHashNotMatching("proof2.to -> publicInput.to"));
|
|
110
|
+
}
|
|
111
|
+
getZkProgram() {
|
|
112
|
+
return this.program;
|
|
113
|
+
}
|
|
114
|
+
getProofType() {
|
|
115
|
+
return ((instance) => { var _a; return _a = class StateTransitionProof extends Proof {
|
|
116
|
+
},
|
|
117
|
+
_a.publicInputType = StateTransitionProverPublicInput,
|
|
118
|
+
_a.tag = () => instance.getZkProgram(),
|
|
119
|
+
_a; })(this);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
StateTransitionProver = __decorate([
|
|
123
|
+
injectable(),
|
|
124
|
+
__param(0, inject("StateTransitionWitnessProvider")),
|
|
125
|
+
__metadata("design:paramtypes", [Object])
|
|
126
|
+
], StateTransitionProver);
|
|
127
|
+
export { StateTransitionProver };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Field } from "snarkyjs";
|
|
2
|
+
import { RollupMerkleWitness } from "../../utils/merkletree/RollupMerkleTree.js";
|
|
3
|
+
/**
|
|
4
|
+
* Interface for providing merkle witnesses to the state-transition prover
|
|
5
|
+
*/
|
|
6
|
+
export interface StateTransitionWitnessProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Provides the merkle witness corresponding to the given key
|
|
9
|
+
* @param key Merkle-tree key
|
|
10
|
+
*/
|
|
11
|
+
getWitness: (key: Field) => RollupMerkleWitness;
|
|
12
|
+
}
|
|
13
|
+
export declare class NoOpStateTransitionWitnessProvider implements StateTransitionWitnessProvider {
|
|
14
|
+
getWitness(): RollupMerkleWitness;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=StateTransitionWitnessProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateTransitionWitnessProvider.d.ts","sourceRoot":"","sources":["../../../src/prover/statetransition/StateTransitionWitnessProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,UAAU,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,mBAAmB,CAAC;CACjD;AAED,qBACa,kCACX,YAAW,8BAA8B;IAElC,UAAU,IAAI,mBAAmB;CAGzC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { injectable } from "tsyringe";
|
|
8
|
+
import { RollupMerkleWitness } from "../../utils/merkletree/RollupMerkleTree.js";
|
|
9
|
+
let NoOpStateTransitionWitnessProvider = class NoOpStateTransitionWitnessProvider {
|
|
10
|
+
getWitness() {
|
|
11
|
+
return new RollupMerkleWitness({ path: [], isLeft: [] });
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
NoOpStateTransitionWitnessProvider = __decorate([
|
|
15
|
+
injectable()
|
|
16
|
+
], NoOpStateTransitionWitnessProvider);
|
|
17
|
+
export { NoOpStateTransitionWitnessProvider };
|