@aztec/bb-prover 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108

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 (93) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +7 -6
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
  3. package/dest/avm_proving_tests/avm_proving_tester.js +33 -13
  4. package/dest/bb/cli.d.ts +1 -1
  5. package/dest/bb/execute.d.ts +5 -13
  6. package/dest/bb/execute.d.ts.map +1 -1
  7. package/dest/bb/execute.js +30 -92
  8. package/dest/bb/index.d.ts +1 -1
  9. package/dest/config.d.ts +1 -1
  10. package/dest/honk.d.ts +2 -2
  11. package/dest/honk.js +2 -2
  12. package/dest/index.d.ts +1 -1
  13. package/dest/instrumentation.d.ts +3 -3
  14. package/dest/instrumentation.d.ts.map +1 -1
  15. package/dest/prover/client/bb_private_kernel_prover.d.ts +12 -6
  16. package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
  17. package/dest/prover/client/bb_private_kernel_prover.js +36 -7
  18. package/dest/prover/client/bundle.d.ts +6 -0
  19. package/dest/prover/client/bundle.d.ts.map +1 -0
  20. package/dest/prover/client/bundle.js +7 -0
  21. package/dest/prover/client/lazy.d.ts +6 -0
  22. package/dest/prover/client/lazy.d.ts.map +1 -0
  23. package/dest/prover/client/lazy.js +7 -0
  24. package/dest/prover/index.d.ts +1 -1
  25. package/dest/prover/proof_utils.d.ts +9 -9
  26. package/dest/prover/proof_utils.d.ts.map +1 -1
  27. package/dest/prover/proof_utils.js +42 -25
  28. package/dest/prover/server/bb_prover.d.ts +23 -43
  29. package/dest/prover/server/bb_prover.d.ts.map +1 -1
  30. package/dest/prover/server/bb_prover.js +464 -165
  31. package/dest/test/delay_values.d.ts +1 -1
  32. package/dest/test/delay_values.d.ts.map +1 -1
  33. package/dest/test/delay_values.js +37 -25
  34. package/dest/test/index.d.ts +2 -1
  35. package/dest/test/index.d.ts.map +1 -1
  36. package/dest/test/index.js +1 -0
  37. package/dest/test/test_circuit_prover.d.ts +21 -31
  38. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  39. package/dest/test/test_circuit_prover.js +503 -81
  40. package/dest/test/test_verifier.d.ts +3 -1
  41. package/dest/test/test_verifier.d.ts.map +1 -1
  42. package/dest/test/test_verifier.js +15 -0
  43. package/dest/verification_key/verification_key_data.d.ts +1 -1
  44. package/dest/verification_key/verification_key_data.js +1 -1
  45. package/dest/verifier/bb_verifier.d.ts +3 -5
  46. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  47. package/dest/verifier/bb_verifier.js +24 -26
  48. package/dest/verifier/index.d.ts +2 -2
  49. package/dest/verifier/index.d.ts.map +1 -1
  50. package/dest/verifier/index.js +1 -1
  51. package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
  52. package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
  53. package/dest/verifier/{queued_ivc_verifier.js → queued_chonk_verifier.js} +3 -3
  54. package/package.json +23 -23
  55. package/src/avm_proving_tests/avm_proving_tester.ts +43 -19
  56. package/src/bb/execute.ts +20 -90
  57. package/src/honk.ts +1 -1
  58. package/src/instrumentation.ts +2 -2
  59. package/src/prover/client/bb_private_kernel_prover.ts +49 -10
  60. package/src/prover/client/bundle.ts +10 -0
  61. package/src/prover/client/lazy.ts +10 -0
  62. package/src/prover/proof_utils.ts +53 -31
  63. package/src/prover/server/bb_prover.ts +231 -293
  64. package/src/test/delay_values.ts +38 -24
  65. package/src/test/index.ts +1 -0
  66. package/src/test/test_circuit_prover.ts +219 -142
  67. package/src/test/test_verifier.ts +8 -0
  68. package/src/verification_key/verification_key_data.ts +1 -1
  69. package/src/verifier/bb_verifier.ts +34 -33
  70. package/src/verifier/index.ts +1 -1
  71. package/src/verifier/{queued_ivc_verifier.ts → queued_chonk_verifier.ts} +3 -3
  72. package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts +0 -23
  73. package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts.map +0 -1
  74. package/dest/prover/client/native/bb_native_private_kernel_prover.js +0 -66
  75. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts +0 -15
  76. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
  77. package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.js +0 -48
  78. package/dest/prover/client/wasm/bundle.d.ts +0 -6
  79. package/dest/prover/client/wasm/bundle.d.ts.map +0 -1
  80. package/dest/prover/client/wasm/bundle.js +0 -8
  81. package/dest/prover/client/wasm/lazy.d.ts +0 -6
  82. package/dest/prover/client/wasm/lazy.d.ts.map +0 -1
  83. package/dest/prover/client/wasm/lazy.js +0 -8
  84. package/dest/stats.d.ts +0 -4
  85. package/dest/stats.d.ts.map +0 -1
  86. package/dest/stats.js +0 -45
  87. package/dest/verifier/queued_ivc_verifier.d.ts +0 -15
  88. package/dest/verifier/queued_ivc_verifier.d.ts.map +0 -1
  89. package/src/prover/client/native/bb_native_private_kernel_prover.ts +0 -105
  90. package/src/prover/client/wasm/bb_wasm_private_kernel_prover.ts +0 -60
  91. package/src/prover/client/wasm/bundle.ts +0 -11
  92. package/src/prover/client/wasm/lazy.ts +0 -11
  93. package/src/stats.ts +0 -47
@@ -1,8 +1,13 @@
1
1
  import { runInDirectory } from '@aztec/foundation/fs';
2
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
3
3
  import { Timer } from '@aztec/foundation/timer';
4
- import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
5
- import type { ClientProtocolArtifact, ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
4
+ import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
5
+ import {
6
+ type ClientProtocolArtifact,
7
+ type ProtocolArtifact,
8
+ type ServerProtocolArtifact,
9
+ mapProtocolArtifactNameToCircuitName,
10
+ } from '@aztec/noir-protocol-circuits-types/types';
6
11
  import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
7
12
  import type { Proof } from '@aztec/stdlib/proofs';
8
13
  import type { CircuitVerificationStats } from '@aztec/stdlib/stats';
@@ -11,26 +16,18 @@ import type { VerificationKeyData } from '@aztec/stdlib/vks';
11
16
 
12
17
  import { promises as fs } from 'fs';
13
18
  import * as path from 'path';
14
- import { fileURLToPath } from 'url';
15
19
 
16
20
  import {
17
21
  BB_RESULT,
18
22
  PROOF_FILENAME,
19
23
  PUBLIC_INPUTS_FILENAME,
20
24
  VK_FILENAME,
21
- verifyClientIvcProof,
25
+ verifyChonkProof,
22
26
  verifyProof,
23
27
  } from '../bb/execute.js';
24
28
  import type { BBConfig } from '../config.js';
25
29
  import { getUltraHonkFlavorForCircuit } from '../honk.js';
26
- import { writeClientIVCProofToOutputDirectory } from '../prover/proof_utils.js';
27
- import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
28
-
29
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
30
-
31
- // Built by yarn generate
32
- export const PRIVATE_TAIL_CIVC_VK = path.join(__dirname, '../../artifacts/private-civc-vk');
33
- export const PUBLIC_TAIL_CIVC_VK = path.join(__dirname, '../../artifacts/public-civc-vk');
30
+ import { writeChonkProofToPath } from '../prover/proof_utils.js';
34
31
 
35
32
  export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
36
33
  private constructor(
@@ -43,14 +40,17 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
43
40
  }
44
41
 
45
42
  public static async new(config: BBConfig, logger = createLogger('bb-prover:verifier')) {
43
+ if (!config.bbWorkingDirectory) {
44
+ throw new Error(`Barretenberg working directory (BB_WORKING_DIRECTORY) is not set`);
45
+ }
46
46
  await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
47
47
  return new BBCircuitVerifier(config, logger);
48
48
  }
49
49
 
50
- public getVerificationKeyData(circuitType: ServerProtocolArtifact): VerificationKeyData {
51
- const vk = ServerCircuitVks[circuitType];
50
+ public getVerificationKeyData(circuit: ProtocolArtifact): VerificationKeyData {
51
+ const vk = ProtocolCircuitVks[circuit];
52
52
  if (vk === undefined) {
53
- throw new Error('Could not find VK for server artifact ' + circuitType);
53
+ throw new Error(`Could not find VK for artifact ${circuit}`);
54
54
  }
55
55
  return vk;
56
56
  }
@@ -93,51 +93,52 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
93
93
  }
94
94
 
95
95
  public async verifyProof(tx: Tx): Promise<IVCProofVerificationResult> {
96
+ const proofType = 'Chonk';
96
97
  try {
97
98
  const totalTimer = new Timer();
98
99
  let verificationDuration = 0;
99
- // TODO(#7370) The verification keys should be supplied separately and based on the expectedCircuit
100
- // rather than read from the tx object itself. We also need the vks for the translator and ecc, which
101
- // are not being saved along the other vks yet. Reuse the 'verifyProofForCircuit' method above once
102
- // we have all the verification keys available.
103
- const expectedCircuit: ClientProtocolArtifact = tx.data.forPublic
104
- ? 'PrivateKernelTailToPublicArtifact'
105
- : 'PrivateKernelTailArtifact';
106
- const circuit = 'ClientIVC';
100
+
101
+ const circuit: ClientProtocolArtifact = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
107
102
 
108
103
  // Block below is almost copy-pasted from verifyProofForCircuit
109
104
  const operation = async (bbWorkingDirectory: string) => {
110
105
  const logFunction = (message: string) => {
111
- this.logger.debug(`${circuit} BB out - ${message}`);
106
+ this.logger.debug(`${proofType} BB out - ${message}`);
112
107
  };
113
108
 
114
- await writeClientIVCProofToOutputDirectory(tx.clientIvcProof, bbWorkingDirectory);
109
+ const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
110
+ await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
111
+
112
+ const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
113
+ const verificationKey = this.getVerificationKeyData(circuit);
114
+ await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
115
+
115
116
  const timer = new Timer();
116
- const result = await verifyClientIvcProof(
117
+ const result = await verifyChonkProof(
117
118
  this.config.bbBinaryPath,
118
- bbWorkingDirectory.concat('/proof'),
119
- tx.data.forPublic ? PUBLIC_TAIL_CIVC_VK : PRIVATE_TAIL_CIVC_VK,
119
+ proofPath,
120
+ verificationKeyPath,
120
121
  logFunction,
121
122
  this.config.bbIVCConcurrency,
122
123
  );
123
124
  verificationDuration = timer.ms();
124
125
 
125
126
  if (result.status === BB_RESULT.FAILURE) {
126
- const errorMessage = `Failed to verify ${circuit} proof for ${expectedCircuit}!`;
127
+ const errorMessage = `Failed to verify ${proofType} proof for ${circuit}!`;
127
128
  throw new Error(errorMessage);
128
129
  }
129
130
 
130
- this.logger.debug(`${circuit} verification successful`, {
131
- circuitName: mapProtocolArtifactNameToCircuitName(expectedCircuit),
131
+ this.logger.debug(`${proofType} verification successful`, {
132
+ circuitName: mapProtocolArtifactNameToCircuitName(circuit),
132
133
  duration: result.durationMs,
133
134
  eventName: 'circuit-verification',
134
- proofType: 'client-ivc',
135
+ proofType: 'chonk',
135
136
  } satisfies CircuitVerificationStats);
136
137
  };
137
138
  await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
138
139
  return { valid: true, durationMs: verificationDuration, totalDurationMs: totalTimer.ms() };
139
140
  } catch (err) {
140
- this.logger.warn(`Failed to verify ClientIVC proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
141
+ this.logger.warn(`Failed to verify ${proofType} proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
141
142
  return { valid: false, durationMs: 0, totalDurationMs: 0 };
142
143
  }
143
144
  }
@@ -1,2 +1,2 @@
1
1
  export * from './bb_verifier.js';
2
- export * from './queued_ivc_verifier.js';
2
+ export * from './queued_chonk_verifier.js';
@@ -38,13 +38,13 @@ class IVCVerifierMetrics {
38
38
 
39
39
  this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME, {
40
40
  unit: 'ms',
41
- description: 'Duration to verify client IVC proofs',
41
+ description: 'Duration to verify chonk proofs',
42
42
  valueType: ValueType.INT,
43
43
  });
44
44
 
45
45
  this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
46
46
  unit: 'ms',
47
- description: 'Total duration to verify client IVC proofs, including serde',
47
+ description: 'Total duration to verify chonk proofs, including serde',
48
48
  valueType: ValueType.INT,
49
49
  });
50
50
 
@@ -120,7 +120,7 @@ export class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
120
120
  config: BBConfig,
121
121
  private verifier: ClientProtocolCircuitVerifier,
122
122
  private telemetry: TelemetryClient = getTelemetryClient(),
123
- private logger = createLogger('bb-prover:queued_ivc_verifier'),
123
+ private logger = createLogger('bb-prover:queued_chonk_verifier'),
124
124
  ) {
125
125
  this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
126
126
  this.queue = new SerialQueue();
@@ -1,23 +0,0 @@
1
- import { type Logger } from '@aztec/foundation/log';
2
- import type { CircuitSimulator } from '@aztec/simulator/server';
3
- import { type PrivateExecutionStep } from '@aztec/stdlib/kernel';
4
- import type { ClientIvcProof } from '@aztec/stdlib/proofs';
5
- import type { BBConfig } from '../../../config.js';
6
- import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
7
- /**
8
- * This proof creator implementation uses the native bb binary.
9
- */
10
- export declare class BBNativePrivateKernelProver extends BBPrivateKernelProver {
11
- private bbBinaryPath;
12
- private bbWorkingDirectory;
13
- private skipCleanup;
14
- protected simulator: CircuitSimulator;
15
- protected log: Logger;
16
- private constructor();
17
- static new(config: BBConfig, simulator: CircuitSimulator, log?: Logger): Promise<BBNativePrivateKernelProver>;
18
- private _createClientIvcProof;
19
- createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof>;
20
- computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number>;
21
- private runInDirectory;
22
- }
23
- //# sourceMappingURL=bb_native_private_kernel_prover.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bb_native_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/native/bb_native_private_kernel_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,KAAK,oBAAoB,EAAkC,MAAM,sBAAsB,CAAC;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAM3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,qBAAqB;IAElE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,WAAW;cACA,SAAS,EAAE,gBAAgB;cAC3B,GAAG;IALxB,OAAO;WAUa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,MAAM;YAWrE,qBAAqB;IAuBb,oBAAoB,CAAC,cAAc,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAQrF,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxG,OAAO,CAAC,cAAc;CAavB"}
@@ -1,66 +0,0 @@
1
- import { runInDirectory } from '@aztec/foundation/fs';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
4
- import { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
5
- import { promises as fs } from 'fs';
6
- import path from 'path';
7
- import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../../../bb/execute.js';
8
- import { readClientIVCProofFromOutputDirectory } from '../../proof_utils.js';
9
- import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
10
- /**
11
- * This proof creator implementation uses the native bb binary.
12
- */ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
13
- bbBinaryPath;
14
- bbWorkingDirectory;
15
- skipCleanup;
16
- simulator;
17
- log;
18
- constructor(bbBinaryPath, bbWorkingDirectory, skipCleanup, simulator, log = createLogger('bb-prover:native')){
19
- super(new BundleArtifactProvider(), simulator, log), this.bbBinaryPath = bbBinaryPath, this.bbWorkingDirectory = bbWorkingDirectory, this.skipCleanup = skipCleanup, this.simulator = simulator, this.log = log;
20
- }
21
- static async new(config, simulator, log) {
22
- await fs.mkdir(config.bbWorkingDirectory, {
23
- recursive: true
24
- });
25
- return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, simulator, log);
26
- }
27
- async _createClientIvcProof(directory, executionSteps) {
28
- const inputsPath = path.join(directory, 'ivc-inputs.msgpack');
29
- await fs.writeFile(inputsPath, serializePrivateExecutionSteps(executionSteps));
30
- const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, inputsPath, this.log.info);
31
- if (provingResult.status === BB_RESULT.FAILURE) {
32
- this.log.error(`Failed to generate client ivc proof`);
33
- throw new Error(provingResult.reason);
34
- }
35
- const proof = await readClientIVCProofFromOutputDirectory(directory);
36
- this.log.info(`Generated IVC proof`, {
37
- duration: provingResult.durationMs,
38
- eventName: 'circuit-proving'
39
- });
40
- return proof;
41
- }
42
- async createClientIvcProof(executionSteps) {
43
- this.log.info(`Generating Client IVC proof`);
44
- const operation = async (directory)=>{
45
- return await this._createClientIvcProof(directory, executionSteps);
46
- };
47
- return await this.runInDirectory(operation);
48
- }
49
- async computeGateCountForCircuit(bytecode, circuitName) {
50
- const logFunction = (message)=>{
51
- this.log.debug(`$bb gates ${circuitName} - ${message}`);
52
- };
53
- const result = await computeGateCountForCircuit(this.bbBinaryPath, this.bbWorkingDirectory, circuitName, bytecode, 'mega_honk', logFunction);
54
- if (result.status === BB_RESULT.FAILURE) {
55
- throw new Error(result.reason);
56
- }
57
- return result.circuitSize;
58
- }
59
- runInDirectory(fn) {
60
- const log = this.log;
61
- return runInDirectory(this.bbWorkingDirectory, (dir)=>fn(dir).catch((err)=>{
62
- log.error(`Error running operation at ${dir}: ${err}`);
63
- throw err;
64
- }), this.skipCleanup, this.log);
65
- }
66
- }
@@ -1,15 +0,0 @@
1
- import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
2
- import type { CircuitSimulator } from '@aztec/simulator/client';
3
- import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
4
- import { ClientIvcProof } from '@aztec/stdlib/proofs';
5
- import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
6
- export declare abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
7
- protected artifactProvider: ArtifactProvider;
8
- protected simulator: CircuitSimulator;
9
- private threads;
10
- protected log: import("@aztec/foundation/log").Logger;
11
- constructor(artifactProvider: ArtifactProvider, simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
12
- createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof>;
13
- computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
14
- }
15
- //# sourceMappingURL=bb_wasm_private_kernel_prover.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bb_wasm_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/bb_wasm_private_kernel_prover.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,8BAAsB,yBAA0B,SAAQ,qBAAqB;cAEtD,gBAAgB,EAAE,gBAAgB;cAClC,SAAS,EAAE,gBAAgB;IAC9C,OAAO,CAAC,OAAO;cACI,GAAG;gBAHH,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,gBAAgB,EACtC,OAAO,GAAE,MAAU,EACR,GAAG,yCAAiC;IAKnC,oBAAoB,CAAC,cAAc,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAuBrF,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAa3G"}
@@ -1,48 +0,0 @@
1
- import { AztecClientBackend } from '@aztec/bb.js';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { Timer } from '@aztec/foundation/timer';
4
- import { serializeWitness } from '@aztec/noir-noirc_abi';
5
- import { ClientIvcProof } from '@aztec/stdlib/proofs';
6
- import { ungzip } from 'pako';
7
- import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
8
- export class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
9
- artifactProvider;
10
- simulator;
11
- threads;
12
- log;
13
- constructor(artifactProvider, simulator, threads = 1, log = createLogger('bb-prover:wasm')){
14
- super(artifactProvider, simulator, log), this.artifactProvider = artifactProvider, this.simulator = simulator, this.threads = threads, this.log = log;
15
- }
16
- async createClientIvcProof(executionSteps) {
17
- const timer = new Timer();
18
- this.log.info(`Generating ClientIVC proof...`);
19
- const backend = new AztecClientBackend(executionSteps.map((step)=>ungzip(step.bytecode)), {
20
- threads: this.threads,
21
- logger: this.log.verbose,
22
- wasmPath: process.env.BB_WASM_PATH
23
- });
24
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1297): the vk is not provided to the network anymore.
25
- // Move this sanity check inside the wasm code and remove the vk from the return value.
26
- const [proof, _vk] = await backend.prove(executionSteps.map((step)=>ungzip(serializeWitness(step.witness))), executionSteps.map((step)=>step.vk));
27
- await backend.destroy();
28
- this.log.info(`Generated ClientIVC proof`, {
29
- eventName: 'client-ivc-proof-generation',
30
- duration: timer.ms(),
31
- proofSize: proof.length
32
- });
33
- return new ClientIvcProof(Buffer.from(proof));
34
- }
35
- async computeGateCountForCircuit(_bytecode, _circuitName) {
36
- // Note we do not pass the vk to the backend. This is unneeded for gate counts.
37
- const backend = new AztecClientBackend([
38
- ungzip(_bytecode)
39
- ], {
40
- threads: this.threads,
41
- logger: this.log.verbose,
42
- wasmPath: process.env.BB_WASM_PATH
43
- });
44
- const gateCount = await backend.gates();
45
- await backend.destroy();
46
- return gateCount[0];
47
- }
48
- }
@@ -1,6 +0,0 @@
1
- import type { CircuitSimulator } from '@aztec/simulator/client';
2
- import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
3
- export declare class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
4
- constructor(simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
5
- }
6
- //# sourceMappingURL=bundle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,+BAAgC,SAAQ,yBAAyB;gBAChE,SAAS,EAAE,gBAAgB,EAAE,OAAO,SAAK,EAAE,GAAG,yCAAwC;CAGnG"}
@@ -1,8 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
3
- import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
4
- export class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
5
- constructor(simulator, threads = 16, log = createLogger('bb-prover:wasm:bundle')){
6
- super(new BundleArtifactProvider(), simulator, threads, log);
7
- }
8
- }
@@ -1,6 +0,0 @@
1
- import type { CircuitSimulator } from '@aztec/simulator/client';
2
- import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
3
- export declare class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
4
- constructor(simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
5
- }
6
- //# sourceMappingURL=lazy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/lazy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,6BAA8B,SAAQ,yBAAyB;gBAC9D,SAAS,EAAE,gBAAgB,EAAE,OAAO,SAAK,EAAE,GAAG,yCAAsC;CAGjG"}
@@ -1,8 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
3
- import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
4
- export class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
5
- constructor(simulator, threads = 16, log = createLogger('bb-prover:wasm:lazy')){
6
- super(new LazyArtifactProvider(), simulator, threads, log);
7
- }
8
- }
package/dest/stats.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { ProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
2
- import type { CircuitName } from '@aztec/stdlib/stats';
3
- export declare function mapProtocolArtifactNameToCircuitName(artifact: ProtocolArtifact): CircuitName;
4
- //# sourceMappingURL=stats.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../src/stats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,gBAAgB,GAAG,WAAW,CA2C5F"}
package/dest/stats.js DELETED
@@ -1,45 +0,0 @@
1
- export function mapProtocolArtifactNameToCircuitName(artifact) {
2
- switch(artifact){
3
- case 'BaseParityArtifact':
4
- return 'base-parity';
5
- case 'RootParityArtifact':
6
- return 'root-parity';
7
- case 'PrivateBaseRollupArtifact':
8
- return 'private-base-rollup';
9
- case 'PublicBaseRollupArtifact':
10
- return 'public-base-rollup';
11
- case 'MergeRollupArtifact':
12
- return 'merge-rollup';
13
- case 'BlockRootRollupArtifact':
14
- return 'block-root-rollup';
15
- case 'SingleTxBlockRootRollupArtifact':
16
- return 'single-tx-block-root-rollup';
17
- case 'EmptyBlockRootRollupArtifact':
18
- return 'empty-block-root-rollup';
19
- case 'PaddingBlockRootRollupArtifact':
20
- return 'padding-block-root-rollup';
21
- case 'BlockMergeRollupArtifact':
22
- return 'block-merge-rollup';
23
- case 'RootRollupArtifact':
24
- return 'root-rollup';
25
- case 'PrivateKernelInitArtifact':
26
- return 'private-kernel-init';
27
- case 'PrivateKernelInnerArtifact':
28
- return 'private-kernel-inner';
29
- case 'PrivateKernelTailArtifact':
30
- return 'private-kernel-tail';
31
- case 'PrivateKernelTailToPublicArtifact':
32
- return 'private-kernel-tail-to-public';
33
- case 'HidingKernelToRollup':
34
- return 'hiding-kernel-to-rollup';
35
- case 'HidingKernelToPublic':
36
- return 'hiding-kernel-to-public';
37
- default:
38
- {
39
- if (artifact.startsWith('PrivateKernelReset')) {
40
- return 'private-kernel-reset';
41
- }
42
- throw new Error(`Unknown circuit type: ${artifact}`);
43
- }
44
- }
45
- }
@@ -1,15 +0,0 @@
1
- import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
2
- import type { Tx } from '@aztec/stdlib/tx';
3
- import { type TelemetryClient } from '@aztec/telemetry-client';
4
- import type { BBConfig } from '../config.js';
5
- export declare class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
6
- private verifier;
7
- private telemetry;
8
- private logger;
9
- private queue;
10
- private metrics;
11
- constructor(config: BBConfig, verifier: ClientProtocolCircuitVerifier, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
12
- verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
13
- stop(): Promise<void>;
14
- }
15
- //# sourceMappingURL=queued_ivc_verifier.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queued_ivc_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_ivc_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAgG7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAMnE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IAPhB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAqB;gBAGlC,MAAM,EAAE,QAAQ,EACR,QAAQ,EAAE,6BAA6B,EACvC,SAAS,GAAE,eAAsC,EACjD,MAAM,yCAAgD;IAQnD,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAMrE,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtB"}
@@ -1,105 +0,0 @@
1
- import { runInDirectory } from '@aztec/foundation/fs';
2
- import { type Logger, createLogger } from '@aztec/foundation/log';
3
- import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
4
- import type { CircuitSimulator } from '@aztec/simulator/server';
5
- import { type PrivateExecutionStep, serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
6
- import type { ClientIvcProof } from '@aztec/stdlib/proofs';
7
-
8
- import { promises as fs } from 'fs';
9
- import path from 'path';
10
-
11
- import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../../../bb/execute.js';
12
- import type { BBConfig } from '../../../config.js';
13
- import { readClientIVCProofFromOutputDirectory } from '../../proof_utils.js';
14
- import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
15
-
16
- /**
17
- * This proof creator implementation uses the native bb binary.
18
- */
19
- export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
20
- private constructor(
21
- private bbBinaryPath: string,
22
- private bbWorkingDirectory: string,
23
- private skipCleanup: boolean,
24
- protected override simulator: CircuitSimulator,
25
- protected override log = createLogger('bb-prover:native'),
26
- ) {
27
- super(new BundleArtifactProvider(), simulator, log);
28
- }
29
-
30
- public static async new(config: BBConfig, simulator: CircuitSimulator, log?: Logger) {
31
- await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
32
- return new BBNativePrivateKernelProver(
33
- config.bbBinaryPath,
34
- config.bbWorkingDirectory,
35
- !!config.bbSkipCleanup,
36
- simulator,
37
- log,
38
- );
39
- }
40
-
41
- private async _createClientIvcProof(
42
- directory: string,
43
- executionSteps: PrivateExecutionStep[],
44
- ): Promise<ClientIvcProof> {
45
- const inputsPath = path.join(directory, 'ivc-inputs.msgpack');
46
- await fs.writeFile(inputsPath, serializePrivateExecutionSteps(executionSteps));
47
- const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, inputsPath, this.log.info);
48
-
49
- if (provingResult.status === BB_RESULT.FAILURE) {
50
- this.log.error(`Failed to generate client ivc proof`);
51
- throw new Error(provingResult.reason);
52
- }
53
-
54
- const proof = await readClientIVCProofFromOutputDirectory(directory);
55
-
56
- this.log.info(`Generated IVC proof`, {
57
- duration: provingResult.durationMs,
58
- eventName: 'circuit-proving',
59
- });
60
-
61
- return proof;
62
- }
63
-
64
- public override async createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof> {
65
- this.log.info(`Generating Client IVC proof`);
66
- const operation = async (directory: string) => {
67
- return await this._createClientIvcProof(directory, executionSteps);
68
- };
69
- return await this.runInDirectory(operation);
70
- }
71
-
72
- public override async computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number> {
73
- const logFunction = (message: string) => {
74
- this.log.debug(`$bb gates ${circuitName} - ${message}`);
75
- };
76
-
77
- const result = await computeGateCountForCircuit(
78
- this.bbBinaryPath,
79
- this.bbWorkingDirectory,
80
- circuitName,
81
- bytecode,
82
- 'mega_honk',
83
- logFunction,
84
- );
85
- if (result.status === BB_RESULT.FAILURE) {
86
- throw new Error(result.reason);
87
- }
88
-
89
- return result.circuitSize as number;
90
- }
91
-
92
- private runInDirectory<T>(fn: (dir: string) => Promise<T>) {
93
- const log = this.log;
94
- return runInDirectory(
95
- this.bbWorkingDirectory,
96
- (dir: string) =>
97
- fn(dir).catch(err => {
98
- log.error(`Error running operation at ${dir}: ${err}`);
99
- throw err;
100
- }),
101
- this.skipCleanup,
102
- this.log,
103
- );
104
- }
105
- }
@@ -1,60 +0,0 @@
1
- import { AztecClientBackend } from '@aztec/bb.js';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { Timer } from '@aztec/foundation/timer';
4
- import { serializeWitness } from '@aztec/noir-noirc_abi';
5
- import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
6
- import type { CircuitSimulator } from '@aztec/simulator/client';
7
- import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
8
- import { ClientIvcProof } from '@aztec/stdlib/proofs';
9
-
10
- import { ungzip } from 'pako';
11
-
12
- import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
13
-
14
- export abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
15
- constructor(
16
- protected override artifactProvider: ArtifactProvider,
17
- protected override simulator: CircuitSimulator,
18
- private threads: number = 1,
19
- protected override log = createLogger('bb-prover:wasm'),
20
- ) {
21
- super(artifactProvider, simulator, log);
22
- }
23
-
24
- public override async createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof> {
25
- const timer = new Timer();
26
- this.log.info(`Generating ClientIVC proof...`);
27
- const backend = new AztecClientBackend(
28
- executionSteps.map(step => ungzip(step.bytecode)),
29
- { threads: this.threads, logger: this.log.verbose, wasmPath: process.env.BB_WASM_PATH },
30
- );
31
-
32
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1297): the vk is not provided to the network anymore.
33
- // Move this sanity check inside the wasm code and remove the vk from the return value.
34
- const [proof, _vk] = await backend.prove(
35
- executionSteps.map(step => ungzip(serializeWitness(step.witness))),
36
- executionSteps.map(step => step.vk),
37
- );
38
- await backend.destroy();
39
- this.log.info(`Generated ClientIVC proof`, {
40
- eventName: 'client-ivc-proof-generation',
41
- duration: timer.ms(),
42
- proofSize: proof.length,
43
- });
44
- return new ClientIvcProof(Buffer.from(proof));
45
- }
46
-
47
- public override async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
48
- // Note we do not pass the vk to the backend. This is unneeded for gate counts.
49
- const backend = new AztecClientBackend([ungzip(_bytecode)], {
50
- threads: this.threads,
51
- logger: this.log.verbose,
52
- wasmPath: process.env.BB_WASM_PATH,
53
- });
54
-
55
- const gateCount = await backend.gates();
56
- await backend.destroy();
57
-
58
- return gateCount[0];
59
- }
60
- }
@@ -1,11 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
3
- import type { CircuitSimulator } from '@aztec/simulator/client';
4
-
5
- import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
6
-
7
- export class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
8
- constructor(simulator: CircuitSimulator, threads = 16, log = createLogger('bb-prover:wasm:bundle')) {
9
- super(new BundleArtifactProvider(), simulator, threads, log);
10
- }
11
- }
@@ -1,11 +0,0 @@
1
- import { createLogger } from '@aztec/foundation/log';
2
- import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
3
- import type { CircuitSimulator } from '@aztec/simulator/client';
4
-
5
- import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
6
-
7
- export class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
8
- constructor(simulator: CircuitSimulator, threads = 16, log = createLogger('bb-prover:wasm:lazy')) {
9
- super(new LazyArtifactProvider(), simulator, threads, log);
10
- }
11
- }