@aztec/bb-prover 0.87.3-nightly.20250528 → 0.87.3

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
- AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
3
- AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED,
2
+ AVM_PROOF_LENGTH_IN_FIELDS,
3
+ AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS,
4
4
  NESTED_RECURSIVE_PROOF_LENGTH,
5
5
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
6
6
  RECURSIVE_PROOF_LENGTH,
@@ -302,16 +302,14 @@ export class TestCircuitProver implements ServerCircuitProver {
302
302
  );
303
303
  }
304
304
 
305
- public getAvmProof(
306
- _inputs: AvmCircuitInputs,
307
- ): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
305
+ public getAvmProof(_inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>> {
308
306
  // We can't simulate the AVM because we don't have enough context to do so (e.g., DBs).
309
307
  // We just return an empty proof and VK data.
310
308
  this.logger.debug('Skipping AVM simulation in TestCircuitProver.');
311
309
  return this.applyDelay(ProvingRequestType.PUBLIC_VM, () =>
312
310
  makeProofAndVerificationKey(
313
- makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
314
- VerificationKeyData.makeFake(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED),
311
+ makeEmptyRecursiveProof(AVM_PROOF_LENGTH_IN_FIELDS),
312
+ VerificationKeyData.makeFake(AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS),
315
313
  ),
316
314
  );
317
315
  }
@@ -1,6 +1,5 @@
1
- import { AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED } from '@aztec/constants';
1
+ import { AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
- import { BufferReader } from '@aztec/foundation/serialize';
4
3
  import { hashVK } from '@aztec/stdlib/hash';
5
4
  import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
6
5
 
@@ -28,25 +27,19 @@ export async function extractVkData(vkDirectoryPath: string): Promise<Verificati
28
27
  return new VerificationKeyData(vkAsFields, rawBinary);
29
28
  }
30
29
 
31
- /**
32
- * Reads the verification key data stored in a binary file at the specified directory location and parses into a VerificationKeyData.
33
- * We do not assume any JSON file available but only the binary version, contrary to the above extractVkData() method.
34
- * @param vkDirectoryPath - The directory containing the verification key binary data file.
35
- * @returns The verification key data
36
- */
30
+ // TODO: This was adapted from the above function. A refactor might be needed.
37
31
  export async function extractAvmVkData(vkDirectoryPath: string): Promise<VerificationKeyData> {
38
- const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
39
-
40
- const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
41
- assert(numFields <= AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED, 'Invalid AVM verification key length');
42
- const reader = BufferReader.asReader(rawBinary);
43
- const fieldsArray = reader.readArray(numFields, Fr);
44
-
45
- const fieldsArrayPadded = fieldsArray.concat(
46
- Array(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED - fieldsArray.length).fill(new Fr(0)),
47
- );
48
- // Currently, we do not need the vk hash for the AVM as we are not adding in the vk tree.
49
- const vkAsFields = new VerificationKeyAsFields(fieldsArrayPadded, new Fr(0));
32
+ const [rawFields, rawBinary] = await Promise.all([
33
+ fs.readFile(path.join(vkDirectoryPath, VK_FIELDS_FILENAME), { encoding: 'utf-8' }),
34
+ fs.readFile(path.join(vkDirectoryPath, VK_FILENAME)),
35
+ ]);
36
+ const fieldsJson = JSON.parse(rawFields);
37
+ const fields = fieldsJson.map(Fr.fromHexString);
38
+ // The first item is the hash, this is not part of the actual VK
39
+ // TODO: is the above actually the case?
40
+ const vkHash = fields[0];
41
+ assert(fields.length === AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, 'Invalid AVM verification key length');
42
+ const vkAsFields = new VerificationKeyAsFields(fields, vkHash);
50
43
  const vk = new VerificationKeyData(vkAsFields, rawBinary);
51
44
  return vk;
52
45
  }