@aztec/bb-prover 3.0.0-devnet.2 → 3.0.0-devnet.20251212

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 (82) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +3 -4
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
  3. package/dest/avm_proving_tests/avm_proving_tester.js +16 -2
  4. package/dest/bb/cli.d.ts +1 -1
  5. package/dest/bb/execute.d.ts +4 -4
  6. package/dest/bb/execute.d.ts.map +1 -1
  7. package/dest/bb/execute.js +19 -15
  8. package/dest/bb/index.d.ts +1 -1
  9. package/dest/config.d.ts +1 -1
  10. package/dest/honk.d.ts +1 -1
  11. package/dest/index.d.ts +1 -1
  12. package/dest/instrumentation.d.ts +1 -1
  13. package/dest/instrumentation.d.ts.map +1 -1
  14. package/dest/prover/client/bb_private_kernel_prover.d.ts +3 -3
  15. package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
  16. package/dest/prover/client/bb_private_kernel_prover.js +24 -5
  17. package/dest/prover/client/bundle.d.ts +6 -0
  18. package/dest/prover/client/bundle.d.ts.map +1 -0
  19. package/dest/prover/client/bundle.js +8 -0
  20. package/dest/prover/client/lazy.d.ts +6 -0
  21. package/dest/prover/client/lazy.d.ts.map +1 -0
  22. package/dest/prover/client/lazy.js +8 -0
  23. package/dest/prover/index.d.ts +1 -1
  24. package/dest/prover/proof_utils.d.ts +8 -8
  25. package/dest/prover/proof_utils.d.ts.map +1 -1
  26. package/dest/prover/proof_utils.js +18 -18
  27. package/dest/prover/server/bb_prover.d.ts +3 -12
  28. package/dest/prover/server/bb_prover.d.ts.map +1 -1
  29. package/dest/prover/server/bb_prover.js +6 -6
  30. package/dest/test/delay_values.d.ts +1 -1
  31. package/dest/test/delay_values.js +23 -23
  32. package/dest/test/index.d.ts +1 -1
  33. package/dest/test/test_circuit_prover.d.ts +3 -3
  34. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  35. package/dest/test/test_circuit_prover.js +3 -3
  36. package/dest/test/test_verifier.d.ts +3 -1
  37. package/dest/test/test_verifier.d.ts.map +1 -1
  38. package/dest/test/test_verifier.js +15 -0
  39. package/dest/verification_key/verification_key_data.d.ts +1 -1
  40. package/dest/verification_key/verification_key_data.js +1 -1
  41. package/dest/verifier/bb_verifier.d.ts +1 -1
  42. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  43. package/dest/verifier/bb_verifier.js +9 -6
  44. package/dest/verifier/index.d.ts +2 -2
  45. package/dest/verifier/index.d.ts.map +1 -1
  46. package/dest/verifier/index.js +1 -1
  47. package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
  48. package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
  49. package/dest/verifier/{queued_ivc_verifier.js → queued_chonk_verifier.js} +3 -3
  50. package/package.json +23 -22
  51. package/src/avm_proving_tests/avm_proving_tester.ts +17 -3
  52. package/src/bb/execute.ts +12 -15
  53. package/src/prover/client/bb_private_kernel_prover.ts +29 -5
  54. package/src/prover/client/bundle.ts +11 -0
  55. package/src/prover/client/lazy.ts +11 -0
  56. package/src/prover/proof_utils.ts +18 -18
  57. package/src/prover/server/bb_prover.ts +14 -12
  58. package/src/test/delay_values.ts +23 -23
  59. package/src/test/test_circuit_prover.ts +10 -8
  60. package/src/test/test_verifier.ts +8 -0
  61. package/src/verification_key/verification_key_data.ts +1 -1
  62. package/src/verifier/bb_verifier.ts +9 -9
  63. package/src/verifier/index.ts +1 -1
  64. package/src/verifier/{queued_ivc_verifier.ts → queued_chonk_verifier.ts} +3 -3
  65. package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts +0 -23
  66. package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts.map +0 -1
  67. package/dest/prover/client/native/bb_native_private_kernel_prover.js +0 -66
  68. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts +0 -15
  69. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
  70. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.js +0 -46
  71. package/dest/prover/client/wasm/bundle.d.ts +0 -6
  72. package/dest/prover/client/wasm/bundle.d.ts.map +0 -1
  73. package/dest/prover/client/wasm/bundle.js +0 -8
  74. package/dest/prover/client/wasm/lazy.d.ts +0 -6
  75. package/dest/prover/client/wasm/lazy.d.ts.map +0 -1
  76. package/dest/prover/client/wasm/lazy.js +0 -8
  77. package/dest/verifier/queued_ivc_verifier.d.ts +0 -15
  78. package/dest/verifier/queued_ivc_verifier.d.ts.map +0 -1
  79. package/src/prover/client/native/bb_native_private_kernel_prover.ts +0 -107
  80. package/src/prover/client/wasm/bb_wasm_private_kernel_prover.ts +0 -60
  81. package/src/prover/client/wasm/bundle.ts +0 -11
  82. package/src/prover/client/wasm/lazy.ts +0 -11
package/src/bb/execute.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { sha256 } from '@aztec/foundation/crypto';
1
+ import { sha256 } from '@aztec/foundation/crypto/sha256';
2
2
  import type { LogFn, Logger } from '@aztec/foundation/log';
3
3
  import { Timer } from '@aztec/foundation/timer';
4
4
  import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
@@ -6,6 +6,7 @@ import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm
6
6
  import * as proc from 'child_process';
7
7
  import { promises as fs } from 'fs';
8
8
  import { basename, dirname, join } from 'path';
9
+ import readline from 'readline';
9
10
 
10
11
  import type { UltraHonkFlavor } from '../honk.js';
11
12
 
@@ -85,6 +86,7 @@ export function executeBB(
85
86
  logger(`BB concurrency: ${env.HARDWARE_CONCURRENCY}`);
86
87
  logger(`Executing BB with: ${pathToBB} ${command} ${args.join(' ')}`);
87
88
  const bb = proc.spawn(pathToBB, [command, ...args], {
89
+ stdio: ['ignore', 'pipe', 'pipe'],
88
90
  env,
89
91
  });
90
92
 
@@ -99,14 +101,9 @@ export function executeBB(
99
101
  }, timeout);
100
102
  }
101
103
 
102
- bb.stdout.on('data', data => {
103
- const message = data.toString('utf-8').replace(/\n$/, '');
104
- logger(message);
105
- });
106
- bb.stderr.on('data', data => {
107
- const message = data.toString('utf-8').replace(/\n$/, '');
108
- logger(message);
109
- });
104
+ readline.createInterface({ input: bb.stdout }).on('line', logger);
105
+ readline.createInterface({ input: bb.stderr }).on('line', logger);
106
+
110
107
  bb.on('close', (exitCode: number, signal?: string) => {
111
108
  if (timeoutId) {
112
109
  clearTimeout(timeoutId);
@@ -120,7 +117,7 @@ export function executeBB(
120
117
  }).catch(_ => ({ status: BB_RESULT.FAILURE, exitCode: -1, signal: undefined }));
121
118
  }
122
119
 
123
- export async function executeBbClientIvcProof(
120
+ export async function executeBbChonkProof(
124
121
  pathToBB: string,
125
122
  workingDirectory: string,
126
123
  inputsPath: string,
@@ -153,7 +150,7 @@ export async function executeBbClientIvcProof(
153
150
  log(`bb - ${message}`);
154
151
  };
155
152
 
156
- const args = ['-o', outputPath, '--ivc_inputs_path', inputsPath, '-v', '--scheme', 'client_ivc'];
153
+ const args = ['-o', outputPath, '--ivc_inputs_path', inputsPath, '-v', '--scheme', 'chonk'];
157
154
  if (writeVk) {
158
155
  args.push('--write_vk');
159
156
  }
@@ -424,7 +421,7 @@ export async function verifyAvmProof(
424
421
  }
425
422
 
426
423
  /**
427
- * Verifies a ClientIvcProof
424
+ * Verifies a ChonkProof
428
425
  * TODO(#7370) The verification keys should be supplied separately
429
426
  * @param pathToBB - The full path to the bb binary
430
427
  * @param targetPath - The path to the folder with the proof, accumulator, and verification keys
@@ -432,7 +429,7 @@ export async function verifyAvmProof(
432
429
  * @param concurrency - The number of threads to use for the verification
433
430
  * @returns An object containing a result indication and duration taken
434
431
  */
435
- export async function verifyClientIvcProof(
432
+ export async function verifyChonkProof(
436
433
  pathToBB: string,
437
434
  proofPath: string,
438
435
  keyPath: string,
@@ -448,7 +445,7 @@ export async function verifyClientIvcProof(
448
445
  }
449
446
 
450
447
  try {
451
- const args = ['--scheme', 'client_ivc', '-p', proofPath, '-k', keyPath, '-v'];
448
+ const args = ['--scheme', 'chonk', '-p', proofPath, '-k', keyPath, '-v'];
452
449
  const timer = new Timer();
453
450
  const command = 'verify';
454
451
 
@@ -638,7 +635,7 @@ export async function computeGateCountForCircuit(
638
635
  const result = await executeBB(
639
636
  pathToBB,
640
637
  'gates',
641
- ['--scheme', flavor === 'mega_honk' ? 'client_ivc' : 'ultra_honk', '-b', bytecodePath, '-v'],
638
+ ['--scheme', flavor === 'mega_honk' ? 'chonk' : 'ultra_honk', '-b', bytecodePath, '-v'],
642
639
  logHandler,
643
640
  );
644
641
  const duration = timer.ms();
@@ -1,4 +1,7 @@
1
+ import { AztecClientBackend, Barretenberg } from '@aztec/bb.js';
1
2
  import { createLogger } from '@aztec/foundation/log';
3
+ import { Timer } from '@aztec/foundation/timer';
4
+ import { serializeWitness } from '@aztec/noir-noirc_abi';
2
5
  import {
3
6
  convertHidingKernelPublicInputsToWitnessMapWithAbi,
4
7
  convertHidingKernelToRollupInputsToWitnessMapWithAbi,
@@ -37,9 +40,11 @@ import type {
37
40
  PrivateKernelTailCircuitPublicInputs,
38
41
  } from '@aztec/stdlib/kernel';
39
42
  import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
40
- import type { ClientIvcProofWithPublicInputs } from '@aztec/stdlib/proofs';
43
+ import { ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
41
44
  import type { CircuitSimulationStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
42
45
 
46
+ import { ungzip } from 'pako';
47
+
43
48
  export abstract class BBPrivateKernelProver implements PrivateKernelProver {
44
49
  constructor(
45
50
  protected artifactProvider: ArtifactProvider,
@@ -263,11 +268,30 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
263
268
  return kernelProofOutput;
264
269
  }
265
270
 
266
- public createClientIvcProof(_executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProofWithPublicInputs> {
267
- throw new Error('Not implemented');
271
+ public async createChonkProof(executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs> {
272
+ const timer = new Timer();
273
+ this.log.info(`Generating ClientIVC proof...`);
274
+ const backend = new AztecClientBackend(
275
+ executionSteps.map(step => ungzip(step.bytecode)),
276
+ await Barretenberg.initSingleton(),
277
+ );
278
+
279
+ const [proof] = await backend.prove(
280
+ executionSteps.map(step => ungzip(serializeWitness(step.witness))),
281
+ executionSteps.map(step => step.vk),
282
+ );
283
+ this.log.info(`Generated ClientIVC proof`, {
284
+ eventName: 'client-ivc-proof-generation',
285
+ duration: timer.ms(),
286
+ proofSize: proof.length,
287
+ });
288
+ return ChonkProofWithPublicInputs.fromBufferArray(proof);
268
289
  }
269
290
 
270
- public computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
271
- throw new Error('Not implemented');
291
+ public async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
292
+ // Note we do not pass the vk to the backend. This is unneeded for gate counts.
293
+ const backend = new AztecClientBackend([ungzip(_bytecode)], await Barretenberg.initSingleton());
294
+ const gateCount = await backend.gates();
295
+ return gateCount[0];
272
296
  }
273
297
  }
@@ -0,0 +1,11 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
3
+ import type { CircuitSimulator } from '@aztec/simulator/client';
4
+
5
+ import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
6
+
7
+ export class BBBundlePrivateKernelProver extends BBPrivateKernelProver {
8
+ constructor(simulator: CircuitSimulator, log = createLogger('bb-prover:bundle')) {
9
+ super(new BundleArtifactProvider(), simulator, log);
10
+ }
11
+ }
@@ -0,0 +1,11 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
3
+ import type { CircuitSimulator } from '@aztec/simulator/client';
4
+
5
+ import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
6
+
7
+ export class BBLazyPrivateKernelProver extends BBPrivateKernelProver {
8
+ constructor(simulator: CircuitSimulator, log = createLogger('bb-prover:lazy')) {
9
+ super(new LazyArtifactProvider(), simulator, log);
10
+ }
11
+ }
@@ -1,5 +1,5 @@
1
1
  import {
2
- CIVC_PROOF_LENGTH,
2
+ CHONK_PROOF_LENGTH,
3
3
  HIDING_KERNEL_IO_PUBLIC_INPUTS_SIZE,
4
4
  IPA_CLAIM_SIZE,
5
5
  NESTED_RECURSIVE_PROOF_LENGTH,
@@ -7,9 +7,9 @@ import {
7
7
  PAIRING_POINTS_SIZE,
8
8
  ULTRA_KECCAK_PROOF_LENGTH,
9
9
  } from '@aztec/constants';
10
- import { Fr } from '@aztec/foundation/fields';
10
+ import { Fr } from '@aztec/foundation/curves/bn254';
11
11
  import type { Logger } from '@aztec/foundation/log';
12
- import { ClientIvcProofWithPublicInputs, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
12
+ import { ChonkProofWithPublicInputs, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
13
13
  import type { VerificationKeyData } from '@aztec/stdlib/vks';
14
14
 
15
15
  import assert from 'assert';
@@ -19,33 +19,33 @@ import * as path from 'path';
19
19
  import { PROOF_FILENAME, PUBLIC_INPUTS_FILENAME } from '../bb/execute.js';
20
20
 
21
21
  /**
22
- * Create a ClientIvcProof proof file.
22
+ * Create a ChonkProof proof file.
23
23
  *
24
24
  * @param directory the directory to read the proof from.
25
- * @returns the encapsulated client ivc proof
25
+ * @returns the encapsulated chonk proof
26
26
  */
27
- export async function readClientIVCProofFromOutputDirectory(directory: string) {
27
+ export async function readChonkProofFromOutputDirectory(directory: string) {
28
28
  const proofFilename = path.join(directory, PROOF_FILENAME);
29
29
  const binaryProof = await fs.readFile(proofFilename);
30
30
  const proofFields = splitBufferIntoFields(binaryProof);
31
- return new ClientIvcProofWithPublicInputs(proofFields);
31
+ return new ChonkProofWithPublicInputs(proofFields);
32
32
  }
33
33
 
34
34
  /**
35
- * Serialize a ClientIvcProof to a proof file.
35
+ * Serialize a ChonkProof to a proof file.
36
36
  *
37
- * @param proof the ClientIvcProof from object
37
+ * @param proof the ChonkProof from object
38
38
  * @param directory the directory to write in
39
39
  */
40
- export async function writeClientIVCProofToPath(clientIvcProof: ClientIvcProofWithPublicInputs, outputPath: string) {
41
- // NB: Don't use clientIvcProof.toBuffer here because it will include the proof length.
42
- const fieldsBuf = Buffer.concat(clientIvcProof.fieldsWithPublicInputs.map(field => field.toBuffer()));
40
+ export async function writeChonkProofToPath(chonkProof: ChonkProofWithPublicInputs, outputPath: string) {
41
+ // NB: Don't use chonkProof.toBuffer here because it will include the proof length.
42
+ const fieldsBuf = Buffer.concat(chonkProof.fieldsWithPublicInputs.map(field => field.toBuffer()));
43
43
  await fs.writeFile(outputPath, fieldsBuf);
44
44
  }
45
45
 
46
46
  function getNumCustomPublicInputs(proofLength: number, vkData: VerificationKeyData) {
47
47
  let numPublicInputs = vkData.numPublicInputs;
48
- if (proofLength == CIVC_PROOF_LENGTH) {
48
+ if (proofLength == CHONK_PROOF_LENGTH) {
49
49
  numPublicInputs -= HIDING_KERNEL_IO_PUBLIC_INPUTS_SIZE;
50
50
  } else {
51
51
  numPublicInputs -= PAIRING_POINTS_SIZE;
@@ -71,7 +71,7 @@ export async function readProofsFromOutputDirectory<PROOF_LENGTH extends number>
71
71
  logger: Logger,
72
72
  ): Promise<RecursiveProof<PROOF_LENGTH>> {
73
73
  assert(
74
- proofLength == CIVC_PROOF_LENGTH ||
74
+ proofLength == CHONK_PROOF_LENGTH ||
75
75
  proofLength == NESTED_RECURSIVE_PROOF_LENGTH ||
76
76
  proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH ||
77
77
  proofLength == ULTRA_KECCAK_PROOF_LENGTH,
@@ -81,17 +81,17 @@ export async function readProofsFromOutputDirectory<PROOF_LENGTH extends number>
81
81
  const publicInputsFilename = path.join(directory, PUBLIC_INPUTS_FILENAME);
82
82
  const proofFilename = path.join(directory, PROOF_FILENAME);
83
83
 
84
- // Handle CIVC separately because bb outputs the proof fields with public inputs for CIVC.
85
- const isCIVC = proofLength == CIVC_PROOF_LENGTH;
84
+ // Handle CHONK separately because bb outputs the proof fields with public inputs for CHONK.
85
+ const isChonk = proofLength == CHONK_PROOF_LENGTH;
86
86
 
87
87
  const [binaryPublicInputs, binaryProof] = await Promise.all([
88
- isCIVC ? Buffer.alloc(0) : fs.readFile(publicInputsFilename),
88
+ isChonk ? Buffer.alloc(0) : fs.readFile(publicInputsFilename),
89
89
  fs.readFile(proofFilename),
90
90
  ]);
91
91
 
92
92
  const numPublicInputs = getNumCustomPublicInputs(proofLength, vkData);
93
93
  let fieldsWithoutPublicInputs = splitBufferIntoFields(binaryProof);
94
- if (isCIVC) {
94
+ if (isChonk) {
95
95
  fieldsWithoutPublicInputs = fieldsWithoutPublicInputs.slice(numPublicInputs);
96
96
  }
97
97
 
@@ -6,7 +6,7 @@ import {
6
6
  RECURSIVE_PROOF_LENGTH,
7
7
  ULTRA_KECCAK_PROOF_LENGTH,
8
8
  } from '@aztec/constants';
9
- import { Fr } from '@aztec/foundation/fields';
9
+ import { Fr } from '@aztec/foundation/curves/bn254';
10
10
  import { runInDirectory } from '@aztec/foundation/fs';
11
11
  import { createLogger } from '@aztec/foundation/log';
12
12
  import { BufferReader } from '@aztec/foundation/serialize';
@@ -38,8 +38,8 @@ import {
38
38
  convertParityRootPrivateInputsToWitnessMap,
39
39
  convertPrivateTxBaseRollupOutputsFromWitnessMap,
40
40
  convertPrivateTxBaseRollupPrivateInputsToWitnessMap,
41
- convertPublicTubeOutputsFromWitnessMap,
42
- convertPublicTubePrivateInputsToWitnessMap,
41
+ convertPublicChonkVerifierOutputsFromWitnessMap,
42
+ convertPublicChonkVerifierPrivateInputsToWitnessMap,
43
43
  convertPublicTxBaseRollupOutputsFromWitnessMap,
44
44
  convertPublicTxBaseRollupPrivateInputsToWitnessMap,
45
45
  convertRootRollupOutputsFromWitnessMap,
@@ -77,8 +77,8 @@ import {
77
77
  CheckpointRootRollupPrivateInputs,
78
78
  CheckpointRootSingleBlockRollupPrivateInputs,
79
79
  type PrivateTxBaseRollupPrivateInputs,
80
- PublicTubePrivateInputs,
81
- PublicTubePublicInputs,
80
+ PublicChonkVerifierPrivateInputs,
81
+ PublicChonkVerifierPublicInputs,
82
82
  PublicTxBaseRollupPrivateInputs,
83
83
  type RootRollupPrivateInputs,
84
84
  type RootRollupPublicInputs,
@@ -202,17 +202,19 @@ export class BBNativeRollupProver implements ServerCircuitProver {
202
202
  return proofAndVk;
203
203
  }
204
204
 
205
- public async getPublicTubeProof(
206
- inputs: PublicTubePrivateInputs,
207
- ): Promise<PublicInputsAndRecursiveProof<PublicTubePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
208
- const artifactName = 'PublicTube';
205
+ public async getPublicChonkVerifierProof(
206
+ inputs: PublicChonkVerifierPrivateInputs,
207
+ ): Promise<
208
+ PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
209
+ > {
210
+ const artifactName = 'PublicChonkVerifier';
209
211
 
210
212
  const { circuitOutput, proof } = await this.createRecursiveProof(
211
213
  inputs,
212
214
  artifactName,
213
215
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
214
- convertPublicTubePrivateInputsToWitnessMap,
215
- convertPublicTubeOutputsFromWitnessMap,
216
+ convertPublicChonkVerifierPrivateInputsToWitnessMap,
217
+ convertPublicChonkVerifierOutputsFromWitnessMap,
216
218
  );
217
219
 
218
220
  const verificationKey = this.getVerificationKeyDataForCircuit(artifactName);
@@ -585,7 +587,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
585
587
  convertInput: (input: CircuitInputType) => WitnessMap,
586
588
  convertOutput: (outputWitness: WitnessMap) => CircuitOutputType,
587
589
  ): Promise<{ circuitOutput: CircuitOutputType; proof: RecursiveProof<PROOF_LENGTH> }> {
588
- // this probably is gonna need to call client ivc
590
+ // this probably is gonna need to call chonk
589
591
  const operation = async (bbWorkingDirectory: string) => {
590
592
  const { provingResult, circuitOutput: output } = await this.generateProofWithBB(
591
593
  input,
@@ -1,43 +1,43 @@
1
1
  import { ProvingRequestType } from '@aztec/stdlib/proofs';
2
2
 
3
3
  export const WITGEN_DELAY_MS: Record<ProvingRequestType, number> = {
4
- [ProvingRequestType.PARITY_BASE]: 60,
5
- [ProvingRequestType.BLOCK_MERGE_ROLLUP]: 650,
6
- [ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: 60_000,
7
- [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: 40_000,
8
- [ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: 20_000,
4
+ [ProvingRequestType.PARITY_BASE]: 2_000,
5
+ [ProvingRequestType.BLOCK_MERGE_ROLLUP]: 30,
6
+ [ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: 45,
7
+ [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: 27,
8
+ [ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: 18,
9
9
  [ProvingRequestType.BLOCK_ROOT_ROLLUP]: 40_000,
10
10
  [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP]: 20_000,
11
11
  [ProvingRequestType.CHECKPOINT_ROOT_ROLLUP]: 40_000,
12
- [ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: 20_000,
12
+ [ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: 36_600,
13
13
  [ProvingRequestType.CHECKPOINT_PADDING_ROLLUP]: 0,
14
- [ProvingRequestType.CHECKPOINT_MERGE_ROLLUP]: 650,
14
+ [ProvingRequestType.CHECKPOINT_MERGE_ROLLUP]: 30,
15
15
  [ProvingRequestType.TX_MERGE_ROLLUP]: 0,
16
- [ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 400_000,
17
- [ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: 470_000,
18
- [ProvingRequestType.PARITY_ROOT]: 100,
19
- [ProvingRequestType.ROOT_ROLLUP]: 650,
20
- [ProvingRequestType.PUBLIC_TUBE]: 0,
16
+ [ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 2_500, // Guess based on public
17
+ [ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: 2_500,
18
+ [ProvingRequestType.PARITY_ROOT]: 40,
19
+ [ProvingRequestType.ROOT_ROLLUP]: 35,
20
+ [ProvingRequestType.PUBLIC_CHONK_VERIFIER]: 60,
21
21
  [ProvingRequestType.PUBLIC_VM]: 0,
22
22
  };
23
23
 
24
24
  export const PROOF_DELAY_MS: Record<ProvingRequestType, number> = {
25
- [ProvingRequestType.PARITY_BASE]: 3_000,
25
+ [ProvingRequestType.PARITY_BASE]: 16_300,
26
26
  [ProvingRequestType.BLOCK_MERGE_ROLLUP]: 15_000,
27
- [ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: 55_000,
28
- [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: 35_000,
29
- [ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: 15_000,
27
+ [ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: 16_500,
28
+ [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: 9_210,
29
+ [ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: 4_560,
30
30
  [ProvingRequestType.BLOCK_ROOT_ROLLUP]: 35_000,
31
31
  [ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP]: 15_000,
32
32
  [ProvingRequestType.CHECKPOINT_ROOT_ROLLUP]: 35_000,
33
- [ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: 15_000,
33
+ [ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: 38_800,
34
34
  [ProvingRequestType.CHECKPOINT_PADDING_ROLLUP]: 0,
35
- [ProvingRequestType.CHECKPOINT_MERGE_ROLLUP]: 15_000,
35
+ [ProvingRequestType.CHECKPOINT_MERGE_ROLLUP]: 9_760,
36
36
  [ProvingRequestType.TX_MERGE_ROLLUP]: 0,
37
- [ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 145_000,
38
- [ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: 160_000,
39
- [ProvingRequestType.PARITY_ROOT]: 30_000,
40
- [ProvingRequestType.ROOT_ROLLUP]: 15_000,
41
- [ProvingRequestType.PUBLIC_TUBE]: 30_000,
37
+ [ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 45_000, // Guess based on public
38
+ [ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: 45_000,
39
+ [ProvingRequestType.PARITY_ROOT]: 18_600,
40
+ [ProvingRequestType.ROOT_ROLLUP]: 84_000,
41
+ [ProvingRequestType.PUBLIC_CHONK_VERIFIER]: 16_300,
42
42
  [ProvingRequestType.PUBLIC_VM]: 0,
43
43
  };
@@ -73,8 +73,8 @@ import {
73
73
  type CheckpointRootRollupPrivateInputs,
74
74
  type CheckpointRootSingleBlockRollupPrivateInputs,
75
75
  type PrivateTxBaseRollupPrivateInputs,
76
- type PublicTubePrivateInputs,
77
- PublicTubePublicInputs,
76
+ type PublicChonkVerifierPrivateInputs,
77
+ PublicChonkVerifierPublicInputs,
78
78
  type PublicTxBaseRollupPrivateInputs,
79
79
  type RootRollupPrivateInputs,
80
80
  type RootRollupPublicInputs,
@@ -158,14 +158,16 @@ export class TestCircuitProver implements ServerCircuitProver {
158
158
  );
159
159
  }
160
160
 
161
- public getPublicTubeProof(
162
- inputs: PublicTubePrivateInputs,
163
- ): Promise<PublicInputsAndRecursiveProof<PublicTubePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
164
- return this.applyDelay(ProvingRequestType.PUBLIC_TUBE, () =>
161
+ public getPublicChonkVerifierProof(
162
+ inputs: PublicChonkVerifierPrivateInputs,
163
+ ): Promise<
164
+ PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
165
+ > {
166
+ return this.applyDelay(ProvingRequestType.PUBLIC_CHONK_VERIFIER, () =>
165
167
  makePublicInputsAndRecursiveProof(
166
- new PublicTubePublicInputs(inputs.hidingKernelProofData.publicInputs, inputs.proverId),
168
+ new PublicChonkVerifierPublicInputs(inputs.hidingKernelProofData.publicInputs, inputs.proverId),
167
169
  makeEmptyRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH),
168
- ProtocolCircuitVks.PublicTube,
170
+ ProtocolCircuitVks.PublicChonkVerifier,
169
171
  ),
170
172
  );
171
173
  }
@@ -2,7 +2,15 @@ import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '
2
2
  import type { Tx } from '@aztec/stdlib/tx';
3
3
 
4
4
  export class TestCircuitVerifier implements ClientProtocolCircuitVerifier {
5
+ constructor(private verificationDelayMs?: number) {}
5
6
  verifyProof(_tx: Tx): Promise<IVCProofVerificationResult> {
7
+ if (this.verificationDelayMs !== undefined && this.verificationDelayMs > 0) {
8
+ return new Promise(resolve => {
9
+ setTimeout(() => {
10
+ resolve({ valid: true, durationMs: this.verificationDelayMs!, totalDurationMs: this.verificationDelayMs! });
11
+ }, this.verificationDelayMs);
12
+ });
13
+ }
6
14
  return Promise.resolve({ valid: true, durationMs: 0, totalDurationMs: 0 });
7
15
  }
8
16
 
@@ -1,5 +1,5 @@
1
1
  import { AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { BufferReader } from '@aztec/foundation/serialize';
4
4
  import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
5
5
 
@@ -22,12 +22,12 @@ import {
22
22
  PROOF_FILENAME,
23
23
  PUBLIC_INPUTS_FILENAME,
24
24
  VK_FILENAME,
25
- verifyClientIvcProof,
25
+ verifyChonkProof,
26
26
  verifyProof,
27
27
  } from '../bb/execute.js';
28
28
  import type { BBConfig } from '../config.js';
29
29
  import { getUltraHonkFlavorForCircuit } from '../honk.js';
30
- import { writeClientIVCProofToPath } from '../prover/proof_utils.js';
30
+ import { writeChonkProofToPath } from '../prover/proof_utils.js';
31
31
 
32
32
  export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
33
33
  private constructor(
@@ -40,6 +40,9 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
40
40
  }
41
41
 
42
42
  public static async new(config: BBConfig, logger = createLogger('bb-prover:verifier')) {
43
+ if (!config.bbWorkingDirectory) {
44
+ throw new Error(`Barretenberg working directory (BB_WORKING_DIRECTORY) is not set`);
45
+ }
43
46
  await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
44
47
  return new BBCircuitVerifier(config, logger);
45
48
  }
@@ -90,7 +93,7 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
90
93
  }
91
94
 
92
95
  public async verifyProof(tx: Tx): Promise<IVCProofVerificationResult> {
93
- const proofType = 'ClientIVC';
96
+ const proofType = 'Chonk';
94
97
  try {
95
98
  const totalTimer = new Timer();
96
99
  let verificationDuration = 0;
@@ -104,17 +107,14 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
104
107
  };
105
108
 
106
109
  const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
107
- await writeClientIVCProofToPath(
108
- tx.clientIvcProof.attachPublicInputs(tx.data.publicInputs().toFields()),
109
- proofPath,
110
- );
110
+ await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
111
111
 
112
112
  const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
113
113
  const verificationKey = this.getVerificationKeyData(circuit);
114
114
  await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
115
115
 
116
116
  const timer = new Timer();
117
- const result = await verifyClientIvcProof(
117
+ const result = await verifyChonkProof(
118
118
  this.config.bbBinaryPath,
119
119
  proofPath,
120
120
  verificationKeyPath,
@@ -132,7 +132,7 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
132
132
  circuitName: mapProtocolArtifactNameToCircuitName(circuit),
133
133
  duration: result.durationMs,
134
134
  eventName: 'circuit-verification',
135
- proofType: 'client-ivc',
135
+ proofType: 'chonk',
136
136
  } satisfies CircuitVerificationStats);
137
137
  };
138
138
  await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
@@ -1,2 +1,2 @@
1
1
  export * from './bb_verifier.js';
2
- export * from './queued_ivc_verifier.js';
2
+ export * from './queued_chonk_verifier.js';
@@ -38,13 +38,13 @@ class IVCVerifierMetrics {
38
38
 
39
39
  this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME, {
40
40
  unit: 'ms',
41
- description: 'Duration to verify client IVC proofs',
41
+ description: 'Duration to verify chonk proofs',
42
42
  valueType: ValueType.INT,
43
43
  });
44
44
 
45
45
  this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
46
46
  unit: 'ms',
47
- description: 'Total duration to verify client IVC proofs, including serde',
47
+ description: 'Total duration to verify chonk proofs, including serde',
48
48
  valueType: ValueType.INT,
49
49
  });
50
50
 
@@ -120,7 +120,7 @@ export class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
120
120
  config: BBConfig,
121
121
  private verifier: ClientProtocolCircuitVerifier,
122
122
  private telemetry: TelemetryClient = getTelemetryClient(),
123
- private logger = createLogger('bb-prover:queued_ivc_verifier'),
123
+ private logger = createLogger('bb-prover:queued_chonk_verifier'),
124
124
  ) {
125
125
  this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
126
126
  this.queue = new SerialQueue();
@@ -1,23 +0,0 @@
1
- import { type Logger } from '@aztec/foundation/log';
2
- import type { CircuitSimulator } from '@aztec/simulator/server';
3
- import { type PrivateExecutionStep } from '@aztec/stdlib/kernel';
4
- import type { ClientIvcProofWithPublicInputs } from '@aztec/stdlib/proofs';
5
- import type { BBConfig } from '../../../config.js';
6
- import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
7
- /**
8
- * This proof creator implementation uses the native bb binary.
9
- */
10
- export declare class BBNativePrivateKernelProver extends BBPrivateKernelProver {
11
- private bbBinaryPath;
12
- private bbWorkingDirectory;
13
- private skipCleanup;
14
- protected simulator: CircuitSimulator;
15
- protected log: Logger;
16
- private constructor();
17
- static new(config: BBConfig, simulator: CircuitSimulator, log?: Logger): Promise<BBNativePrivateKernelProver>;
18
- private _createClientIvcProof;
19
- createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProofWithPublicInputs>;
20
- computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number>;
21
- private runInDirectory;
22
- }
23
- //# sourceMappingURL=bb_native_private_kernel_prover.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bb_native_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/native/bb_native_private_kernel_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,KAAK,oBAAoB,EAAkC,MAAM,sBAAsB,CAAC;AACjG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAM3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,qBAAqB;IAElE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,WAAW;cACA,SAAS,EAAE,gBAAgB;cAC3B,GAAG;IALxB,OAAO;WAUa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,MAAM;YAWrE,qBAAqB;IAuBb,oBAAoB,CACxC,cAAc,EAAE,oBAAoB,EAAE,GACrC,OAAO,CAAC,8BAA8B,CAAC;IAQpB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxG,OAAO,CAAC,cAAc;CAavB"}
@@ -1,66 +0,0 @@
1
- import { runInDirectory } from '@aztec/foundation/fs';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
4
- import { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
5
- import { promises as fs } from 'fs';
6
- import path from 'path';
7
- import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../../../bb/execute.js';
8
- import { readClientIVCProofFromOutputDirectory } from '../../proof_utils.js';
9
- import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
10
- /**
11
- * This proof creator implementation uses the native bb binary.
12
- */ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
13
- bbBinaryPath;
14
- bbWorkingDirectory;
15
- skipCleanup;
16
- simulator;
17
- log;
18
- constructor(bbBinaryPath, bbWorkingDirectory, skipCleanup, simulator, log = createLogger('bb-prover:native')){
19
- super(new BundleArtifactProvider(), simulator, log), this.bbBinaryPath = bbBinaryPath, this.bbWorkingDirectory = bbWorkingDirectory, this.skipCleanup = skipCleanup, this.simulator = simulator, this.log = log;
20
- }
21
- static async new(config, simulator, log) {
22
- await fs.mkdir(config.bbWorkingDirectory, {
23
- recursive: true
24
- });
25
- return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, simulator, log);
26
- }
27
- async _createClientIvcProof(directory, executionSteps) {
28
- const inputsPath = path.join(directory, 'ivc-inputs.msgpack');
29
- await fs.writeFile(inputsPath, serializePrivateExecutionSteps(executionSteps));
30
- const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, inputsPath, this.log.info);
31
- if (provingResult.status === BB_RESULT.FAILURE) {
32
- this.log.error(`Failed to generate client ivc proof`);
33
- throw new Error(provingResult.reason);
34
- }
35
- const proof = await readClientIVCProofFromOutputDirectory(directory);
36
- this.log.info(`Generated IVC proof`, {
37
- duration: provingResult.durationMs,
38
- eventName: 'circuit-proving'
39
- });
40
- return proof;
41
- }
42
- async createClientIvcProof(executionSteps) {
43
- this.log.info(`Generating Client IVC proof`);
44
- const operation = async (directory)=>{
45
- return await this._createClientIvcProof(directory, executionSteps);
46
- };
47
- return await this.runInDirectory(operation);
48
- }
49
- async computeGateCountForCircuit(bytecode, circuitName) {
50
- const logFunction = (message)=>{
51
- this.log.debug(`$bb gates ${circuitName} - ${message}`);
52
- };
53
- const result = await computeGateCountForCircuit(this.bbBinaryPath, this.bbWorkingDirectory, circuitName, bytecode, 'mega_honk', logFunction);
54
- if (result.status === BB_RESULT.FAILURE) {
55
- throw new Error(result.reason);
56
- }
57
- return result.circuitSize;
58
- }
59
- runInDirectory(fn) {
60
- const log = this.log;
61
- return runInDirectory(this.bbWorkingDirectory, (dir)=>fn(dir).catch((err)=>{
62
- log.error(`Error running operation at ${dir}: ${err}`);
63
- throw err;
64
- }), this.skipCleanup, this.log);
65
- }
66
- }