@aztec/bb-prover 0.46.2 → 0.46.3

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.
Files changed (36) hide show
  1. package/dest/bb/cli.d.ts.map +1 -1
  2. package/dest/bb/cli.js +22 -1
  3. package/dest/bb/execute.d.ts +25 -0
  4. package/dest/bb/execute.d.ts.map +1 -1
  5. package/dest/bb/execute.js +185 -7
  6. package/dest/prover/bb_private_kernel_prover.d.ts +49 -0
  7. package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -0
  8. package/dest/prover/bb_private_kernel_prover.js +201 -0
  9. package/dest/prover/bb_prover.d.ts +20 -5
  10. package/dest/prover/bb_prover.d.ts.map +1 -1
  11. package/dest/prover/bb_prover.js +118 -15
  12. package/dest/prover/index.d.ts +1 -1
  13. package/dest/prover/index.d.ts.map +1 -1
  14. package/dest/prover/index.js +2 -2
  15. package/dest/stats.d.ts.map +1 -1
  16. package/dest/stats.js +3 -1
  17. package/dest/test/test_circuit_prover.d.ts +6 -1
  18. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  19. package/dest/test/test_circuit_prover.js +17 -3
  20. package/dest/verification_key/verification_key_data.d.ts.map +1 -1
  21. package/dest/verification_key/verification_key_data.js +2 -3
  22. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  23. package/dest/verifier/bb_verifier.js +8 -7
  24. package/package.json +8 -7
  25. package/src/bb/cli.ts +32 -0
  26. package/src/bb/execute.ts +227 -7
  27. package/src/prover/{bb_native_proof_creator.ts → bb_private_kernel_prover.ts} +114 -114
  28. package/src/prover/bb_prover.ts +167 -17
  29. package/src/prover/index.ts +1 -1
  30. package/src/stats.ts +2 -0
  31. package/src/test/test_circuit_prover.ts +42 -0
  32. package/src/verification_key/verification_key_data.ts +1 -5
  33. package/src/verifier/bb_verifier.ts +7 -6
  34. package/dest/prover/bb_native_proof_creator.d.ts +0 -47
  35. package/dest/prover/bb_native_proof_creator.d.ts.map +0 -1
  36. package/dest/prover/bb_native_proof_creator.js +0 -198
@@ -9,7 +9,6 @@ import {
9
9
  } from '@aztec/circuit-types';
10
10
  import { type CircuitProvingStats, type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
11
11
  import {
12
- AGGREGATION_OBJECT_LENGTH,
13
12
  type AvmCircuitInputs,
14
13
  type BaseOrMergeRollupPublicInputs,
15
14
  type BaseParityInputs,
@@ -30,6 +29,8 @@ import {
30
29
  type RootParityInputs,
31
30
  type RootRollupInputs,
32
31
  type RootRollupPublicInputs,
32
+ TUBE_PROOF_LENGTH,
33
+ TubeInputs,
33
34
  type VerificationKeyAsFields,
34
35
  type VerificationKeyData,
35
36
  makeRecursiveProofFromBinary,
@@ -62,6 +63,7 @@ import { Attributes, type TelemetryClient, trackSpan } from '@aztec/telemetry-cl
62
63
 
63
64
  import { abiEncode } from '@noir-lang/noirc_abi';
64
65
  import { type Abi, type WitnessMap } from '@noir-lang/types';
66
+ import crypto from 'crypto';
65
67
  import * as fs from 'fs/promises';
66
68
  import * as path from 'path';
67
69
 
@@ -75,6 +77,7 @@ import {
75
77
  generateAvmProof,
76
78
  generateKeyForNoirCircuit,
77
79
  generateProof,
80
+ generateTubeProof,
78
81
  verifyAvmProof,
79
82
  verifyProof,
80
83
  writeProofAsFields,
@@ -222,6 +225,16 @@ export class BBNativeRollupProver implements ServerCircuitProver {
222
225
  kernelRequest.inputs.previousKernel.vk,
223
226
  );
224
227
 
228
+ // PUBLIC KERNEL: kernel request should be nonempty at start of public kernel proving but it is not
229
+ // TODO(#7369): We should properly enqueue the tube in the public kernel lifetime
230
+ if (!kernelRequest.inputs.previousKernel.clientIvcProof.isEmpty()) {
231
+ const { tubeVK, tubeProof } = await this.getTubeProof(
232
+ new TubeInputs(kernelRequest.inputs.previousKernel.clientIvcProof),
233
+ );
234
+ kernelRequest.inputs.previousKernel.vk = tubeVK;
235
+ kernelRequest.inputs.previousKernel.proof = tubeProof;
236
+ }
237
+
225
238
  await this.verifyWithKey(
226
239
  kernelRequest.inputs.previousKernel.vk,
227
240
  kernelRequest.inputs.previousKernel.proof.binaryProof,
@@ -267,23 +280,27 @@ export class BBNativeRollupProver implements ServerCircuitProver {
267
280
 
268
281
  /**
269
282
  * Simulates the base rollup circuit from its inputs.
270
- * @param input - Inputs to the circuit.
283
+ * @param baseRollupInput - Inputs to the circuit.
271
284
  * @returns The public inputs as outputs of the simulation.
272
285
  */
273
286
  public async getBaseRollupProof(
274
- input: BaseRollupInputs,
287
+ baseRollupInput: BaseRollupInputs, // TODO: remove tail proof from here
275
288
  ): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs>> {
276
289
  // We may need to convert the recursive proof into fields format
277
- input.kernelData.proof = await this.ensureValidProof(
278
- input.kernelData.proof,
290
+ logger.debug(`kernel Data proof: ${baseRollupInput.kernelData.proof}`);
291
+ logger.info(`in getBaseRollupProof`);
292
+ logger.info(`Number of public inputs in baseRollupInput: ${baseRollupInput.kernelData.vk.numPublicInputs}`);
293
+ logger.info(`Number of public inputs ${baseRollupInput.kernelData.publicInputs}`);
294
+ baseRollupInput.kernelData.proof = await this.ensureValidProof(
295
+ baseRollupInput.kernelData.proof,
279
296
  'BaseRollupArtifact',
280
- input.kernelData.vk,
297
+ baseRollupInput.kernelData.vk,
281
298
  );
282
299
 
283
300
  const { circuitOutput, proof } = await this.createRecursiveProof(
284
- input,
301
+ baseRollupInput, // BaseRollupInputs
285
302
  'BaseRollupArtifact',
286
- NESTED_RECURSIVE_PROOF_LENGTH,
303
+ NESTED_RECURSIVE_PROOF_LENGTH, // WORKTODO: this should be BASE_ROLLUP_PROOF_LENGTH or something like this
287
304
  convertBaseRollupInputsToWitnessMap,
288
305
  convertBaseRollupOutputsFromWitnessMap,
289
306
  );
@@ -356,6 +373,20 @@ export class BBNativeRollupProver implements ServerCircuitProver {
356
373
  return emptyPrivateKernelProof;
357
374
  }
358
375
 
376
+ public async getEmptyTubeProof(
377
+ inputs: PrivateKernelEmptyInputData,
378
+ ): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> {
379
+ const emptyNested = await this.getEmptyNestedProof();
380
+ const emptyPrivateKernelProof = await this.getEmptyTubeProofFromEmptyNested(
381
+ PrivateKernelEmptyInputs.from({
382
+ ...inputs,
383
+ emptyNested,
384
+ }),
385
+ );
386
+
387
+ return emptyPrivateKernelProof;
388
+ }
389
+
359
390
  private async getEmptyNestedProof(): Promise<EmptyNestedData> {
360
391
  const inputs = new EmptyNestedCircuitInputs();
361
392
  const { proof } = await this.createRecursiveProof(
@@ -368,11 +399,15 @@ export class BBNativeRollupProver implements ServerCircuitProver {
368
399
 
369
400
  const verificationKey = await this.getVerificationKeyDataForCircuit('EmptyNestedArtifact');
370
401
  await this.verifyProof('EmptyNestedArtifact', proof.binaryProof);
402
+ // logger.debug(`EmptyNestedData proof size: ${proof.proof.length}`);
403
+ // logger.debug(`EmptyNestedData proof: ${proof.proof}`);
404
+ // logger.debug(`EmptyNestedData vk size: ${verificationKey.keyAsFields.key.length}`);
405
+ // logger.debug(`EmptyNestedData vk: ${verificationKey.keyAsFields.key}`);
371
406
 
372
407
  return new EmptyNestedData(proof, verificationKey.keyAsFields);
373
408
  }
374
409
 
375
- private async getEmptyPrivateKernelProofFromEmptyNested(
410
+ private async getEmptyTubeProofFromEmptyNested(
376
411
  inputs: PrivateKernelEmptyInputs,
377
412
  ): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> {
378
413
  const { circuitOutput, proof } = await this.createRecursiveProof(
@@ -382,7 +417,24 @@ export class BBNativeRollupProver implements ServerCircuitProver {
382
417
  convertPrivateKernelEmptyInputsToWitnessMap,
383
418
  convertPrivateKernelEmptyOutputsFromWitnessMap,
384
419
  );
420
+ // info(`proof: ${proof.proof}`);
421
+ const verificationKey = await this.getVerificationKeyDataForCircuit('PrivateKernelEmptyArtifact');
422
+ await this.verifyProof('PrivateKernelEmptyArtifact', proof.binaryProof);
385
423
 
424
+ return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
425
+ }
426
+
427
+ private async getEmptyPrivateKernelProofFromEmptyNested(
428
+ inputs: PrivateKernelEmptyInputs,
429
+ ): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> {
430
+ const { circuitOutput, proof } = await this.createRecursiveProof(
431
+ inputs,
432
+ 'PrivateKernelEmptyArtifact',
433
+ NESTED_RECURSIVE_PROOF_LENGTH,
434
+ convertPrivateKernelEmptyInputsToWitnessMap,
435
+ convertPrivateKernelEmptyOutputsFromWitnessMap,
436
+ );
437
+ //info(`proof: ${proof.proof}`);
386
438
  const verificationKey = await this.getVerificationKeyDataForCircuit('PrivateKernelEmptyArtifact');
387
439
  await this.verifyProof('PrivateKernelEmptyArtifact', proof.binaryProof);
388
440
 
@@ -513,6 +565,22 @@ export class BBNativeRollupProver implements ServerCircuitProver {
513
565
  return provingResult;
514
566
  }
515
567
 
568
+ private async generateTubeProofWithBB(bbWorkingDirectory: string, input: TubeInputs): Promise<BBSuccess> {
569
+ logger.debug(`Proving tube...`);
570
+
571
+ const hasher = crypto.createHash('sha256');
572
+ hasher.update(input.toBuffer());
573
+
574
+ await input.clientIVCData.writeToOutputDirectory(bbWorkingDirectory);
575
+ const provingResult = await generateTubeProof(this.config.bbBinaryPath, bbWorkingDirectory, logger.verbose);
576
+
577
+ if (provingResult.status === BB_RESULT.FAILURE) {
578
+ logger.error(`Failed to generate proof for tube proof: ${provingResult.reason}`);
579
+ throw new Error(provingResult.reason);
580
+ }
581
+ return provingResult;
582
+ }
583
+
516
584
  private async createAvmProof(input: AvmCircuitInputs): Promise<ProofAndVerificationKey> {
517
585
  const cleanupDir: boolean = !process.env.AVM_PROVING_PRESERVE_WORKING_DIR;
518
586
  const operation = async (bbWorkingDirectory: string): Promise<ProofAndVerificationKey> => {
@@ -554,8 +622,34 @@ export class BBNativeRollupProver implements ServerCircuitProver {
554
622
  return await runInDirectory(this.config.bbWorkingDirectory, operation, cleanupDir);
555
623
  }
556
624
 
625
+ public async getTubeProof(
626
+ input: TubeInputs,
627
+ ): Promise<{ tubeVK: VerificationKeyData; tubeProof: RecursiveProof<typeof TUBE_PROOF_LENGTH> }> {
628
+ // this probably is gonna need to call client ivc
629
+ const operation = async (bbWorkingDirectory: string) => {
630
+ logger.debug(`createTubeProof: ${bbWorkingDirectory}`);
631
+ const provingResult = await this.generateTubeProofWithBB(bbWorkingDirectory, input);
632
+
633
+ // Read the proof as fields
634
+ const tubeVK = await extractVkData(provingResult.vkPath!);
635
+ const tubeProof = await this.readTubeProofAsFields(provingResult.proofPath!, tubeVK, TUBE_PROOF_LENGTH);
636
+ // Sanity check the tube proof (can be removed later)
637
+ await this.verifyWithKey(tubeVK, tubeProof.binaryProof);
638
+
639
+ // TODO(#7369): properly time tube construction
640
+ logger.info(
641
+ `Generated proof for tubeCircuit in ${Math.ceil(provingResult.durationMs)} ms, size: ${
642
+ tubeProof.proof.length
643
+ } fields`,
644
+ );
645
+
646
+ return { tubeVK, tubeProof };
647
+ };
648
+ return await runInDirectory(this.config.bbWorkingDirectory, operation);
649
+ }
650
+
557
651
  /**
558
- * Executes a circuit and returns it's outputs and corresponding proof with embedded aggregation object
652
+ * Executes a circuit and returns its outputs and corresponding proof with embedded aggregation object
559
653
  * @param witnessMap - The input witness
560
654
  * @param circuitType - The type of circuit to be executed
561
655
  * @param proofLength - The length of the proof to be generated. This is a dummy parameter to aid in type checking
@@ -574,6 +668,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
574
668
  convertInput: (input: CircuitInputType) => WitnessMap,
575
669
  convertOutput: (outputWitness: WitnessMap) => CircuitOutputType,
576
670
  ): Promise<{ circuitOutput: CircuitOutputType; proof: RecursiveProof<PROOF_LENGTH> }> {
671
+ // this probably is gonna need to call client ivc
577
672
  const operation = async (bbWorkingDirectory: string) => {
578
673
  const {
579
674
  provingResult,
@@ -619,6 +714,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
619
714
  */
620
715
  public async verifyProof(circuitType: ServerProtocolArtifact, proof: Proof) {
621
716
  const verificationKey = await this.getVerificationKeyDataForCircuit(circuitType);
717
+ // info(`vkey in: ${verificationKey.keyAsFields.key}`);
622
718
  return await this.verifyWithKey(verificationKey, proof);
623
719
  }
624
720
 
@@ -691,7 +787,8 @@ export class BBNativeRollupProver implements ServerCircuitProver {
691
787
  }
692
788
 
693
789
  const operation = async (bbWorkingDirectory: string) => {
694
- const numPublicInputs = vk.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
790
+ // const numPublicInputs = vk.numPublicInputs;
791
+ const numPublicInputs = vk.numPublicInputs; // - AGGREGATION_OBJECT_LENGTH;
695
792
  const proofFullFilename = path.join(bbWorkingDirectory, PROOF_FILENAME);
696
793
  const vkFullFilename = path.join(bbWorkingDirectory, VK_FILENAME);
697
794
 
@@ -723,7 +820,10 @@ export class BBNativeRollupProver implements ServerCircuitProver {
723
820
  encoding: 'utf-8',
724
821
  });
725
822
  const json = JSON.parse(proofString);
726
- const fields = json.slice(numPublicInputs).map(Fr.fromString);
823
+ const fields = json
824
+ .slice(0, 3)
825
+ .map(Fr.fromString)
826
+ .concat(json.slice(3 + numPublicInputs).map(Fr.fromString));
727
827
  return new RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>(
728
828
  fields,
729
829
  new Proof(proof.binaryProof.buffer, vk.numPublicInputs),
@@ -800,13 +900,21 @@ export class BBNativeRollupProver implements ServerCircuitProver {
800
900
  if (!vkData) {
801
901
  throw new Error(`Invalid verification key for ${circuitType}`);
802
902
  }
803
- const numPublicInputs = CIRCUITS_WITHOUT_AGGREGATION.has(circuitType)
804
- ? vkData.numPublicInputs
805
- : vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
806
- const fieldsWithoutPublicInputs = json.slice(numPublicInputs).map(Fr.fromString);
903
+ const numPublicInputs = vkData.numPublicInputs;
904
+ // TODO(https://github.com/AztecProtocol/barretenberg/issues/1044): Reinstate aggregation
905
+ // const numPublicInputs = CIRCUITS_WITHOUT_AGGREGATION.has(circuitType)
906
+ // ? vkData.numPublicInputs
907
+ // : vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
908
+ const fieldsWithoutPublicInputs = json
909
+ .slice(0, 3)
910
+ .map(Fr.fromString)
911
+ .concat(json.slice(3 + numPublicInputs).map(Fr.fromString));
807
912
  logger.debug(
808
- `Circuit type: ${circuitType}, complete proof length: ${json.length}, without public inputs: ${fieldsWithoutPublicInputs.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProof.length}`,
913
+ `num pub inputs ${vkData.numPublicInputs} and without aggregation ${CIRCUITS_WITHOUT_AGGREGATION.has(
914
+ circuitType,
915
+ )}`,
809
916
  );
917
+
810
918
  const proof = new RecursiveProof<PROOF_LENGTH>(
811
919
  fieldsWithoutPublicInputs,
812
920
  new Proof(binaryProof, numPublicInputs),
@@ -818,4 +926,46 @@ export class BBNativeRollupProver implements ServerCircuitProver {
818
926
 
819
927
  return proof;
820
928
  }
929
+
930
+ /**
931
+ * Parses and returns a tube proof stored in the specified directory. TODO merge wih above
932
+ * @param filePath - The directory containing the proof data
933
+ * @param circuitType - The type of circuit proven
934
+ * @returns The proof
935
+ * TODO(#7369) This is entirely redundant now with the above method, deduplicate
936
+ */
937
+ private async readTubeProofAsFields<PROOF_LENGTH extends number>(
938
+ filePath: string,
939
+ vkData: VerificationKeyData,
940
+ proofLength: PROOF_LENGTH,
941
+ ): Promise<RecursiveProof<PROOF_LENGTH>> {
942
+ const proofFilename = path.join(filePath, PROOF_FILENAME);
943
+ const proofFieldsFilename = path.join(filePath, PROOF_FIELDS_FILENAME);
944
+
945
+ const [binaryProof, proofString] = await Promise.all([
946
+ fs.readFile(proofFilename),
947
+ fs.readFile(proofFieldsFilename, { encoding: 'utf-8' }),
948
+ ]);
949
+
950
+ const json = JSON.parse(proofString);
951
+
952
+ const numPublicInputs = vkData.numPublicInputs;
953
+ if (numPublicInputs === 0) {
954
+ throw new Error(`Tube proof should have public inputs (e.g. the number of public inputs from PrivateKernelTail)`);
955
+ }
956
+
957
+ const proofFields = json
958
+ .slice(0, 3)
959
+ .map(Fr.fromString)
960
+ .concat(json.slice(3 + numPublicInputs).map(Fr.fromString));
961
+ logger.debug(
962
+ `Circuit type: tube circuit, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProof.length}`,
963
+ );
964
+ const proof = new RecursiveProof<PROOF_LENGTH>(proofFields, new Proof(binaryProof, numPublicInputs), true);
965
+ if (proof.proof.length !== proofLength) {
966
+ throw new Error(`Proof length doesn't match expected length (${proof.proof.length} != ${proofLength})`);
967
+ }
968
+
969
+ return proof;
970
+ }
821
971
  }
@@ -1,2 +1,2 @@
1
1
  export * from './bb_prover.js';
2
- export * from './bb_native_proof_creator.js';
2
+ export * from './bb_private_kernel_prover.js';
package/src/stats.ts CHANGED
@@ -41,6 +41,8 @@ export function mapProtocolArtifactNameToCircuitName(
41
41
  return 'private-kernel-reset-medium';
42
42
  case 'PrivateKernelResetSmallArtifact':
43
43
  return 'private-kernel-reset-small';
44
+ case 'PrivateKernelResetTinyArtifact':
45
+ return 'private-kernel-reset-tiny';
44
46
  case 'EmptyNestedArtifact':
45
47
  return 'empty-nested';
46
48
  case 'PrivateKernelEmptyArtifact':
@@ -20,10 +20,13 @@ import {
20
20
  type Proof,
21
21
  type PublicKernelCircuitPublicInputs,
22
22
  RECURSIVE_PROOF_LENGTH,
23
+ type RecursiveProof,
23
24
  RootParityInput,
24
25
  type RootParityInputs,
25
26
  type RootRollupInputs,
26
27
  type RootRollupPublicInputs,
28
+ TUBE_PROOF_LENGTH,
29
+ type TubeInputs,
27
30
  VerificationKeyData,
28
31
  makeEmptyProof,
29
32
  makeEmptyRecursiveProof,
@@ -41,6 +44,7 @@ import {
41
44
  convertMergeRollupInputsToWitnessMap,
42
45
  convertMergeRollupOutputsFromWitnessMap,
43
46
  convertPrivateKernelEmptyInputsToWitnessMap,
47
+ convertPrivateKernelEmptyOutputsFromWitnessMap,
44
48
  convertRootParityInputsToWitnessMap,
45
49
  convertRootParityOutputsFromWitnessMap,
46
50
  convertRootRollupInputsToWitnessMap,
@@ -107,6 +111,34 @@ export class TestCircuitProver implements ServerCircuitProver {
107
111
  );
108
112
  }
109
113
 
114
+ public async getEmptyTubeProof(
115
+ inputs: PrivateKernelEmptyInputData,
116
+ ): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> {
117
+ const emptyNested = new EmptyNestedData(
118
+ makeRecursiveProof(RECURSIVE_PROOF_LENGTH),
119
+ ProtocolCircuitVks['EmptyNestedArtifact'].keyAsFields,
120
+ );
121
+ const kernelInputs = new PrivateKernelEmptyInputs(
122
+ emptyNested,
123
+ inputs.header,
124
+ inputs.chainId,
125
+ inputs.version,
126
+ inputs.vkTreeRoot,
127
+ );
128
+ const witnessMap = convertPrivateKernelEmptyInputsToWitnessMap(kernelInputs);
129
+ const witness = await this.wasmSimulator.simulateCircuit(
130
+ witnessMap,
131
+ SimulatedServerCircuitArtifacts.PrivateKernelEmptyArtifact,
132
+ );
133
+ const result = convertPrivateKernelEmptyOutputsFromWitnessMap(witness);
134
+
135
+ return makePublicInputsAndRecursiveProof(
136
+ result,
137
+ makeRecursiveProof(NESTED_RECURSIVE_PROOF_LENGTH),
138
+ VerificationKeyData.makeFake(),
139
+ );
140
+ }
141
+
110
142
  /**
111
143
  * Simulates the base parity circuit from its inputs.
112
144
  * @param inputs - Inputs to the circuit.
@@ -217,6 +249,16 @@ export class TestCircuitProver implements ServerCircuitProver {
217
249
  ProtocolCircuitVks['BaseRollupArtifact'],
218
250
  );
219
251
  }
252
+
253
+ public getTubeProof(
254
+ _tubeInput: TubeInputs,
255
+ ): Promise<{ tubeVK: VerificationKeyData; tubeProof: RecursiveProof<typeof TUBE_PROOF_LENGTH> }> {
256
+ return Promise.resolve({
257
+ tubeVK: VerificationKeyData.makeFake(),
258
+ tubeProof: makeEmptyRecursiveProof(TUBE_PROOF_LENGTH),
259
+ });
260
+ }
261
+
220
262
  /**
221
263
  * Simulates the merge rollup circuit from its inputs.
222
264
  * @param input - Inputs to the circuit.
@@ -25,11 +25,7 @@ export async function extractVkData(vkDirectoryPath: string): Promise<Verificati
25
25
  const fields = fieldsJson.map(Fr.fromString);
26
26
  // The first item is the hash, this is not part of the actual VK
27
27
  const vkHash = fields[0];
28
- const actualVk = fields.slice(1);
29
- const vkAsFields = new VerificationKeyAsFields(
30
- actualVk as Tuple<Fr, typeof VERIFICATION_KEY_LENGTH_IN_FIELDS>,
31
- vkHash,
32
- );
28
+ const vkAsFields = new VerificationKeyAsFields(fields as Tuple<Fr, typeof VERIFICATION_KEY_LENGTH_IN_FIELDS>, vkHash);
33
29
  const vk = new VerificationKeyData(vkAsFields, rawBinary);
34
30
  return vk;
35
31
  }
@@ -128,18 +128,19 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
128
128
  return fs.readFile(result.contractPath!, 'utf-8');
129
129
  }
130
130
 
131
- async verifyProof(tx: Tx): Promise<boolean> {
132
- const { proof, data } = tx;
133
- const expectedCircuit: ClientProtocolArtifact = data.forPublic
131
+ verifyProof(tx: Tx): Promise<boolean> {
132
+ const expectedCircuit: ClientProtocolArtifact = tx.data.forPublic
134
133
  ? 'PrivateKernelTailToPublicArtifact'
135
134
  : 'PrivateKernelTailArtifact';
136
135
 
137
136
  try {
138
- await this.verifyProofForCircuit(expectedCircuit, proof);
139
- return true;
137
+ // TODO(https://github.com/AztecProtocol/barretenberg/issues/1050) we need a proper verify flow for clientIvcProof
138
+ // For now we handle only the trivial blank data case
139
+ // await this.verifyProofForCircuit(expectedCircuit, proof);
140
+ return Promise.resolve(!tx.clientIvcProof.isEmpty());
140
141
  } catch (err) {
141
142
  this.logger.warn(`Failed to verify ${expectedCircuit} proof for tx ${Tx.getHash(tx)}: ${String(err)}`);
142
- return false;
143
+ return Promise.resolve(false);
143
144
  }
144
145
  }
145
146
  }
@@ -1,47 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { type AppCircuitProofOutput, type KernelProofOutput, type ProofCreator } from '@aztec/circuit-types';
3
- import { Fr, type PrivateCircuitPublicInputs, type PrivateKernelCircuitPublicInputs, type PrivateKernelInitCircuitPrivateInputs, type PrivateKernelInnerCircuitPrivateInputs, type PrivateKernelResetCircuitPrivateInputsVariants, type PrivateKernelTailCircuitPrivateInputs, type PrivateKernelTailCircuitPublicInputs, Proof } from '@aztec/circuits.js';
4
- import { type ClientProtocolArtifact } from '@aztec/noir-protocol-circuits-types';
5
- import { type WitnessMap } from '@noir-lang/types';
6
- /**
7
- * This proof creator implementation uses the native bb binary.
8
- * This is a temporary implementation until we make the WASM version work.
9
- */
10
- export declare class BBNativeProofCreator implements ProofCreator {
11
- private bbBinaryPath;
12
- private bbWorkingDirectory;
13
- private log;
14
- private simulator;
15
- private verificationKeys;
16
- constructor(bbBinaryPath: string, bbWorkingDirectory: string, log?: import("@aztec/foundation/log").Logger);
17
- getSiloedCommitments(publicInputs: PrivateCircuitPublicInputs): Promise<Fr[]>;
18
- createProofInit(inputs: PrivateKernelInitCircuitPrivateInputs): Promise<KernelProofOutput<PrivateKernelCircuitPublicInputs>>;
19
- createProofInner(inputs: PrivateKernelInnerCircuitPrivateInputs): Promise<KernelProofOutput<PrivateKernelCircuitPublicInputs>>;
20
- createProofReset(inputs: PrivateKernelResetCircuitPrivateInputsVariants): Promise<KernelProofOutput<PrivateKernelCircuitPublicInputs>>;
21
- createProofTail(inputs: PrivateKernelTailCircuitPrivateInputs): Promise<KernelProofOutput<PrivateKernelTailCircuitPublicInputs>>;
22
- createAppCircuitProof(partialWitness: WitnessMap, bytecode: Buffer, appCircuitName?: string): Promise<AppCircuitProofOutput>;
23
- /**
24
- * Verifies a proof, will generate the verification key if one is not cached internally
25
- * @param circuitType - The type of circuit whose proof is to be verified
26
- * @param proof - The proof to be verified
27
- */
28
- verifyProofForProtocolCircuit(circuitType: ClientProtocolArtifact, proof: Proof): Promise<void>;
29
- private verifyProofFromKey;
30
- /**
31
- * Ensures our verification key cache includes the key data located at the specified directory
32
- * @param filePath - The directory containing the verification key data files
33
- * @param circuitType - The type of circuit to which the verification key corresponds
34
- */
35
- private updateVerificationKeyAfterProof;
36
- private createSafeProof;
37
- private generateWitnessAndCreateProof;
38
- private createProof;
39
- /**
40
- * Parses and returns the proof data stored at the specified directory
41
- * @param filePath - The directory containing the proof data
42
- * @param circuitType - The type of circuit proven
43
- * @returns The proof
44
- */
45
- private readProofAsFields;
46
- }
47
- //# sourceMappingURL=bb_native_proof_creator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bb_native_proof_creator.d.ts","sourceRoot":"","sources":["../../src/prover/bb_native_proof_creator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE7G,OAAO,EAEL,EAAE,EAEF,KAAK,0BAA0B,EAC/B,KAAK,gCAAgC,EACrC,KAAK,qCAAqC,EAC1C,KAAK,sCAAsC,EAC3C,KAAK,8CAA8C,EACnD,KAAK,qCAAqC,EAC1C,KAAK,oCAAoC,EACzC,KAAK,EAKN,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAEL,KAAK,sBAAsB,EAa5B,MAAM,qCAAqC,CAAC;AAK7C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQnD;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IASrD,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,GAAG;IAVb,OAAO,CAAC,SAAS,CAAuB;IAExC,OAAO,CAAC,gBAAgB,CAGpB;gBAGM,YAAY,EAAE,MAAM,EACpB,kBAAkB,EAAE,MAAM,EAC1B,GAAG,yCAA8C;IAGpD,oBAAoB,CAAC,YAAY,EAAE,0BAA0B;IAMvD,eAAe,CAC1B,MAAM,EAAE,qCAAqC,GAC5C,OAAO,CAAC,iBAAiB,CAAC,gCAAgC,CAAC,CAAC;IASlD,gBAAgB,CAC3B,MAAM,EAAE,sCAAsC,GAC7C,OAAO,CAAC,iBAAiB,CAAC,gCAAgC,CAAC,CAAC;IASlD,gBAAgB,CAC3B,MAAM,EAAE,8CAA8C,GACrD,OAAO,CAAC,iBAAiB,CAAC,gCAAgC,CAAC,CAAC;IASlD,eAAe,CAC1B,MAAM,EAAE,qCAAqC,GAC5C,OAAO,CAAC,iBAAiB,CAAC,oCAAoC,CAAC,CAAC;IAiBtD,qBAAqB,CAChC,cAAc,EAAE,UAAU,EAC1B,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,qBAAqB,CAAC;IAkBjC;;;;OAIG;IACU,6BAA6B,CAAC,WAAW,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK;YAmB9E,kBAAkB;IAgBhC;;;;OAIG;YACW,+BAA+B;YAU/B,eAAe;YAYf,6BAA6B;YA6C7B,WAAW;IA4EzB;;;;;OAKG;YACW,iBAAiB;CAwBhC"}