@aztec-labs/bb-prover 6.0.0-nightly.20260829

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 (101) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +27 -0
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -0
  3. package/dest/avm_proving_tests/avm_proving_tester.js +236 -0
  4. package/dest/bb/bb_js_backend.d.ts +196 -0
  5. package/dest/bb/bb_js_backend.d.ts.map +1 -0
  6. package/dest/bb/bb_js_backend.js +385 -0
  7. package/dest/bb/bb_js_debug.d.ts +52 -0
  8. package/dest/bb/bb_js_debug.d.ts.map +1 -0
  9. package/dest/bb/bb_js_debug.js +176 -0
  10. package/dest/bb/cli.d.ts +12 -0
  11. package/dest/bb/cli.d.ts.map +1 -0
  12. package/dest/bb/cli.js +19 -0
  13. package/dest/bb/file_names.d.ts +4 -0
  14. package/dest/bb/file_names.d.ts.map +1 -0
  15. package/dest/bb/file_names.js +5 -0
  16. package/dest/bb/index.d.ts +3 -0
  17. package/dest/bb/index.d.ts.map +1 -0
  18. package/dest/bb/index.js +16 -0
  19. package/dest/config.d.ts +31 -0
  20. package/dest/config.d.ts.map +1 -0
  21. package/dest/config.js +1 -0
  22. package/dest/honk.d.ts +13 -0
  23. package/dest/honk.d.ts.map +1 -0
  24. package/dest/honk.js +20 -0
  25. package/dest/index.d.ts +10 -0
  26. package/dest/index.d.ts.map +1 -0
  27. package/dest/index.js +8 -0
  28. package/dest/instrumentation.d.ts +47 -0
  29. package/dest/instrumentation.d.ts.map +1 -0
  30. package/dest/instrumentation.js +76 -0
  31. package/dest/prover/client/bb_private_kernel_prover.d.ts +54 -0
  32. package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
  33. package/dest/prover/client/bb_private_kernel_prover.js +205 -0
  34. package/dest/prover/client/bundle.d.ts +6 -0
  35. package/dest/prover/client/bundle.d.ts.map +1 -0
  36. package/dest/prover/client/bundle.js +7 -0
  37. package/dest/prover/client/lazy.d.ts +6 -0
  38. package/dest/prover/client/lazy.d.ts.map +1 -0
  39. package/dest/prover/client/lazy.js +7 -0
  40. package/dest/prover/index.d.ts +3 -0
  41. package/dest/prover/index.d.ts.map +1 -0
  42. package/dest/prover/index.js +2 -0
  43. package/dest/prover/proof_utils.d.ts +29 -0
  44. package/dest/prover/proof_utils.d.ts.map +1 -0
  45. package/dest/prover/proof_utils.js +95 -0
  46. package/dest/prover/server/bb_prover.d.ts +88 -0
  47. package/dest/prover/server/bb_prover.d.ts.map +1 -0
  48. package/dest/prover/server/bb_prover.js +823 -0
  49. package/dest/test/delay_values.d.ts +4 -0
  50. package/dest/test/delay_values.d.ts.map +1 -0
  51. package/dest/test/delay_values.js +37 -0
  52. package/dest/test/index.d.ts +4 -0
  53. package/dest/test/index.d.ts.map +1 -0
  54. package/dest/test/index.js +3 -0
  55. package/dest/test/test_circuit_prover.d.ts +64 -0
  56. package/dest/test/test_circuit_prover.d.ts.map +1 -0
  57. package/dest/test/test_circuit_prover.js +576 -0
  58. package/dest/test/test_verifier.d.ts +9 -0
  59. package/dest/test/test_verifier.d.ts.map +1 -0
  60. package/dest/test/test_verifier.js +27 -0
  61. package/dest/verification_key/verification_key_data.d.ts +8 -0
  62. package/dest/verification_key/verification_key_data.d.ts.map +1 -0
  63. package/dest/verification_key/verification_key_data.js +19 -0
  64. package/dest/verifier/batch_chonk_verifier.d.ts +57 -0
  65. package/dest/verifier/batch_chonk_verifier.d.ts.map +1 -0
  66. package/dest/verifier/batch_chonk_verifier.js +389 -0
  67. package/dest/verifier/bb_verifier.d.ts +21 -0
  68. package/dest/verifier/bb_verifier.d.ts.map +1 -0
  69. package/dest/verifier/bb_verifier.js +193 -0
  70. package/dest/verifier/index.d.ts +4 -0
  71. package/dest/verifier/index.d.ts.map +1 -0
  72. package/dest/verifier/index.js +3 -0
  73. package/dest/verifier/queued_chonk_verifier.d.ts +26 -0
  74. package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
  75. package/dest/verifier/queued_chonk_verifier.js +102 -0
  76. package/package.json +113 -0
  77. package/src/avm_proving_tests/avm_proving_tester.ts +235 -0
  78. package/src/bb/bb_js_backend.ts +442 -0
  79. package/src/bb/bb_js_debug.ts +227 -0
  80. package/src/bb/cli.ts +31 -0
  81. package/src/bb/file_names.ts +6 -0
  82. package/src/bb/index.ts +22 -0
  83. package/src/config.ts +31 -0
  84. package/src/honk.ts +35 -0
  85. package/src/index.ts +10 -0
  86. package/src/instrumentation.ts +119 -0
  87. package/src/prover/client/bb_private_kernel_prover.ts +531 -0
  88. package/src/prover/client/bundle.ts +10 -0
  89. package/src/prover/client/lazy.ts +10 -0
  90. package/src/prover/index.ts +2 -0
  91. package/src/prover/proof_utils.ts +154 -0
  92. package/src/prover/server/bb_prover.ts +658 -0
  93. package/src/test/delay_values.ts +41 -0
  94. package/src/test/index.ts +3 -0
  95. package/src/test/test_circuit_prover.ts +424 -0
  96. package/src/test/test_verifier.ts +20 -0
  97. package/src/verification_key/verification_key_data.ts +24 -0
  98. package/src/verifier/batch_chonk_verifier.ts +420 -0
  99. package/src/verifier/bb_verifier.ts +130 -0
  100. package/src/verifier/index.ts +3 -0
  101. package/src/verifier/queued_chonk_verifier.ts +108 -0
@@ -0,0 +1,57 @@
1
+ import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec-labs/stdlib/interfaces/server';
2
+ import type { Tx } from '@aztec-labs/stdlib/tx';
3
+ import type { BBConfig } from '../config.js';
4
+ /**
5
+ * Batch verifier for Chonk IVC proofs. Uses the bb batch verifier service
6
+ * which batches IPA verification into a constant number of SRS MSMs for better throughput.
7
+ *
8
+ * Architecture:
9
+ * - Spawns a persistent `bb msgpack run` process via Barretenberg (native backend)
10
+ * - Sends proofs via the msgpack RPC protocol (ChonkBatchVerifierQueue)
11
+ * - Receives results via a named FIFO pipe (async, out-of-order)
12
+ * - Bisects batch failures to isolate individual bad proofs
13
+ */
14
+ export declare class BatchChonkVerifier implements ClientProtocolCircuitVerifier {
15
+ private config;
16
+ private vkBuffers;
17
+ private batchSize;
18
+ private label;
19
+ private bb;
20
+ private fifoDir;
21
+ private fifoPath;
22
+ private nextRequestId;
23
+ private pendingRequests;
24
+ private sendQueue;
25
+ private fifoReader;
26
+ private logger;
27
+ private metrics;
28
+ /** Maps artifact name to VK index in the batch verifier. */
29
+ private vkIndexMap;
30
+ /** Bound cleanup handler for process exit signals. */
31
+ private exitCleanup;
32
+ private stopped;
33
+ private fatalError;
34
+ private pendingDrainedResolvers;
35
+ private constructor();
36
+ /** Create and start a BatchChonkVerifier using the protocol circuit VKs. */
37
+ static new(config: BBConfig, batchSize: number, label: string): Promise<BatchChonkVerifier>;
38
+ /** Create and start a BatchChonkVerifier with custom VKs (for testing). */
39
+ static newForTesting(config: Pick<BBConfig, 'bbChonkVerifyConcurrency'> & Partial<Pick<BBConfig, 'bbBinaryPath'>>, vks: Uint8Array[], batchSize: number): Promise<BatchChonkVerifier>;
40
+ private start;
41
+ verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
42
+ /** Enqueue raw proof fields for verification. Used directly by tests with custom VKs. */
43
+ enqueueProof(vkIndex: number, proofFields: Uint8Array[]): Promise<IVCProofVerificationResult>;
44
+ stop(): Promise<void>;
45
+ private withTimeout;
46
+ private startFifoReader;
47
+ private handleResult;
48
+ private registerExitCleanup;
49
+ private deregisterExitCleanup;
50
+ private rejectPendingRequests;
51
+ private failVerifier;
52
+ private waitForPendingRequestsToDrain;
53
+ private notifyPendingDrained;
54
+ private cleanupFifo;
55
+ private cleanupFifoSync;
56
+ }
57
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmF0Y2hfY2hvbmtfdmVyaWZpZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9iYXRjaF9jaG9ua192ZXJpZmllci50cyJdLCJuYW1lcyI6W10sIm1h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;YAEa,KAAK;IAiCZ,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAe9D;IAED,yFAAyF;IAClF,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAkDnG;IAEY,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA+BjC;YAOa,WAAW;IAkBzB,OAAO,CAAC,eAAe;IA6BvB,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,6BAA6B;IA0BrC,OAAO,CAAC,oBAAoB;YASd,WAAW;IAUzB,OAAO,CAAC,eAAe;CAWxB"}
@@ -0,0 +1,389 @@
1
+ import { BackendType, Barretenberg } from '@aztec/bb.js';
2
+ import { FifoFrameReader } from '@aztec-labs/foundation/fifo';
3
+ import { createLogger } from '@aztec-labs/foundation/log';
4
+ import { SerialQueue } from '@aztec-labs/foundation/queue';
5
+ import { Timer } from '@aztec-labs/foundation/timer';
6
+ import { ProtocolCircuitVks } from '@aztec-labs/noir-protocol-circuits-types/server/vks';
7
+ import { getTelemetryClient } from '@aztec-labs/telemetry-client';
8
+ import { Unpackr } from 'msgpackr';
9
+ import { execFile } from 'node:child_process';
10
+ import { rmSync } from 'node:fs';
11
+ import { mkdtemp, rm } from 'node:fs/promises';
12
+ import * as os from 'node:os';
13
+ import * as path from 'node:path';
14
+ import { promisify } from 'node:util';
15
+ import { IVCVerifierMetrics } from './queued_chonk_verifier.js';
16
+ const execFileAsync = promisify(execFile);
17
+ const RESULT_TIMEOUT_MS = 5 * 60 * 1000;
18
+ const STOP_DRAIN_TIMEOUT_MS = 5_000;
19
+ /** Maps client protocol artifacts used for chonk verification to VK indices. */ const CHONK_VK_ARTIFACTS = [
20
+ 'HidingKernelToRollup',
21
+ 'HidingKernelToPublic'
22
+ ];
23
+ /**
24
+ * Batch verifier for Chonk IVC proofs. Uses the bb batch verifier service
25
+ * which batches IPA verification into a constant number of SRS MSMs for better throughput.
26
+ *
27
+ * Architecture:
28
+ * - Spawns a persistent `bb msgpack run` process via Barretenberg (native backend)
29
+ * - Sends proofs via the msgpack RPC protocol (ChonkBatchVerifierQueue)
30
+ * - Receives results via a named FIFO pipe (async, out-of-order)
31
+ * - Bisects batch failures to isolate individual bad proofs
32
+ */ export class BatchChonkVerifier {
33
+ config;
34
+ vkBuffers;
35
+ batchSize;
36
+ label;
37
+ bb;
38
+ fifoDir;
39
+ fifoPath;
40
+ nextRequestId;
41
+ pendingRequests;
42
+ sendQueue;
43
+ fifoReader;
44
+ logger;
45
+ metrics;
46
+ /** Maps artifact name to VK index in the batch verifier. */ vkIndexMap;
47
+ /** Bound cleanup handler for process exit signals. */ exitCleanup;
48
+ stopped;
49
+ fatalError;
50
+ pendingDrainedResolvers;
51
+ constructor(config, vkBuffers, batchSize, label){
52
+ this.config = config;
53
+ this.vkBuffers = vkBuffers;
54
+ this.batchSize = batchSize;
55
+ this.label = label;
56
+ this.fifoPath = '';
57
+ this.nextRequestId = 0;
58
+ this.pendingRequests = new Map();
59
+ this.logger = createLogger('bb-prover:batch_chonk_verifier');
60
+ this.vkIndexMap = new Map();
61
+ this.exitCleanup = null;
62
+ this.stopped = false;
63
+ this.pendingDrainedResolvers = new Set();
64
+ this.fifoReader = new FifoFrameReader();
65
+ this.sendQueue = new SerialQueue();
66
+ this.sendQueue.start(1);
67
+ this.metrics = new IVCVerifierMetrics(getTelemetryClient(), `BatchChonkVerifier-${label}`);
68
+ }
69
+ /** Create and start a BatchChonkVerifier using the protocol circuit VKs. */ static async new(config, batchSize, label) {
70
+ const vkBuffers = [];
71
+ const vkIndexMap = new Map();
72
+ for (const artifact of CHONK_VK_ARTIFACTS){
73
+ const vk = ProtocolCircuitVks[artifact];
74
+ if (!vk) {
75
+ throw new Error(`Missing VK for ${artifact}`);
76
+ }
77
+ vkIndexMap.set(artifact, vkBuffers.length);
78
+ vkBuffers.push(vk.keyAsBytes);
79
+ }
80
+ const verifier = new BatchChonkVerifier(config, vkBuffers, batchSize, label);
81
+ verifier.vkIndexMap = vkIndexMap;
82
+ await verifier.start();
83
+ return verifier;
84
+ }
85
+ /** Create and start a BatchChonkVerifier with custom VKs (for testing). */ static async newForTesting(config, vks, batchSize) {
86
+ const verifier = new BatchChonkVerifier(config, vks, batchSize, 'test');
87
+ for(let i = 0; i < vks.length; i++){
88
+ verifier.vkIndexMap.set(String(i), i);
89
+ }
90
+ await verifier.start();
91
+ return verifier;
92
+ }
93
+ async start() {
94
+ this.logger.info('Starting BatchChonkVerifier');
95
+ try {
96
+ this.bb = await Barretenberg.new({
97
+ bbPath: this.config.bbBinaryPath,
98
+ backend: BackendType.NativeUnixSocket
99
+ });
100
+ await this.bb.initSRSChonk();
101
+ // Keep the FIFO in a private directory so cleanup has a single owner.
102
+ this.fifoDir = await mkdtemp(path.join(os.tmpdir(), `bb-batch-${this.label}-${process.pid}-`));
103
+ this.fifoPath = path.join(this.fifoDir, 'results.fifo');
104
+ await execFileAsync('mkfifo', [
105
+ this.fifoPath
106
+ ]);
107
+ this.registerExitCleanup();
108
+ this.startFifoReader();
109
+ await this.bb.chonkBatchVerifierStart({
110
+ vks: this.vkBuffers,
111
+ numCores: this.config.bbChonkVerifyConcurrency || 0,
112
+ batchSize: this.batchSize,
113
+ fifoPath: this.fifoPath
114
+ });
115
+ } catch (err) {
116
+ this.fifoReader.stop();
117
+ this.deregisterExitCleanup();
118
+ await this.cleanupFifo();
119
+ await this.bb?.destroy().catch(()=>{});
120
+ throw err;
121
+ }
122
+ this.logger.info('BatchChonkVerifier started', {
123
+ fifoPath: this.fifoPath
124
+ });
125
+ }
126
+ verifyProof(tx) {
127
+ const totalTimer = new Timer();
128
+ return (async ()=>{
129
+ const circuit = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
130
+ const vkIndex = this.vkIndexMap.get(circuit);
131
+ if (vkIndex === undefined) {
132
+ throw new Error(`No VK index for circuit ${circuit}`);
133
+ }
134
+ const proofWithPubInputs = tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields());
135
+ const proofFields = proofWithPubInputs.fieldsWithPublicInputs.map((f)=>f.toBuffer());
136
+ return await this.enqueueProof(vkIndex, proofFields);
137
+ })().catch((err)=>{
138
+ this.logger.warn(`Failed to verify Chonk proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
139
+ return {
140
+ valid: false,
141
+ durationMs: 0,
142
+ totalDurationMs: totalTimer.ms()
143
+ };
144
+ });
145
+ }
146
+ /** Enqueue raw proof fields for verification. Used directly by tests with custom VKs. */ enqueueProof(vkIndex, proofFields) {
147
+ if (this.stopped) {
148
+ return Promise.reject(new Error('BatchChonkVerifier stopped'));
149
+ }
150
+ if (this.fatalError) {
151
+ return Promise.reject(this.fatalError);
152
+ }
153
+ const totalTimer = new Timer();
154
+ const requestId = this.nextRequestId++;
155
+ const resultPromise = new Promise((resolve, reject)=>{
156
+ const timeout = setTimeout(()=>{
157
+ const pending = this.pendingRequests.get(requestId);
158
+ if (!pending) {
159
+ return;
160
+ }
161
+ this.pendingRequests.delete(requestId);
162
+ pending.reject(new Error(`BatchChonkVerifier result timed out for request_id=${requestId}`));
163
+ this.notifyPendingDrained();
164
+ }, RESULT_TIMEOUT_MS);
165
+ // A pending result timer must never keep the host process alive on its own (e.g. an
166
+ // orphaned request at process exit); the FIFO reader keeps the loop alive while results
167
+ // are genuinely awaited.
168
+ timeout.unref();
169
+ this.pendingRequests.set(requestId, {
170
+ resolve,
171
+ reject,
172
+ totalTimer,
173
+ timeout
174
+ });
175
+ });
176
+ void this.sendQueue.put(async ()=>{
177
+ if (this.fatalError) {
178
+ throw this.fatalError;
179
+ }
180
+ await this.bb.chonkBatchVerifierQueue({
181
+ requestId,
182
+ vkIndex,
183
+ proofFields
184
+ });
185
+ }).catch((err)=>{
186
+ const pending = this.pendingRequests.get(requestId);
187
+ if (pending) {
188
+ this.pendingRequests.delete(requestId);
189
+ clearTimeout(pending.timeout);
190
+ pending.reject(err instanceof Error ? err : new Error(String(err)));
191
+ this.notifyPendingDrained();
192
+ }
193
+ });
194
+ return resultPromise;
195
+ }
196
+ async stop() {
197
+ this.logger.info('Stopping BatchChonkVerifier');
198
+ this.stopped = true;
199
+ try {
200
+ // Stop accepting new proofs and flush the send queue. Bound it so an unresponsive
201
+ // native process can't block teardown of our own event-loop handles indefinitely.
202
+ await this.withTimeout(this.sendQueue.end(), STOP_DRAIN_TIMEOUT_MS, 'send queue flush');
203
+ // Stop the bb service (flushes remaining proofs).
204
+ await this.withTimeout(this.bb.chonkBatchVerifierStop({}), STOP_DRAIN_TIMEOUT_MS, 'chonkBatchVerifierStop');
205
+ // Native stop flushes callbacks; keep the FIFO open until those frames are observed.
206
+ const drained = await this.waitForPendingRequestsToDrain(STOP_DRAIN_TIMEOUT_MS);
207
+ if (!drained) {
208
+ this.rejectPendingRequests(new Error('Timed out waiting for BatchChonkVerifier results during stop'));
209
+ }
210
+ } catch (err) {
211
+ this.logger.warn(`Error during BatchChonkVerifier graceful stop: ${err}`);
212
+ this.rejectPendingRequests(err instanceof Error ? err : new Error(String(err)));
213
+ } finally{
214
+ // Always release our own event-loop handles — the FIFO read stream (a blocking
215
+ // threadpool read that can't be unref'd), the unix socket, the native process, and the
216
+ // exit handler — so the host process exits cleanly even if the native backend is wedged.
217
+ this.fifoReader.stop();
218
+ this.deregisterExitCleanup();
219
+ await this.cleanupFifo();
220
+ await this.bb.destroy().catch((err)=>this.logger.warn(`Error destroying bb backend during stop: ${err}`));
221
+ }
222
+ this.logger.info('BatchChonkVerifier stopped');
223
+ }
224
+ /**
225
+ * Races a promise against a timeout so a wedged native backend can't block teardown. The
226
+ * timer is unref'd so it never keeps the process alive; the underlying promise stays handled
227
+ * by the race even if the timeout wins, so it cannot surface as an unhandled rejection.
228
+ */ async withTimeout(promise, timeoutMs, label) {
229
+ let timer;
230
+ const timeout = new Promise((_, reject)=>{
231
+ timer = setTimeout(()=>reject(new Error(`BatchChonkVerifier ${label} timed out after ${timeoutMs}ms`)), timeoutMs);
232
+ timer.unref();
233
+ });
234
+ try {
235
+ return await Promise.race([
236
+ promise,
237
+ timeout
238
+ ]);
239
+ } finally{
240
+ if (timer) {
241
+ clearTimeout(timer);
242
+ }
243
+ }
244
+ }
245
+ startFifoReader() {
246
+ const unpackr = new Unpackr({
247
+ useRecords: false
248
+ });
249
+ this.fifoReader.on('frame', (payload)=>{
250
+ try {
251
+ const result = unpackr.unpack(payload);
252
+ this.handleResult(result);
253
+ } catch (err) {
254
+ this.logger.error(`FIFO: failed to decode msgpack result: ${err}`);
255
+ // A corrupt result stream cannot safely be matched to outstanding requests.
256
+ this.failVerifier(err instanceof Error ? err : new Error(String(err)));
257
+ }
258
+ });
259
+ this.fifoReader.on('error', (err)=>{
260
+ this.logger.error(`FIFO reader error: ${err}`);
261
+ this.failVerifier(err);
262
+ });
263
+ this.fifoReader.on('end', ()=>{
264
+ this.logger.debug('FIFO reader: stream ended');
265
+ if (!this.stopped) {
266
+ this.failVerifier(new Error('FIFO stream ended unexpectedly'));
267
+ }
268
+ });
269
+ this.fifoReader.start(this.fifoPath);
270
+ }
271
+ handleResult(result) {
272
+ const pending = this.pendingRequests.get(result.request_id);
273
+ if (!pending) {
274
+ this.logger.warn(`Received result for unknown request_id=${result.request_id}`);
275
+ return;
276
+ }
277
+ this.pendingRequests.delete(result.request_id);
278
+ clearTimeout(pending.timeout);
279
+ const valid = result.status === 0; // VerifyStatus::OK
280
+ const durationMs = result.time_in_verify_ms;
281
+ const totalDurationMs = pending.totalTimer.ms();
282
+ const ivcResult = {
283
+ valid,
284
+ durationMs,
285
+ totalDurationMs
286
+ };
287
+ this.metrics.recordIVCVerification(ivcResult);
288
+ if (!valid) {
289
+ this.logger.warn(`Proof verification failed for request_id=${result.request_id}: ${result.error_message}`);
290
+ } else {
291
+ this.logger.debug(`Proof verified`, {
292
+ requestId: result.request_id,
293
+ durationMs: Math.ceil(durationMs),
294
+ totalDurationMs: Math.ceil(totalDurationMs)
295
+ });
296
+ }
297
+ pending.resolve(ivcResult);
298
+ this.notifyPendingDrained();
299
+ }
300
+ registerExitCleanup() {
301
+ this.exitCleanup = ()=>{
302
+ this.cleanupFifoSync();
303
+ };
304
+ process.on('exit', this.exitCleanup);
305
+ }
306
+ deregisterExitCleanup() {
307
+ if (this.exitCleanup) {
308
+ process.removeListener('exit', this.exitCleanup);
309
+ this.exitCleanup = null;
310
+ }
311
+ }
312
+ rejectPendingRequests(error) {
313
+ for (const [id, pending] of Array.from(this.pendingRequests)){
314
+ pending.reject(error);
315
+ clearTimeout(pending.timeout);
316
+ this.pendingRequests.delete(id);
317
+ }
318
+ this.notifyPendingDrained();
319
+ }
320
+ failVerifier(error) {
321
+ if (!this.fatalError) {
322
+ this.fatalError = error;
323
+ }
324
+ this.rejectPendingRequests(error);
325
+ }
326
+ waitForPendingRequestsToDrain(timeoutMs) {
327
+ if (this.pendingRequests.size === 0) {
328
+ return Promise.resolve(true);
329
+ }
330
+ let timeout;
331
+ let onDrain;
332
+ const drained = new Promise((resolve)=>{
333
+ onDrain = ()=>resolve(true);
334
+ this.pendingDrainedResolvers.add(onDrain);
335
+ });
336
+ const timedOut = new Promise((resolve)=>{
337
+ timeout = setTimeout(()=>resolve(false), timeoutMs);
338
+ timeout.unref();
339
+ });
340
+ return Promise.race([
341
+ drained,
342
+ timedOut
343
+ ]).finally(()=>{
344
+ if (timeout) {
345
+ clearTimeout(timeout);
346
+ }
347
+ if (onDrain) {
348
+ this.pendingDrainedResolvers.delete(onDrain);
349
+ }
350
+ });
351
+ }
352
+ notifyPendingDrained() {
353
+ if (this.pendingRequests.size > 0) {
354
+ return;
355
+ }
356
+ for (const resolve of Array.from(this.pendingDrainedResolvers)){
357
+ resolve();
358
+ }
359
+ }
360
+ async cleanupFifo() {
361
+ if (this.fifoDir) {
362
+ await rm(this.fifoDir, {
363
+ recursive: true,
364
+ force: true
365
+ }).catch(()=>{});
366
+ } else if (this.fifoPath) {
367
+ await rm(this.fifoPath, {
368
+ force: true
369
+ }).catch(()=>{});
370
+ }
371
+ this.fifoDir = undefined;
372
+ this.fifoPath = '';
373
+ }
374
+ cleanupFifoSync() {
375
+ try {
376
+ if (this.fifoDir) {
377
+ rmSync(this.fifoDir, {
378
+ recursive: true,
379
+ force: true
380
+ });
381
+ } else if (this.fifoPath) {
382
+ rmSync(this.fifoPath, {
383
+ force: true
384
+ });
385
+ }
386
+ } catch {
387
+ /* ignore */ }
388
+ }
389
+ }
@@ -0,0 +1,21 @@
1
+ import { type Logger } from '@aztec-labs/foundation/log';
2
+ import { type ProtocolArtifact, type ServerProtocolArtifact } from '@aztec-labs/noir-protocol-circuits-types/types';
3
+ import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec-labs/stdlib/interfaces/server';
4
+ import type { Proof } from '@aztec-labs/stdlib/proofs';
5
+ import { Tx } from '@aztec-labs/stdlib/tx';
6
+ import type { VerificationKeyData } from '@aztec-labs/stdlib/vks';
7
+ import type { BBConfig } from '../config.js';
8
+ export declare class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
9
+ private config;
10
+ private logger;
11
+ private bbJsFactory;
12
+ private constructor();
13
+ stop(): Promise<void>;
14
+ static new(config: BBConfig, logger?: Logger): Promise<BBCircuitVerifier>;
15
+ getVerificationKeyData(circuit: ProtocolArtifact): VerificationKeyData;
16
+ /** Verify an UltraHonk proof via bb.js API (no temp files). */
17
+ verifyProofForCircuit(circuit: ServerProtocolArtifact, proof: Proof): Promise<void>;
18
+ /** Verify a Chonk (IVC) proof from a transaction via bb.js API. */
19
+ verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
20
+ }
21
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmJfdmVyaWZpZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2Vz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0RCxXQUFXLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsMEJBQTBCLENBQUMsQ0ErQnBFO0NBQ0YifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bb_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/bb_verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,4BAA4B,CAAC;AAGvE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AACtH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAIlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAInE,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IAJhB,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO,eAWN;IAEM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED,OAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAqC,8BAMpF;IAEM,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,CAM5E;IAED,+DAA+D;IAClD,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK,iBA4B/E;IAED,mEAAmE;IACtD,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA+BpE;CACF"}
@@ -0,0 +1,193 @@
1
+ function _ts_add_disposable_resource(env, value, async) {
2
+ if (value !== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() {
16
+ try {
17
+ inner.call(this);
18
+ } catch (e) {
19
+ return Promise.reject(e);
20
+ }
21
+ };
22
+ env.stack.push({
23
+ value: value,
24
+ dispose: dispose,
25
+ async: async
26
+ });
27
+ } else if (async) {
28
+ env.stack.push({
29
+ async: true
30
+ });
31
+ }
32
+ return value;
33
+ }
34
+ function _ts_dispose_resources(env) {
35
+ var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
36
+ var e = new Error(message);
37
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
38
+ };
39
+ return (_ts_dispose_resources = function _ts_dispose_resources(env) {
40
+ function fail(e) {
41
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
42
+ env.hasError = true;
43
+ }
44
+ var r, s = 0;
45
+ function next() {
46
+ while(r = env.stack.pop()){
47
+ try {
48
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
49
+ if (r.dispose) {
50
+ var result = r.dispose.call(r.value);
51
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
52
+ fail(e);
53
+ return next();
54
+ });
55
+ } else s |= 1;
56
+ } catch (e) {
57
+ fail(e);
58
+ }
59
+ }
60
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
61
+ if (env.hasError) throw env.error;
62
+ }
63
+ return next();
64
+ })(env);
65
+ }
66
+ import { createLogger } from '@aztec-labs/foundation/log';
67
+ import { Timer } from '@aztec-labs/foundation/timer';
68
+ import { ProtocolCircuitVks } from '@aztec-labs/noir-protocol-circuits-types/server/vks';
69
+ import { mapProtocolArtifactNameToCircuitName } from '@aztec-labs/noir-protocol-circuits-types/types';
70
+ import { promises as fs } from 'fs';
71
+ import { BBJsFactory } from '../bb/bb_js_backend.js';
72
+ import { getUltraHonkFlavorForCircuit } from '../honk.js';
73
+ export class BBCircuitVerifier {
74
+ config;
75
+ logger;
76
+ bbJsFactory;
77
+ constructor(config, logger){
78
+ this.config = config;
79
+ this.logger = logger;
80
+ // BB_NUM_IVC_VERIFIERS bounds the number of long-lived bb processes the pool keeps alive.
81
+ // If 0, fall back to spawning a fresh bb per verification.
82
+ this.bbJsFactory = new BBJsFactory(config.bbBinaryPath, {
83
+ poolSize: config.numConcurrentIVCVerifiers > 0 ? config.numConcurrentIVCVerifiers : undefined,
84
+ logger,
85
+ debugDir: config.bbDebugOutputDir
86
+ });
87
+ }
88
+ stop() {
89
+ return this.bbJsFactory.destroy();
90
+ }
91
+ static async new(config, logger = createLogger('bb-prover:verifier')) {
92
+ if (!config.bbWorkingDirectory) {
93
+ throw new Error(`Barretenberg working directory (BB_WORKING_DIRECTORY) is not set`);
94
+ }
95
+ await fs.mkdir(config.bbWorkingDirectory, {
96
+ recursive: true
97
+ });
98
+ return new BBCircuitVerifier(config, logger);
99
+ }
100
+ getVerificationKeyData(circuit) {
101
+ const vk = ProtocolCircuitVks[circuit];
102
+ if (vk === undefined) {
103
+ throw new Error(`Could not find VK for artifact ${circuit}`);
104
+ }
105
+ return vk;
106
+ }
107
+ /** Verify an UltraHonk proof via bb.js API (no temp files). */ async verifyProofForCircuit(circuit, proof) {
108
+ const env = {
109
+ stack: [],
110
+ error: void 0,
111
+ hasError: false
112
+ };
113
+ try {
114
+ const verificationKey = this.getVerificationKeyData(circuit);
115
+ const flavor = getUltraHonkFlavorForCircuit(circuit);
116
+ this.logger.debug(`${circuit} Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
117
+ // Split proof buffer into public input fields and proof fields (32-byte each)
118
+ const publicInputFields = splitBufferToFieldArrays(proof.buffer.subarray(0, proof.numPublicInputs * 32));
119
+ const proofFields = splitBufferToFieldArrays(proof.buffer.subarray(proof.numPublicInputs * 32));
120
+ const instance = _ts_add_disposable_resource(env, await this.bbJsFactory.getInstance(), true);
121
+ const { verified, durationMs } = await instance.verifyProof(proofFields, verificationKey.keyAsBytes, publicInputFields, flavor);
122
+ if (!verified) {
123
+ throw new Error(`Failed to verify ${circuit} proof!`);
124
+ }
125
+ this.logger.debug(`${circuit} verification successful`, {
126
+ circuitName: mapProtocolArtifactNameToCircuitName(circuit),
127
+ duration: durationMs,
128
+ eventName: 'circuit-verification',
129
+ proofType: 'ultra-honk'
130
+ });
131
+ } catch (e) {
132
+ env.error = e;
133
+ env.hasError = true;
134
+ } finally{
135
+ const result = _ts_dispose_resources(env);
136
+ if (result) await result;
137
+ }
138
+ }
139
+ /** Verify a Chonk (IVC) proof from a transaction via bb.js API. */ async verifyProof(tx) {
140
+ const proofType = 'Chonk';
141
+ try {
142
+ const env = {
143
+ stack: [],
144
+ error: void 0,
145
+ hasError: false
146
+ };
147
+ try {
148
+ const totalTimer = new Timer();
149
+ const circuit = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
150
+ const verificationKey = this.getVerificationKeyData(circuit);
151
+ // Reconstruct the full proof with public inputs prepended, then convert Fr[] to Uint8Array[]
152
+ const proofWithPubInputs = tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields());
153
+ const fieldsAsBuffers = proofWithPubInputs.fieldsWithPublicInputs.map((f)=>new Uint8Array(f.toBuffer()));
154
+ const instance = _ts_add_disposable_resource(env, await this.bbJsFactory.getInstance(), true);
155
+ const { verified, durationMs } = await instance.verifyChonkProof(fieldsAsBuffers, verificationKey.keyAsBytes);
156
+ if (!verified) {
157
+ throw new Error(`Failed to verify ${proofType} proof for ${circuit}!`);
158
+ }
159
+ this.logger.debug(`${proofType} verification successful`, {
160
+ circuitName: mapProtocolArtifactNameToCircuitName(circuit),
161
+ duration: durationMs,
162
+ eventName: 'circuit-verification',
163
+ proofType: 'chonk'
164
+ });
165
+ return {
166
+ valid: true,
167
+ durationMs,
168
+ totalDurationMs: totalTimer.ms()
169
+ };
170
+ } catch (e) {
171
+ env.error = e;
172
+ env.hasError = true;
173
+ } finally{
174
+ const result = _ts_dispose_resources(env);
175
+ if (result) await result;
176
+ }
177
+ } catch (err) {
178
+ this.logger.warn(`Failed to verify ${proofType} proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
179
+ return {
180
+ valid: false,
181
+ durationMs: 0,
182
+ totalDurationMs: 0
183
+ };
184
+ }
185
+ }
186
+ }
187
+ /** Split a buffer into 32-byte Uint8Array field elements. */ function splitBufferToFieldArrays(buffer) {
188
+ const fields = [];
189
+ for(let i = 0; i < buffer.length; i += 32){
190
+ fields.push(new Uint8Array(buffer.subarray(i, i + 32)));
191
+ }
192
+ return fields;
193
+ }
@@ -0,0 +1,4 @@
1
+ export * from './batch_chonk_verifier.js';
2
+ export * from './bb_verifier.js';
3
+ export * from './queued_chonk_verifier.js';
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDJCQUEyQixDQUFDO0FBQzFDLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyw0QkFBNEIsQ0FBQyJ9