@aztec/bb-prover 0.83.1 → 0.84.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.
@@ -1 +1 @@
1
- {"version":3,"file":"bb_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,0BAA0B,EAE1B,6BAA6B,EAC7B,yCAAyC,EACzC,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EACL,KAAK,sBAAsB,EAsB5B,MAAM,4CAA4C,CAAC;AAIpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EAGzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,KAAK,EAAgD,MAAM,sBAAsB,CAAC;AAC3F,OAAO,KAAK,EACV,6BAA6B,EAC7B,sBAAsB,EACtB,iCAAiC,EACjC,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,6BAA6B,EAC7B,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAc,KAAK,eAAe,EAAiC,MAAM,yBAAyB,CAAC;AAqB1G,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,KAAK,eAAe,EAAgC,MAAM,YAAY,CAAC;AAYhF,MAAM,WAAW,cAAe,SAAQ,QAAQ,EAAE,UAAU;IAE1D,aAAa,CAAC,EAAE,sBAAsB,EAA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,CAAC,sBAAsB,CAAC,CAAC;YAkBnD,mBAAmB;YAqEnB,WAAW;YAyCX,sBAAsB;YAatB,uBAAuB;YAsBvB,cAAc;IAsCf,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,OAAO,iBAAiB,CAAC,CAAC;IA6BxG;;;;;;;;OAQG;YACW,oBAAoB;IAqDlC;;;;OAIG;IACU,WAAW,CAAC,WAAW,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK;IAK7D,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,mBAAmB;IAMjE,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK;YAMxF,qBAAqB;IA2BnC;;;;OAIG;IACH,OAAO,CAAC,gCAAgC;YAQ1B,iBAAiB;YAgDjB,oBAAoB;IAelC,OAAO,CAAC,cAAc;CAYvB"}
@@ -17,7 +17,7 @@ import { ProvingError } from '@aztec/stdlib/errors';
17
17
  import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
18
18
  import { Proof, RecursiveProof, makeRecursiveProofFromBinary } from '@aztec/stdlib/proofs';
19
19
  import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
20
- import { assert } from 'console';
20
+ import assert from 'assert';
21
21
  import crypto from 'crypto';
22
22
  import { promises as fs } from 'fs';
23
23
  import * as path from 'path';
@@ -353,8 +353,9 @@ const SERVER_CIRCUIT_RECURSIVE = true;
353
353
  const publicInputsFileName = path.join(bbWorkingDirectory, PUBLIC_INPUTS_FILENAME);
354
354
  const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
355
355
  const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
356
- await fs.writeFile(publicInputsFileName, proof.buffer.slice(0, proof.numPublicInputs * 32 + 4));
357
- await fs.writeFile(proofFileName, proof.buffer.slice(proof.numPublicInputs * 32 + 4));
356
+ // TODO(https://github.com/AztecProtocol/aztec-packages/issues/13189): Put this proof parsing logic in the proof class.
357
+ await fs.writeFile(publicInputsFileName, proof.buffer.slice(0, proof.numPublicInputs * 32));
358
+ await fs.writeFile(proofFileName, proof.buffer.slice(proof.numPublicInputs * 32));
358
359
  await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
359
360
  const result = await verificationFunction(proofFileName, verificationKeyPath);
360
361
  if (result.status === BB_RESULT.FAILURE) {
@@ -389,21 +390,20 @@ const SERVER_CIRCUIT_RECURSIVE = true;
389
390
  ]);
390
391
  const json = JSON.parse(proofString);
391
392
  let numPublicInputs = vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
393
+ assert(proofLength == NESTED_RECURSIVE_PROOF_LENGTH || proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, `Proof length must be one of the expected proof lengths, received ${proofLength}`);
392
394
  if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
393
395
  numPublicInputs -= IPA_CLAIM_LENGTH;
394
396
  }
395
- assert(json.length == proofLength, 'Proof length mismatch');
397
+ assert(json.length == proofLength, `Proof length mismatch: ${json.length} != ${proofLength}`);
396
398
  const fieldsWithoutPublicInputs = json.map(Fr.fromHexString);
397
399
  // Concat binary public inputs and binary proof
398
- // This buffer will have the form: [4 bytes of metadata for public inputs, binary public inputs, 4 bytes of metadata for proof, binary proof]
400
+ // This buffer will have the form: [binary public inputs, binary proof]
399
401
  const binaryProofWithPublicInputs = Buffer.concat([
400
402
  binaryPublicInputs,
401
403
  binaryProof
402
404
  ]);
403
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1312): Get rid of if possible.
404
- const metadataLength = 4;
405
- assert(binaryProofWithPublicInputs.length == metadataLength + numPublicInputs * 32 + metadataLength + NESTED_RECURSIVE_PROOF_LENGTH * 32);
406
405
  logger.debug(`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProofWithPublicInputs.length}`);
406
+ assert(binaryProofWithPublicInputs.length == numPublicInputs * 32 + proofLength * 32, `Proof length mismatch: ${binaryProofWithPublicInputs.length} != ${numPublicInputs * 32 + proofLength * 32}`);
407
407
  return new RecursiveProof(fieldsWithoutPublicInputs, new Proof(binaryProofWithPublicInputs, numPublicInputs), true, proofLength);
408
408
  }
409
409
  async readAvmProofAsFields(proofFilename, vkData) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/bb-prover",
3
- "version": "0.83.1",
3
+ "version": "0.84.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -68,16 +68,16 @@
68
68
  ]
69
69
  },
70
70
  "dependencies": {
71
- "@aztec/bb.js": "0.83.1",
72
- "@aztec/constants": "0.83.1",
73
- "@aztec/foundation": "0.83.1",
74
- "@aztec/noir-noirc_abi": "0.83.1",
75
- "@aztec/noir-protocol-circuits-types": "0.83.1",
76
- "@aztec/noir-types": "0.83.1",
77
- "@aztec/simulator": "0.83.1",
78
- "@aztec/stdlib": "0.83.1",
79
- "@aztec/telemetry-client": "0.83.1",
80
- "@aztec/world-state": "0.83.1",
71
+ "@aztec/bb.js": "0.84.0",
72
+ "@aztec/constants": "0.84.0",
73
+ "@aztec/foundation": "0.84.0",
74
+ "@aztec/noir-noirc_abi": "0.84.0",
75
+ "@aztec/noir-protocol-circuits-types": "0.84.0",
76
+ "@aztec/noir-types": "0.84.0",
77
+ "@aztec/simulator": "0.84.0",
78
+ "@aztec/stdlib": "0.84.0",
79
+ "@aztec/telemetry-client": "0.84.0",
80
+ "@aztec/world-state": "0.84.0",
81
81
  "@msgpack/msgpack": "^3.0.0-beta2",
82
82
  "commander": "^12.1.0",
83
83
  "pako": "^2.1.0",
@@ -85,10 +85,10 @@
85
85
  "tslib": "^2.4.0"
86
86
  },
87
87
  "devDependencies": {
88
- "@aztec/ethereum": "0.83.1",
89
- "@aztec/kv-store": "0.83.1",
90
- "@aztec/noir-contracts.js": "0.83.1",
91
- "@aztec/protocol-contracts": "0.83.1",
88
+ "@aztec/ethereum": "0.84.0",
89
+ "@aztec/kv-store": "0.84.0",
90
+ "@aztec/noir-contracts.js": "0.84.0",
91
+ "@aztec/protocol-contracts": "0.84.0",
92
92
  "@jest/globals": "^29.5.0",
93
93
  "@types/jest": "^29.5.0",
94
94
  "@types/memdown": "^3.0.0",
@@ -69,7 +69,7 @@ import type { CircuitProvingStats, CircuitWitnessGenerationStats } from '@aztec/
69
69
  import type { VerificationKeyData } from '@aztec/stdlib/vks';
70
70
  import { Attributes, type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
71
71
 
72
- import { assert } from 'console';
72
+ import assert from 'assert';
73
73
  import crypto from 'crypto';
74
74
  import { promises as fs } from 'fs';
75
75
  import * as path from 'path';
@@ -697,8 +697,9 @@ export class BBNativeRollupProver implements ServerCircuitProver {
697
697
  const publicInputsFileName = path.join(bbWorkingDirectory, PUBLIC_INPUTS_FILENAME);
698
698
  const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
699
699
  const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
700
- await fs.writeFile(publicInputsFileName, proof.buffer.slice(0, proof.numPublicInputs * 32 + 4));
701
- await fs.writeFile(proofFileName, proof.buffer.slice(proof.numPublicInputs * 32 + 4));
700
+ // TODO(https://github.com/AztecProtocol/aztec-packages/issues/13189): Put this proof parsing logic in the proof class.
701
+ await fs.writeFile(publicInputsFileName, proof.buffer.slice(0, proof.numPublicInputs * 32));
702
+ await fs.writeFile(proofFileName, proof.buffer.slice(proof.numPublicInputs * 32));
702
703
  await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
703
704
 
704
705
  const result = await verificationFunction(proofFileName, verificationKeyPath!);
@@ -745,26 +746,28 @@ export class BBNativeRollupProver implements ServerCircuitProver {
745
746
  const json = JSON.parse(proofString);
746
747
 
747
748
  let numPublicInputs = vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
749
+ assert(
750
+ proofLength == NESTED_RECURSIVE_PROOF_LENGTH || proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
751
+ `Proof length must be one of the expected proof lengths, received ${proofLength}`,
752
+ );
748
753
  if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
749
754
  numPublicInputs -= IPA_CLAIM_LENGTH;
750
755
  }
751
756
 
752
- assert(json.length == proofLength, 'Proof length mismatch');
757
+ assert(json.length == proofLength, `Proof length mismatch: ${json.length} != ${proofLength}`);
753
758
 
754
759
  const fieldsWithoutPublicInputs = json.map(Fr.fromHexString);
755
760
 
756
761
  // Concat binary public inputs and binary proof
757
- // This buffer will have the form: [4 bytes of metadata for public inputs, binary public inputs, 4 bytes of metadata for proof, binary proof]
762
+ // This buffer will have the form: [binary public inputs, binary proof]
758
763
  const binaryProofWithPublicInputs = Buffer.concat([binaryPublicInputs, binaryProof]);
759
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1312): Get rid of if possible.
760
- const metadataLength = 4;
761
- assert(
762
- binaryProofWithPublicInputs.length ==
763
- metadataLength + numPublicInputs * 32 + metadataLength + NESTED_RECURSIVE_PROOF_LENGTH * 32,
764
- );
765
764
  logger.debug(
766
765
  `Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProofWithPublicInputs.length}`,
767
766
  );
767
+ assert(
768
+ binaryProofWithPublicInputs.length == numPublicInputs * 32 + proofLength * 32,
769
+ `Proof length mismatch: ${binaryProofWithPublicInputs.length} != ${numPublicInputs * 32 + proofLength * 32}`,
770
+ );
768
771
  return new RecursiveProof(
769
772
  fieldsWithoutPublicInputs,
770
773
  new Proof(binaryProofWithPublicInputs, numPublicInputs),