@aztec/bb-prover 0.76.4 → 0.77.0-testnet-ignition.21

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 +8 -8
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
  3. package/dest/avm_proving_tests/avm_proving_tester.js +24 -25
  4. package/dest/bb/cli.d.ts +3 -3
  5. package/dest/bb/cli.d.ts.map +1 -1
  6. package/dest/bb/cli.js +4 -9
  7. package/dest/bb/execute.d.ts +7 -37
  8. package/dest/bb/execute.d.ts.map +1 -1
  9. package/dest/bb/execute.js +359 -357
  10. package/dest/bb/index.js +4 -6
  11. package/dest/config.js +1 -2
  12. package/dest/honk.d.ts +1 -1
  13. package/dest/honk.d.ts.map +1 -1
  14. package/dest/honk.js +8 -5
  15. package/dest/index.d.ts +1 -1
  16. package/dest/index.d.ts.map +1 -1
  17. package/dest/index.js +0 -1
  18. package/dest/instrumentation.d.ts +2 -2
  19. package/dest/instrumentation.d.ts.map +1 -1
  20. package/dest/instrumentation.js +50 -47
  21. package/dest/prover/bb_native_private_kernel_prover.d.ts +4 -4
  22. package/dest/prover/bb_native_private_kernel_prover.d.ts.map +1 -1
  23. package/dest/prover/bb_native_private_kernel_prover.js +19 -19
  24. package/dest/prover/bb_private_kernel_prover.d.ts +7 -6
  25. package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
  26. package/dest/prover/bb_private_kernel_prover.js +14 -15
  27. package/dest/prover/bb_prover.d.ts +7 -10
  28. package/dest/prover/bb_prover.d.ts.map +1 -1
  29. package/dest/prover/bb_prover.js +402 -447
  30. package/dest/prover/client_ivc_proof_utils.d.ts +3 -3
  31. package/dest/prover/client_ivc_proof_utils.d.ts.map +1 -1
  32. package/dest/prover/client_ivc_proof_utils.js +18 -12
  33. package/dest/prover/index.js +0 -1
  34. package/dest/stats.d.ts +2 -2
  35. package/dest/stats.d.ts.map +1 -1
  36. package/dest/stats.js +15 -14
  37. package/dest/test/delay_values.d.ts +4 -0
  38. package/dest/test/delay_values.d.ts.map +1 -0
  39. package/dest/test/delay_values.js +29 -0
  40. package/dest/test/index.js +0 -1
  41. package/dest/test/test_circuit_prover.d.ts +16 -7
  42. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  43. package/dest/test/test_circuit_prover.js +165 -161
  44. package/dest/test/test_verifier.d.ts +2 -1
  45. package/dest/test/test_verifier.d.ts.map +1 -1
  46. package/dest/test/test_verifier.js +0 -1
  47. package/dest/verification_key/verification_key_data.d.ts +1 -1
  48. package/dest/verification_key/verification_key_data.d.ts.map +1 -1
  49. package/dest/verification_key/verification_key_data.js +13 -9
  50. package/dest/verifier/bb_verifier.d.ts +6 -4
  51. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  52. package/dest/verifier/bb_verifier.js +18 -18
  53. package/dest/verifier/index.js +0 -1
  54. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +5 -4
  55. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -1
  56. package/dest/wasm/bb_wasm_private_kernel_prover.js +26 -11
  57. package/dest/wasm/bundle.d.ts +1 -1
  58. package/dest/wasm/bundle.d.ts.map +1 -1
  59. package/dest/wasm/bundle.js +1 -2
  60. package/dest/wasm/lazy.d.ts +1 -1
  61. package/dest/wasm/lazy.d.ts.map +1 -1
  62. package/dest/wasm/lazy.js +1 -2
  63. package/package.json +18 -19
  64. package/src/avm_proving_tests/avm_proving_tester.ts +17 -33
  65. package/src/bb/cli.ts +3 -3
  66. package/src/bb/execute.ts +80 -211
  67. package/src/honk.ts +1 -1
  68. package/src/index.ts +1 -1
  69. package/src/instrumentation.ts +10 -10
  70. package/src/prover/bb_native_private_kernel_prover.ts +5 -4
  71. package/src/prover/bb_private_kernel_prover.ts +20 -20
  72. package/src/prover/bb_prover.ts +33 -100
  73. package/src/prover/client_ivc_proof_utils.ts +3 -3
  74. package/src/stats.ts +2 -2
  75. package/src/test/delay_values.ts +31 -0
  76. package/src/test/test_circuit_prover.ts +149 -120
  77. package/src/test/test_verifier.ts +2 -1
  78. package/src/verification_key/verification_key_data.ts +4 -7
  79. package/src/verifier/bb_verifier.ts +16 -9
  80. package/src/wasm/bb_wasm_private_kernel_prover.ts +18 -5
  81. package/src/wasm/bundle.ts +1 -1
  82. package/src/wasm/lazy.ts +1 -1
package/src/bb/execute.ts CHANGED
@@ -1,19 +1,20 @@
1
- import { type AvmCircuitInputs, serializeWithMessagePack } from '@aztec/circuits.js';
2
1
  import { sha256 } from '@aztec/foundation/crypto';
3
- import { type LogFn, type Logger } from '@aztec/foundation/log';
2
+ import type { LogFn, Logger } from '@aztec/foundation/log';
4
3
  import { Timer } from '@aztec/foundation/timer';
4
+ import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
5
5
 
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
9
 
10
- import { type UltraHonkFlavor } from '../honk.js';
10
+ import type { UltraHonkFlavor } from '../honk.js';
11
11
  import { CLIENT_IVC_PROOF_FILE_NAME, CLIENT_IVC_VK_FILE_NAME } from '../prover/client_ivc_proof_utils.js';
12
12
 
13
13
  export const VK_FILENAME = 'vk';
14
14
  export const VK_FIELDS_FILENAME = 'vk_fields.json';
15
15
  export const PROOF_FILENAME = 'proof';
16
16
  export const PROOF_FIELDS_FILENAME = 'proof_fields.json';
17
+ export const AVM_INPUTS_FILENAME = 'avm_inputs.bin';
17
18
  export const AVM_BYTECODE_FILENAME = 'avm_bytecode.bin';
18
19
  export const AVM_PUBLIC_INPUTS_FILENAME = 'avm_public_inputs.bin';
19
20
  export const AVM_HINTS_FILENAME = 'avm_hints.bin';
@@ -139,6 +140,7 @@ export async function executeBbClientIvcProof(
139
140
  'client_ivc',
140
141
  '--input_type',
141
142
  'runtime_stack',
143
+ '--write_vk',
142
144
  ];
143
145
 
144
146
  const timer = new Timer();
@@ -169,83 +171,17 @@ export async function executeBbClientIvcProof(
169
171
  }
170
172
  }
171
173
 
172
- /**
173
- * Used for generating verification keys of noir circuits.
174
- * It is assumed that the working directory is a temporary and/or random directory used solely for generating this VK.
175
- * @param pathToBB - The full path to the bb binary
176
- * @param workingDirectory - A working directory for use by bb
177
- * @param circuitName - An identifier for the circuit
178
- * @param bytecode - The compiled circuit bytecode
179
- * @param inputWitnessFile - The circuit input witness
180
- * @param log - A logging function
181
- * @returns An object containing a result indication, the location of the VK and the duration taken
182
- */
183
- export async function computeVerificationKey(
184
- pathToBB: string,
185
- workingDirectory: string,
186
- circuitName: string,
187
- bytecode: Buffer,
188
- recursive: boolean,
189
- flavor: UltraHonkFlavor | 'mega_honk',
190
- log: LogFn,
191
- ): Promise<BBFailure | BBSuccess> {
192
- // Check that the working directory exists
193
- try {
194
- await fs.access(workingDirectory);
195
- } catch (error) {
196
- return { status: BB_RESULT.FAILURE, reason: `Working directory ${workingDirectory} does not exist` };
197
- }
198
-
199
- // The bytecode is written to e.g. /workingDirectory/BaseParityArtifact-bytecode
200
- const bytecodePath = `${workingDirectory}/${circuitName}-bytecode`;
201
-
202
- // The verification key is written to this path
203
- const outputPath = `${workingDirectory}/vk`;
204
-
205
- const binaryPresent = await fs
206
- .access(pathToBB, fs.constants.R_OK)
207
- .then(_ => true)
208
- .catch(_ => false);
209
- if (!binaryPresent) {
210
- return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
211
- }
212
-
213
- try {
214
- // Write the bytecode to the working directory
215
- await fs.writeFile(bytecodePath, bytecode);
216
- const timer = new Timer();
217
- const logFunction = (message: string) => {
218
- log(`computeVerificationKey(${circuitName}) BB out - ${message}`);
219
- };
220
- const args = ['-o', outputPath, '-b', bytecodePath, '-v', recursive ? '--recursive' : ''];
221
- let result = await executeBB(pathToBB, `write_vk_${flavor}`, args, logFunction);
222
- if (result.status == BB_RESULT.FAILURE) {
223
- return { status: BB_RESULT.FAILURE, reason: 'Failed writing VK.' };
174
+ function getArgs(flavor: UltraHonkFlavor) {
175
+ switch (flavor) {
176
+ case 'ultra_honk': {
177
+ return ['--scheme', 'ultra_honk', '--oracle_hash', 'poseidon2'];
224
178
  }
225
- result = await executeBB(
226
- pathToBB,
227
- `vk_as_fields_${flavor}`,
228
- ['-o', outputPath + '_fields.json', '-k', outputPath, '-v'],
229
- logFunction,
230
- );
231
- const duration = timer.ms();
232
-
233
- if (result.status == BB_RESULT.SUCCESS) {
234
- return {
235
- status: BB_RESULT.SUCCESS,
236
- durationMs: duration,
237
- pkPath: undefined,
238
- vkPath: `${outputPath}`,
239
- };
179
+ case 'ultra_keccak_honk': {
180
+ return ['--scheme', 'ultra_honk', '--oracle_hash', 'keccak'];
181
+ }
182
+ case 'ultra_rollup_honk': {
183
+ return ['--scheme', 'ultra_honk', '--oracle_hash', 'poseidon2', '--ipa_accumulation'];
240
184
  }
241
- // Not a great error message here but it is difficult to decipher what comes from bb
242
- return {
243
- status: BB_RESULT.FAILURE,
244
- reason: `Failed to write VK. Exit code ${result.exitCode}. Signal ${result.signal}.`,
245
- retry: !!result.signal,
246
- };
247
- } catch (error) {
248
- return { status: BB_RESULT.FAILURE, reason: `${error}` };
249
185
  }
250
186
  }
251
187
 
@@ -294,12 +230,26 @@ export async function generateProof(
294
230
  try {
295
231
  // Write the bytecode to the working directory
296
232
  await fs.writeFile(bytecodePath, bytecode);
297
- const args = ['-o', outputPath, '-b', bytecodePath, '-w', inputWitnessFile, '-v', recursive ? '--recursive' : ''];
233
+ const args = getArgs(flavor).concat([
234
+ '--output_format',
235
+ 'bytes_and_fields',
236
+ '--write_vk',
237
+ '-o',
238
+ outputPath,
239
+ '-b',
240
+ bytecodePath,
241
+ '-w',
242
+ inputWitnessFile,
243
+ '-v',
244
+ ]);
245
+ if (recursive) {
246
+ args.push('--init_kzg_accumulator');
247
+ }
298
248
  const timer = new Timer();
299
249
  const logFunction = (message: string) => {
300
250
  log(`${circuitName} BB out - ${message}`);
301
251
  };
302
- const result = await executeBB(pathToBB, `prove_${flavor}_output_all`, args, logFunction);
252
+ const result = await executeBB(pathToBB, `prove`, args, logFunction);
303
253
  const duration = timer.ms();
304
254
 
305
255
  if (result.status == BB_RESULT.SUCCESS) {
@@ -431,23 +381,22 @@ export async function generateAvmProofV2(
431
381
  return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
432
382
  }
433
383
 
434
- const inputsBuffer = input.serializeForAvm2();
384
+ const inputsBuffer = input.serializeWithMessagePack();
435
385
 
436
386
  try {
437
387
  // Write the inputs to the working directory.
438
- const avmInputsPath = join(workingDirectory, 'avm_inputs.bin');
388
+ const avmInputsPath = join(workingDirectory, AVM_INPUTS_FILENAME);
439
389
  await fs.writeFile(avmInputsPath, inputsBuffer);
440
390
  if (!(await filePresent(avmInputsPath))) {
441
391
  return { status: BB_RESULT.FAILURE, reason: `Could not write avm inputs to ${avmInputsPath}` };
442
392
  }
443
393
 
444
- const args = [
445
- '--avm-inputs',
446
- avmInputsPath,
447
- '-o',
448
- outputPath,
449
- logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '',
450
- ];
394
+ const args = ['--avm-inputs', avmInputsPath, '-o', outputPath];
395
+ const loggingArg =
396
+ logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
397
+ if (loggingArg !== '') {
398
+ args.push(loggingArg);
399
+ }
451
400
  const timer = new Timer();
452
401
  const logFunction = (message: string) => {
453
402
  logger.verbose(`AvmCircuit (prove) BB out - ${message}`);
@@ -487,7 +436,7 @@ export async function generateAvmProofV2(
487
436
  export async function generateAvmProof(
488
437
  pathToBB: string,
489
438
  workingDirectory: string,
490
- input: AvmCircuitInputs,
439
+ _input: AvmCircuitInputs,
491
440
  logger: Logger,
492
441
  checkCircuitOnly: boolean = false,
493
442
  ): Promise<BBFailure | BBSuccess> {
@@ -519,26 +468,24 @@ export async function generateAvmProof(
519
468
  try {
520
469
  // Write the inputs to the working directory.
521
470
 
522
- await fs.writeFile(publicInputsPath, input.publicInputs.toBuffer());
523
- if (!(await filePresent(publicInputsPath))) {
524
- return { status: BB_RESULT.FAILURE, reason: `Could not write publicInputs at ${publicInputsPath}` };
525
- }
526
-
527
- await fs.writeFile(avmHintsPath, input.avmHints.toBuffer());
528
- if (!(await filePresent(avmHintsPath))) {
529
- return { status: BB_RESULT.FAILURE, reason: `Could not write avmHints at ${avmHintsPath}` };
471
+ // WARNING: Not writing the inputs since VM1 is disabled!
472
+ // await fs.writeFile(publicInputsPath, input.publicInputs.toBuffer());
473
+ // if (!(await filePresent(publicInputsPath))) {
474
+ // return { status: BB_RESULT.FAILURE, reason: `Could not write publicInputs at ${publicInputsPath}` };
475
+ // }
476
+
477
+ // await fs.writeFile(avmHintsPath, input.avmHints.toBuffer());
478
+ // if (!(await filePresent(avmHintsPath))) {
479
+ // return { status: BB_RESULT.FAILURE, reason: `Could not write avmHints at ${avmHintsPath}` };
480
+ // }
481
+
482
+ const args = ['--avm-public-inputs', publicInputsPath, '--avm-hints', avmHintsPath, '-o', outputPath];
483
+ const loggingArg =
484
+ logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
485
+ if (loggingArg !== '') {
486
+ args.push(loggingArg);
530
487
  }
531
488
 
532
- const args = [
533
- '--avm-public-inputs',
534
- publicInputsPath,
535
- '--avm-hints',
536
- avmHintsPath,
537
- '-o',
538
- outputPath,
539
- logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '',
540
- checkCircuitOnly ? '--check-circuit-only' : '',
541
- ];
542
489
  const timer = new Timer();
543
490
  const cmd = checkCircuitOnly ? 'check_circuit' : 'prove';
544
491
  const logFunction = (message: string) => {
@@ -582,7 +529,14 @@ export async function verifyProof(
582
529
  ultraHonkFlavor: UltraHonkFlavor,
583
530
  log: Logger,
584
531
  ): Promise<BBFailure | BBSuccess> {
585
- return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, `verify_${ultraHonkFlavor}`, log);
532
+ return await verifyProofInternal(
533
+ pathToBB,
534
+ proofFullPath,
535
+ verificationKeyPath,
536
+ `verify`,
537
+ log,
538
+ getArgs(ultraHonkFlavor),
539
+ );
586
540
  }
587
541
 
588
542
  /**
@@ -606,11 +560,11 @@ export async function verifyAvmProofV2(
606
560
  pathToBB: string,
607
561
  workingDirectory: string,
608
562
  proofFullPath: string,
609
- publicInputs: any,
563
+ publicInputs: AvmCircuitPublicInputs,
610
564
  verificationKeyPath: string,
611
565
  logger: Logger,
612
566
  ): Promise<BBFailure | BBSuccess> {
613
- const inputsBuffer = serializeWithMessagePack(publicInputs);
567
+ const inputsBuffer = publicInputs.serializeWithMessagePack();
614
568
 
615
569
  // Write the inputs to the working directory.
616
570
  const filePresent = async (file: string) =>
@@ -640,7 +594,8 @@ export async function verifyAvmProofV2(
640
594
  */
641
595
  export async function verifyClientIvcProof(
642
596
  pathToBB: string,
643
- targetPath: string,
597
+ proofPath: string,
598
+ keyPath: string,
644
599
  log: LogFn,
645
600
  ): Promise<BBFailure | BBSuccess> {
646
601
  const binaryPresent = await fs
@@ -652,7 +607,7 @@ export async function verifyClientIvcProof(
652
607
  }
653
608
 
654
609
  try {
655
- const args = ['-o', targetPath, '--scheme', 'client_ivc'];
610
+ const args = ['--scheme', 'client_ivc', '-p', proofPath, '-k', keyPath];
656
611
  const timer = new Timer();
657
612
  const command = 'verify';
658
613
  const result = await executeBB(pathToBB, command, args, log);
@@ -684,7 +639,7 @@ async function verifyProofInternal(
684
639
  pathToBB: string,
685
640
  proofFullPath: string,
686
641
  verificationKeyPath: string,
687
- command: 'verify_ultra_honk' | 'verify_ultra_rollup_honk' | 'verify_ultra_keccak_honk' | 'avm_verify' | 'avm2_verify',
642
+ command: 'verify' | 'avm_verify' | 'avm2_verify',
688
643
  logger: Logger,
689
644
  extraArgs: string[] = [],
690
645
  ): Promise<BBFailure | BBSuccess> {
@@ -697,18 +652,16 @@ async function verifyProofInternal(
697
652
  }
698
653
 
699
654
  const logFunction = (message: string) => {
700
- logger.verbose(`AvmCircuit (verify) BB out - ${message}`);
655
+ logger.verbose(`bb-prover (verify) BB out - ${message}`);
701
656
  };
702
657
 
703
658
  try {
704
- const args = [
705
- '-p',
706
- proofFullPath,
707
- '-k',
708
- verificationKeyPath,
709
- logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '',
710
- ...extraArgs,
711
- ];
659
+ const args = ['-p', proofFullPath, '-k', verificationKeyPath, ...extraArgs];
660
+ const loggingArg =
661
+ logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
662
+ if (loggingArg !== '') {
663
+ args.push(loggingArg);
664
+ }
712
665
  const timer = new Timer();
713
666
  const result = await executeBB(pathToBB, command, args, logFunction);
714
667
  const duration = timer.ms();
@@ -726,90 +679,6 @@ async function verifyProofInternal(
726
679
  }
727
680
  }
728
681
 
729
- /**
730
- * Used for verifying proofs of noir circuits
731
- * @param pathToBB - The full path to the bb binary
732
- * @param verificationKeyPath - The directory containing the binary verification key
733
- * @param verificationKeyFilename - The filename of the verification key
734
- * @param log - A logging function
735
- * @returns An object containing a result indication and duration taken
736
- */
737
- export async function writeVkAsFields(
738
- pathToBB: string,
739
- verificationKeyPath: string,
740
- verificationKeyFilename: string,
741
- log: LogFn,
742
- ): Promise<BBFailure | BBSuccess> {
743
- const binaryPresent = await fs
744
- .access(pathToBB, fs.constants.R_OK)
745
- .then(_ => true)
746
- .catch(_ => false);
747
- if (!binaryPresent) {
748
- return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
749
- }
750
-
751
- try {
752
- const args = ['-k', `${verificationKeyPath}/${verificationKeyFilename}`, '-v'];
753
- const timer = new Timer();
754
- const result = await executeBB(pathToBB, 'vk_as_fields_ultra_honk', args, log);
755
- const duration = timer.ms();
756
- if (result.status == BB_RESULT.SUCCESS) {
757
- return { status: BB_RESULT.SUCCESS, durationMs: duration, vkPath: verificationKeyPath };
758
- }
759
- // Not a great error message here but it is difficult to decipher what comes from bb
760
- return {
761
- status: BB_RESULT.FAILURE,
762
- reason: `Failed to create vk as fields. Exit code ${result.exitCode}. Signal ${result.signal}.`,
763
- retry: !!result.signal,
764
- };
765
- } catch (error) {
766
- return { status: BB_RESULT.FAILURE, reason: `${error}` };
767
- }
768
- }
769
-
770
- /**
771
- * Used for verifying proofs of noir circuits
772
- * @param pathToBB - The full path to the bb binary
773
- * @param proofPath - The directory containing the binary proof
774
- * @param proofFileName - The filename of the proof
775
- * @param vkFileName - The filename of the verification key
776
- * @param log - A logging function
777
- * @returns An object containing a result indication and duration taken
778
- */
779
- export async function writeProofAsFields(
780
- pathToBB: string,
781
- proofPath: string,
782
- proofFileName: string,
783
- vkFilePath: string,
784
- log: LogFn,
785
- ): Promise<BBFailure | BBSuccess> {
786
- const binaryPresent = await fs
787
- .access(pathToBB, fs.constants.R_OK)
788
- .then(_ => true)
789
- .catch(_ => false);
790
- if (!binaryPresent) {
791
- return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
792
- }
793
-
794
- try {
795
- const args = ['-p', `${proofPath}/${proofFileName}`, '-k', vkFilePath, '-v'];
796
- const timer = new Timer();
797
- const result = await executeBB(pathToBB, 'proof_as_fields_honk', args, log);
798
- const duration = timer.ms();
799
- if (result.status == BB_RESULT.SUCCESS) {
800
- return { status: BB_RESULT.SUCCESS, durationMs: duration, proofPath: proofPath };
801
- }
802
- // Not a great error message here but it is difficult to decipher what comes from bb
803
- return {
804
- status: BB_RESULT.FAILURE,
805
- reason: `Failed to create proof as fields. Exit code ${result.exitCode}. Signal ${result.signal}.`,
806
- retry: !!result.signal,
807
- };
808
- } catch (error) {
809
- return { status: BB_RESULT.FAILURE, reason: `${error}` };
810
- }
811
- }
812
-
813
682
  export async function generateContractForVerificationKey(
814
683
  pathToBB: string,
815
684
  vkFilePath: string,
@@ -834,9 +703,9 @@ export async function generateContractForVerificationKey(
834
703
 
835
704
  const res = await fsCache<BBSuccess | BBFailure>(outputDir, cacheKey, log, false, async () => {
836
705
  try {
837
- const args = ['-k', vkFilePath, '-o', contractPath, '-v'];
706
+ const args = ['--scheme', 'ultra_honk', '-k', vkFilePath, '-o', contractPath, '-v'];
838
707
  const timer = new Timer();
839
- const result = await executeBB(pathToBB, 'contract_ultra_honk', args, log);
708
+ const result = await executeBB(pathToBB, 'contract', args, log);
840
709
  const duration = timer.ms();
841
710
  if (result.status == BB_RESULT.SUCCESS) {
842
711
  return { status: BB_RESULT.SUCCESS, durationMs: duration, contractPath };
@@ -912,8 +781,8 @@ export async function computeGateCountForCircuit(
912
781
 
913
782
  const result = await executeBB(
914
783
  pathToBB,
915
- flavor === 'mega_honk' ? `gates_for_ivc` : `gates`,
916
- ['-b', bytecodePath, '-v'],
784
+ 'gates',
785
+ ['--scheme', flavor === 'mega_honk' ? 'client_ivc' : 'ultra_honk', '-b', bytecodePath, '-v'],
917
786
  logHandler,
918
787
  );
919
788
  const duration = timer.ms();
package/src/honk.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
1
+ import type { ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
2
2
 
3
3
  export type UltraHonkFlavor = 'ultra_honk' | 'ultra_keccak_honk' | 'ultra_rollup_honk';
4
4
 
package/src/index.ts CHANGED
@@ -5,4 +5,4 @@ export * from './config.js';
5
5
  export * from './bb/execute.js';
6
6
  export * from './honk.js';
7
7
 
8
- export { type ClientProtocolCircuitVerifier } from '@aztec/circuit-types';
8
+ export { type ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
@@ -1,5 +1,5 @@
1
- import { type CircuitName } from '@aztec/circuit-types/stats';
2
- import { type Timer } from '@aztec/foundation/timer';
1
+ import type { Timer } from '@aztec/foundation/timer';
2
+ import type { CircuitName } from '@aztec/stdlib/stats';
3
3
  import {
4
4
  Attributes,
5
5
  type Gauge,
@@ -39,14 +39,14 @@ export class ProverInstrumentation {
39
39
 
40
40
  this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION, {
41
41
  description: 'Records how long it takes to generate the partial witness for a circuit',
42
- unit: 'ms',
43
- valueType: ValueType.INT,
42
+ unit: 's',
43
+ valueType: ValueType.DOUBLE,
44
44
  });
45
45
 
46
46
  this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION, {
47
- unit: 'ms',
47
+ unit: 's',
48
48
  description: 'Records how long it takes to prove a circuit',
49
- valueType: ValueType.INT,
49
+ valueType: ValueType.DOUBLE,
50
50
  });
51
51
 
52
52
  this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE, {
@@ -89,8 +89,8 @@ export class ProverInstrumentation {
89
89
  circuitName: CircuitName | 'tubeCircuit',
90
90
  timerOrMS: Timer | number,
91
91
  ) {
92
- const ms = typeof timerOrMS === 'number' ? timerOrMS : timerOrMS.ms();
93
- this[metric].record(Math.ceil(ms), {
92
+ const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
93
+ this[metric].record(s, {
94
94
  [Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
95
95
  [Attributes.PROTOCOL_CIRCUIT_TYPE]: 'server',
96
96
  });
@@ -103,8 +103,8 @@ export class ProverInstrumentation {
103
103
  * @param timerOrMS - The duration
104
104
  */
105
105
  recordAvmDuration(metric: 'witGenDuration' | 'provingDuration', appCircuitName: string, timerOrMS: Timer | number) {
106
- const ms = typeof timerOrMS === 'number' ? timerOrMS : timerOrMS.s();
107
- this[metric].record(Math.ceil(ms), {
106
+ const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
107
+ this[metric].record(s, {
108
108
  [Attributes.APP_CIRCUIT_NAME]: appCircuitName,
109
109
  });
110
110
  }
@@ -1,17 +1,17 @@
1
- import { type ClientIvcProof } from '@aztec/circuits.js';
2
1
  import { runInDirectory } from '@aztec/foundation/fs';
3
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
4
3
  import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
5
- import { type SimulationProvider } from '@aztec/simulator/server';
4
+ import type { SimulationProvider } from '@aztec/simulator/server';
5
+ import type { ClientIvcProof } from '@aztec/stdlib/proofs';
6
6
 
7
7
  import { encode } from '@msgpack/msgpack';
8
8
  import { serializeWitness } from '@noir-lang/noirc_abi';
9
- import { type WitnessMap } from '@noir-lang/types';
9
+ import type { WitnessMap } from '@noir-lang/types';
10
10
  import { promises as fs } from 'fs';
11
11
  import path from 'path';
12
12
 
13
13
  import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../bb/execute.js';
14
- import { type BBConfig } from '../config.js';
14
+ import type { BBConfig } from '../config.js';
15
15
  import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
16
16
  import { readFromOutputDirectory } from './client_ivc_proof_utils.js';
17
17
 
@@ -113,6 +113,7 @@ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
113
113
  throw err;
114
114
  }),
115
115
  this.skipCleanup,
116
+ this.log,
116
117
  );
117
118
  }
118
119
  }
@@ -1,14 +1,3 @@
1
- import { type PrivateKernelProver, type PrivateKernelSimulateOutput } from '@aztec/circuit-types';
2
- import { type CircuitSimulationStats, type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
3
- import {
4
- type ClientIvcProof,
5
- type PrivateKernelCircuitPublicInputs,
6
- type PrivateKernelInitCircuitPrivateInputs,
7
- type PrivateKernelInnerCircuitPrivateInputs,
8
- type PrivateKernelResetCircuitPrivateInputs,
9
- type PrivateKernelTailCircuitPrivateInputs,
10
- type PrivateKernelTailCircuitPublicInputs,
11
- } from '@aztec/circuits.js';
12
1
  import { createLogger } from '@aztec/foundation/log';
13
2
  import { Timer } from '@aztec/foundation/timer';
14
3
  import {
@@ -25,12 +14,23 @@ import {
25
14
  getPrivateKernelResetArtifactName,
26
15
  updateResetCircuitSampleInputs,
27
16
  } from '@aztec/noir-protocol-circuits-types/client';
28
- import { type ArtifactProvider, type ClientProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
29
- import { ClientCircuitVks } from '@aztec/noir-protocol-circuits-types/vks';
30
- import { type SimulationProvider } from '@aztec/simulator/client';
31
- import { type NoirCompiledCircuit } from '@aztec/types/noir';
32
-
33
- import { type Abi, type WitnessMap } from '@noir-lang/types';
17
+ import type { ArtifactProvider, ClientProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
18
+ import type { SimulationProvider } from '@aztec/simulator/client';
19
+ import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
20
+ import type {
21
+ PrivateKernelCircuitPublicInputs,
22
+ PrivateKernelInitCircuitPrivateInputs,
23
+ PrivateKernelInnerCircuitPrivateInputs,
24
+ PrivateKernelResetCircuitPrivateInputs,
25
+ PrivateKernelSimulateOutput,
26
+ PrivateKernelTailCircuitPrivateInputs,
27
+ PrivateKernelTailCircuitPublicInputs,
28
+ } from '@aztec/stdlib/kernel';
29
+ import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
30
+ import type { ClientIvcProof } from '@aztec/stdlib/proofs';
31
+ import type { CircuitSimulationStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
32
+
33
+ import type { Abi, WitnessMap } from '@noir-lang/types';
34
34
 
35
35
  import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
36
36
 
@@ -215,7 +215,7 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
215
215
  outputSize: output.toBuffer().length,
216
216
  } satisfies CircuitWitnessGenerationStats);
217
217
 
218
- const verificationKey = ClientCircuitVks[circuitType].keyAsFields;
218
+ const verificationKey = (await this.artifactProvider.getCircuitVkByName(circuitType)).keyAsFields;
219
219
  const bytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
220
220
 
221
221
  const kernelOutput: PrivateKernelSimulateOutput<O> = {
@@ -227,12 +227,12 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
227
227
  return kernelOutput;
228
228
  }
229
229
 
230
- public makeEmptyKernelSimulateOutput<
230
+ public async makeEmptyKernelSimulateOutput<
231
231
  PublicInputsType extends PrivateKernelTailCircuitPublicInputs | PrivateKernelCircuitPublicInputs,
232
232
  >(publicInputs: PublicInputsType, circuitType: ClientProtocolArtifact) {
233
233
  const kernelProofOutput: PrivateKernelSimulateOutput<PublicInputsType> = {
234
234
  publicInputs,
235
- verificationKey: ClientCircuitVks[circuitType].keyAsFields,
235
+ verificationKey: (await this.artifactProvider.getCircuitVkByName(circuitType)).keyAsFields,
236
236
  outputWitness: new Map(),
237
237
  bytecode: Buffer.from([]),
238
238
  };