@aztec/bb-prover 0.40.1 → 0.42.0

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 (60) hide show
  1. package/dest/bb/cli.d.ts.map +1 -1
  2. package/dest/bb/cli.js +24 -2
  3. package/dest/bb/execute.d.ts +37 -2
  4. package/dest/bb/execute.d.ts.map +1 -1
  5. package/dest/bb/execute.js +276 -75
  6. package/dest/config.d.ts +9 -0
  7. package/dest/config.d.ts.map +1 -0
  8. package/dest/config.js +2 -0
  9. package/dest/index.d.ts +2 -0
  10. package/dest/index.d.ts.map +1 -1
  11. package/dest/index.js +3 -1
  12. package/dest/mappings/mappings.d.ts +1 -0
  13. package/dest/mappings/mappings.d.ts.map +1 -1
  14. package/dest/mappings/mappings.js +27 -8
  15. package/dest/prover/bb_native_proof_creator.d.ts +4 -9
  16. package/dest/prover/bb_native_proof_creator.d.ts.map +1 -1
  17. package/dest/prover/bb_native_proof_creator.js +77 -101
  18. package/dest/prover/bb_prover.d.ts +35 -23
  19. package/dest/prover/bb_prover.d.ts.map +1 -1
  20. package/dest/prover/bb_prover.js +247 -155
  21. package/dest/stats.d.ts +2 -5
  22. package/dest/stats.d.ts.map +1 -1
  23. package/dest/stats.js +27 -26
  24. package/dest/test/index.d.ts +1 -0
  25. package/dest/test/index.d.ts.map +1 -1
  26. package/dest/test/index.js +2 -1
  27. package/dest/test/test_circuit_prover.d.ts +9 -7
  28. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  29. package/dest/test/test_circuit_prover.js +31 -15
  30. package/dest/test/test_verifier.d.ts +7 -0
  31. package/dest/test/test_verifier.d.ts.map +1 -0
  32. package/dest/test/test_verifier.js +10 -0
  33. package/dest/verification_key/verification_key_data.d.ts +8 -0
  34. package/dest/verification_key/verification_key_data.d.ts.map +1 -0
  35. package/dest/verification_key/verification_key_data.js +24 -0
  36. package/dest/verifier/bb_verifier.d.ts +18 -0
  37. package/dest/verifier/bb_verifier.d.ts.map +1 -0
  38. package/dest/verifier/bb_verifier.js +90 -0
  39. package/dest/verifier/index.d.ts +2 -0
  40. package/dest/verifier/index.d.ts.map +1 -0
  41. package/dest/verifier/index.js +2 -0
  42. package/package.json +6 -6
  43. package/src/bb/cli.ts +36 -1
  44. package/src/bb/execute.ts +371 -83
  45. package/src/config.ts +9 -0
  46. package/src/index.ts +2 -0
  47. package/src/mappings/mappings.ts +38 -12
  48. package/src/prover/bb_native_proof_creator.ts +139 -119
  49. package/src/prover/bb_prover.ts +454 -242
  50. package/src/stats.ts +30 -45
  51. package/src/test/index.ts +1 -0
  52. package/src/test/test_circuit_prover.ts +84 -21
  53. package/src/test/test_verifier.ts +12 -0
  54. package/src/verification_key/verification_key_data.ts +35 -0
  55. package/src/verifier/bb_verifier.ts +156 -0
  56. package/src/verifier/index.ts +1 -0
  57. package/dest/prover/verification_key_data.d.ts +0 -16
  58. package/dest/prover/verification_key_data.d.ts.map +0 -1
  59. package/dest/prover/verification_key_data.js +0 -5
  60. package/src/prover/verification_key_data.ts +0 -16
@@ -1,36 +1,42 @@
1
1
  import { type AppCircuitProofOutput, type KernelProofOutput, type ProofCreator } from '@aztec/circuit-types';
2
+ import { type CircuitProvingStats, type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
2
3
  import {
4
+ AGGREGATION_OBJECT_LENGTH,
3
5
  Fr,
4
6
  NESTED_RECURSIVE_PROOF_LENGTH,
5
7
  type PrivateCircuitPublicInputs,
6
8
  type PrivateKernelCircuitPublicInputs,
7
9
  type PrivateKernelInitCircuitPrivateInputs,
8
10
  type PrivateKernelInnerCircuitPrivateInputs,
11
+ type PrivateKernelResetCircuitPrivateInputsVariants,
9
12
  type PrivateKernelTailCircuitPrivateInputs,
10
13
  type PrivateKernelTailCircuitPublicInputs,
11
14
  Proof,
12
15
  RECURSIVE_PROOF_LENGTH,
13
16
  RecursiveProof,
14
- type VERIFICATION_KEY_LENGTH_IN_FIELDS,
15
- VerificationKeyAsFields,
17
+ type VerificationKeyAsFields,
18
+ type VerificationKeyData,
16
19
  } from '@aztec/circuits.js';
17
20
  import { siloNoteHash } from '@aztec/circuits.js/hash';
18
- import { randomBytes } from '@aztec/foundation/crypto';
21
+ import { runInDirectory } from '@aztec/foundation/fs';
19
22
  import { createDebugLogger } from '@aztec/foundation/log';
20
- import { type Tuple } from '@aztec/foundation/serialize';
23
+ import { Timer } from '@aztec/foundation/timer';
21
24
  import {
22
25
  ClientCircuitArtifacts,
23
26
  type ClientProtocolArtifact,
27
+ PrivateResetTagToArtifactName,
24
28
  convertPrivateKernelInitInputsToWitnessMap,
25
29
  convertPrivateKernelInitOutputsFromWitnessMap,
26
30
  convertPrivateKernelInnerInputsToWitnessMap,
27
31
  convertPrivateKernelInnerOutputsFromWitnessMap,
32
+ convertPrivateKernelResetInputsToWitnessMap,
33
+ convertPrivateKernelResetOutputsFromWitnessMap,
28
34
  convertPrivateKernelTailForPublicOutputsFromWitnessMap,
29
35
  convertPrivateKernelTailInputsToWitnessMap,
30
36
  convertPrivateKernelTailOutputsFromWitnessMap,
31
37
  convertPrivateKernelTailToPublicInputsToWitnessMap,
32
38
  } from '@aztec/noir-protocol-circuits-types';
33
- import { type ACVMField, WASMSimulator } from '@aztec/simulator';
39
+ import { WASMSimulator } from '@aztec/simulator';
34
40
  import { type NoirCompiledCircuit } from '@aztec/types/noir';
35
41
 
36
42
  import { serializeWitness } from '@noir-lang/noirc_abi';
@@ -41,38 +47,12 @@ import {
41
47
  BB_RESULT,
42
48
  PROOF_FIELDS_FILENAME,
43
49
  PROOF_FILENAME,
44
- VK_FIELDS_FILENAME,
45
- VK_FILENAME,
46
50
  generateKeyForNoirCircuit,
47
51
  generateProof,
48
52
  verifyProof,
49
53
  } from '../bb/execute.js';
50
- import {
51
- AGGREGATION_OBJECT_SIZE,
52
- CIRCUIT_PUBLIC_INPUTS_INDEX,
53
- CIRCUIT_RECURSIVE_INDEX,
54
- CIRCUIT_SIZE_INDEX,
55
- type VerificationKeyData,
56
- } from './verification_key_data.js';
57
-
58
- type PrivateKernelProvingOps = {
59
- convertOutputs: (outputs: WitnessMap) => PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs;
60
- };
61
-
62
- const PrivateKernelArtifactMapping: Record<ClientProtocolArtifact, PrivateKernelProvingOps> = {
63
- PrivateKernelInitArtifact: {
64
- convertOutputs: convertPrivateKernelInitOutputsFromWitnessMap,
65
- },
66
- PrivateKernelInnerArtifact: {
67
- convertOutputs: convertPrivateKernelInnerOutputsFromWitnessMap,
68
- },
69
- PrivateKernelTailArtifact: {
70
- convertOutputs: convertPrivateKernelTailOutputsFromWitnessMap,
71
- },
72
- PrivateKernelTailToPublicArtifact: {
73
- convertOutputs: convertPrivateKernelTailForPublicOutputsFromWitnessMap,
74
- },
75
- };
54
+ import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
55
+ import { extractVkData } from '../verification_key/verification_key_data.js';
76
56
 
77
57
  /**
78
58
  * This proof creator implementation uses the native bb binary.
@@ -103,38 +83,63 @@ export class BBNativeProofCreator implements ProofCreator {
103
83
  public async createProofInit(
104
84
  inputs: PrivateKernelInitCircuitPrivateInputs,
105
85
  ): Promise<KernelProofOutput<PrivateKernelCircuitPublicInputs>> {
106
- const witnessMap = convertPrivateKernelInitInputsToWitnessMap(inputs);
107
- return await this.createSafeProof(witnessMap, 'PrivateKernelInitArtifact');
86
+ return await this.createSafeProof(
87
+ inputs,
88
+ 'PrivateKernelInitArtifact',
89
+ convertPrivateKernelInitInputsToWitnessMap,
90
+ convertPrivateKernelInitOutputsFromWitnessMap,
91
+ );
108
92
  }
109
93
 
110
94
  public async createProofInner(
111
95
  inputs: PrivateKernelInnerCircuitPrivateInputs,
112
96
  ): Promise<KernelProofOutput<PrivateKernelCircuitPublicInputs>> {
113
- const witnessMap = convertPrivateKernelInnerInputsToWitnessMap(inputs);
114
- return await this.createSafeProof(witnessMap, 'PrivateKernelInnerArtifact');
97
+ return await this.createSafeProof(
98
+ inputs,
99
+ 'PrivateKernelInnerArtifact',
100
+ convertPrivateKernelInnerInputsToWitnessMap,
101
+ convertPrivateKernelInnerOutputsFromWitnessMap,
102
+ );
103
+ }
104
+
105
+ public async createProofReset(
106
+ inputs: PrivateKernelResetCircuitPrivateInputsVariants,
107
+ ): Promise<KernelProofOutput<PrivateKernelCircuitPublicInputs>> {
108
+ return await this.createSafeProof(
109
+ inputs,
110
+ PrivateResetTagToArtifactName[inputs.sizeTag],
111
+ convertPrivateKernelResetInputsToWitnessMap,
112
+ output => convertPrivateKernelResetOutputsFromWitnessMap(output, inputs.sizeTag),
113
+ );
115
114
  }
116
115
 
117
116
  public async createProofTail(
118
117
  inputs: PrivateKernelTailCircuitPrivateInputs,
119
118
  ): Promise<KernelProofOutput<PrivateKernelTailCircuitPublicInputs>> {
120
119
  if (!inputs.isForPublic()) {
121
- const witnessMap = convertPrivateKernelTailInputsToWitnessMap(inputs);
122
- return await this.createSafeProof(witnessMap, 'PrivateKernelTailArtifact');
120
+ return await this.createSafeProof(
121
+ inputs,
122
+ 'PrivateKernelTailArtifact',
123
+ convertPrivateKernelTailInputsToWitnessMap,
124
+ convertPrivateKernelTailOutputsFromWitnessMap,
125
+ );
123
126
  }
124
- const witnessMap = convertPrivateKernelTailToPublicInputsToWitnessMap(inputs);
125
- return await this.createSafeProof(witnessMap, 'PrivateKernelTailToPublicArtifact');
127
+ return await this.createSafeProof(
128
+ inputs,
129
+ 'PrivateKernelTailToPublicArtifact',
130
+ convertPrivateKernelTailToPublicInputsToWitnessMap,
131
+ convertPrivateKernelTailForPublicOutputsFromWitnessMap,
132
+ );
126
133
  }
127
134
 
128
135
  public async createAppCircuitProof(
129
- partialWitness: Map<number, ACVMField>,
136
+ partialWitness: WitnessMap,
130
137
  bytecode: Buffer,
138
+ appCircuitName?: string,
131
139
  ): Promise<AppCircuitProofOutput> {
132
- const directory = `${this.bbWorkingDirectory}/${randomBytes(8).toString('hex')}`;
133
- await fs.mkdir(directory, { recursive: true });
134
- this.log.debug(`Created directory: ${directory}`);
135
- try {
140
+ const operation = async (directory: string) => {
136
141
  this.log.debug(`Proving app circuit`);
137
- const proofOutput = await this.createProof(directory, partialWitness, bytecode, 'App');
142
+ const proofOutput = await this.createProof(directory, partialWitness, bytecode, 'App', appCircuitName);
138
143
  if (proofOutput.proof.proof.length != RECURSIVE_PROOF_LENGTH) {
139
144
  throw new Error(`Incorrect proof length`);
140
145
  }
@@ -144,10 +149,9 @@ export class BBNativeProofCreator implements ProofCreator {
144
149
  verificationKey: proofOutput.verificationKey,
145
150
  };
146
151
  return output;
147
- } finally {
148
- await fs.rm(directory, { recursive: true, force: true });
149
- this.log.debug(`Deleted directory: ${directory}`);
150
- }
152
+ };
153
+
154
+ return await runInDirectory(this.bbWorkingDirectory, operation);
151
155
  }
152
156
 
153
157
  /**
@@ -158,7 +162,7 @@ export class BBNativeProofCreator implements ProofCreator {
158
162
  public async verifyProofForProtocolCircuit(circuitType: ClientProtocolArtifact, proof: Proof) {
159
163
  const verificationKey = await this.getVerificationKeyDataForCircuit(circuitType);
160
164
 
161
- this.log.debug(`Verifying with key: ${verificationKey.hash.toString()}`);
165
+ this.log.debug(`Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
162
166
 
163
167
  const logFunction = (message: string) => {
164
168
  this.log.debug(`${circuitType} BB out - ${message}`);
@@ -179,21 +183,15 @@ export class BBNativeProofCreator implements ProofCreator {
179
183
  proof: Proof,
180
184
  logFunction: (message: string) => void = () => {},
181
185
  ) {
182
- // Create random directory to be used for temp files
183
- const bbWorkingDirectory = `${this.bbWorkingDirectory}/${randomBytes(8).toString('hex')}`;
184
- await fs.mkdir(bbWorkingDirectory, { recursive: true });
185
-
186
- const proofFileName = `${bbWorkingDirectory}/proof`;
187
- const verificationKeyPath = `${bbWorkingDirectory}/vk`;
186
+ const operation = async (bbWorkingDirectory: string) => {
187
+ const proofFileName = `${bbWorkingDirectory}/proof`;
188
+ const verificationKeyPath = `${bbWorkingDirectory}/vk`;
188
189
 
189
- await fs.writeFile(proofFileName, proof.buffer);
190
- await fs.writeFile(verificationKeyPath, verificationKey);
191
-
192
- try {
190
+ await fs.writeFile(proofFileName, proof.buffer);
191
+ await fs.writeFile(verificationKeyPath, verificationKey);
193
192
  return await verifyProof(this.bbBinaryPath, proofFileName, verificationKeyPath!, logFunction);
194
- } finally {
195
- await fs.rm(bbWorkingDirectory, { recursive: true, force: true });
196
- }
193
+ };
194
+ return await runInDirectory(this.bbWorkingDirectory, operation);
197
195
  }
198
196
 
199
197
  /**
@@ -215,39 +213,13 @@ export class BBNativeProofCreator implements ProofCreator {
215
213
  if (result.status === BB_RESULT.FAILURE) {
216
214
  throw new Error(`Failed to generate verification key for ${circuitType}, ${result.reason}`);
217
215
  }
218
- return this.convertVk(result.vkPath!);
216
+ return extractVkData(result.vkPath!);
219
217
  });
220
218
  this.verificationKeys.set(circuitType, promise);
221
219
  }
222
220
  return await promise;
223
221
  }
224
222
 
225
- /**
226
- * Reads the verification key data stored at the specified location and parses into a VerificationKeyData
227
- * @param filePath - The directory containing the verification key data files
228
- * @returns The verification key data
229
- */
230
- private async convertVk(filePath: string): Promise<VerificationKeyData> {
231
- const [rawFields, rawBinary] = await Promise.all([
232
- fs.readFile(`${filePath}/${VK_FIELDS_FILENAME}`, { encoding: 'utf-8' }),
233
- fs.readFile(`${filePath}/${VK_FILENAME}`),
234
- ]);
235
- const fieldsJson = JSON.parse(rawFields);
236
- const fields = fieldsJson.map(Fr.fromString);
237
- // The first item is the hash, this is not part of the actual VK
238
- const vkHash = fields[0];
239
- const actualVk = fields.slice(1);
240
- const vk: VerificationKeyData = {
241
- hash: vkHash,
242
- keyAsFields: actualVk as Tuple<Fr, typeof VERIFICATION_KEY_LENGTH_IN_FIELDS>,
243
- keyAsBytes: rawBinary,
244
- numPublicInputs: Number(actualVk[CIRCUIT_PUBLIC_INPUTS_INDEX]),
245
- circuitSize: Number(actualVk[CIRCUIT_SIZE_INDEX]),
246
- isRecursive: actualVk[CIRCUIT_RECURSIVE_INDEX] == Fr.ONE,
247
- };
248
- return vk;
249
- }
250
-
251
223
  /**
252
224
  * Ensures our verification key cache includes the key data located at the specified directory
253
225
  * @param filePath - The directory containing the verification key data files
@@ -256,41 +228,50 @@ export class BBNativeProofCreator implements ProofCreator {
256
228
  private async updateVerificationKeyAfterProof(filePath: string, circuitType: ClientProtocolArtifact) {
257
229
  let promise = this.verificationKeys.get(circuitType);
258
230
  if (!promise) {
259
- promise = this.convertVk(filePath);
231
+ promise = extractVkData(filePath);
260
232
  this.log.debug(`Updated verification key for circuit: ${circuitType}`);
261
233
  this.verificationKeys.set(circuitType, promise);
262
234
  }
263
235
  return await promise;
264
236
  }
265
237
 
266
- private async createSafeProof<T>(
267
- inputs: WitnessMap,
238
+ private async createSafeProof<I extends { toBuffer: () => Buffer }, O extends { toBuffer: () => Buffer }>(
239
+ inputs: I,
268
240
  circuitType: ClientProtocolArtifact,
269
- ): Promise<KernelProofOutput<T>> {
270
- const directory = `${this.bbWorkingDirectory}/${randomBytes(8).toString('hex')}`;
271
- await fs.mkdir(directory, { recursive: true });
272
- this.log.debug(`Created directory: ${directory}`);
273
- try {
274
- return await this.generateWitnessAndCreateProof(inputs, circuitType, directory);
275
- } finally {
276
- await fs.rm(directory, { recursive: true, force: true });
277
- this.log.debug(`Deleted directory: ${directory}`);
278
- }
241
+ convertInputs: (inputs: I) => WitnessMap,
242
+ convertOutputs: (outputs: WitnessMap) => O,
243
+ ): Promise<KernelProofOutput<O>> {
244
+ const operation = async (directory: string) => {
245
+ return await this.generateWitnessAndCreateProof(inputs, circuitType, directory, convertInputs, convertOutputs);
246
+ };
247
+ return await runInDirectory(this.bbWorkingDirectory, operation);
279
248
  }
280
249
 
281
- private async generateWitnessAndCreateProof<T>(
282
- inputs: WitnessMap,
250
+ private async generateWitnessAndCreateProof<
251
+ I extends { toBuffer: () => Buffer },
252
+ O extends { toBuffer: () => Buffer },
253
+ >(
254
+ inputs: I,
283
255
  circuitType: ClientProtocolArtifact,
284
256
  directory: string,
285
- ): Promise<KernelProofOutput<T>> {
257
+ convertInputs: (inputs: I) => WitnessMap,
258
+ convertOutputs: (outputs: WitnessMap) => O,
259
+ ): Promise<KernelProofOutput<O>> {
286
260
  this.log.debug(`Generating witness for ${circuitType}`);
287
261
  const compiledCircuit: NoirCompiledCircuit = ClientCircuitArtifacts[circuitType];
288
262
 
289
- const outputWitness = await this.simulator.simulateCircuit(inputs, compiledCircuit);
263
+ const witnessMap = convertInputs(inputs);
264
+ const timer = new Timer();
265
+ const outputWitness = await this.simulator.simulateCircuit(witnessMap, compiledCircuit);
266
+ const output = convertOutputs(outputWitness);
290
267
 
291
- this.log.debug(`Generated witness for ${circuitType}`);
292
-
293
- const publicInputs = PrivateKernelArtifactMapping[circuitType].convertOutputs(outputWitness) as T;
268
+ this.log.debug(`Generated witness for ${circuitType}`, {
269
+ eventName: 'circuit-witness-generation',
270
+ circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
271
+ duration: timer.ms(),
272
+ inputSize: inputs.toBuffer().length,
273
+ outputSize: output.toBuffer().length,
274
+ } satisfies CircuitWitnessGenerationStats);
294
275
 
295
276
  const proofOutput = await this.createProof(
296
277
  directory,
@@ -303,8 +284,8 @@ export class BBNativeProofCreator implements ProofCreator {
303
284
  }
304
285
  const nestedProof = proofOutput.proof as RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>;
305
286
 
306
- const kernelOutput: KernelProofOutput<T> = {
307
- publicInputs,
287
+ const kernelOutput: KernelProofOutput<O> = {
288
+ publicInputs: output,
308
289
  proof: nestedProof,
309
290
  verificationKey: proofOutput.verificationKey,
310
291
  };
@@ -316,6 +297,7 @@ export class BBNativeProofCreator implements ProofCreator {
316
297
  partialWitness: WitnessMap,
317
298
  bytecode: Buffer,
318
299
  circuitType: ClientProtocolArtifact | 'App',
300
+ appCircuitName?: string,
319
301
  ): Promise<{
320
302
  proof: RecursiveProof<typeof RECURSIVE_PROOF_LENGTH> | RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>;
321
303
  verificationKey: VerificationKeyAsFields;
@@ -328,6 +310,10 @@ export class BBNativeProofCreator implements ProofCreator {
328
310
 
329
311
  this.log.debug(`Written ${inputsWitnessFile}`);
330
312
 
313
+ this.log.info(`Proving ${circuitType} circuit...`);
314
+
315
+ const timer = new Timer();
316
+
331
317
  const provingResult = await generateProof(
332
318
  this.bbBinaryPath,
333
319
  directory,
@@ -342,15 +328,45 @@ export class BBNativeProofCreator implements ProofCreator {
342
328
  throw new Error(provingResult.reason);
343
329
  }
344
330
 
331
+ this.log.info(
332
+ `Generated ${circuitType === 'App' ? appCircuitName : circuitType} circuit proof in ${timer.ms()} ms`,
333
+ );
334
+
345
335
  if (circuitType === 'App') {
346
- const vkData = await this.convertVk(directory);
336
+ const vkData = await extractVkData(directory);
347
337
  const proof = await this.readProofAsFields<typeof RECURSIVE_PROOF_LENGTH>(directory, circuitType, vkData);
348
- return { proof, verificationKey: new VerificationKeyAsFields(vkData.keyAsFields, vkData.hash) };
338
+
339
+ this.log.debug(`Generated proof`, {
340
+ eventName: 'circuit-proving',
341
+ circuitName: 'app-circuit',
342
+ duration: provingResult.duration,
343
+ inputSize: compressedBincodedWitness.length,
344
+ proofSize: proof.binaryProof.buffer.length,
345
+ appCircuitName,
346
+ circuitSize: vkData.circuitSize,
347
+ numPublicInputs: vkData.numPublicInputs,
348
+ } as CircuitProvingStats);
349
+
350
+ return { proof, verificationKey: vkData.keyAsFields };
349
351
  }
350
352
 
351
353
  const vkData = await this.updateVerificationKeyAfterProof(directory, circuitType);
354
+
352
355
  const proof = await this.readProofAsFields<typeof NESTED_RECURSIVE_PROOF_LENGTH>(directory, circuitType, vkData);
353
- return { proof, verificationKey: new VerificationKeyAsFields(vkData.keyAsFields, vkData.hash) };
356
+
357
+ await this.verifyProofForProtocolCircuit(circuitType, proof.binaryProof);
358
+
359
+ this.log.debug(`Generated proof`, {
360
+ circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
361
+ duration: provingResult.duration,
362
+ eventName: 'circuit-proving',
363
+ inputSize: compressedBincodedWitness.length,
364
+ proofSize: proof.binaryProof.buffer.length,
365
+ circuitSize: vkData.circuitSize,
366
+ numPublicInputs: vkData.numPublicInputs,
367
+ } as CircuitProvingStats);
368
+
369
+ return { proof, verificationKey: vkData.keyAsFields };
354
370
  }
355
371
 
356
372
  /**
@@ -371,12 +387,16 @@ export class BBNativeProofCreator implements ProofCreator {
371
387
  const json = JSON.parse(proofString);
372
388
  const fields = json.map(Fr.fromString);
373
389
  const numPublicInputs =
374
- circuitType === 'App' ? vkData.numPublicInputs : vkData.numPublicInputs - AGGREGATION_OBJECT_SIZE;
390
+ circuitType === 'App' ? vkData.numPublicInputs : vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
375
391
  const fieldsWithoutPublicInputs = fields.slice(numPublicInputs);
376
392
  this.log.debug(
377
393
  `Circuit type: ${circuitType}, complete proof length: ${fields.length}, without public inputs: ${fieldsWithoutPublicInputs.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProof.length}`,
378
394
  );
379
- const proof = new RecursiveProof<PROOF_LENGTH>(fieldsWithoutPublicInputs, new Proof(binaryProof));
395
+ const proof = new RecursiveProof<PROOF_LENGTH>(
396
+ fieldsWithoutPublicInputs,
397
+ new Proof(binaryProof, vkData.numPublicInputs),
398
+ true,
399
+ );
380
400
  return proof;
381
401
  }
382
402
  }