@aztec/bb-prover 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

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 (84) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +16 -10
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
  3. package/dest/avm_proving_tests/avm_proving_tester.js +182 -111
  4. package/dest/bb/bb_js_backend.d.ts +196 -0
  5. package/dest/bb/bb_js_backend.d.ts.map +1 -0
  6. package/dest/bb/bb_js_backend.js +379 -0
  7. package/dest/bb/bb_js_debug.d.ts +52 -0
  8. package/dest/bb/bb_js_debug.d.ts.map +1 -0
  9. package/dest/bb/bb_js_debug.js +176 -0
  10. package/dest/bb/file_names.d.ts +4 -0
  11. package/dest/bb/file_names.d.ts.map +1 -0
  12. package/dest/bb/file_names.js +5 -0
  13. package/dest/config.d.ts +17 -1
  14. package/dest/config.d.ts.map +1 -1
  15. package/dest/index.d.ts +3 -2
  16. package/dest/index.d.ts.map +1 -1
  17. package/dest/index.js +2 -1
  18. package/dest/instrumentation.d.ts +1 -1
  19. package/dest/instrumentation.d.ts.map +1 -1
  20. package/dest/instrumentation.js +21 -43
  21. package/dest/prover/client/bb_private_kernel_prover.d.ts +29 -7
  22. package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
  23. package/dest/prover/client/bb_private_kernel_prover.js +90 -16
  24. package/dest/prover/client/bundle.d.ts +3 -3
  25. package/dest/prover/client/bundle.d.ts.map +1 -1
  26. package/dest/prover/client/bundle.js +2 -3
  27. package/dest/prover/client/lazy.d.ts +3 -3
  28. package/dest/prover/client/lazy.d.ts.map +1 -1
  29. package/dest/prover/client/lazy.js +2 -3
  30. package/dest/prover/proof_utils.d.ts +11 -1
  31. package/dest/prover/proof_utils.d.ts.map +1 -1
  32. package/dest/prover/proof_utils.js +25 -2
  33. package/dest/prover/server/bb_prover.d.ts +9 -13
  34. package/dest/prover/server/bb_prover.d.ts.map +1 -1
  35. package/dest/prover/server/bb_prover.js +613 -113
  36. package/dest/test/delay_values.d.ts +1 -1
  37. package/dest/test/delay_values.d.ts.map +1 -1
  38. package/dest/test/delay_values.js +28 -26
  39. package/dest/test/index.d.ts +2 -1
  40. package/dest/test/index.d.ts.map +1 -1
  41. package/dest/test/index.js +1 -0
  42. package/dest/test/test_circuit_prover.d.ts +5 -5
  43. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  44. package/dest/test/test_circuit_prover.js +462 -59
  45. package/dest/verification_key/verification_key_data.d.ts +1 -8
  46. package/dest/verification_key/verification_key_data.d.ts.map +1 -1
  47. package/dest/verification_key/verification_key_data.js +2 -21
  48. package/dest/verifier/batch_chonk_verifier.d.ts +56 -0
  49. package/dest/verifier/batch_chonk_verifier.d.ts.map +1 -0
  50. package/dest/verifier/batch_chonk_verifier.js +384 -0
  51. package/dest/verifier/bb_verifier.d.ts +4 -1
  52. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  53. package/dest/verifier/bb_verifier.js +134 -48
  54. package/dest/verifier/index.d.ts +2 -1
  55. package/dest/verifier/index.d.ts.map +1 -1
  56. package/dest/verifier/index.js +1 -0
  57. package/dest/verifier/queued_chonk_verifier.d.ts +2 -3
  58. package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -1
  59. package/dest/verifier/queued_chonk_verifier.js +15 -45
  60. package/package.json +20 -18
  61. package/src/avm_proving_tests/avm_proving_tester.ts +91 -142
  62. package/src/bb/bb_js_backend.ts +435 -0
  63. package/src/bb/bb_js_debug.ts +227 -0
  64. package/src/bb/file_names.ts +6 -0
  65. package/src/config.ts +16 -0
  66. package/src/index.ts +2 -1
  67. package/src/instrumentation.ts +20 -43
  68. package/src/prover/client/bb_private_kernel_prover.ts +259 -25
  69. package/src/prover/client/bundle.ts +3 -4
  70. package/src/prover/client/lazy.ts +3 -4
  71. package/src/prover/proof_utils.ts +42 -2
  72. package/src/prover/server/bb_prover.ts +132 -162
  73. package/src/test/delay_values.ts +30 -26
  74. package/src/test/index.ts +1 -0
  75. package/src/test/test_circuit_prover.ts +11 -16
  76. package/src/verification_key/verification_key_data.ts +2 -27
  77. package/src/verifier/batch_chonk_verifier.ts +415 -0
  78. package/src/verifier/bb_verifier.ts +66 -80
  79. package/src/verifier/index.ts +1 -0
  80. package/src/verifier/queued_chonk_verifier.ts +15 -47
  81. package/dest/bb/execute.d.ts +0 -107
  82. package/dest/bb/execute.d.ts.map +0 -1
  83. package/dest/bb/execute.js +0 -676
  84. package/src/bb/execute.ts +0 -706
package/src/index.ts CHANGED
@@ -2,7 +2,8 @@ export * from './prover/index.js';
2
2
  export * from './test/index.js';
3
3
  export * from './verifier/index.js';
4
4
  export * from './config.js';
5
- export * from './bb/execute.js';
5
+ export * from './bb/file_names.js';
6
+ export * from './bb/bb_js_backend.js';
6
7
  export * from './honk.js';
7
8
  export * from './verification_key/verification_key_data.js';
8
9
 
@@ -7,7 +7,6 @@ import {
7
7
  Metrics,
8
8
  type TelemetryClient,
9
9
  type Tracer,
10
- ValueType,
11
10
  } from '@aztec/telemetry-client';
12
11
 
13
12
  /**
@@ -31,51 +30,21 @@ export class ProverInstrumentation {
31
30
  this.tracer = telemetry.getTracer(name);
32
31
  const meter = telemetry.getMeter(name);
33
32
 
34
- this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION, {
35
- description: 'Records how long it takes to simulate a circuit',
36
- unit: 'ms',
37
- valueType: ValueType.INT,
38
- });
33
+ this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION);
39
34
 
40
- this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION, {
41
- description: 'Records how long it takes to generate the partial witness for a circuit',
42
- unit: 's',
43
- valueType: ValueType.DOUBLE,
44
- });
35
+ this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION);
45
36
 
46
- this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION, {
47
- unit: 's',
48
- description: 'Records how long it takes to prove a circuit',
49
- valueType: ValueType.DOUBLE,
50
- });
37
+ this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION);
51
38
 
52
- this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE, {
53
- unit: 'By',
54
- description: 'Records the size of the input to the witness generation',
55
- valueType: ValueType.INT,
56
- });
39
+ this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE);
57
40
 
58
- this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE, {
59
- unit: 'By',
60
- description: 'Records the size of the output of the witness generation',
61
- valueType: ValueType.INT,
62
- });
41
+ this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE);
63
42
 
64
- this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE, {
65
- unit: 'By',
66
- description: 'Records the size of the proof generated for a circuit',
67
- valueType: ValueType.INT,
68
- });
43
+ this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE);
69
44
 
70
- this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT, {
71
- description: 'Records the number of public inputs in a circuit',
72
- valueType: ValueType.INT,
73
- });
45
+ this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT);
74
46
 
75
- this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE, {
76
- description: 'Records the size of the circuit in gates',
77
- valueType: ValueType.INT,
78
- });
47
+ this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE);
79
48
  }
80
49
 
81
50
  /**
@@ -89,10 +58,18 @@ export class ProverInstrumentation {
89
58
  circuitName: CircuitName,
90
59
  timerOrMS: Timer | number,
91
60
  ) {
92
- const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
93
- this[metric].record(s, {
94
- [Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
95
- });
61
+ // Simulation duration is stored in ms, while the others are stored in seconds
62
+ if (metric === 'simulationDuration') {
63
+ const ms = typeof timerOrMS === 'number' ? timerOrMS : timerOrMS.ms();
64
+ this[metric].record(Math.trunc(ms), {
65
+ [Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
66
+ });
67
+ } else {
68
+ const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
69
+ this[metric].record(s, {
70
+ [Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
71
+ });
72
+ }
96
73
  }
97
74
 
98
75
  /**
@@ -1,22 +1,39 @@
1
- import { AztecClientBackend, Barretenberg } from '@aztec/bb.js';
2
- import { createLogger } from '@aztec/foundation/log';
1
+ import { AztecClientBackend, type BackendOptions, Barretenberg } from '@aztec/bb.js';
2
+ import { type LogLevel, type Logger, createLogger } from '@aztec/foundation/log';
3
3
  import { Timer } from '@aztec/foundation/timer';
4
4
  import { serializeWitness } from '@aztec/noir-noirc_abi';
5
5
  import {
6
6
  convertHidingKernelPublicInputsToWitnessMapWithAbi,
7
7
  convertHidingKernelToRollupInputsToWitnessMapWithAbi,
8
+ convertPrivateKernelInit2InputsToWitnessMapWithAbi,
9
+ convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
10
+ convertPrivateKernelInit3InputsToWitnessMapWithAbi,
11
+ convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
12
+ convertPrivateKernelInit4InputsToWitnessMapWithAbi,
13
+ convertPrivateKernelInit4OutputsFromWitnessMapWithAbi,
14
+ convertPrivateKernelInit5InputsToWitnessMapWithAbi,
15
+ convertPrivateKernelInit5OutputsFromWitnessMapWithAbi,
8
16
  convertPrivateKernelInitInputsToWitnessMapWithAbi,
9
17
  convertPrivateKernelInitOutputsFromWitnessMapWithAbi,
18
+ convertPrivateKernelInner2InputsToWitnessMapWithAbi,
19
+ convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
20
+ convertPrivateKernelInner3InputsToWitnessMapWithAbi,
21
+ convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
22
+ convertPrivateKernelInner4InputsToWitnessMapWithAbi,
23
+ convertPrivateKernelInner4OutputsFromWitnessMapWithAbi,
24
+ convertPrivateKernelInner5InputsToWitnessMapWithAbi,
25
+ convertPrivateKernelInner5OutputsFromWitnessMapWithAbi,
10
26
  convertPrivateKernelInnerInputsToWitnessMapWithAbi,
11
27
  convertPrivateKernelInnerOutputsFromWitnessMapWithAbi,
12
28
  convertPrivateKernelResetInputsToWitnessMapWithAbi,
13
29
  convertPrivateKernelResetOutputsFromWitnessMapWithAbi,
30
+ convertPrivateKernelResetTailInputsToWitnessMapWithAbi,
31
+ convertPrivateKernelResetTailToPublicInputsToWitnessMapWithAbi,
14
32
  convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
15
- convertPrivateKernelTailInputsToWitnessMapWithAbi,
16
33
  convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
17
- convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi,
18
34
  foreignCallHandler,
19
35
  getPrivateKernelResetArtifactName,
36
+ getPrivateKernelResetTailArtifactName,
20
37
  updateResetCircuitSampleInputs,
21
38
  } from '@aztec/noir-protocol-circuits-types/client';
22
39
  import {
@@ -32,11 +49,19 @@ import type {
32
49
  HidingKernelToRollupPrivateInputs,
33
50
  PrivateExecutionStep,
34
51
  PrivateKernelCircuitPublicInputs,
52
+ PrivateKernelInit2CircuitPrivateInputs,
53
+ PrivateKernelInit3CircuitPrivateInputs,
54
+ PrivateKernelInit4CircuitPrivateInputs,
55
+ PrivateKernelInit5CircuitPrivateInputs,
35
56
  PrivateKernelInitCircuitPrivateInputs,
57
+ PrivateKernelInner2CircuitPrivateInputs,
58
+ PrivateKernelInner3CircuitPrivateInputs,
59
+ PrivateKernelInner4CircuitPrivateInputs,
60
+ PrivateKernelInner5CircuitPrivateInputs,
36
61
  PrivateKernelInnerCircuitPrivateInputs,
37
62
  PrivateKernelResetCircuitPrivateInputs,
63
+ PrivateKernelResetTailCircuitPrivateInputs,
38
64
  PrivateKernelSimulateOutput,
39
- PrivateKernelTailCircuitPrivateInputs,
40
65
  PrivateKernelTailCircuitPublicInputs,
41
66
  } from '@aztec/stdlib/kernel';
42
67
  import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
@@ -45,12 +70,17 @@ import type { CircuitSimulationStats, CircuitWitnessGenerationStats } from '@azt
45
70
 
46
71
  import { ungzip } from 'pako';
47
72
 
73
+ export type BBPrivateKernelProverOptions = Omit<BackendOptions, 'logger'> & { logger?: Logger };
48
74
  export abstract class BBPrivateKernelProver implements PrivateKernelProver {
75
+ private log: Logger;
76
+
49
77
  constructor(
50
78
  protected artifactProvider: ArtifactProvider,
51
79
  protected simulator: CircuitSimulator,
52
- protected log = createLogger('bb-prover'),
53
- ) {}
80
+ protected options: BBPrivateKernelProverOptions = {},
81
+ ) {
82
+ this.log = options.logger || createLogger('bb-prover:private-kernel');
83
+ }
54
84
 
55
85
  public async generateInitOutput(
56
86
  inputs: PrivateKernelInitCircuitPrivateInputs,
@@ -74,6 +104,94 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
74
104
  );
75
105
  }
76
106
 
107
+ public async generateInit2Output(
108
+ inputs: PrivateKernelInit2CircuitPrivateInputs,
109
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
110
+ return await this.generateCircuitOutput(
111
+ inputs,
112
+ 'PrivateKernelInit2Artifact',
113
+ convertPrivateKernelInit2InputsToWitnessMapWithAbi,
114
+ convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
115
+ );
116
+ }
117
+
118
+ public async simulateInit2(
119
+ inputs: PrivateKernelInit2CircuitPrivateInputs,
120
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
121
+ return await this.simulateCircuitOutput(
122
+ inputs,
123
+ 'PrivateKernelInit2Artifact',
124
+ convertPrivateKernelInit2InputsToWitnessMapWithAbi,
125
+ convertPrivateKernelInit2OutputsFromWitnessMapWithAbi,
126
+ );
127
+ }
128
+
129
+ public async generateInit3Output(
130
+ inputs: PrivateKernelInit3CircuitPrivateInputs,
131
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
132
+ return await this.generateCircuitOutput(
133
+ inputs,
134
+ 'PrivateKernelInit3Artifact',
135
+ convertPrivateKernelInit3InputsToWitnessMapWithAbi,
136
+ convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
137
+ );
138
+ }
139
+
140
+ public async simulateInit3(
141
+ inputs: PrivateKernelInit3CircuitPrivateInputs,
142
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
143
+ return await this.simulateCircuitOutput(
144
+ inputs,
145
+ 'PrivateKernelInit3Artifact',
146
+ convertPrivateKernelInit3InputsToWitnessMapWithAbi,
147
+ convertPrivateKernelInit3OutputsFromWitnessMapWithAbi,
148
+ );
149
+ }
150
+
151
+ public async generateInit4Output(
152
+ inputs: PrivateKernelInit4CircuitPrivateInputs,
153
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
154
+ return await this.generateCircuitOutput(
155
+ inputs,
156
+ 'PrivateKernelInit4Artifact',
157
+ convertPrivateKernelInit4InputsToWitnessMapWithAbi,
158
+ convertPrivateKernelInit4OutputsFromWitnessMapWithAbi,
159
+ );
160
+ }
161
+
162
+ public async simulateInit4(
163
+ inputs: PrivateKernelInit4CircuitPrivateInputs,
164
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
165
+ return await this.simulateCircuitOutput(
166
+ inputs,
167
+ 'PrivateKernelInit4Artifact',
168
+ convertPrivateKernelInit4InputsToWitnessMapWithAbi,
169
+ convertPrivateKernelInit4OutputsFromWitnessMapWithAbi,
170
+ );
171
+ }
172
+
173
+ public async generateInit5Output(
174
+ inputs: PrivateKernelInit5CircuitPrivateInputs,
175
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
176
+ return await this.generateCircuitOutput(
177
+ inputs,
178
+ 'PrivateKernelInit5Artifact',
179
+ convertPrivateKernelInit5InputsToWitnessMapWithAbi,
180
+ convertPrivateKernelInit5OutputsFromWitnessMapWithAbi,
181
+ );
182
+ }
183
+
184
+ public async simulateInit5(
185
+ inputs: PrivateKernelInit5CircuitPrivateInputs,
186
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
187
+ return await this.simulateCircuitOutput(
188
+ inputs,
189
+ 'PrivateKernelInit5Artifact',
190
+ convertPrivateKernelInit5InputsToWitnessMapWithAbi,
191
+ convertPrivateKernelInit5OutputsFromWitnessMapWithAbi,
192
+ );
193
+ }
194
+
77
195
  public async generateInnerOutput(
78
196
  inputs: PrivateKernelInnerCircuitPrivateInputs,
79
197
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
@@ -96,6 +214,94 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
96
214
  );
97
215
  }
98
216
 
217
+ public async generateInner2Output(
218
+ inputs: PrivateKernelInner2CircuitPrivateInputs,
219
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
220
+ return await this.generateCircuitOutput(
221
+ inputs,
222
+ 'PrivateKernelInner2Artifact',
223
+ convertPrivateKernelInner2InputsToWitnessMapWithAbi,
224
+ convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
225
+ );
226
+ }
227
+
228
+ public async simulateInner2(
229
+ inputs: PrivateKernelInner2CircuitPrivateInputs,
230
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
231
+ return await this.simulateCircuitOutput(
232
+ inputs,
233
+ 'PrivateKernelInner2Artifact',
234
+ convertPrivateKernelInner2InputsToWitnessMapWithAbi,
235
+ convertPrivateKernelInner2OutputsFromWitnessMapWithAbi,
236
+ );
237
+ }
238
+
239
+ public async generateInner3Output(
240
+ inputs: PrivateKernelInner3CircuitPrivateInputs,
241
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
242
+ return await this.generateCircuitOutput(
243
+ inputs,
244
+ 'PrivateKernelInner3Artifact',
245
+ convertPrivateKernelInner3InputsToWitnessMapWithAbi,
246
+ convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
247
+ );
248
+ }
249
+
250
+ public async simulateInner3(
251
+ inputs: PrivateKernelInner3CircuitPrivateInputs,
252
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
253
+ return await this.simulateCircuitOutput(
254
+ inputs,
255
+ 'PrivateKernelInner3Artifact',
256
+ convertPrivateKernelInner3InputsToWitnessMapWithAbi,
257
+ convertPrivateKernelInner3OutputsFromWitnessMapWithAbi,
258
+ );
259
+ }
260
+
261
+ public async generateInner4Output(
262
+ inputs: PrivateKernelInner4CircuitPrivateInputs,
263
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
264
+ return await this.generateCircuitOutput(
265
+ inputs,
266
+ 'PrivateKernelInner4Artifact',
267
+ convertPrivateKernelInner4InputsToWitnessMapWithAbi,
268
+ convertPrivateKernelInner4OutputsFromWitnessMapWithAbi,
269
+ );
270
+ }
271
+
272
+ public async simulateInner4(
273
+ inputs: PrivateKernelInner4CircuitPrivateInputs,
274
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
275
+ return await this.simulateCircuitOutput(
276
+ inputs,
277
+ 'PrivateKernelInner4Artifact',
278
+ convertPrivateKernelInner4InputsToWitnessMapWithAbi,
279
+ convertPrivateKernelInner4OutputsFromWitnessMapWithAbi,
280
+ );
281
+ }
282
+
283
+ public async generateInner5Output(
284
+ inputs: PrivateKernelInner5CircuitPrivateInputs,
285
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
286
+ return await this.generateCircuitOutput(
287
+ inputs,
288
+ 'PrivateKernelInner5Artifact',
289
+ convertPrivateKernelInner5InputsToWitnessMapWithAbi,
290
+ convertPrivateKernelInner5OutputsFromWitnessMapWithAbi,
291
+ );
292
+ }
293
+
294
+ public async simulateInner5(
295
+ inputs: PrivateKernelInner5CircuitPrivateInputs,
296
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
297
+ return await this.simulateCircuitOutput(
298
+ inputs,
299
+ 'PrivateKernelInner5Artifact',
300
+ convertPrivateKernelInner5InputsToWitnessMapWithAbi,
301
+ convertPrivateKernelInner5OutputsFromWitnessMapWithAbi,
302
+ );
303
+ }
304
+
99
305
  public async generateResetOutput(
100
306
  inputs: PrivateKernelResetCircuitPrivateInputs,
101
307
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
@@ -123,40 +329,42 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
123
329
  );
124
330
  }
125
331
 
126
- public async generateTailOutput(
127
- inputs: PrivateKernelTailCircuitPrivateInputs,
332
+ public async generateResetTailOutput(
333
+ inputs: PrivateKernelResetTailCircuitPrivateInputs,
128
334
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
335
+ const artifactName = getPrivateKernelResetTailArtifactName(inputs.dimensions, inputs.isForPublic());
129
336
  if (!inputs.isForPublic()) {
130
337
  return await this.generateCircuitOutput(
131
338
  inputs,
132
- 'PrivateKernelTailArtifact',
133
- convertPrivateKernelTailInputsToWitnessMapWithAbi,
339
+ artifactName,
340
+ convertPrivateKernelResetTailInputsToWitnessMapWithAbi,
134
341
  convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
135
342
  );
136
343
  }
137
344
  return await this.generateCircuitOutput(
138
345
  inputs,
139
- 'PrivateKernelTailToPublicArtifact',
140
- convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi,
346
+ artifactName,
347
+ convertPrivateKernelResetTailToPublicInputsToWitnessMapWithAbi,
141
348
  convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
142
349
  );
143
350
  }
144
351
 
145
- public async simulateTail(
146
- inputs: PrivateKernelTailCircuitPrivateInputs,
352
+ public async simulateResetTail(
353
+ inputs: PrivateKernelResetTailCircuitPrivateInputs,
147
354
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
355
+ const artifactName = getPrivateKernelResetTailArtifactName(inputs.dimensions, inputs.isForPublic());
148
356
  if (!inputs.isForPublic()) {
149
357
  return await this.simulateCircuitOutput(
150
358
  inputs,
151
- 'PrivateKernelTailArtifact',
152
- convertPrivateKernelTailInputsToWitnessMapWithAbi,
359
+ artifactName,
360
+ convertPrivateKernelResetTailInputsToWitnessMapWithAbi,
153
361
  convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
154
362
  );
155
363
  }
156
364
  return await this.simulateCircuitOutput(
157
365
  inputs,
158
- 'PrivateKernelTailToPublicArtifact',
159
- convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi,
366
+ artifactName,
367
+ convertPrivateKernelResetTailToPublicInputsToWitnessMapWithAbi,
160
368
  convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
161
369
  );
162
370
  }
@@ -271,26 +479,52 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
271
479
  public async createChonkProof(executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs> {
272
480
  const timer = new Timer();
273
481
  this.log.info(`Generating ClientIVC proof...`);
482
+ const barretenberg = await Barretenberg.initSingleton({
483
+ ...this.options,
484
+ logger: this.options.logger?.verbose,
485
+ });
274
486
  const backend = new AztecClientBackend(
275
487
  executionSteps.map(step => ungzip(step.bytecode)),
276
- await Barretenberg.initSingleton(),
488
+ barretenberg,
489
+ executionSteps.map(step => step.functionName),
490
+ executionSteps.map(step => step.kind),
277
491
  );
278
492
 
279
- const [proof] = await backend.prove(
493
+ // Use compressed prove path to get both proof fields and compressed proof bytes
494
+ const result = await backend.prove(
280
495
  executionSteps.map(step => ungzip(serializeWitness(step.witness))),
281
496
  executionSteps.map(step => step.vk),
497
+ { compress: true },
282
498
  );
283
499
  this.log.info(`Generated ClientIVC proof`, {
284
500
  eventName: 'client-ivc-proof-generation',
285
501
  duration: timer.ms(),
286
- proofSize: proof.length,
502
+ proofSize: result.proofFields.length,
503
+ compressedSize: result.compressedProof?.length,
287
504
  });
288
- return ChonkProofWithPublicInputs.fromBufferArray(proof);
505
+
506
+ // Create ChonkProofWithPublicInputs from the flat field elements
507
+ const proofWithPubInputs = ChonkProofWithPublicInputs.fromBufferArray(result.proofFields);
508
+
509
+ // Attach compressed proof bytes to the ChonkProof (without public inputs).
510
+ // The compressed bytes are for the full proof WITH public inputs from bb;
511
+ // when deserializing, the decompressor will strip them to match CHONK_PROOF_LENGTH.
512
+ proofWithPubInputs.compressedProof = result.compressedProof ? Buffer.from(result.compressedProof) : undefined;
513
+
514
+ return proofWithPubInputs;
289
515
  }
290
516
 
291
- public async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
517
+ public async computeGateCountForCircuit(
518
+ _bytecode: Buffer,
519
+ _circuitName: string,
520
+ _circuitKind: PrivateExecutionStep['kind'],
521
+ ): Promise<number> {
292
522
  // 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());
523
+ const barretenberg = await Barretenberg.initSingleton({
524
+ ...this.options,
525
+ logger: this.options.logger?.[(process.env.LOG_LEVEL as LogLevel) || 'verbose'],
526
+ });
527
+ const backend = new AztecClientBackend([ungzip(_bytecode)], barretenberg, [_circuitName], [_circuitKind]);
294
528
  const gateCount = await backend.gates();
295
529
  return gateCount[0];
296
530
  }
@@ -1,11 +1,10 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
1
  import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
3
2
  import type { CircuitSimulator } from '@aztec/simulator/client';
4
3
 
5
- import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
4
+ import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
6
5
 
7
6
  export class BBBundlePrivateKernelProver extends BBPrivateKernelProver {
8
- constructor(simulator: CircuitSimulator, log = createLogger('bb-prover:bundle')) {
9
- super(new BundleArtifactProvider(), simulator, log);
7
+ constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
8
+ super(new BundleArtifactProvider(), simulator, options);
10
9
  }
11
10
  }
@@ -1,11 +1,10 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
1
  import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
3
2
  import type { CircuitSimulator } from '@aztec/simulator/client';
4
3
 
5
- import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
4
+ import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
6
5
 
7
6
  export class BBLazyPrivateKernelProver extends BBPrivateKernelProver {
8
- constructor(simulator: CircuitSimulator, log = createLogger('bb-prover:lazy')) {
9
- super(new LazyArtifactProvider(), simulator, log);
7
+ constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
8
+ super(new LazyArtifactProvider(), simulator, options);
10
9
  }
11
10
  }
@@ -7,7 +7,7 @@ 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
12
  import { ChonkProofWithPublicInputs, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
13
13
  import type { VerificationKeyData } from '@aztec/stdlib/vks';
@@ -16,7 +16,7 @@ import assert from 'assert';
16
16
  import { promises as fs } from 'fs';
17
17
  import * as path from 'path';
18
18
 
19
- import { PROOF_FILENAME, PUBLIC_INPUTS_FILENAME } from '../bb/execute.js';
19
+ import { PROOF_FILENAME, PUBLIC_INPUTS_FILENAME } from '../bb/file_names.js';
20
20
 
21
21
  /**
22
22
  * Create a ChonkProof proof file.
@@ -113,3 +113,43 @@ export async function readProofsFromOutputDirectory<PROOF_LENGTH extends number>
113
113
  proofLength,
114
114
  );
115
115
  }
116
+
117
+ /**
118
+ * Construct a RecursiveProof from in-memory proof and public input field arrays
119
+ * returned by the bb.js circuitProve API, without reading from files.
120
+ *
121
+ * @param proofFields - Proof fields as 32-byte Uint8Arrays from circuitProve.
122
+ * @param publicInputFields - Public input fields as 32-byte Uint8Arrays from circuitProve.
123
+ * @param vkData - Verification key data for the circuit.
124
+ * @param proofLength - Expected proof field count.
125
+ */
126
+ export function constructRecursiveProofFromBuffers<PROOF_LENGTH extends number>(
127
+ proofFields: Uint8Array[],
128
+ publicInputFields: Uint8Array[],
129
+ vkData: VerificationKeyData,
130
+ proofLength: PROOF_LENGTH,
131
+ ): RecursiveProof<PROOF_LENGTH> {
132
+ assert(
133
+ proofLength == NESTED_RECURSIVE_PROOF_LENGTH ||
134
+ proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH ||
135
+ proofLength == ULTRA_KECCAK_PROOF_LENGTH,
136
+ `Proof length must be one of the expected proof lengths, received ${proofLength}`,
137
+ );
138
+
139
+ // Convert Uint8Array fields to Fr instances
140
+ const proofFieldsFr = proofFields.map(f => Fr.fromBuffer(Buffer.from(f)));
141
+
142
+ assert(
143
+ proofFieldsFr.length == proofLength,
144
+ `Proof fields length mismatch: ${proofFieldsFr.length} != ${proofLength}`,
145
+ );
146
+
147
+ // Reconstruct the binary proof with public inputs prepended (same format as file-based path)
148
+ const binaryPublicInputs = Buffer.concat(publicInputFields.map(f => Buffer.from(f)));
149
+ const binaryProof = Buffer.concat(proofFields.map(f => Buffer.from(f)));
150
+ const binaryProofWithPublicInputs = Buffer.concat([binaryPublicInputs, binaryProof]);
151
+
152
+ const numPublicInputs = getNumCustomPublicInputs(proofLength, vkData);
153
+
154
+ return new RecursiveProof(proofFieldsFr, new Proof(binaryProofWithPublicInputs, numPublicInputs), true, proofLength);
155
+ }