@aztec/bb-prover 0.0.0-test.1 → 0.0.1-commit.03f7ef2

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 (109) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +14 -18
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
  3. package/dest/avm_proving_tests/avm_proving_tester.js +143 -79
  4. package/dest/bb/cli.d.ts +1 -1
  5. package/dest/bb/execute.d.ts +14 -47
  6. package/dest/bb/execute.d.ts.map +1 -1
  7. package/dest/bb/execute.js +133 -237
  8. package/dest/bb/index.d.ts +1 -1
  9. package/dest/config.d.ts +3 -1
  10. package/dest/config.d.ts.map +1 -1
  11. package/dest/honk.d.ts +3 -3
  12. package/dest/honk.d.ts.map +1 -1
  13. package/dest/honk.js +3 -2
  14. package/dest/index.d.ts +2 -1
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +1 -0
  17. package/dest/instrumentation.d.ts +3 -3
  18. package/dest/instrumentation.d.ts.map +1 -1
  19. package/dest/instrumentation.js +2 -4
  20. package/dest/prover/client/bb_private_kernel_prover.d.ts +32 -0
  21. package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
  22. package/dest/prover/{bb_private_kernel_prover.js → client/bb_private_kernel_prover.js} +42 -20
  23. package/dest/prover/client/bundle.d.ts +6 -0
  24. package/dest/prover/client/bundle.d.ts.map +1 -0
  25. package/dest/prover/client/bundle.js +8 -0
  26. package/dest/prover/client/lazy.d.ts +6 -0
  27. package/dest/prover/client/lazy.d.ts.map +1 -0
  28. package/dest/prover/client/lazy.js +8 -0
  29. package/dest/prover/index.d.ts +3 -4
  30. package/dest/prover/index.d.ts.map +1 -1
  31. package/dest/prover/index.js +2 -3
  32. package/dest/prover/proof_utils.d.ts +19 -0
  33. package/dest/prover/proof_utils.d.ts.map +1 -0
  34. package/dest/prover/proof_utils.js +72 -0
  35. package/dest/prover/server/bb_prover.d.ts +100 -0
  36. package/dest/prover/server/bb_prover.d.ts.map +1 -0
  37. package/dest/prover/server/bb_prover.js +336 -0
  38. package/dest/test/delay_values.d.ts +1 -1
  39. package/dest/test/delay_values.d.ts.map +1 -1
  40. package/dest/test/delay_values.js +33 -21
  41. package/dest/test/index.d.ts +1 -1
  42. package/dest/test/test_circuit_prover.d.ts +25 -34
  43. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  44. package/dest/test/test_circuit_prover.js +85 -59
  45. package/dest/test/test_verifier.d.ts +6 -3
  46. package/dest/test/test_verifier.d.ts.map +1 -1
  47. package/dest/test/test_verifier.js +23 -1
  48. package/dest/verification_key/verification_key_data.d.ts +7 -1
  49. package/dest/verification_key/verification_key_data.d.ts.map +1 -1
  50. package/dest/verification_key/verification_key_data.js +24 -30
  51. package/dest/verifier/bb_verifier.d.ts +6 -5
  52. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  53. package/dest/verifier/bb_verifier.js +46 -25
  54. package/dest/verifier/index.d.ts +2 -1
  55. package/dest/verifier/index.d.ts.map +1 -1
  56. package/dest/verifier/index.js +1 -0
  57. package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
  58. package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
  59. package/dest/verifier/queued_chonk_verifier.js +132 -0
  60. package/package.json +35 -33
  61. package/src/avm_proving_tests/avm_proving_tester.ts +224 -104
  62. package/src/bb/execute.ts +104 -251
  63. package/src/config.ts +2 -0
  64. package/src/honk.ts +3 -2
  65. package/src/index.ts +1 -0
  66. package/src/instrumentation.ts +2 -4
  67. package/src/prover/{bb_private_kernel_prover.ts → client/bb_private_kernel_prover.ts} +78 -30
  68. package/src/prover/client/bundle.ts +11 -0
  69. package/src/prover/client/lazy.ts +11 -0
  70. package/src/prover/index.ts +2 -3
  71. package/src/prover/proof_utils.ts +115 -0
  72. package/src/prover/server/bb_prover.ts +728 -0
  73. package/src/test/delay_values.ts +33 -21
  74. package/src/test/test_circuit_prover.ts +260 -147
  75. package/src/test/test_verifier.ts +15 -3
  76. package/src/verification_key/verification_key_data.ts +30 -25
  77. package/src/verifier/bb_verifier.ts +63 -32
  78. package/src/verifier/index.ts +1 -0
  79. package/src/verifier/queued_chonk_verifier.ts +140 -0
  80. package/dest/prover/bb_native_private_kernel_prover.d.ts +0 -25
  81. package/dest/prover/bb_native_private_kernel_prover.d.ts.map +0 -1
  82. package/dest/prover/bb_native_private_kernel_prover.js +0 -69
  83. package/dest/prover/bb_private_kernel_prover.d.ts +0 -32
  84. package/dest/prover/bb_private_kernel_prover.d.ts.map +0 -1
  85. package/dest/prover/bb_prover.d.ts +0 -120
  86. package/dest/prover/bb_prover.d.ts.map +0 -1
  87. package/dest/prover/bb_prover.js +0 -423
  88. package/dest/prover/client_ivc_proof_utils.d.ts +0 -25
  89. package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
  90. package/dest/prover/client_ivc_proof_utils.js +0 -43
  91. package/dest/stats.d.ts +0 -5
  92. package/dest/stats.d.ts.map +0 -1
  93. package/dest/stats.js +0 -62
  94. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +0 -17
  95. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
  96. package/dest/wasm/bb_wasm_private_kernel_prover.js +0 -46
  97. package/dest/wasm/bundle.d.ts +0 -6
  98. package/dest/wasm/bundle.d.ts.map +0 -1
  99. package/dest/wasm/bundle.js +0 -8
  100. package/dest/wasm/lazy.d.ts +0 -6
  101. package/dest/wasm/lazy.d.ts.map +0 -1
  102. package/dest/wasm/lazy.js +0 -8
  103. package/src/prover/bb_native_private_kernel_prover.ts +0 -119
  104. package/src/prover/bb_prover.ts +0 -781
  105. package/src/prover/client_ivc_proof_utils.ts +0 -42
  106. package/src/stats.ts +0 -64
  107. package/src/wasm/bb_wasm_private_kernel_prover.ts +0 -55
  108. package/src/wasm/bundle.ts +0 -11
  109. package/src/wasm/lazy.ts +0 -11
@@ -1,17 +1,15 @@
1
- import { sha256 } from '@aztec/foundation/crypto';
1
+ import { sha256 } from '@aztec/foundation/crypto/sha256';
2
2
  import { Timer } from '@aztec/foundation/timer';
3
3
  import * as proc from 'child_process';
4
4
  import { promises as fs } from 'fs';
5
5
  import { basename, dirname, join } from 'path';
6
- import { CLIENT_IVC_PROOF_FILE_NAME, CLIENT_IVC_VK_FILE_NAME } from '../prover/client_ivc_proof_utils.js';
6
+ import readline from 'readline';
7
7
  export const VK_FILENAME = 'vk';
8
- export const VK_FIELDS_FILENAME = 'vk_fields.json';
8
+ export const PUBLIC_INPUTS_FILENAME = 'public_inputs';
9
9
  export const PROOF_FILENAME = 'proof';
10
- export const PROOF_FIELDS_FILENAME = 'proof_fields.json';
11
10
  export const AVM_INPUTS_FILENAME = 'avm_inputs.bin';
12
11
  export const AVM_BYTECODE_FILENAME = 'avm_bytecode.bin';
13
12
  export const AVM_PUBLIC_INPUTS_FILENAME = 'avm_public_inputs.bin';
14
- export const AVM_HINTS_FILENAME = 'avm_hints.bin';
15
13
  export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
16
14
  BB_RESULT[BB_RESULT["SUCCESS"] = 0] = "SUCCESS";
17
15
  BB_RESULT[BB_RESULT["FAILURE"] = 1] = "FAILURE";
@@ -24,29 +22,57 @@ export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
24
22
  * @param command - The command to execute
25
23
  * @param args - The arguments to pass
26
24
  * @param logger - A log function
25
+ * @param timeout - An optional timeout before killing the BB process
27
26
  * @param resultParser - An optional handler for detecting success or failure
28
27
  * @returns The completed partial witness outputted from the circuit
29
- */ export function executeBB(pathToBB, command, args, logger, resultParser = (code)=>code === 0) {
28
+ */ export function executeBB(pathToBB, command, args, logger, concurrency, timeout, resultParser = (code)=>code === 0) {
30
29
  return new Promise((resolve)=>{
31
30
  // spawn the bb process
32
31
  const { HARDWARE_CONCURRENCY: _, ...envWithoutConcurrency } = process.env;
33
- const env = process.env.HARDWARE_CONCURRENCY ? process.env : envWithoutConcurrency;
32
+ const env = envWithoutConcurrency;
33
+ // We prioritise the concurrency argument if provided and > 0
34
+ if (concurrency && concurrency > 0) {
35
+ env.HARDWARE_CONCURRENCY = concurrency.toString();
36
+ } else if (process.env.HARDWARE_CONCURRENCY) {
37
+ env.HARDWARE_CONCURRENCY = process.env.HARDWARE_CONCURRENCY;
38
+ }
39
+ logger(`BB concurrency: ${env.HARDWARE_CONCURRENCY}`);
34
40
  logger(`Executing BB with: ${pathToBB} ${command} ${args.join(' ')}`);
35
41
  const bb = proc.spawn(pathToBB, [
36
42
  command,
37
43
  ...args
38
44
  ], {
45
+ stdio: [
46
+ 'ignore',
47
+ 'pipe',
48
+ 'pipe'
49
+ ],
39
50
  env
40
51
  });
41
- bb.stdout.on('data', (data)=>{
42
- const message = data.toString('utf-8').replace(/\n$/, '');
43
- logger(message);
44
- });
45
- bb.stderr.on('data', (data)=>{
46
- const message = data.toString('utf-8').replace(/\n$/, '');
47
- logger(message);
48
- });
52
+ let timeoutId;
53
+ if (timeout !== undefined) {
54
+ timeoutId = setTimeout(()=>{
55
+ logger(`BB execution timed out after ${timeout}ms, killing process`);
56
+ if (bb.pid) {
57
+ bb.kill('SIGKILL');
58
+ }
59
+ resolve({
60
+ status: 1,
61
+ exitCode: -1,
62
+ signal: 'TIMEOUT'
63
+ });
64
+ }, timeout);
65
+ }
66
+ readline.createInterface({
67
+ input: bb.stdout
68
+ }).on('line', logger);
69
+ readline.createInterface({
70
+ input: bb.stderr
71
+ }).on('line', logger);
49
72
  bb.on('close', (exitCode, signal)=>{
73
+ if (timeoutId) {
74
+ clearTimeout(timeoutId);
75
+ }
50
76
  if (resultParser(exitCode)) {
51
77
  resolve({
52
78
  status: 0,
@@ -67,12 +93,11 @@ export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
67
93
  signal: undefined
68
94
  }));
69
95
  }
70
- // TODO(#7369) comment this etc (really just take inspiration from this and rewrite it all O:))
71
- export async function executeBbClientIvcProof(pathToBB, workingDirectory, bytecodeStackPath, witnessStackPath, log) {
96
+ export async function executeBbChonkProof(pathToBB, workingDirectory, inputsPath, log, writeVk = false) {
72
97
  // Check that the working directory exists
73
98
  try {
74
99
  await fs.access(workingDirectory);
75
- } catch (error) {
100
+ } catch {
76
101
  return {
77
102
  status: 1,
78
103
  reason: `Working directory ${workingDirectory} does not exist`
@@ -89,26 +114,23 @@ export async function executeBbClientIvcProof(pathToBB, workingDirectory, byteco
89
114
  }
90
115
  try {
91
116
  // Write the bytecode to the working directory
92
- log(`bytecodePath ${bytecodeStackPath}`);
93
- log(`outputPath ${outputPath}`);
117
+ log(`inputsPath ${inputsPath}`);
118
+ const timer = new Timer();
119
+ const logFunction = (message)=>{
120
+ log(`bb - ${message}`);
121
+ };
94
122
  const args = [
95
123
  '-o',
96
124
  outputPath,
97
- '-b',
98
- bytecodeStackPath,
99
- '-w',
100
- witnessStackPath,
125
+ '--ivc_inputs_path',
126
+ inputsPath,
101
127
  '-v',
102
128
  '--scheme',
103
- 'client_ivc',
104
- '--input_type',
105
- 'runtime_stack',
106
- '--write_vk'
129
+ 'chonk'
107
130
  ];
108
- const timer = new Timer();
109
- const logFunction = (message)=>{
110
- log(`bb - ${message}`);
111
- };
131
+ if (writeVk) {
132
+ args.push('--write_vk');
133
+ }
112
134
  const result = await executeBB(pathToBB, 'prove', args, logFunction);
113
135
  const durationMs = timer.ms();
114
136
  if (result.status == 0) {
@@ -117,7 +139,7 @@ export async function executeBbClientIvcProof(pathToBB, workingDirectory, byteco
117
139
  durationMs,
118
140
  proofPath: `${outputPath}`,
119
141
  pkPath: undefined,
120
- vkPath: `${outputPath}`
142
+ vkDirectoryPath: `${outputPath}`
121
143
  };
122
144
  }
123
145
  // Not a great error message here but it is difficult to decipher what comes from bb
@@ -153,6 +175,15 @@ function getArgs(flavor) {
153
175
  'keccak'
154
176
  ];
155
177
  }
178
+ case 'ultra_starknet_honk':
179
+ {
180
+ return [
181
+ '--scheme',
182
+ 'ultra_honk',
183
+ '--oracle_hash',
184
+ 'starknet'
185
+ ];
186
+ }
156
187
  case 'ultra_rollup_honk':
157
188
  {
158
189
  return [
@@ -175,18 +206,19 @@ function getArgs(flavor) {
175
206
  * @param inputWitnessFile - The circuit input witness
176
207
  * @param log - A logging function
177
208
  * @returns An object containing a result indication, the location of the proof and the duration taken
178
- */ export async function generateProof(pathToBB, workingDirectory, circuitName, bytecode, recursive, inputWitnessFile, flavor, log) {
209
+ */ export async function generateProof(pathToBB, workingDirectory, circuitName, bytecode, verificationKey, inputWitnessFile, flavor, log) {
179
210
  // Check that the working directory exists
180
211
  try {
181
212
  await fs.access(workingDirectory);
182
- } catch (error) {
213
+ } catch {
183
214
  return {
184
215
  status: 1,
185
216
  reason: `Working directory ${workingDirectory} does not exist`
186
217
  };
187
218
  }
188
- // The bytecode is written to e.g. /workingDirectory/BaseParityArtifact-bytecode
219
+ // The bytecode is written to e.g. /workingDirectory/ParityBaseArtifact-bytecode
189
220
  const bytecodePath = `${workingDirectory}/${circuitName}-bytecode`;
221
+ const vkPath = `${workingDirectory}/${circuitName}-vk`;
190
222
  // The proof is written to e.g. /workingDirectory/ultra_honk/proof
191
223
  const outputPath = `${workingDirectory}`;
192
224
  const binaryPresent = await fs.access(pathToBB, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
@@ -197,26 +229,30 @@ function getArgs(flavor) {
197
229
  };
198
230
  }
199
231
  try {
200
- // Write the bytecode to the working directory
201
- await fs.writeFile(bytecodePath, bytecode);
232
+ // Write the bytecode and vk to the working directory
233
+ await Promise.all([
234
+ fs.writeFile(bytecodePath, bytecode),
235
+ fs.writeFile(vkPath, verificationKey)
236
+ ]);
202
237
  const args = getArgs(flavor).concat([
203
- '--output_format',
204
- 'bytes_and_fields',
205
- '--write_vk',
238
+ '--disable_zk',
206
239
  '-o',
207
240
  outputPath,
208
241
  '-b',
209
242
  bytecodePath,
243
+ '-k',
244
+ vkPath,
210
245
  '-w',
211
246
  inputWitnessFile,
212
247
  '-v'
213
248
  ]);
214
- if (recursive) {
215
- args.push('--init_kzg_accumulator');
249
+ const loggingArg = log.level === 'debug' || log.level === 'trace' ? '-d' : log.level === 'verbose' ? '-v' : '';
250
+ if (loggingArg !== '') {
251
+ args.push(loggingArg);
216
252
  }
217
253
  const timer = new Timer();
218
254
  const logFunction = (message)=>{
219
- log(`${circuitName} BB out - ${message}`);
255
+ log.info(`${circuitName} BB out - ${message}`);
220
256
  };
221
257
  const result = await executeBB(pathToBB, `prove`, args, logFunction);
222
258
  const duration = timer.ms();
@@ -226,80 +262,7 @@ function getArgs(flavor) {
226
262
  durationMs: duration,
227
263
  proofPath: `${outputPath}`,
228
264
  pkPath: undefined,
229
- vkPath: `${outputPath}`
230
- };
231
- }
232
- // Not a great error message here but it is difficult to decipher what comes from bb
233
- return {
234
- status: 1,
235
- reason: `Failed to generate proof. Exit code ${result.exitCode}. Signal ${result.signal}.`,
236
- retry: !!result.signal
237
- };
238
- } catch (error) {
239
- return {
240
- status: 1,
241
- reason: `${error}`
242
- };
243
- }
244
- }
245
- /**
246
- * Used for generating proofs of the tube circuit
247
- * It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
248
- * @param pathToBB - The full path to the bb binary
249
- * @param workingDirectory - A working directory for use by bb
250
- * @param circuitName - An identifier for the circuit
251
- * @param bytecode - The compiled circuit bytecode
252
- * @param inputWitnessFile - The circuit input witness
253
- * @param log - A logging function
254
- * @returns An object containing a result indication, the location of the proof and the duration taken
255
- */ export async function generateTubeProof(pathToBB, workingDirectory, log) {
256
- // Check that the working directory exists
257
- try {
258
- await fs.access(workingDirectory);
259
- } catch (error) {
260
- return {
261
- status: 1,
262
- reason: `Working directory ${workingDirectory} does not exist`
263
- };
264
- }
265
- // // Paths for the inputs
266
- const vkPath = join(workingDirectory, CLIENT_IVC_VK_FILE_NAME);
267
- const proofPath = join(workingDirectory, CLIENT_IVC_PROOF_FILE_NAME);
268
- // The proof is written to e.g. /workingDirectory/proof
269
- const outputPath = workingDirectory;
270
- const filePresent = async (file)=>await fs.access(file, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
271
- const binaryPresent = await filePresent(pathToBB);
272
- if (!binaryPresent) {
273
- return {
274
- status: 1,
275
- reason: `Failed to find bb binary at ${pathToBB}`
276
- };
277
- }
278
- try {
279
- if (!await filePresent(vkPath) || !await filePresent(proofPath)) {
280
- return {
281
- status: 1,
282
- reason: `Client IVC input files not present in ${workingDirectory}`
283
- };
284
- }
285
- const args = [
286
- '-o',
287
- outputPath,
288
- '-v'
289
- ];
290
- const timer = new Timer();
291
- const logFunction = (message)=>{
292
- log(`TubeCircuit (prove) BB out - ${message}`);
293
- };
294
- const result = await executeBB(pathToBB, 'prove_tube', args, logFunction);
295
- const durationMs = timer.ms();
296
- if (result.status == 0) {
297
- return {
298
- status: 0,
299
- durationMs,
300
- proofPath: outputPath,
301
- pkPath: undefined,
302
- vkPath: outputPath
265
+ vkDirectoryPath: `${outputPath}`
303
266
  };
304
267
  }
305
268
  // Not a great error message here but it is difficult to decipher what comes from bb
@@ -321,13 +284,14 @@ function getArgs(flavor) {
321
284
  * @param pathToBB - The full path to the bb binary
322
285
  * @param workingDirectory - A working directory for use by bb
323
286
  * @param input - The inputs for the public function to be proven
324
- * @param log - A logging function
287
+ * @param logger - A logging function
288
+ * @param checkCircuitOnly - A boolean to toggle a "check-circuit only" operation instead of proving.
325
289
  * @returns An object containing a result indication, the location of the proof and the duration taken
326
- */ export async function generateAvmProofV2(pathToBB, workingDirectory, input, logger) {
290
+ */ export async function generateAvmProof(pathToBB, workingDirectory, input, logger, checkCircuitOnly = false) {
327
291
  // Check that the working directory exists
328
292
  try {
329
293
  await fs.access(workingDirectory);
330
- } catch (error) {
294
+ } catch {
331
295
  return {
332
296
  status: 1,
333
297
  reason: `Working directory ${workingDirectory} does not exist`
@@ -354,7 +318,10 @@ function getArgs(flavor) {
354
318
  reason: `Could not write avm inputs to ${avmInputsPath}`
355
319
  };
356
320
  }
357
- const args = [
321
+ const args = checkCircuitOnly ? [
322
+ '--avm-inputs',
323
+ avmInputsPath
324
+ ] : [
358
325
  '--avm-inputs',
359
326
  avmInputsPath,
360
327
  '-o',
@@ -365,93 +332,11 @@ function getArgs(flavor) {
365
332
  args.push(loggingArg);
366
333
  }
367
334
  const timer = new Timer();
368
- const logFunction = (message)=>{
369
- logger.verbose(`AvmCircuit (prove) BB out - ${message}`);
370
- };
371
- const result = await executeBB(pathToBB, 'avm2_prove', args, logFunction);
372
- const duration = timer.ms();
373
- if (result.status == 0) {
374
- return {
375
- status: 0,
376
- durationMs: duration,
377
- proofPath: join(outputPath, PROOF_FILENAME),
378
- pkPath: undefined,
379
- vkPath: outputPath
380
- };
381
- }
382
- // Not a great error message here but it is difficult to decipher what comes from bb
383
- return {
384
- status: 1,
385
- reason: `Failed to generate proof. Exit code ${result.exitCode}. Signal ${result.signal}.`,
386
- retry: !!result.signal
387
- };
388
- } catch (error) {
389
- return {
390
- status: 1,
391
- reason: `${error}`
392
- };
393
- }
394
- }
395
- /**
396
- * Used for generating AVM proofs (or doing check-circuit).
397
- * It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
398
- * @param pathToBB - The full path to the bb binary
399
- * @param workingDirectory - A working directory for use by bb
400
- * @param bytecode - The AVM bytecode for the public function to be proven (expected to be decompressed)
401
- * @param log - A logging function
402
- * @returns An object containing a result indication, the location of the proof and the duration taken
403
- */ export async function generateAvmProof(pathToBB, workingDirectory, _input, logger, checkCircuitOnly = false) {
404
- // Check that the working directory exists
405
- try {
406
- await fs.access(workingDirectory);
407
- } catch (error) {
408
- return {
409
- status: 1,
410
- reason: `Working directory ${workingDirectory} does not exist`
411
- };
412
- }
413
- // Paths for the inputs
414
- const publicInputsPath = join(workingDirectory, AVM_PUBLIC_INPUTS_FILENAME);
415
- const avmHintsPath = join(workingDirectory, AVM_HINTS_FILENAME);
416
- // The proof is written to e.g. /workingDirectory/proof
417
- const outputPath = workingDirectory;
418
- const filePresent = async (file)=>await fs.access(file, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
419
- const binaryPresent = await filePresent(pathToBB);
420
- if (!binaryPresent) {
421
- return {
422
- status: 1,
423
- reason: `Failed to find bb binary at ${pathToBB}`
424
- };
425
- }
426
- try {
427
- // Write the inputs to the working directory.
428
- // WARNING: Not writing the inputs since VM1 is disabled!
429
- // await fs.writeFile(publicInputsPath, input.publicInputs.toBuffer());
430
- // if (!(await filePresent(publicInputsPath))) {
431
- // return { status: BB_RESULT.FAILURE, reason: `Could not write publicInputs at ${publicInputsPath}` };
432
- // }
433
- // await fs.writeFile(avmHintsPath, input.avmHints.toBuffer());
434
- // if (!(await filePresent(avmHintsPath))) {
435
- // return { status: BB_RESULT.FAILURE, reason: `Could not write avmHints at ${avmHintsPath}` };
436
- // }
437
- const args = [
438
- '--avm-public-inputs',
439
- publicInputsPath,
440
- '--avm-hints',
441
- avmHintsPath,
442
- '-o',
443
- outputPath
444
- ];
445
- const loggingArg = logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
446
- if (loggingArg !== '') {
447
- args.push(loggingArg);
448
- }
449
- const timer = new Timer();
450
- const cmd = checkCircuitOnly ? 'check_circuit' : 'prove';
335
+ const cmd = checkCircuitOnly ? 'avm_check_circuit' : 'avm_prove';
451
336
  const logFunction = (message)=>{
452
337
  logger.verbose(`AvmCircuit (${cmd}) BB out - ${message}`);
453
338
  };
454
- const result = await executeBB(pathToBB, `avm_${cmd}`, args, logFunction);
339
+ const result = await executeBB(pathToBB, cmd, args, logFunction);
455
340
  const duration = timer.ms();
456
341
  if (result.status == 0) {
457
342
  return {
@@ -459,14 +344,14 @@ function getArgs(flavor) {
459
344
  durationMs: duration,
460
345
  proofPath: join(outputPath, PROOF_FILENAME),
461
346
  pkPath: undefined,
462
- vkPath: outputPath
347
+ vkDirectoryPath: outputPath
463
348
  };
464
349
  }
465
350
  // Not a great error message here but it is difficult to decipher what comes from bb
466
351
  return {
467
352
  status: 1,
468
- reason: `Failed to generate proof. Exit code ${result.exitCode}. Signal ${result.signal}.`,
469
- retry: !!result.signal
353
+ reason: `Failed to generate proof. AVM proof for TX hash ${input.hints.tx.hash}. Exit code ${result.exitCode}. Signal ${result.signal}.`,
354
+ retry: result.signal === 'SIGKILL'
470
355
  };
471
356
  } catch (error) {
472
357
  return {
@@ -485,17 +370,7 @@ function getArgs(flavor) {
485
370
  */ export async function verifyProof(pathToBB, proofFullPath, verificationKeyPath, ultraHonkFlavor, log) {
486
371
  return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, `verify`, log, getArgs(ultraHonkFlavor));
487
372
  }
488
- /**
489
- * Used for verifying proofs of the AVM
490
- * @param pathToBB - The full path to the bb binary
491
- * @param proofFullPath - The full path to the proof to be verified
492
- * @param verificationKeyPath - The full path to the circuit verification key
493
- * @param log - A logging function
494
- * @returns An object containing a result indication and duration taken
495
- */ export async function verifyAvmProof(pathToBB, proofFullPath, verificationKeyPath, logger) {
496
- return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, 'avm_verify', logger);
497
- }
498
- export async function verifyAvmProofV2(pathToBB, workingDirectory, proofFullPath, publicInputs, verificationKeyPath, logger) {
373
+ export async function verifyAvmProof(pathToBB, workingDirectory, proofFullPath, publicInputs, verificationKeyPath, logger) {
499
374
  const inputsBuffer = publicInputs.serializeWithMessagePack();
500
375
  // Write the inputs to the working directory.
501
376
  const filePresent = async (file)=>await fs.access(file, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
@@ -507,19 +382,20 @@ export async function verifyAvmProofV2(pathToBB, workingDirectory, proofFullPath
507
382
  reason: `Could not write avm inputs to ${avmInputsPath}`
508
383
  };
509
384
  }
510
- return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, 'avm2_verify', logger, [
385
+ return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, 'avm_verify', logger, [
511
386
  '--avm-public-inputs',
512
387
  avmInputsPath
513
388
  ]);
514
389
  }
515
390
  /**
516
- * Verifies a ClientIvcProof
391
+ * Verifies a ChonkProof
517
392
  * TODO(#7370) The verification keys should be supplied separately
518
393
  * @param pathToBB - The full path to the bb binary
519
394
  * @param targetPath - The path to the folder with the proof, accumulator, and verification keys
520
395
  * @param log - A logging function
396
+ * @param concurrency - The number of threads to use for the verification
521
397
  * @returns An object containing a result indication and duration taken
522
- */ export async function verifyClientIvcProof(pathToBB, proofPath, keyPath, log) {
398
+ */ export async function verifyChonkProof(pathToBB, proofPath, keyPath, log, concurrency = 1) {
523
399
  const binaryPresent = await fs.access(pathToBB, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
524
400
  if (!binaryPresent) {
525
401
  return {
@@ -530,15 +406,16 @@ export async function verifyAvmProofV2(pathToBB, workingDirectory, proofFullPath
530
406
  try {
531
407
  const args = [
532
408
  '--scheme',
533
- 'client_ivc',
409
+ 'chonk',
534
410
  '-p',
535
411
  proofPath,
536
412
  '-k',
537
- keyPath
413
+ keyPath,
414
+ '-v'
538
415
  ];
539
416
  const timer = new Timer();
540
417
  const command = 'verify';
541
- const result = await executeBB(pathToBB, command, args, log);
418
+ const result = await executeBB(pathToBB, command, args, log, concurrency);
542
419
  const duration = timer.ms();
543
420
  if (result.status == 0) {
544
421
  return {
@@ -579,13 +456,32 @@ export async function verifyAvmProofV2(pathToBB, workingDirectory, proofFullPath
579
456
  logger.verbose(`bb-prover (verify) BB out - ${message}`);
580
457
  };
581
458
  try {
582
- const args = [
583
- '-p',
584
- proofFullPath,
585
- '-k',
586
- verificationKeyPath,
587
- ...extraArgs
588
- ];
459
+ let args;
460
+ if (command == 'verify') {
461
+ // Specify the public inputs path in the case of UH verification.
462
+ // Take proofFullPath and remove the suffix past the / to get the directory.
463
+ const proofDir = proofFullPath.substring(0, proofFullPath.lastIndexOf('/'));
464
+ const publicInputsFullPath = join(proofDir, '/public_inputs');
465
+ logger.debug(`public inputs path: ${publicInputsFullPath}`);
466
+ args = [
467
+ '-p',
468
+ proofFullPath,
469
+ '-k',
470
+ verificationKeyPath,
471
+ '-i',
472
+ publicInputsFullPath,
473
+ '--disable_zk',
474
+ ...extraArgs
475
+ ];
476
+ } else {
477
+ args = [
478
+ '-p',
479
+ proofFullPath,
480
+ '-k',
481
+ verificationKeyPath,
482
+ ...extraArgs
483
+ ];
484
+ }
589
485
  const loggingArg = logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
590
486
  if (loggingArg !== '') {
591
487
  args.push(loggingArg);
@@ -685,13 +581,13 @@ export async function generateContractForVerificationKey(pathToBB, vkFilePath, c
685
581
  // Check that the working directory exists
686
582
  try {
687
583
  await fs.access(workingDirectory);
688
- } catch (error) {
584
+ } catch {
689
585
  return {
690
586
  status: 1,
691
587
  reason: `Working directory ${workingDirectory} does not exist`
692
588
  };
693
589
  }
694
- // The bytecode is written to e.g. /workingDirectory/BaseParityArtifact-bytecode
590
+ // The bytecode is written to e.g. /workingDirectory/ParityBaseArtifact-bytecode
695
591
  const bytecodePath = `${workingDirectory}/${circuitName}-bytecode`;
696
592
  const binaryPresent = await fs.access(pathToBB, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
697
593
  if (!binaryPresent) {
@@ -712,7 +608,7 @@ export async function generateContractForVerificationKey(pathToBB, vkFilePath, c
712
608
  const timer = new Timer();
713
609
  const result = await executeBB(pathToBB, 'gates', [
714
610
  '--scheme',
715
- flavor === 'mega_honk' ? 'client_ivc' : 'ultra_honk',
611
+ flavor === 'mega_honk' ? 'chonk' : 'ultra_honk',
716
612
  '-b',
717
613
  bytecodePath,
718
614
  '-v'
@@ -772,7 +668,7 @@ async function fsCache(dir, expectedCacheKey, logger, force, action) {
772
668
  }
773
669
  try {
774
670
  await fs.writeFile(cacheFilePath, expectedCacheKey);
775
- } catch (err) {
671
+ } catch {
776
672
  logger(`Couldn't write cache data to ${cacheFilePath}. Skipping cache...`);
777
673
  // ignore
778
674
  }
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
2
  import 'source-map-support/register.js';
3
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBR0EsT0FBTyxnQ0FBZ0MsQ0FBQyJ9
package/dest/config.d.ts CHANGED
@@ -3,6 +3,8 @@ export interface BBConfig {
3
3
  bbWorkingDirectory: string;
4
4
  /** Whether to skip tmp dir cleanup for debugging purposes */
5
5
  bbSkipCleanup: boolean;
6
+ numConcurrentIVCVerifiers: number;
7
+ bbIVCConcurrency: number;
6
8
  }
7
9
  export interface ACVMConfig {
8
10
  /** The path to the ACVM binary */
@@ -10,4 +12,4 @@ export interface ACVMConfig {
10
12
  /** The working directory to use for simulation/proving */
11
13
  acvmWorkingDirectory: string;
12
14
  }
13
- //# sourceMappingURL=config.d.ts.map
15
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE1BQU0sV0FBVyxRQUFRO0lBQ3ZCLFlBQVksRUFBRSxNQUFNLENBQUM7SUFDckIsa0JBQWtCLEVBQUUsTUFBTSxDQUFDO0lBQzNCLDZEQUE2RDtJQUM3RCxhQUFhLEVBQUUsT0FBTyxDQUFDO0lBQ3ZCLHlCQUF5QixFQUFFLE1BQU0sQ0FBQztJQUNsQyxnQkFBZ0IsRUFBRSxNQUFNLENBQUM7Q0FDMUI7QUFFRCxNQUFNLFdBQVcsVUFBVTtJQUN6QixrQ0FBa0M7SUFDbEMsY0FBYyxFQUFFLE1BQU0sQ0FBQztJQUN2QiwwREFBMEQ7SUFDMUQsb0JBQW9CLEVBQUUsTUFBTSxDQUFDO0NBQzlCIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,kCAAkC;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,oBAAoB,EAAE,MAAM,CAAC;CAC9B"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,aAAa,EAAE,OAAO,CAAC;IACvB,yBAAyB,EAAE,MAAM,CAAC;IAClC,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,kCAAkC;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,oBAAoB,EAAE,MAAM,CAAC;CAC9B"}
package/dest/honk.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
2
- export type UltraHonkFlavor = 'ultra_honk' | 'ultra_keccak_honk' | 'ultra_rollup_honk';
2
+ export type UltraHonkFlavor = 'ultra_honk' | 'ultra_keccak_honk' | 'ultra_starknet_honk' | 'ultra_rollup_honk';
3
3
  declare const UltraKeccakHonkCircuits: ["RootRollupArtifact"];
4
- declare const UltraHonkCircuits: ["BaseParityArtifact", "RootParityArtifact"];
4
+ declare const UltraHonkCircuits: ["ParityBaseArtifact", "ParityRootArtifact"];
5
5
  export type UltraKeccakHonkServerProtocolArtifact = (typeof UltraKeccakHonkCircuits)[number];
6
6
  export type UltraHonkServerProtocolArtifact = (typeof UltraHonkCircuits)[number];
7
7
  export type UltraRollupHonkServerProtocolArtifact = Exclude<Exclude<ServerProtocolArtifact, UltraKeccakHonkServerProtocolArtifact>, UltraHonkServerProtocolArtifact>;
@@ -10,4 +10,4 @@ export declare function getUltraHonkFlavorForCircuit(artifact: UltraHonkServerPr
10
10
  export declare function getUltraHonkFlavorForCircuit(artifact: UltraRollupHonkServerProtocolArtifact): 'ultra_rollup_honk';
11
11
  export declare function getUltraHonkFlavorForCircuit(artifact: ServerProtocolArtifact): UltraHonkFlavor;
12
12
  export {};
13
- //# sourceMappingURL=honk.d.ts.map
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9uay5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2hvbmsudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSw0Q0FBNEMsQ0FBQztBQUV6RixNQUFNLE1BQU0sZUFBZSxHQUFHLFlBQVksR0FBRyxtQkFBbUIsR0FBRyxxQkFBcUIsR0FBRyxtQkFBbUIsQ0FBQztBQUUvRyxRQUFBLE1BQU0sdUJBQXVCLHdCQUFxRSxDQUFDO0FBQ25HLFFBQUEsTUFBTSxpQkFBaUIsOENBQTJGLENBQUM7QUFFbkgsTUFBTSxNQUFNLHFDQUFxQyxHQUFHLENBQUMsT0FBTyx1QkFBdUIsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBQzdGLE1BQU0sTUFBTSwrQkFBK0IsR0FBRyxDQUFDLE9BQU8saUJBQWlCLENBQUMsQ0FBQyxNQUFNLENBQUMsQ0FBQztBQUNqRixNQUFNLE1BQU0scUNBQXFDLEdBQUcsT0FBTyxDQUN6RCxPQUFPLENBQUMsc0JBQXNCLEVBQUUscUNBQXFDLENBQUMsRUFDdEUsK0JBQStCLENBQ2hDLENBQUM7QUFFRix3QkFBZ0IsNEJBQTRCLENBQUMsUUFBUSxFQUFFLHFDQUFxQyxHQUFHLG1CQUFtQixDQUFDO0FBQ25ILHdCQUFnQiw0QkFBNEIsQ0FBQyxRQUFRLEVBQUUsK0JBQStCLEdBQUcsWUFBWSxDQUFDO0FBQ3RHLHdCQUFnQiw0QkFBNEIsQ0FBQyxRQUFRLEVBQUUscUNBQXFDLEdBQUcsbUJBQW1CLENBQUM7QUFDbkgsd0JBQWdCLDRCQUE0QixDQUFDLFFBQVEsRUFBRSxzQkFBc0IsR0FBRyxlQUFlLENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"honk.d.ts","sourceRoot":"","sources":["../src/honk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEzF,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAEvF,QAAA,MAAM,uBAAuB,wBAAqE,CAAC;AACnG,QAAA,MAAM,iBAAiB,8CAA2F,CAAC;AAEnH,MAAM,MAAM,qCAAqC,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7F,MAAM,MAAM,+BAA+B,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjF,MAAM,MAAM,qCAAqC,GAAG,OAAO,CACzD,OAAO,CAAC,sBAAsB,EAAE,qCAAqC,CAAC,EACtE,+BAA+B,CAChC,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,qCAAqC,GAAG,mBAAmB,CAAC;AACnH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,+BAA+B,GAAG,YAAY,CAAC;AACtG,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,qCAAqC,GAAG,mBAAmB,CAAC;AACnH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,sBAAsB,GAAG,eAAe,CAAC"}
1
+ {"version":3,"file":"honk.d.ts","sourceRoot":"","sources":["../src/honk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEzF,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,mBAAmB,CAAC;AAE/G,QAAA,MAAM,uBAAuB,wBAAqE,CAAC;AACnG,QAAA,MAAM,iBAAiB,8CAA2F,CAAC;AAEnH,MAAM,MAAM,qCAAqC,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7F,MAAM,MAAM,+BAA+B,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AACjF,MAAM,MAAM,qCAAqC,GAAG,OAAO,CACzD,OAAO,CAAC,sBAAsB,EAAE,qCAAqC,CAAC,EACtE,+BAA+B,CAChC,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,qCAAqC,GAAG,mBAAmB,CAAC;AACnH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,+BAA+B,GAAG,YAAY,CAAC;AACtG,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,qCAAqC,GAAG,mBAAmB,CAAC;AACnH,wBAAgB,4BAA4B,CAAC,QAAQ,EAAE,sBAAsB,GAAG,eAAe,CAAC"}
package/dest/honk.js CHANGED
@@ -2,10 +2,11 @@ const UltraKeccakHonkCircuits = [
2
2
  'RootRollupArtifact'
3
3
  ];
4
4
  const UltraHonkCircuits = [
5
- 'BaseParityArtifact',
6
- 'RootParityArtifact'
5
+ 'ParityBaseArtifact',
6
+ 'ParityRootArtifact'
7
7
  ];
8
8
  export function getUltraHonkFlavorForCircuit(artifact) {
9
+ // STARKNET: how to allow for the distinction between keccak/starknet? ultra_keccak_honk is returned in both cases
9
10
  if (isUltraKeccakHonkCircuit(artifact)) {
10
11
  return 'ultra_keccak_honk';
11
12
  } else if (UltraHonkCircuits.includes(artifact)) {
package/dest/index.d.ts CHANGED
@@ -4,5 +4,6 @@ export * from './verifier/index.js';
4
4
  export * from './config.js';
5
5
  export * from './bb/execute.js';
6
6
  export * from './honk.js';
7
+ export * from './verification_key/verification_key_data.js';
7
8
  export { type ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
8
- //# sourceMappingURL=index.d.ts.map
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLG1CQUFtQixDQUFDO0FBQ2xDLGNBQWMsaUJBQWlCLENBQUM7QUFDaEMsY0FBYyxxQkFBcUIsQ0FBQztBQUNwQyxjQUFjLGFBQWEsQ0FBQztBQUM1QixjQUFjLGlCQUFpQixDQUFDO0FBQ2hDLGNBQWMsV0FBVyxDQUFDO0FBQzFCLGNBQWMsNkNBQTZDLENBQUM7QUFFNUQsT0FBTyxFQUFFLEtBQUssNkJBQTZCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQyJ9