@aztec/bb-prover 0.71.0 → 0.72.1

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.
package/src/bb/cli.ts CHANGED
@@ -5,11 +5,6 @@ import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types
5
5
  import { type NoirCompiledCircuit } from '@aztec/types/noir';
6
6
 
7
7
  import { Command } from 'commander';
8
- import { promises as fs } from 'fs';
9
-
10
- import { generateContractForCircuit, generateKeyForNoirCircuit } from './execute.js';
11
-
12
- const { BB_WORKING_DIRECTORY, BB_BINARY_PATH } = process.env;
13
8
 
14
9
  export const ProtocolCircuitArtifacts: Record<ProtocolArtifact, NoirCompiledCircuit> = {
15
10
  ...ClientCircuitArtifacts,
@@ -33,76 +28,5 @@ export function getProgram(log: LogFn): Command {
33
28
  log(Object.keys(ProtocolCircuitArtifacts).reduce((prev: string, x: string) => prev.concat(`\n${x}`)));
34
29
  });
35
30
 
36
- program
37
- .command('write-vk')
38
- .description('Generates the verification key for the specified circuit')
39
- .requiredOption(
40
- '-w, --working-directory <string>',
41
- 'A directory to use for storing input/output files',
42
- BB_WORKING_DIRECTORY,
43
- )
44
- .requiredOption('-b, --bb-path <string>', 'The path to the BB binary', BB_BINARY_PATH)
45
- .requiredOption('-c, --circuit <string>', 'The name of a protocol circuit')
46
- .requiredOption('-f, --flavor <string>', 'The name of the verification key flavor', 'ultra_honk')
47
- .option('-r, --recursive', 'Whether a SNARK friendly key should be generated', false)
48
- .action(async options => {
49
- const compiledCircuit = ProtocolCircuitArtifacts[options.circuit as ProtocolArtifact];
50
- if (!compiledCircuit) {
51
- log(`Failed to find circuit ${options.circuit}`);
52
- return;
53
- }
54
- try {
55
- await fs.access(options.workingDirectory, fs.constants.W_OK);
56
- } catch (error) {
57
- log(`Working directory does not exist`);
58
- return;
59
- }
60
- await generateKeyForNoirCircuit(
61
- options.bbPath,
62
- options.workingDirectory,
63
- options.circuit,
64
- compiledCircuit,
65
- options.recursive,
66
- options.flavor,
67
- // (options.circuit as ServerProtocolArtifact) === 'RootRollupArtifact' ? 'ultra_keccak_honk' : 'ultra_honk',
68
- log,
69
- );
70
- });
71
-
72
- program
73
- .command('write-contract')
74
- .description('Generates the verification contract for the specified circuit')
75
- .requiredOption(
76
- '-w, --working-directory <string>',
77
- 'A directory to use for storing input/output files',
78
- BB_WORKING_DIRECTORY,
79
- )
80
- .requiredOption('-b, --bb-path <string>', 'The path to the BB binary', BB_BINARY_PATH)
81
- .requiredOption('-c, --circuit <string>', 'The name of a protocol circuit')
82
- .requiredOption('-n --contract-name <string>', 'The name of the contract to generate', 'contract.sol')
83
- .action(async options => {
84
- const compiledCircuit = ProtocolCircuitArtifacts[options.circuit as ProtocolArtifact];
85
- if (!compiledCircuit) {
86
- log(`Failed to find circuit ${options.circuit}`);
87
- return;
88
- }
89
- try {
90
- await fs.access(options.workingDirectory, fs.constants.W_OK);
91
- } catch (error) {
92
- log(`Working directory does not exist`);
93
- return;
94
- }
95
-
96
- await generateContractForCircuit(
97
- options.bbPath,
98
- options.workingDirectory,
99
- options.circuit,
100
- compiledCircuit,
101
- options.contractName,
102
- log,
103
- /*force= */ true,
104
- );
105
- });
106
-
107
31
  return program;
108
32
  }
package/src/bb/execute.ts CHANGED
@@ -2,7 +2,6 @@ import { type AvmCircuitInputs, serializeWithMessagePack } from '@aztec/circuits
2
2
  import { sha256 } from '@aztec/foundation/crypto';
3
3
  import { type LogFn, type Logger } from '@aztec/foundation/log';
4
4
  import { Timer } from '@aztec/foundation/timer';
5
- import { type NoirCompiledCircuit } from '@aztec/types/noir';
6
5
 
7
6
  import * as proc from 'child_process';
8
7
  import { promises as fs } from 'fs';
@@ -97,103 +96,6 @@ export function executeBB(
97
96
  }).catch(_ => ({ status: BB_RESULT.FAILURE, exitCode: -1, signal: undefined }));
98
97
  }
99
98
 
100
- const bytecodeFilename = 'bytecode';
101
-
102
- /**
103
- * Used for generating either a proving or verification key, will exit early if the key already exists
104
- * It assumes the provided working directory is one where the caller wishes to maintain a permanent set of keys
105
- * It is not considered a temporary directory
106
- * @param pathToBB - The full path to the bb binary
107
- * @param workingDirectory - The directory into which the key should be created
108
- * @param circuitName - An identifier for the circuit
109
- * @param compiledCircuit - The compiled circuit
110
- * @param key - The type of key, either 'pk' or 'vk'
111
- * @param log - A logging function
112
- * @param force - Force the key to be regenerated even if it already exists
113
- * @returns An instance of BBResult
114
- */
115
- export async function generateKeyForNoirCircuit(
116
- pathToBB: string,
117
- workingDirectory: string,
118
- circuitName: string,
119
- compiledCircuit: NoirCompiledCircuit,
120
- recursive: boolean,
121
- flavor: UltraHonkFlavor,
122
- log: LogFn,
123
- force = false,
124
- ): Promise<BBSuccess | BBFailure> {
125
- const bytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
126
-
127
- // The key generation is written to e.g. /workingDirectory/pk/BaseParityArtifact/pk
128
- // The bytecode hash file is also written here as /workingDirectory/pk/BaseParityArtifact/bytecode-hash
129
- // The bytecode is written to e.g. /workingDirectory/pk/BaseParityArtifact/bytecode
130
- // The bytecode is removed after the key is generated, leaving just the hash file
131
- const circuitOutputDirectory = `${workingDirectory}/vk/${circuitName}`;
132
- const outputPath = `${circuitOutputDirectory}`;
133
- const bytecodeHash = sha256(bytecode);
134
-
135
- // ensure the directory exists
136
- await fs.mkdir(circuitOutputDirectory, { recursive: true });
137
-
138
- const res = await fsCache<BBSuccess | BBFailure>(circuitOutputDirectory, bytecodeHash, log, force, async () => {
139
- const binaryPresent = await fs
140
- .access(pathToBB, fs.constants.R_OK)
141
- .then(_ => true)
142
- .catch(_ => false);
143
- if (!binaryPresent) {
144
- return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
145
- }
146
-
147
- // We are now going to generate the key
148
- try {
149
- const bytecodePath = `${circuitOutputDirectory}/${bytecodeFilename}`;
150
- // Write the bytecode to the working directory
151
- await fs.writeFile(bytecodePath, bytecode);
152
-
153
- // args are the output path and the input bytecode path
154
- const args = ['-o', `${outputPath}/${VK_FILENAME}`, '-b', bytecodePath, recursive ? '--recursive' : ''];
155
- const timer = new Timer();
156
- let result = await executeBB(pathToBB, `write_vk_${flavor}`, args, log);
157
-
158
- // If we succeeded and the type of key if verification, have bb write the 'fields' version too
159
- if (result.status == BB_RESULT.SUCCESS) {
160
- const asFieldsArgs = ['-k', `${outputPath}/${VK_FILENAME}`, '-o', `${outputPath}/${VK_FIELDS_FILENAME}`, '-v'];
161
- result = await executeBB(pathToBB, `vk_as_fields_${flavor}`, asFieldsArgs, log);
162
- }
163
- const duration = timer.ms();
164
-
165
- if (result.status == BB_RESULT.SUCCESS) {
166
- return {
167
- status: BB_RESULT.SUCCESS,
168
- durationMs: duration,
169
- pkPath: undefined,
170
- vkPath: outputPath,
171
- proofPath: undefined,
172
- };
173
- }
174
- // Not a great error message here but it is difficult to decipher what comes from bb
175
- return {
176
- status: BB_RESULT.FAILURE,
177
- reason: `Failed to generate key. Exit code: ${result.exitCode}. Signal ${result.signal}.`,
178
- retry: !!result.signal,
179
- };
180
- } catch (error) {
181
- return { status: BB_RESULT.FAILURE, reason: `${error}` };
182
- }
183
- });
184
-
185
- if (!res) {
186
- return {
187
- status: BB_RESULT.ALREADY_PRESENT,
188
- durationMs: 0,
189
- pkPath: undefined,
190
- vkPath: outputPath,
191
- };
192
- }
193
-
194
- return res;
195
- }
196
-
197
99
  // TODO(#7369) comment this etc (really just take inspiration from this and rewrite it all O:))
198
100
  export async function executeBbClientIvcProof(
199
101
  pathToBB: string,
@@ -960,43 +862,6 @@ export async function generateContractForVerificationKey(
960
862
  return res;
961
863
  }
962
864
 
963
- export async function generateContractForCircuit(
964
- pathToBB: string,
965
- workingDirectory: string,
966
- circuitName: string,
967
- compiledCircuit: NoirCompiledCircuit,
968
- contractName: string,
969
- log: LogFn,
970
- force = false,
971
- ) {
972
- // Verifier contracts are never recursion friendly, because non-recursive proofs are generated using the keccak256 hash function.
973
- // We need to use the same hash function during verification so proofs generated using keccak256 are cheap to verify on ethereum
974
- // (where the verifier contract would be deployed) whereas if we want to verify the proof within a snark (for recursion) we want
975
- // to use a snark-friendly hash function.
976
- const recursive = false;
977
-
978
- const vkResult = await generateKeyForNoirCircuit(
979
- pathToBB,
980
- workingDirectory,
981
- circuitName,
982
- compiledCircuit,
983
- recursive,
984
- 'ultra_keccak_honk',
985
- log,
986
- force,
987
- );
988
- if (vkResult.status === BB_RESULT.FAILURE) {
989
- return vkResult;
990
- }
991
-
992
- return generateContractForVerificationKey(
993
- pathToBB,
994
- join(vkResult.vkPath!, VK_FILENAME),
995
- join(workingDirectory, 'contract', circuitName, contractName),
996
- log,
997
- );
998
- }
999
-
1000
865
  /**
1001
866
  * Compute bb gate count for a given circuit
1002
867
  * @param pathToBB - The full path to the bb binary
@@ -23,7 +23,6 @@ import {
23
23
  RecursiveProof,
24
24
  type RootParityInputs,
25
25
  TUBE_PROOF_LENGTH,
26
- type VerificationKeyAsFields,
27
26
  type VerificationKeyData,
28
27
  makeRecursiveProofFromBinary,
29
28
  } from '@aztec/circuits.js';
@@ -69,6 +68,7 @@ import {
69
68
  convertSingleTxBlockRootRollupInputsToWitnessMap,
70
69
  convertSingleTxBlockRootRollupOutputsFromWitnessMap,
71
70
  } from '@aztec/noir-protocol-circuits-types/server';
71
+ import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/vks';
72
72
  import { NativeACVMSimulator } from '@aztec/simulator/server';
73
73
  import { Attributes, type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
74
74
 
@@ -86,7 +86,6 @@ import {
86
86
  PROOF_FILENAME,
87
87
  VK_FILENAME,
88
88
  generateAvmProof,
89
- generateKeyForNoirCircuit,
90
89
  generateProof,
91
90
  generateTubeProof,
92
91
  verifyAvmProof,
@@ -114,11 +113,6 @@ export interface BBProverConfig extends BBConfig, ACVMConfig {
114
113
  * Prover implementation that uses barretenberg native proving
115
114
  */
116
115
  export class BBNativeRollupProver implements ServerCircuitProver {
117
- private verificationKeys = new Map<
118
- `ultra${'_keccak_' | '_' | '_rollup_'}honk_${ServerProtocolArtifact}`,
119
- Promise<VerificationKeyData>
120
- >();
121
-
122
116
  private instrumentation: ProverInstrumentation;
123
117
 
124
118
  constructor(private config: BBProverConfig, telemetry: TelemetryClient) {
@@ -157,7 +151,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
157
151
  convertBaseParityOutputsFromWitnessMap,
158
152
  );
159
153
 
160
- const verificationKey = await this.getVerificationKeyDataForCircuit('BaseParityArtifact');
154
+ const verificationKey = this.getVerificationKeyDataForCircuit('BaseParityArtifact');
161
155
  await this.verifyProof('BaseParityArtifact', proof.binaryProof);
162
156
 
163
157
  return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
@@ -180,7 +174,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
180
174
  convertRootParityOutputsFromWitnessMap,
181
175
  );
182
176
 
183
- const verificationKey = await this.getVerificationKeyDataForCircuit('RootParityArtifact');
177
+ const verificationKey = this.getVerificationKeyDataForCircuit('RootParityArtifact');
184
178
  await this.verifyProof('RootParityArtifact', proof.binaryProof);
185
179
 
186
180
  return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
@@ -222,7 +216,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
222
216
  convertPrivateBaseRollupOutputsFromWitnessMap,
223
217
  );
224
218
 
225
- const verificationKey = await this.getVerificationKeyDataForCircuit(artifactName);
219
+ const verificationKey = this.getVerificationKeyDataForCircuit(artifactName);
226
220
 
227
221
  await this.verifyProof(artifactName, proof.binaryProof);
228
222
 
@@ -249,7 +243,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
249
243
  convertPublicBaseRollupOutputsFromWitnessMap,
250
244
  );
251
245
 
252
- const verificationKey = await this.getVerificationKeyDataForCircuit(artifactName);
246
+ const verificationKey = this.getVerificationKeyDataForCircuit(artifactName);
253
247
 
254
248
  await this.verifyProof(artifactName, proof.binaryProof);
255
249
 
@@ -274,7 +268,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
274
268
  convertMergeRollupOutputsFromWitnessMap,
275
269
  );
276
270
 
277
- const verificationKey = await this.getVerificationKeyDataForCircuit('MergeRollupArtifact');
271
+ const verificationKey = this.getVerificationKeyDataForCircuit('MergeRollupArtifact');
278
272
 
279
273
  await this.verifyProof('MergeRollupArtifact', proof.binaryProof);
280
274
 
@@ -299,7 +293,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
299
293
  convertBlockRootRollupOutputsFromWitnessMap,
300
294
  );
301
295
 
302
- const verificationKey = await this.getVerificationKeyDataForCircuit('BlockRootRollupArtifact');
296
+ const verificationKey = this.getVerificationKeyDataForCircuit('BlockRootRollupArtifact');
303
297
 
304
298
  await this.verifyProof('BlockRootRollupArtifact', proof.binaryProof);
305
299
 
@@ -319,7 +313,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
319
313
  convertSingleTxBlockRootRollupOutputsFromWitnessMap,
320
314
  );
321
315
 
322
- const verificationKey = await this.getVerificationKeyDataForCircuit('SingleTxBlockRootRollupArtifact');
316
+ const verificationKey = this.getVerificationKeyDataForCircuit('SingleTxBlockRootRollupArtifact');
323
317
 
324
318
  await this.verifyProof('SingleTxBlockRootRollupArtifact', proof.binaryProof);
325
319
 
@@ -344,7 +338,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
344
338
  convertEmptyBlockRootRollupOutputsFromWitnessMap,
345
339
  );
346
340
 
347
- const verificationKey = await this.getVerificationKeyDataForCircuit('EmptyBlockRootRollupArtifact');
341
+ const verificationKey = this.getVerificationKeyDataForCircuit('EmptyBlockRootRollupArtifact');
348
342
 
349
343
  await this.verifyProof('EmptyBlockRootRollupArtifact', proof.binaryProof);
350
344
 
@@ -369,7 +363,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
369
363
  convertBlockMergeRollupOutputsFromWitnessMap,
370
364
  );
371
365
 
372
- const verificationKey = await this.getVerificationKeyDataForCircuit('BlockMergeRollupArtifact');
366
+ const verificationKey = this.getVerificationKeyDataForCircuit('BlockMergeRollupArtifact');
373
367
 
374
368
  await this.verifyProof('BlockMergeRollupArtifact', proof.binaryProof);
375
369
 
@@ -393,7 +387,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
393
387
 
394
388
  const recursiveProof = makeRecursiveProofFromBinary(proof, NESTED_RECURSIVE_PROOF_LENGTH);
395
389
 
396
- const verificationKey = await this.getVerificationKeyDataForCircuit('RootRollupArtifact');
390
+ const verificationKey = this.getVerificationKeyDataForCircuit('RootRollupArtifact');
397
391
 
398
392
  await this.verifyProof('RootRollupArtifact', proof);
399
393
 
@@ -409,7 +403,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
409
403
  convertInput: (input: Input) => WitnessMap,
410
404
  convertOutput: (outputWitness: WitnessMap) => Output,
411
405
  workingDirectory: string,
412
- ): Promise<{ circuitOutput: Output; vkData: VerificationKeyData; provingResult: BBSuccess }> {
406
+ ): Promise<{ circuitOutput: Output; provingResult: BBSuccess }> {
413
407
  // Have the ACVM write the partial witness here
414
408
  const outputWitnessFile = path.join(workingDirectory, 'partial-witness.gz');
415
409
 
@@ -462,12 +456,8 @@ export class BBNativeRollupProver implements ServerCircuitProver {
462
456
  throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
463
457
  }
464
458
 
465
- // Ensure our vk cache is up to date
466
- const vkData = await this.updateVerificationKeyAfterProof(provingResult.vkPath!, circuitType);
467
-
468
459
  return {
469
460
  circuitOutput: output,
470
- vkData,
471
461
  provingResult,
472
462
  };
473
463
  }
@@ -479,15 +469,17 @@ export class BBNativeRollupProver implements ServerCircuitProver {
479
469
  convertOutput: (outputWitness: WitnessMap) => Output,
480
470
  ): Promise<{ circuitOutput: Output; proof: Proof }> {
481
471
  const operation = async (bbWorkingDirectory: string) => {
482
- const {
483
- provingResult,
484
- vkData,
485
- circuitOutput: output,
486
- } = await this.generateProofWithBB(input, circuitType, convertInput, convertOutput, bbWorkingDirectory);
472
+ const { provingResult, circuitOutput: output } = await this.generateProofWithBB(
473
+ input,
474
+ circuitType,
475
+ convertInput,
476
+ convertOutput,
477
+ bbWorkingDirectory,
478
+ );
487
479
 
488
480
  // Read the binary proof
489
481
  const rawProof = await fs.readFile(`${provingResult.proofPath!}/${PROOF_FILENAME}`);
490
-
482
+ const vkData = this.getVerificationKeyDataForCircuit(circuitType);
491
483
  const proof = new Proof(rawProof, vkData.numPublicInputs);
492
484
  const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
493
485
 
@@ -581,12 +573,12 @@ export class BBNativeRollupProver implements ServerCircuitProver {
581
573
  }
582
574
 
583
575
  public async getTubeProof(input: TubeInputs): Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>> {
584
- // this probably is gonna need to call client ivc
585
576
  const operation = async (bbWorkingDirectory: string) => {
586
577
  logger.debug(`createTubeProof: ${bbWorkingDirectory}`);
587
578
  const provingResult = await this.generateTubeProofWithBB(bbWorkingDirectory, input);
588
579
 
589
580
  // Read the proof as fields
581
+ // TODO(AD): this is the only remaining use of extractVkData.
590
582
  const tubeVK = await extractVkData(provingResult.vkPath!);
591
583
  const tubeProof = await this.readProofAsFields(provingResult.proofPath!, tubeVK, TUBE_PROOF_LENGTH);
592
584
 
@@ -631,12 +623,15 @@ export class BBNativeRollupProver implements ServerCircuitProver {
631
623
  ): Promise<{ circuitOutput: CircuitOutputType; proof: RecursiveProof<PROOF_LENGTH> }> {
632
624
  // this probably is gonna need to call client ivc
633
625
  const operation = async (bbWorkingDirectory: string) => {
634
- const {
635
- provingResult,
636
- vkData,
637
- circuitOutput: output,
638
- } = await this.generateProofWithBB(input, circuitType, convertInput, convertOutput, bbWorkingDirectory);
626
+ const { provingResult, circuitOutput: output } = await this.generateProofWithBB(
627
+ input,
628
+ circuitType,
629
+ convertInput,
630
+ convertOutput,
631
+ bbWorkingDirectory,
632
+ );
639
633
 
634
+ const vkData = this.getVerificationKeyDataForCircuit(circuitType);
640
635
  // Read the proof as fields
641
636
  const proof = await this.readProofAsFields(provingResult.proofPath!, vkData, proofLength);
642
637
 
@@ -674,7 +669,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
674
669
  * @param proof - The proof to be verified
675
670
  */
676
671
  public async verifyProof(circuitType: ServerProtocolArtifact, proof: Proof) {
677
- const verificationKey = await this.getVerificationKeyDataForCircuit(circuitType);
672
+ const verificationKey = this.getVerificationKeyDataForCircuit(circuitType);
678
673
  return await this.verifyWithKey(getUltraHonkFlavorForCircuit(circuitType), verificationKey, proof);
679
674
  }
680
675
 
@@ -715,16 +710,6 @@ export class BBNativeRollupProver implements ServerCircuitProver {
715
710
  await this.runInDirectory(operation);
716
711
  }
717
712
 
718
- /**
719
- * Returns the verification key for a circuit, will generate it if not cached internally
720
- * @param circuitType - The type of circuit for which the verification key is required
721
- * @returns The verification key
722
- */
723
- public async getVerificationKeyForCircuit(circuitType: ServerProtocolArtifact): Promise<VerificationKeyAsFields> {
724
- const vkData = await this.getVerificationKeyDataForCircuit(circuitType);
725
- return vkData.clone().keyAsFields;
726
- }
727
-
728
713
  /**
729
714
  * Will check a recursive proof argument for validity of it's 'fields' format of proof and convert if required
730
715
  * @param proof - The input proof that may need converting
@@ -789,54 +774,16 @@ export class BBNativeRollupProver implements ServerCircuitProver {
789
774
  }
790
775
 
791
776
  /**
792
- * Returns the verification key data for a circuit, will generate and cache it if not cached internally
777
+ * Returns the verification key data for a circuit.
793
778
  * @param circuitType - The type of circuit for which the verification key is required
794
779
  * @returns The verification key data
795
780
  */
796
- private async getVerificationKeyDataForCircuit(circuitType: ServerProtocolArtifact): Promise<VerificationKeyData> {
797
- const flavor = getUltraHonkFlavorForCircuit(circuitType);
798
- let promise = this.verificationKeys.get(`${flavor}_${circuitType}`);
799
- if (!promise) {
800
- promise = generateKeyForNoirCircuit(
801
- this.config.bbBinaryPath,
802
- this.config.bbWorkingDirectory,
803
- circuitType,
804
- ServerCircuitArtifacts[circuitType],
805
- SERVER_CIRCUIT_RECURSIVE,
806
- flavor,
807
- logger.debug,
808
- ).then(result => {
809
- if (result.status === BB_RESULT.FAILURE) {
810
- throw new ProvingError(
811
- `Failed to generate verification key for ${circuitType}, ${result.reason}`,
812
- result,
813
- result.retry,
814
- );
815
- }
816
- return extractVkData(result.vkPath!);
817
- });
818
- this.verificationKeys.set(`${flavor}_${circuitType}`, promise);
819
- }
820
- const vk = await promise;
821
- return vk.clone();
822
- }
823
-
824
- /**
825
- * Ensures our verification key cache includes the key data located at the specified directory
826
- * @param filePath - The directory containing the verification key data files
827
- * @param circuitType - The type of circuit to which the verification key corresponds
828
- */
829
- private async updateVerificationKeyAfterProof(
830
- filePath: string,
831
- circuitType: ServerProtocolArtifact,
832
- ): Promise<VerificationKeyData> {
833
- const flavor = getUltraHonkFlavorForCircuit(circuitType);
834
- let promise = this.verificationKeys.get(`${flavor}_${circuitType}`);
835
- if (!promise) {
836
- promise = extractVkData(filePath);
837
- this.verificationKeys.set(`${flavor}_${circuitType}`, promise);
781
+ private getVerificationKeyDataForCircuit(circuitType: ServerProtocolArtifact): VerificationKeyData {
782
+ const vk = ServerCircuitVks[circuitType];
783
+ if (vk === undefined) {
784
+ throw new Error('Could not find VK for server artifact ' + circuitType);
838
785
  }
839
- return promise;
786
+ return vk;
840
787
  }
841
788
 
842
789
  private async readProofAsFields<PROOF_LENGTH extends number>(
@@ -6,7 +6,6 @@ import {
6
6
  Gas,
7
7
  GlobalVariables,
8
8
  L2ToL1Message,
9
- LogHash,
10
9
  MAX_ENQUEUED_CALLS_PER_CALL,
11
10
  MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL,
12
11
  MAX_L2_TO_L1_MSGS_PER_CALL,
@@ -17,11 +16,12 @@ import {
17
16
  MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
18
17
  MAX_PUBLIC_DATA_READS_PER_CALL,
19
18
  MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
20
- MAX_UNENCRYPTED_LOGS_PER_CALL,
19
+ MAX_PUBLIC_LOGS_PER_CALL,
21
20
  NoteHash,
22
21
  Nullifier,
23
22
  PublicCircuitPublicInputs,
24
23
  PublicInnerCallRequest,
24
+ PublicLog,
25
25
  ReadRequest,
26
26
  RevertCode,
27
27
  TreeLeafReadRequest,
@@ -73,7 +73,7 @@ export function getPublicInputs(result: PublicFunctionCallResult): PublicCircuit
73
73
  MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
74
74
  ),
75
75
  publicCallRequests: padArrayEnd([], PublicInnerCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_CALL),
76
- unencryptedLogsHashes: padArrayEnd(result.unencryptedLogsHashes, LogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_CALL),
76
+ publicLogs: padArrayEnd(result.publicLogs, PublicLog.empty(), MAX_PUBLIC_LOGS_PER_CALL),
77
77
  historicalHeader: BlockHeader.empty(),
78
78
  globalVariables: GlobalVariables.empty(),
79
79
  startGasLeft: Gas.from(result.startGasLeft),