@aztec/bb-prover 4.0.0-nightly.20260107 → 4.0.0-nightly.20260110

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 (35) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +1 -1
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
  3. package/dest/avm_proving_tests/avm_proving_tester.js +2 -2
  4. package/dest/bb/execute.d.ts +6 -6
  5. package/dest/bb/execute.d.ts.map +1 -1
  6. package/dest/bb/execute.js +46 -75
  7. package/dest/instrumentation.d.ts +1 -1
  8. package/dest/instrumentation.d.ts.map +1 -1
  9. package/dest/instrumentation.js +9 -39
  10. package/dest/prover/server/bb_prover.d.ts +6 -9
  11. package/dest/prover/server/bb_prover.d.ts.map +1 -1
  12. package/dest/prover/server/bb_prover.js +14 -17
  13. package/dest/test/delay_values.js +1 -1
  14. package/dest/test/test_circuit_prover.d.ts +4 -4
  15. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  16. package/dest/test/test_circuit_prover.js +4 -5
  17. package/dest/verification_key/verification_key_data.d.ts +1 -8
  18. package/dest/verification_key/verification_key_data.d.ts.map +1 -1
  19. package/dest/verification_key/verification_key_data.js +0 -19
  20. package/dest/verifier/bb_verifier.d.ts +1 -1
  21. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  22. package/dest/verifier/bb_verifier.js +1 -4
  23. package/dest/verifier/queued_chonk_verifier.d.ts +1 -1
  24. package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -1
  25. package/dest/verifier/queued_chonk_verifier.js +9 -40
  26. package/package.json +16 -16
  27. package/src/avm_proving_tests/avm_proving_tester.ts +2 -16
  28. package/src/bb/execute.ts +31 -59
  29. package/src/instrumentation.ts +8 -39
  30. package/src/prover/server/bb_prover.ts +21 -32
  31. package/src/test/delay_values.ts +1 -1
  32. package/src/test/test_circuit_prover.ts +10 -13
  33. package/src/verification_key/verification_key_data.ts +0 -25
  34. package/src/verifier/bb_verifier.ts +1 -5
  35. package/src/verifier/queued_chonk_verifier.ts +8 -40
@@ -55,10 +55,8 @@ import { NativeACVMSimulator } from '@aztec/simulator/server';
55
55
  import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
56
56
  import { ProvingError } from '@aztec/stdlib/errors';
57
57
  import {
58
- type ProofAndVerificationKey,
59
58
  type PublicInputsAndRecursiveProof,
60
59
  type ServerCircuitProver,
61
- makeProofAndVerificationKey,
62
60
  makePublicInputsAndRecursiveProof,
63
61
  } from '@aztec/stdlib/interfaces/server';
64
62
  import type { ParityBasePrivateInputs, ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
@@ -86,7 +84,7 @@ import {
86
84
  type TxRollupPublicInputs,
87
85
  } from '@aztec/stdlib/rollup';
88
86
  import type { CircuitProvingStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
89
- import type { VerificationKeyData } from '@aztec/stdlib/vks';
87
+ import { VerificationKeyData } from '@aztec/stdlib/vks';
90
88
  import { Attributes, type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
91
89
 
92
90
  import { promises as fs } from 'fs';
@@ -105,9 +103,8 @@ import {
105
103
  verifyProof,
106
104
  } from '../../bb/execute.js';
107
105
  import type { ACVMConfig, BBConfig } from '../../config.js';
108
- import { type UltraHonkFlavor, getUltraHonkFlavorForCircuit } from '../../honk.js';
106
+ import { getUltraHonkFlavorForCircuit } from '../../honk.js';
109
107
  import { ProverInstrumentation } from '../../instrumentation.js';
110
- import { extractAvmVkData } from '../../verification_key/verification_key_data.js';
111
108
  import { readProofsFromOutputDirectory } from '../proof_utils.js';
112
109
 
113
110
  const logger = createLogger('bb-prover');
@@ -191,10 +188,10 @@ export class BBNativeRollupProver implements ServerCircuitProver {
191
188
  }))
192
189
  public async getAvmProof(
193
190
  inputs: AvmCircuitInputs,
194
- ): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
195
- const proofAndVk = await this.createAvmProof(inputs);
196
- await this.verifyAvmProof(proofAndVk.proof.binaryProof, proofAndVk.verificationKey, inputs.publicInputs);
197
- return proofAndVk;
191
+ ): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
192
+ const proof = await this.createAvmProof(inputs);
193
+ await this.verifyAvmProof(proof.binaryProof, inputs.publicInputs);
194
+ return proof;
198
195
  }
199
196
 
200
197
  public async getPublicChonkVerifierProof(
@@ -530,11 +527,10 @@ export class BBNativeRollupProver implements ServerCircuitProver {
530
527
 
531
528
  private async createAvmProof(
532
529
  input: AvmCircuitInputs,
533
- ): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
530
+ ): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
534
531
  const operation = async (bbWorkingDirectory: string) => {
535
532
  const provingResult = await this.generateAvmProofWithBB(input, bbWorkingDirectory);
536
533
 
537
- const avmVK = await extractAvmVkData(provingResult.vkDirectoryPath!);
538
534
  const avmProof = await this.readAvmProofAsFields(provingResult.proofPath!);
539
535
 
540
536
  const circuitType = 'avm-circuit' as const;
@@ -557,7 +553,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
557
553
  } satisfies CircuitProvingStats,
558
554
  );
559
555
 
560
- return makeProofAndVerificationKey(avmProof, avmVK);
556
+ return avmProof;
561
557
  };
562
558
  return await this.runInDirectory(operation);
563
559
  }
@@ -631,28 +627,19 @@ export class BBNativeRollupProver implements ServerCircuitProver {
631
627
  */
632
628
  public async verifyProof(circuitType: ServerProtocolArtifact, proof: Proof) {
633
629
  const verificationKey = this.getVerificationKeyDataForCircuit(circuitType);
634
- return await this.verifyWithKey(getUltraHonkFlavorForCircuit(circuitType), verificationKey, proof);
635
- }
636
-
637
- public async verifyAvmProof(
638
- proof: Proof,
639
- verificationKey: VerificationKeyData,
640
- publicInputs: AvmCircuitPublicInputs,
641
- ) {
642
- return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath) =>
643
- verifyAvmProof(this.config.bbBinaryPath, this.config.bbWorkingDirectory, proofPath, publicInputs, vkPath, logger),
630
+ return await this.verifyInternal(proof, verificationKey, (proofPath, vkPath) =>
631
+ verifyProof(this.config.bbBinaryPath, proofPath, vkPath, getUltraHonkFlavorForCircuit(circuitType), logger),
644
632
  );
645
633
  }
646
634
 
647
- public async verifyWithKey(flavor: UltraHonkFlavor, verificationKey: VerificationKeyData, proof: Proof) {
648
- return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath) =>
649
- verifyProof(this.config.bbBinaryPath, proofPath, vkPath, flavor, logger),
635
+ public async verifyAvmProof(proof: Proof, publicInputs: AvmCircuitPublicInputs) {
636
+ return await this.verifyInternal(proof, /*verificationKey=*/ undefined, (proofPath, /*unused*/ _vkPath) =>
637
+ verifyAvmProof(this.config.bbBinaryPath, this.config.bbWorkingDirectory, proofPath, publicInputs, logger),
650
638
  );
651
639
  }
652
-
653
- private async verifyWithKeyInternal(
640
+ private async verifyInternal(
654
641
  proof: Proof,
655
- verificationKey: { keyAsBytes: Buffer },
642
+ verificationKey: { keyAsBytes: Buffer } | undefined,
656
643
  verificationFunction: (proofPath: string, vkPath: string) => Promise<BBFailure | BBSuccess>,
657
644
  ) {
658
645
  const operation = async (bbWorkingDirectory: string) => {
@@ -660,11 +647,13 @@ export class BBNativeRollupProver implements ServerCircuitProver {
660
647
  const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
661
648
  const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
662
649
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/13189): Put this proof parsing logic in the proof class.
663
- await fs.writeFile(publicInputsFileName, proof.buffer.slice(0, proof.numPublicInputs * 32));
664
- await fs.writeFile(proofFileName, proof.buffer.slice(proof.numPublicInputs * 32));
665
- await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
650
+ await fs.writeFile(publicInputsFileName, proof.buffer.subarray(0, proof.numPublicInputs * 32));
651
+ await fs.writeFile(proofFileName, proof.buffer.subarray(proof.numPublicInputs * 32));
652
+ if (verificationKey !== undefined) {
653
+ await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
654
+ }
666
655
 
667
- const result = await verificationFunction(proofFileName, verificationKeyPath!);
656
+ const result = await verificationFunction(proofFileName, verificationKeyPath);
668
657
 
669
658
  if (result.status === BB_RESULT.FAILURE) {
670
659
  const errorMessage = `Failed to verify proof from key!`;
@@ -43,5 +43,5 @@ export const PROOF_DELAY_MS: Record<ProvingRequestType, number> = {
43
43
  [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP]: 15_000,
44
44
  [ProvingRequestType.CHECKPOINT_ROOT_ROLLUP]: 35_000,
45
45
  [ProvingRequestType.CHECKPOINT_PADDING_ROLLUP]: 0,
46
- [ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 45_000, // Guess based on public
46
+ [ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 22_000,
47
47
  };
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
3
- AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED,
4
3
  NESTED_RECURSIVE_PROOF_LENGTH,
5
4
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
6
5
  RECURSIVE_PROOF_LENGTH,
@@ -51,14 +50,18 @@ import type { WitnessMap } from '@aztec/noir-types';
51
50
  import { type CircuitSimulator, WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator/server';
52
51
  import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
53
52
  import {
54
- type ProofAndVerificationKey,
55
53
  type PublicInputsAndRecursiveProof,
56
54
  type ServerCircuitProver,
57
- makeProofAndVerificationKey,
58
55
  makePublicInputsAndRecursiveProof,
59
56
  } from '@aztec/stdlib/interfaces/server';
60
57
  import type { ParityBasePrivateInputs, ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
61
- import { type Proof, ProvingRequestType, makeEmptyRecursiveProof, makeRecursiveProof } from '@aztec/stdlib/proofs';
58
+ import {
59
+ type Proof,
60
+ ProvingRequestType,
61
+ RecursiveProof,
62
+ makeEmptyRecursiveProof,
63
+ makeRecursiveProof,
64
+ } from '@aztec/stdlib/proofs';
62
65
  import {
63
66
  type BlockMergeRollupPrivateInputs,
64
67
  type BlockRollupPublicInputs,
@@ -81,7 +84,6 @@ import {
81
84
  type TxMergeRollupPrivateInputs,
82
85
  type TxRollupPublicInputs,
83
86
  } from '@aztec/stdlib/rollup';
84
- import { VerificationKeyData } from '@aztec/stdlib/vks';
85
87
  import { type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
86
88
 
87
89
  import { ProverInstrumentation } from '../instrumentation.js';
@@ -400,17 +402,12 @@ export class TestCircuitProver implements ServerCircuitProver {
400
402
  );
401
403
  }
402
404
 
403
- public getAvmProof(
404
- _inputs: AvmCircuitInputs,
405
- ): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
405
+ public getAvmProof(_inputs: AvmCircuitInputs): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
406
406
  // We can't simulate the AVM because we don't have enough context to do so (e.g., DBs).
407
- // We just return an empty proof and VK data.
407
+ // We just return an empty proof.
408
408
  this.logger.debug('Skipping AVM simulation in TestCircuitProver.');
409
409
  return this.applyDelay(ProvingRequestType.PUBLIC_VM, () =>
410
- makeProofAndVerificationKey(
411
- makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
412
- VerificationKeyData.makeFake(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED),
413
- ),
410
+ makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
414
411
  );
415
412
  }
416
413
 
@@ -1,9 +1,7 @@
1
- import { AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED } from '@aztec/constants';
2
1
  import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import { BufferReader } from '@aztec/foundation/serialize';
4
3
  import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
5
4
 
6
- import { strict as assert } from 'assert';
7
5
  import { promises as fs } from 'fs';
8
6
  import * as path from 'path';
9
7
 
@@ -25,26 +23,3 @@ export async function extractVkData(vkDirectoryPath: string): Promise<Verificati
25
23
  const vkAsFields = await VerificationKeyAsFields.fromKey(fields);
26
24
  return new VerificationKeyData(vkAsFields, rawBinary);
27
25
  }
28
-
29
- /**
30
- * Reads the verification key data stored in a binary file at the specified directory location and parses into a VerificationKeyData.
31
- * We do not assume any JSON file available but only the binary version, contrary to the above extractVkData() method.
32
- * @param vkDirectoryPath - The directory containing the verification key binary data file.
33
- * @returns The verification key data
34
- */
35
- export async function extractAvmVkData(vkDirectoryPath: string): Promise<VerificationKeyData> {
36
- const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
37
-
38
- const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
39
- assert(numFields <= AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED, 'Invalid AVM verification key length');
40
- const reader = BufferReader.asReader(rawBinary);
41
- const fieldsArray = reader.readArray(numFields, Fr);
42
-
43
- const fieldsArrayPadded = fieldsArray.concat(
44
- Array(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED - fieldsArray.length).fill(new Fr(0)),
45
- );
46
- const vkAsFields = await VerificationKeyAsFields.fromKey(fieldsArrayPadded);
47
- // TODO(#16644): We should have a different type for AVM verification keys since we don't have circuit size or num public inputs in AVM VKs.
48
- const vk = new VerificationKeyData(vkAsFields, rawBinary);
49
- return vk;
50
- }
@@ -102,10 +102,6 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
102
102
 
103
103
  // Block below is almost copy-pasted from verifyProofForCircuit
104
104
  const operation = async (bbWorkingDirectory: string) => {
105
- const logFunction = (message: string) => {
106
- this.logger.debug(`${proofType} BB out - ${message}`);
107
- };
108
-
109
105
  const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
110
106
  await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
111
107
 
@@ -118,7 +114,7 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
118
114
  this.config.bbBinaryPath,
119
115
  proofPath,
120
116
  verificationKeyPath,
121
- logFunction,
117
+ this.logger,
122
118
  this.config.bbIVCConcurrency,
123
119
  );
124
120
  verificationDuration = timer.ms();
@@ -10,7 +10,6 @@ import {
10
10
  type ObservableGauge,
11
11
  type TelemetryClient,
12
12
  type UpDownCounter,
13
- ValueType,
14
13
  getTelemetryClient,
15
14
  } from '@aztec/telemetry-client';
16
15
 
@@ -36,49 +35,18 @@ class IVCVerifierMetrics {
36
35
  constructor(client: TelemetryClient, name = 'QueuedIVCVerifier') {
37
36
  const meter = client.getMeter(name);
38
37
 
39
- this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME, {
40
- unit: 'ms',
41
- description: 'Duration to verify chonk proofs',
42
- valueType: ValueType.INT,
43
- });
38
+ this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME);
44
39
 
45
- this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
46
- unit: 'ms',
47
- description: 'Total duration to verify chonk proofs, including serde',
48
- valueType: ValueType.INT,
49
- });
40
+ this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME);
50
41
 
51
- this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT, {
52
- description: 'Count of failed IVC proof verifications',
53
- valueType: ValueType.INT,
54
- });
42
+ this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT);
55
43
 
56
44
  this.aggDurationMetrics = {
57
- avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG, {
58
- valueType: ValueType.DOUBLE,
59
- description: 'AVG ivc verification',
60
- unit: 'ms',
61
- }),
62
- max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX, {
63
- valueType: ValueType.DOUBLE,
64
- description: 'MAX ivc verification',
65
- unit: 'ms',
66
- }),
67
- min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN, {
68
- valueType: ValueType.DOUBLE,
69
- description: 'MIN ivc verification',
70
- unit: 'ms',
71
- }),
72
- p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50, {
73
- valueType: ValueType.DOUBLE,
74
- description: 'P50 ivc verification',
75
- unit: 'ms',
76
- }),
77
- p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90, {
78
- valueType: ValueType.DOUBLE,
79
- description: 'P90 ivc verification',
80
- unit: 'ms',
81
- }),
45
+ avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG),
46
+ max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX),
47
+ min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN),
48
+ p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50),
49
+ p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90),
82
50
  };
83
51
 
84
52
  meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));