@aztec/bb-prover 0.60.0 → 0.62.0
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/dest/bb/cli.d.ts.map +1 -1
- package/dest/bb/cli.js +3 -2
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +1 -8
- package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_private_kernel_prover.js +2 -2
- package/dest/prover/bb_prover.d.ts +8 -33
- package/dest/prover/bb_prover.d.ts.map +1 -1
- package/dest/prover/bb_prover.js +35 -109
- package/dest/stats.d.ts.map +1 -1
- package/dest/stats.js +5 -9
- package/dest/test/test_circuit_prover.d.ts +5 -11
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +39 -141
- package/package.json +11 -8
- package/src/bb/cli.ts +1 -0
- package/src/bb/execute.ts +1 -7
- package/src/prover/bb_private_kernel_prover.ts +1 -0
- package/src/prover/bb_prover.ts +62 -176
- package/src/stats.ts +4 -8
- package/src/test/test_circuit_prover.ts +128 -327
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
makePublicInputsAndRecursiveProof,
|
|
7
7
|
} from '@aztec/circuit-types';
|
|
8
8
|
import {
|
|
9
|
+
AVM_PROOF_LENGTH_IN_FIELDS,
|
|
9
10
|
AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS,
|
|
10
11
|
type AvmCircuitInputs,
|
|
11
12
|
type BaseOrMergeRollupPublicInputs,
|
|
12
13
|
type BaseParityInputs,
|
|
13
|
-
type BaseRollupInputs,
|
|
14
14
|
type BlockMergeRollupInputs,
|
|
15
15
|
type BlockRootOrBlockMergePublicInputs,
|
|
16
16
|
type BlockRootRollupInputs,
|
|
@@ -19,13 +19,11 @@ import {
|
|
|
19
19
|
type KernelCircuitPublicInputs,
|
|
20
20
|
type MergeRollupInputs,
|
|
21
21
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
22
|
+
type PrivateBaseRollupInputs,
|
|
22
23
|
type PrivateKernelEmptyInputData,
|
|
23
24
|
PrivateKernelEmptyInputs,
|
|
24
25
|
type Proof,
|
|
25
|
-
type
|
|
26
|
-
type PublicKernelCircuitPublicInputs,
|
|
27
|
-
type PublicKernelInnerCircuitPrivateInputs,
|
|
28
|
-
type PublicKernelTailCircuitPrivateInputs,
|
|
26
|
+
type PublicBaseRollupInputs,
|
|
29
27
|
RECURSIVE_PROOF_LENGTH,
|
|
30
28
|
type RecursiveProof,
|
|
31
29
|
RootParityInput,
|
|
@@ -34,9 +32,7 @@ import {
|
|
|
34
32
|
type RootRollupPublicInputs,
|
|
35
33
|
TUBE_PROOF_LENGTH,
|
|
36
34
|
type TubeInputs,
|
|
37
|
-
type VMCircuitPublicInputs,
|
|
38
35
|
VerificationKeyData,
|
|
39
|
-
makeEmptyProof,
|
|
40
36
|
makeEmptyRecursiveProof,
|
|
41
37
|
makeRecursiveProof,
|
|
42
38
|
} from '@aztec/circuits.js';
|
|
@@ -64,20 +60,18 @@ import {
|
|
|
64
60
|
convertRootParityOutputsFromWitnessMap,
|
|
65
61
|
convertRootRollupInputsToWitnessMap,
|
|
66
62
|
convertRootRollupOutputsFromWitnessMap,
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
convertSimulatedPrivateBaseRollupInputsToWitnessMap,
|
|
64
|
+
convertSimulatedPrivateBaseRollupOutputsFromWitnessMap,
|
|
69
65
|
convertSimulatedPrivateKernelEmptyOutputsFromWitnessMap,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
convertSimulatedPublicMergeInputsToWitnessMap,
|
|
73
|
-
convertSimulatedPublicMergeOutputFromWitnessMap,
|
|
74
|
-
convertSimulatedPublicTailInputsToWitnessMap,
|
|
75
|
-
convertSimulatedPublicTailOutputFromWitnessMap,
|
|
66
|
+
convertSimulatedPublicBaseRollupInputsToWitnessMap,
|
|
67
|
+
convertSimulatedPublicBaseRollupOutputsFromWitnessMap,
|
|
76
68
|
getVKSiblingPath,
|
|
77
69
|
} from '@aztec/noir-protocol-circuits-types';
|
|
78
70
|
import { type SimulationProvider, WASMSimulator, emitCircuitSimulationStats } from '@aztec/simulator';
|
|
79
71
|
import { type TelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
80
72
|
|
|
73
|
+
import { type WitnessMap } from '@noir-lang/types';
|
|
74
|
+
|
|
81
75
|
import { ProverInstrumentation } from '../instrumentation.js';
|
|
82
76
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
83
77
|
|
|
@@ -117,17 +111,13 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
117
111
|
inputs.vkTreeRoot,
|
|
118
112
|
inputs.protocolContractTreeRoot,
|
|
119
113
|
);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return makePublicInputsAndRecursiveProof(
|
|
128
|
-
result,
|
|
129
|
-
makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
130
|
-
ProtocolCircuitVks['PrivateKernelEmptyArtifact'],
|
|
114
|
+
|
|
115
|
+
return await this.simulate(
|
|
116
|
+
kernelInputs,
|
|
117
|
+
'PrivateKernelEmptyArtifact',
|
|
118
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
119
|
+
convertPrivateKernelEmptyInputsToWitnessMap,
|
|
120
|
+
convertSimulatedPrivateKernelEmptyOutputsFromWitnessMap,
|
|
131
121
|
);
|
|
132
122
|
}
|
|
133
123
|
|
|
@@ -146,17 +136,13 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
146
136
|
inputs.vkTreeRoot,
|
|
147
137
|
inputs.protocolContractTreeRoot,
|
|
148
138
|
);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return makePublicInputsAndRecursiveProof(
|
|
157
|
-
result,
|
|
158
|
-
makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
159
|
-
VerificationKeyData.makeFakeHonk(),
|
|
139
|
+
|
|
140
|
+
return await this.simulate(
|
|
141
|
+
kernelInputs,
|
|
142
|
+
'EmptyNestedArtifact',
|
|
143
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
144
|
+
convertPrivateKernelEmptyInputsToWitnessMap,
|
|
145
|
+
convertPrivateKernelEmptyOutputsFromWitnessMap,
|
|
160
146
|
);
|
|
161
147
|
}
|
|
162
148
|
|
|
@@ -167,34 +153,20 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
167
153
|
*/
|
|
168
154
|
@trackSpan('TestCircuitProver.getBaseParityProof')
|
|
169
155
|
public async getBaseParityProof(inputs: BaseParityInputs): Promise<RootParityInput<typeof RECURSIVE_PROOF_LENGTH>> {
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
SimulatedServerCircuitArtifacts.BaseParityArtifact,
|
|
156
|
+
const result = await this.simulate(
|
|
157
|
+
inputs,
|
|
158
|
+
'BaseParityArtifact',
|
|
159
|
+
RECURSIVE_PROOF_LENGTH,
|
|
160
|
+
convertBaseParityInputsToWitnessMap,
|
|
161
|
+
convertBaseParityOutputsFromWitnessMap,
|
|
177
162
|
);
|
|
178
|
-
const result = convertBaseParityOutputsFromWitnessMap(witness);
|
|
179
163
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
164
|
+
return new RootParityInput(
|
|
165
|
+
result.proof,
|
|
166
|
+
result.verificationKey.keyAsFields,
|
|
183
167
|
getVKSiblingPath(ProtocolCircuitVkIndexes['BaseParityArtifact']),
|
|
184
|
-
result,
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
this.instrumentation.recordDuration('simulationDuration', 'base-parity', timer);
|
|
188
|
-
|
|
189
|
-
emitCircuitSimulationStats(
|
|
190
|
-
'base-parity',
|
|
191
|
-
timer.ms(),
|
|
192
|
-
inputs.toBuffer().length,
|
|
193
|
-
result.toBuffer().length,
|
|
194
|
-
this.logger,
|
|
168
|
+
result.inputs,
|
|
195
169
|
);
|
|
196
|
-
await this.delay();
|
|
197
|
-
return Promise.resolve(rootParityInput);
|
|
198
170
|
}
|
|
199
171
|
|
|
200
172
|
/**
|
|
@@ -206,77 +178,53 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
206
178
|
public async getRootParityProof(
|
|
207
179
|
inputs: RootParityInputs,
|
|
208
180
|
): Promise<RootParityInput<typeof NESTED_RECURSIVE_PROOF_LENGTH>> {
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
SimulatedServerCircuitArtifacts.RootParityArtifact,
|
|
181
|
+
const result = await this.simulate(
|
|
182
|
+
inputs,
|
|
183
|
+
'RootParityArtifact',
|
|
184
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
185
|
+
convertRootParityInputsToWitnessMap,
|
|
186
|
+
convertRootParityOutputsFromWitnessMap,
|
|
216
187
|
);
|
|
217
188
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
makeRecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
222
|
-
ProtocolCircuitVks['RootParityArtifact'].keyAsFields,
|
|
189
|
+
return new RootParityInput(
|
|
190
|
+
result.proof,
|
|
191
|
+
result.verificationKey.keyAsFields,
|
|
223
192
|
getVKSiblingPath(ProtocolCircuitVkIndexes['RootParityArtifact']),
|
|
224
|
-
result,
|
|
193
|
+
result.inputs,
|
|
225
194
|
);
|
|
195
|
+
}
|
|
226
196
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
timer.ms(),
|
|
231
|
-
inputs.toBuffer().length,
|
|
232
|
-
result.toBuffer().length,
|
|
233
|
-
this.logger,
|
|
234
|
-
);
|
|
197
|
+
public async getTubeProof(
|
|
198
|
+
_tubeInput: TubeInputs,
|
|
199
|
+
): Promise<ProofAndVerificationKey<RecursiveProof<typeof TUBE_PROOF_LENGTH>>> {
|
|
235
200
|
await this.delay();
|
|
236
|
-
return
|
|
201
|
+
return makeProofAndVerificationKey(makeEmptyRecursiveProof(TUBE_PROOF_LENGTH), VerificationKeyData.makeFakeHonk());
|
|
237
202
|
}
|
|
238
203
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
* @returns The public inputs as outputs of the simulation.
|
|
243
|
-
*/
|
|
244
|
-
@trackSpan('TestCircuitProver.getBaseRollupProof')
|
|
245
|
-
public async getBaseRollupProof(
|
|
246
|
-
input: BaseRollupInputs,
|
|
204
|
+
@trackSpan('TestCircuitProver.getPrivateBaseRollupProof')
|
|
205
|
+
public async getPrivateBaseRollupProof(
|
|
206
|
+
inputs: PrivateBaseRollupInputs,
|
|
247
207
|
): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs>> {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
SimulatedServerCircuitArtifacts.BaseRollupArtifact,
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
const result = convertSimulatedBaseRollupOutputsFromWitnessMap(witness);
|
|
258
|
-
|
|
259
|
-
this.instrumentation.recordDuration('simulationDuration', 'base-rollup', timer);
|
|
260
|
-
emitCircuitSimulationStats(
|
|
261
|
-
'base-rollup',
|
|
262
|
-
timer.ms(),
|
|
263
|
-
input.toBuffer().length,
|
|
264
|
-
result.toBuffer().length,
|
|
265
|
-
this.logger,
|
|
266
|
-
);
|
|
267
|
-
await this.delay();
|
|
268
|
-
return makePublicInputsAndRecursiveProof(
|
|
269
|
-
result,
|
|
270
|
-
makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
271
|
-
ProtocolCircuitVks['BaseRollupArtifact'],
|
|
208
|
+
return await this.simulate(
|
|
209
|
+
inputs,
|
|
210
|
+
'PrivateBaseRollupArtifact',
|
|
211
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
212
|
+
convertSimulatedPrivateBaseRollupInputsToWitnessMap,
|
|
213
|
+
convertSimulatedPrivateBaseRollupOutputsFromWitnessMap,
|
|
272
214
|
);
|
|
273
215
|
}
|
|
274
216
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
return
|
|
217
|
+
@trackSpan('TestCircuitProver.getPublicBaseRollupProof')
|
|
218
|
+
public async getPublicBaseRollupProof(
|
|
219
|
+
inputs: PublicBaseRollupInputs,
|
|
220
|
+
): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs>> {
|
|
221
|
+
return await this.simulate(
|
|
222
|
+
inputs,
|
|
223
|
+
'PublicBaseRollupArtifact',
|
|
224
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
225
|
+
convertSimulatedPublicBaseRollupInputsToWitnessMap,
|
|
226
|
+
convertSimulatedPublicBaseRollupOutputsFromWitnessMap,
|
|
227
|
+
);
|
|
280
228
|
}
|
|
281
229
|
|
|
282
230
|
/**
|
|
@@ -288,30 +236,12 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
288
236
|
public async getMergeRollupProof(
|
|
289
237
|
input: MergeRollupInputs,
|
|
290
238
|
): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs>> {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
SimulatedServerCircuitArtifacts.MergeRollupArtifact,
|
|
298
|
-
);
|
|
299
|
-
|
|
300
|
-
const result = convertMergeRollupOutputsFromWitnessMap(witness);
|
|
301
|
-
|
|
302
|
-
this.instrumentation.recordDuration('simulationDuration', 'merge-rollup', timer);
|
|
303
|
-
emitCircuitSimulationStats(
|
|
304
|
-
'merge-rollup',
|
|
305
|
-
timer.ms(),
|
|
306
|
-
input.toBuffer().length,
|
|
307
|
-
result.toBuffer().length,
|
|
308
|
-
this.logger,
|
|
309
|
-
);
|
|
310
|
-
await this.delay();
|
|
311
|
-
return makePublicInputsAndRecursiveProof(
|
|
312
|
-
result,
|
|
313
|
-
makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
314
|
-
ProtocolCircuitVks['MergeRollupArtifact'],
|
|
239
|
+
return await this.simulate(
|
|
240
|
+
input,
|
|
241
|
+
'MergeRollupArtifact',
|
|
242
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
243
|
+
convertMergeRollupInputsToWitnessMap,
|
|
244
|
+
convertMergeRollupOutputsFromWitnessMap,
|
|
315
245
|
);
|
|
316
246
|
}
|
|
317
247
|
|
|
@@ -324,29 +254,12 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
324
254
|
public async getBlockRootRollupProof(
|
|
325
255
|
input: BlockRootRollupInputs,
|
|
326
256
|
): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs>> {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
SimulatedServerCircuitArtifacts.BlockRootRollupArtifact,
|
|
334
|
-
);
|
|
335
|
-
|
|
336
|
-
const result = convertBlockRootRollupOutputsFromWitnessMap(witness);
|
|
337
|
-
|
|
338
|
-
this.instrumentation.recordDuration('simulationDuration', 'block-root-rollup', timer);
|
|
339
|
-
emitCircuitSimulationStats(
|
|
340
|
-
'block-root-rollup',
|
|
341
|
-
timer.ms(),
|
|
342
|
-
input.toBuffer().length,
|
|
343
|
-
result.toBuffer().length,
|
|
344
|
-
this.logger,
|
|
345
|
-
);
|
|
346
|
-
return makePublicInputsAndRecursiveProof(
|
|
347
|
-
result,
|
|
348
|
-
makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
349
|
-
ProtocolCircuitVks['BlockRootRollupArtifact'],
|
|
257
|
+
return await this.simulate(
|
|
258
|
+
input,
|
|
259
|
+
'BlockRootRollupArtifact',
|
|
260
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
261
|
+
convertBlockRootRollupInputsToWitnessMap,
|
|
262
|
+
convertBlockRootRollupOutputsFromWitnessMap,
|
|
350
263
|
);
|
|
351
264
|
}
|
|
352
265
|
|
|
@@ -359,29 +272,12 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
359
272
|
public async getEmptyBlockRootRollupProof(
|
|
360
273
|
input: EmptyBlockRootRollupInputs,
|
|
361
274
|
): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs>> {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
SimulatedServerCircuitArtifacts.EmptyBlockRootRollupArtifact,
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
const result = convertEmptyBlockRootRollupOutputsFromWitnessMap(witness);
|
|
372
|
-
|
|
373
|
-
this.instrumentation.recordDuration('simulationDuration', 'empty-block-root-rollup', timer);
|
|
374
|
-
emitCircuitSimulationStats(
|
|
375
|
-
'empty-block-root-rollup',
|
|
376
|
-
timer.ms(),
|
|
377
|
-
input.toBuffer().length,
|
|
378
|
-
result.toBuffer().length,
|
|
379
|
-
this.logger,
|
|
380
|
-
);
|
|
381
|
-
return makePublicInputsAndRecursiveProof(
|
|
382
|
-
result,
|
|
383
|
-
makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
384
|
-
ProtocolCircuitVks['EmptyBlockRootRollupArtifact'],
|
|
275
|
+
return await this.simulate(
|
|
276
|
+
input,
|
|
277
|
+
'EmptyBlockRootRollupArtifact',
|
|
278
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
279
|
+
convertEmptyBlockRootRollupInputsToWitnessMap,
|
|
280
|
+
convertEmptyBlockRootRollupOutputsFromWitnessMap,
|
|
385
281
|
);
|
|
386
282
|
}
|
|
387
283
|
|
|
@@ -394,29 +290,12 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
394
290
|
public async getBlockMergeRollupProof(
|
|
395
291
|
input: BlockMergeRollupInputs,
|
|
396
292
|
): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs>> {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
SimulatedServerCircuitArtifacts.BlockMergeRollupArtifact,
|
|
404
|
-
);
|
|
405
|
-
|
|
406
|
-
const result = convertBlockMergeRollupOutputsFromWitnessMap(witness);
|
|
407
|
-
|
|
408
|
-
this.instrumentation.recordDuration('simulationDuration', 'block-merge-rollup', timer);
|
|
409
|
-
emitCircuitSimulationStats(
|
|
410
|
-
'block-merge-rollup',
|
|
411
|
-
timer.ms(),
|
|
412
|
-
input.toBuffer().length,
|
|
413
|
-
result.toBuffer().length,
|
|
414
|
-
this.logger,
|
|
415
|
-
);
|
|
416
|
-
return makePublicInputsAndRecursiveProof(
|
|
417
|
-
result,
|
|
418
|
-
makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
419
|
-
ProtocolCircuitVks['BlockMergeRollupArtifact'],
|
|
293
|
+
return await this.simulate(
|
|
294
|
+
input,
|
|
295
|
+
'BlockMergeRollupArtifact',
|
|
296
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
297
|
+
convertBlockMergeRollupInputsToWitnessMap,
|
|
298
|
+
convertBlockMergeRollupOutputsFromWitnessMap,
|
|
420
299
|
);
|
|
421
300
|
}
|
|
422
301
|
|
|
@@ -429,128 +308,24 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
429
308
|
public async getRootRollupProof(
|
|
430
309
|
input: RootRollupInputs,
|
|
431
310
|
): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs>> {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
SimulatedServerCircuitArtifacts.RootRollupArtifact,
|
|
439
|
-
);
|
|
440
|
-
|
|
441
|
-
const result = convertRootRollupOutputsFromWitnessMap(witness);
|
|
442
|
-
|
|
443
|
-
this.instrumentation.recordDuration('simulationDuration', 'root-rollup', timer);
|
|
444
|
-
emitCircuitSimulationStats(
|
|
445
|
-
'root-rollup',
|
|
446
|
-
timer.ms(),
|
|
447
|
-
input.toBuffer().length,
|
|
448
|
-
result.toBuffer().length,
|
|
449
|
-
this.logger,
|
|
450
|
-
);
|
|
451
|
-
await this.delay();
|
|
452
|
-
return makePublicInputsAndRecursiveProof(
|
|
453
|
-
result,
|
|
454
|
-
makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
455
|
-
ProtocolCircuitVks['RootRollupArtifact'],
|
|
456
|
-
);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
@trackSpan('TestCircuitProver.getPublicKernelInnerProof')
|
|
460
|
-
public async getPublicKernelInnerProof(
|
|
461
|
-
inputs: PublicKernelInnerCircuitPrivateInputs,
|
|
462
|
-
): Promise<PublicInputsAndRecursiveProof<VMCircuitPublicInputs>> {
|
|
463
|
-
const timer = new Timer();
|
|
464
|
-
|
|
465
|
-
const artifact = 'PublicKernelInnerArtifact';
|
|
466
|
-
const circuitName = mapProtocolArtifactNameToCircuitName(artifact);
|
|
467
|
-
|
|
468
|
-
const witnessMap = convertSimulatedPublicInnerInputsToWitnessMap(inputs);
|
|
469
|
-
const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts[artifact]);
|
|
470
|
-
|
|
471
|
-
const result = convertSimulatedPublicInnerOutputFromWitnessMap(witness);
|
|
472
|
-
this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
|
|
473
|
-
emitCircuitSimulationStats(
|
|
474
|
-
circuitName,
|
|
475
|
-
timer.ms(),
|
|
476
|
-
inputs.toBuffer().length,
|
|
477
|
-
result.toBuffer().length,
|
|
478
|
-
this.logger,
|
|
479
|
-
);
|
|
480
|
-
await this.delay();
|
|
481
|
-
return makePublicInputsAndRecursiveProof(
|
|
482
|
-
result,
|
|
483
|
-
makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
484
|
-
ProtocolCircuitVks[artifact],
|
|
311
|
+
return await this.simulate(
|
|
312
|
+
input,
|
|
313
|
+
'RootRollupArtifact',
|
|
314
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
315
|
+
convertRootRollupInputsToWitnessMap,
|
|
316
|
+
convertRootRollupOutputsFromWitnessMap,
|
|
485
317
|
);
|
|
486
318
|
}
|
|
487
319
|
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
): Promise<PublicInputsAndRecursiveProof<PublicKernelCircuitPublicInputs>> {
|
|
492
|
-
const timer = new Timer();
|
|
493
|
-
|
|
494
|
-
const artifact = 'PublicKernelMergeArtifact';
|
|
495
|
-
const circuitName = mapProtocolArtifactNameToCircuitName(artifact);
|
|
496
|
-
|
|
497
|
-
const witnessMap = convertSimulatedPublicMergeInputsToWitnessMap(inputs);
|
|
498
|
-
const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts[artifact]);
|
|
499
|
-
|
|
500
|
-
const result = convertSimulatedPublicMergeOutputFromWitnessMap(witness);
|
|
501
|
-
this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
|
|
502
|
-
emitCircuitSimulationStats(
|
|
503
|
-
circuitName,
|
|
504
|
-
timer.ms(),
|
|
505
|
-
inputs.toBuffer().length,
|
|
506
|
-
result.toBuffer().length,
|
|
507
|
-
this.logger,
|
|
508
|
-
);
|
|
509
|
-
await this.delay();
|
|
510
|
-
return makePublicInputsAndRecursiveProof(
|
|
511
|
-
result,
|
|
512
|
-
makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
513
|
-
ProtocolCircuitVks[artifact],
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
@trackSpan('TestCircuitProver.getPublicTailProof')
|
|
518
|
-
public async getPublicTailProof(
|
|
519
|
-
inputs: PublicKernelTailCircuitPrivateInputs,
|
|
520
|
-
): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> {
|
|
521
|
-
const timer = new Timer();
|
|
522
|
-
|
|
523
|
-
const artifact = 'PublicKernelTailArtifact';
|
|
524
|
-
const circuitName = mapProtocolArtifactNameToCircuitName(artifact);
|
|
525
|
-
|
|
526
|
-
const witnessMap = convertSimulatedPublicTailInputsToWitnessMap(inputs);
|
|
527
|
-
// use WASM here as it is faster for small circuits
|
|
528
|
-
const witness = await this.wasmSimulator.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts[artifact]);
|
|
529
|
-
|
|
530
|
-
const result = convertSimulatedPublicTailOutputFromWitnessMap(witness);
|
|
531
|
-
this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
|
|
532
|
-
emitCircuitSimulationStats(
|
|
533
|
-
circuitName,
|
|
534
|
-
timer.ms(),
|
|
535
|
-
inputs.toBuffer().length,
|
|
536
|
-
result.toBuffer().length,
|
|
537
|
-
this.logger,
|
|
538
|
-
);
|
|
539
|
-
await this.delay();
|
|
540
|
-
return makePublicInputsAndRecursiveProof(
|
|
541
|
-
result,
|
|
542
|
-
makeEmptyRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
|
|
543
|
-
ProtocolCircuitVks[artifact],
|
|
544
|
-
);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
public async getAvmProof(_inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<Proof>> {
|
|
320
|
+
public async getAvmProof(
|
|
321
|
+
_inputs: AvmCircuitInputs,
|
|
322
|
+
): Promise<ProofAndVerificationKey<RecursiveProof<typeof AVM_PROOF_LENGTH_IN_FIELDS>>> {
|
|
548
323
|
// We can't simulate the AVM because we don't have enough context to do so (e.g., DBs).
|
|
549
324
|
// We just return an empty proof and VK data.
|
|
550
325
|
this.logger.debug('Skipping AVM simulation in TestCircuitProver.');
|
|
551
326
|
await this.delay();
|
|
552
327
|
return makeProofAndVerificationKey(
|
|
553
|
-
|
|
328
|
+
makeEmptyRecursiveProof(AVM_PROOF_LENGTH_IN_FIELDS),
|
|
554
329
|
VerificationKeyData.makeFake(AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS),
|
|
555
330
|
);
|
|
556
331
|
}
|
|
@@ -565,4 +340,30 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
565
340
|
public verifyProof(_1: ServerProtocolArtifact, _2: Proof): Promise<void> {
|
|
566
341
|
return Promise.reject(new Error('Method not implemented.'));
|
|
567
342
|
}
|
|
343
|
+
|
|
344
|
+
private async simulate<
|
|
345
|
+
PROOF_LENGTH extends number,
|
|
346
|
+
CircuitInputType extends { toBuffer: () => Buffer },
|
|
347
|
+
CircuitOutputType extends { toBuffer: () => Buffer },
|
|
348
|
+
>(
|
|
349
|
+
input: CircuitInputType,
|
|
350
|
+
artifactName: ServerProtocolArtifact,
|
|
351
|
+
proofLength: PROOF_LENGTH,
|
|
352
|
+
convertInput: (input: CircuitInputType) => WitnessMap,
|
|
353
|
+
convertOutput: (outputWitness: WitnessMap) => CircuitOutputType,
|
|
354
|
+
) {
|
|
355
|
+
const timer = new Timer();
|
|
356
|
+
const witnessMap = convertInput(input);
|
|
357
|
+
const circuitName = mapProtocolArtifactNameToCircuitName(artifactName);
|
|
358
|
+
|
|
359
|
+
const simulationProvider = this.simulationProvider ?? this.wasmSimulator;
|
|
360
|
+
const witness = await simulationProvider.simulateCircuit(witnessMap, SimulatedServerCircuitArtifacts[artifactName]);
|
|
361
|
+
|
|
362
|
+
const result = convertOutput(witness);
|
|
363
|
+
|
|
364
|
+
this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
|
|
365
|
+
emitCircuitSimulationStats(circuitName, timer.ms(), input.toBuffer().length, result.toBuffer().length, this.logger);
|
|
366
|
+
await this.delay();
|
|
367
|
+
return makePublicInputsAndRecursiveProof(result, makeRecursiveProof(proofLength), ProtocolCircuitVks[artifactName]);
|
|
368
|
+
}
|
|
568
369
|
}
|