@aztec/bb-prover 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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.
- package/dest/avm_proving_tests/avm_proving_tester.d.ts +7 -6
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +38 -15
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/execute.d.ts +9 -17
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +74 -165
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +1 -1
- package/dest/honk.d.ts +2 -2
- package/dest/honk.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/instrumentation.d.ts +3 -3
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +21 -43
- package/dest/prover/client/bb_private_kernel_prover.d.ts +12 -6
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +38 -7
- package/dest/prover/client/bundle.d.ts +6 -0
- package/dest/prover/client/bundle.d.ts.map +1 -0
- package/dest/prover/client/bundle.js +7 -0
- package/dest/prover/client/lazy.d.ts +6 -0
- package/dest/prover/client/lazy.d.ts.map +1 -0
- package/dest/prover/client/lazy.js +7 -0
- package/dest/prover/index.d.ts +1 -1
- package/dest/prover/proof_utils.d.ts +9 -9
- package/dest/prover/proof_utils.d.ts.map +1 -1
- package/dest/prover/proof_utils.js +42 -25
- package/dest/prover/server/bb_prover.d.ts +27 -50
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +478 -182
- package/dest/test/delay_values.d.ts +1 -1
- package/dest/test/delay_values.d.ts.map +1 -1
- package/dest/test/delay_values.js +37 -25
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -0
- package/dest/test/test_circuit_prover.d.ts +24 -34
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +506 -85
- package/dest/test/test_verifier.d.ts +3 -1
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +15 -0
- package/dest/verification_key/verification_key_data.d.ts +1 -8
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +1 -20
- package/dest/verifier/bb_verifier.d.ts +3 -5
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +23 -28
- package/dest/verifier/index.d.ts +2 -2
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -1
- package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/{queued_ivc_verifier.js → queued_chonk_verifier.js} +10 -41
- package/package.json +23 -23
- package/src/avm_proving_tests/avm_proving_tester.ts +49 -35
- package/src/bb/execute.ts +50 -148
- package/src/honk.ts +1 -1
- package/src/instrumentation.ts +22 -45
- package/src/prover/client/bb_private_kernel_prover.ts +50 -10
- package/src/prover/client/bundle.ts +10 -0
- package/src/prover/client/lazy.ts +10 -0
- package/src/prover/proof_utils.ts +53 -31
- package/src/prover/server/bb_prover.ts +252 -324
- package/src/test/delay_values.ts +38 -24
- package/src/test/index.ts +1 -0
- package/src/test/test_circuit_prover.ts +229 -155
- package/src/test/test_verifier.ts +8 -0
- package/src/verification_key/verification_key_data.ts +1 -26
- package/src/verifier/bb_verifier.ts +33 -36
- package/src/verifier/index.ts +1 -1
- package/src/verifier/{queued_ivc_verifier.ts → queued_chonk_verifier.ts} +10 -41
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts +0 -23
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/client/native/bb_native_private_kernel_prover.js +0 -66
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts +0 -15
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.js +0 -48
- package/dest/prover/client/wasm/bundle.d.ts +0 -6
- package/dest/prover/client/wasm/bundle.d.ts.map +0 -1
- package/dest/prover/client/wasm/bundle.js +0 -8
- package/dest/prover/client/wasm/lazy.d.ts +0 -6
- package/dest/prover/client/wasm/lazy.d.ts.map +0 -1
- package/dest/prover/client/wasm/lazy.js +0 -8
- package/dest/stats.d.ts +0 -4
- package/dest/stats.d.ts.map +0 -1
- package/dest/stats.js +0 -45
- package/dest/verifier/queued_ivc_verifier.d.ts +0 -15
- package/dest/verifier/queued_ivc_verifier.d.ts.map +0 -1
- package/src/prover/client/native/bb_native_private_kernel_prover.ts +0 -105
- package/src/prover/client/wasm/bb_wasm_private_kernel_prover.ts +0 -60
- package/src/prover/client/wasm/bundle.ts +0 -11
- package/src/prover/client/wasm/lazy.ts +0 -11
- package/src/stats.ts +0 -47
package/src/bb/execute.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sha256 } from '@aztec/foundation/crypto';
|
|
1
|
+
import { sha256 } from '@aztec/foundation/crypto/sha256';
|
|
2
2
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
@@ -6,6 +6,7 @@ import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm
|
|
|
6
6
|
import * as proc from 'child_process';
|
|
7
7
|
import { promises as fs } from 'fs';
|
|
8
8
|
import { basename, dirname, join } from 'path';
|
|
9
|
+
import readline from 'readline';
|
|
9
10
|
|
|
10
11
|
import type { UltraHonkFlavor } from '../honk.js';
|
|
11
12
|
|
|
@@ -15,7 +16,6 @@ export const PROOF_FILENAME = 'proof';
|
|
|
15
16
|
export const AVM_INPUTS_FILENAME = 'avm_inputs.bin';
|
|
16
17
|
export const AVM_BYTECODE_FILENAME = 'avm_bytecode.bin';
|
|
17
18
|
export const AVM_PUBLIC_INPUTS_FILENAME = 'avm_public_inputs.bin';
|
|
18
|
-
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
19
19
|
|
|
20
20
|
export enum BB_RESULT {
|
|
21
21
|
SUCCESS,
|
|
@@ -86,6 +86,7 @@ export function executeBB(
|
|
|
86
86
|
logger(`BB concurrency: ${env.HARDWARE_CONCURRENCY}`);
|
|
87
87
|
logger(`Executing BB with: ${pathToBB} ${command} ${args.join(' ')}`);
|
|
88
88
|
const bb = proc.spawn(pathToBB, [command, ...args], {
|
|
89
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
89
90
|
env,
|
|
90
91
|
});
|
|
91
92
|
|
|
@@ -100,14 +101,9 @@ export function executeBB(
|
|
|
100
101
|
}, timeout);
|
|
101
102
|
}
|
|
102
103
|
|
|
103
|
-
bb.stdout.on('
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
107
|
-
bb.stderr.on('data', data => {
|
|
108
|
-
const message = data.toString('utf-8').replace(/\n$/, '');
|
|
109
|
-
logger(message);
|
|
110
|
-
});
|
|
104
|
+
readline.createInterface({ input: bb.stdout }).on('line', logger);
|
|
105
|
+
readline.createInterface({ input: bb.stderr }).on('line', logger);
|
|
106
|
+
|
|
111
107
|
bb.on('close', (exitCode: number, signal?: string) => {
|
|
112
108
|
if (timeoutId) {
|
|
113
109
|
clearTimeout(timeoutId);
|
|
@@ -121,7 +117,7 @@ export function executeBB(
|
|
|
121
117
|
}).catch(_ => ({ status: BB_RESULT.FAILURE, exitCode: -1, signal: undefined }));
|
|
122
118
|
}
|
|
123
119
|
|
|
124
|
-
export async function
|
|
120
|
+
export async function executeBbChonkProof(
|
|
125
121
|
pathToBB: string,
|
|
126
122
|
workingDirectory: string,
|
|
127
123
|
inputsPath: string,
|
|
@@ -154,7 +150,7 @@ export async function executeBbClientIvcProof(
|
|
|
154
150
|
log(`bb - ${message}`);
|
|
155
151
|
};
|
|
156
152
|
|
|
157
|
-
const args = ['-o', outputPath, '--ivc_inputs_path', inputsPath, '-v', '--scheme', '
|
|
153
|
+
const args = ['-o', outputPath, '--ivc_inputs_path', inputsPath, '-v', '--scheme', 'chonk'];
|
|
158
154
|
if (writeVk) {
|
|
159
155
|
args.push('--write_vk');
|
|
160
156
|
}
|
|
@@ -214,6 +210,7 @@ export async function generateProof(
|
|
|
214
210
|
workingDirectory: string,
|
|
215
211
|
circuitName: string,
|
|
216
212
|
bytecode: Buffer,
|
|
213
|
+
verificationKey: Buffer,
|
|
217
214
|
inputWitnessFile: string,
|
|
218
215
|
flavor: UltraHonkFlavor,
|
|
219
216
|
log: Logger,
|
|
@@ -225,8 +222,9 @@ export async function generateProof(
|
|
|
225
222
|
return { status: BB_RESULT.FAILURE, reason: `Working directory ${workingDirectory} does not exist` };
|
|
226
223
|
}
|
|
227
224
|
|
|
228
|
-
// The bytecode is written to e.g. /workingDirectory/
|
|
225
|
+
// The bytecode is written to e.g. /workingDirectory/ParityBaseArtifact-bytecode
|
|
229
226
|
const bytecodePath = `${workingDirectory}/${circuitName}-bytecode`;
|
|
227
|
+
const vkPath = `${workingDirectory}/${circuitName}-vk`;
|
|
230
228
|
|
|
231
229
|
// The proof is written to e.g. /workingDirectory/ultra_honk/proof
|
|
232
230
|
const outputPath = `${workingDirectory}`;
|
|
@@ -240,16 +238,16 @@ export async function generateProof(
|
|
|
240
238
|
}
|
|
241
239
|
|
|
242
240
|
try {
|
|
243
|
-
// Write the bytecode to the working directory
|
|
244
|
-
await fs.writeFile(bytecodePath, bytecode);
|
|
245
|
-
// TODO(#15043): Avoid write_vk flag here.
|
|
241
|
+
// Write the bytecode and vk to the working directory
|
|
242
|
+
await Promise.all([fs.writeFile(bytecodePath, bytecode), fs.writeFile(vkPath, verificationKey)]);
|
|
246
243
|
const args = getArgs(flavor).concat([
|
|
247
244
|
'--disable_zk',
|
|
248
|
-
'--write_vk',
|
|
249
245
|
'-o',
|
|
250
246
|
outputPath,
|
|
251
247
|
'-b',
|
|
252
248
|
bytecodePath,
|
|
249
|
+
'-k',
|
|
250
|
+
vkPath,
|
|
253
251
|
'-w',
|
|
254
252
|
inputWitnessFile,
|
|
255
253
|
'-v',
|
|
@@ -286,74 +284,6 @@ export async function generateProof(
|
|
|
286
284
|
}
|
|
287
285
|
}
|
|
288
286
|
|
|
289
|
-
/**
|
|
290
|
-
* Used for generating proofs of the tube circuit
|
|
291
|
-
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
292
|
-
*
|
|
293
|
-
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
294
|
-
*/
|
|
295
|
-
export async function generateTubeProof(
|
|
296
|
-
pathToBB: string,
|
|
297
|
-
workingDirectory: string,
|
|
298
|
-
vkPath: string,
|
|
299
|
-
log: LogFn,
|
|
300
|
-
): Promise<BBFailure | BBSuccess> {
|
|
301
|
-
// Check that the working directory exists
|
|
302
|
-
try {
|
|
303
|
-
await fs.access(workingDirectory);
|
|
304
|
-
} catch {
|
|
305
|
-
return { status: BB_RESULT.FAILURE, reason: `Working directory ${workingDirectory} does not exist` };
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Paths for the inputs
|
|
309
|
-
const proofPath = join(workingDirectory, CLIENT_IVC_PROOF_FILE_NAME);
|
|
310
|
-
|
|
311
|
-
// The proof is written to e.g. /workingDirectory/proof
|
|
312
|
-
const outputPath = workingDirectory;
|
|
313
|
-
const filePresent = async (file: string) =>
|
|
314
|
-
await fs
|
|
315
|
-
.access(file, fs.constants.R_OK)
|
|
316
|
-
.then(_ => true)
|
|
317
|
-
.catch(_ => false);
|
|
318
|
-
|
|
319
|
-
const binaryPresent = await filePresent(pathToBB);
|
|
320
|
-
if (!binaryPresent) {
|
|
321
|
-
return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
try {
|
|
325
|
-
if (!(await filePresent(proofPath))) {
|
|
326
|
-
return { status: BB_RESULT.FAILURE, reason: `Client IVC input files not present in ${workingDirectory}` };
|
|
327
|
-
}
|
|
328
|
-
const args = ['-o', outputPath, '-k', vkPath, '-v'];
|
|
329
|
-
|
|
330
|
-
const timer = new Timer();
|
|
331
|
-
const logFunction = (message: string) => {
|
|
332
|
-
log(`TubeCircuit (prove) BB out - ${message}`);
|
|
333
|
-
};
|
|
334
|
-
const result = await executeBB(pathToBB, 'prove_tube', args, logFunction);
|
|
335
|
-
const durationMs = timer.ms();
|
|
336
|
-
|
|
337
|
-
if (result.status == BB_RESULT.SUCCESS) {
|
|
338
|
-
return {
|
|
339
|
-
status: BB_RESULT.SUCCESS,
|
|
340
|
-
durationMs,
|
|
341
|
-
proofPath: outputPath,
|
|
342
|
-
pkPath: undefined,
|
|
343
|
-
vkDirectoryPath: outputPath,
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
347
|
-
return {
|
|
348
|
-
status: BB_RESULT.FAILURE,
|
|
349
|
-
reason: `Failed to generate proof. Exit code ${result.exitCode}. Signal ${result.signal}.`,
|
|
350
|
-
retry: !!result.signal,
|
|
351
|
-
};
|
|
352
|
-
} catch (error) {
|
|
353
|
-
return { status: BB_RESULT.FAILURE, reason: `${error}` };
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
287
|
/**
|
|
358
288
|
* Used for generating AVM proofs.
|
|
359
289
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
@@ -423,7 +353,7 @@ export async function generateAvmProof(
|
|
|
423
353
|
durationMs: duration,
|
|
424
354
|
proofPath: join(outputPath, PROOF_FILENAME),
|
|
425
355
|
pkPath: undefined,
|
|
426
|
-
vkDirectoryPath:
|
|
356
|
+
vkDirectoryPath: undefined, // AVM VK is fixed in the binary.
|
|
427
357
|
};
|
|
428
358
|
}
|
|
429
359
|
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
@@ -442,7 +372,7 @@ export async function generateAvmProof(
|
|
|
442
372
|
* @param pathToBB - The full path to the bb binary
|
|
443
373
|
* @param proofFullPath - The full path to the proof to be verified
|
|
444
374
|
* @param verificationKeyPath - The full path to the circuit verification key
|
|
445
|
-
* @param
|
|
375
|
+
* @param logger - A logger
|
|
446
376
|
* @returns An object containing a result indication and duration taken
|
|
447
377
|
*/
|
|
448
378
|
export async function verifyProof(
|
|
@@ -450,16 +380,25 @@ export async function verifyProof(
|
|
|
450
380
|
proofFullPath: string,
|
|
451
381
|
verificationKeyPath: string,
|
|
452
382
|
ultraHonkFlavor: UltraHonkFlavor,
|
|
453
|
-
|
|
383
|
+
logger: Logger,
|
|
454
384
|
): Promise<BBFailure | BBSuccess> {
|
|
455
|
-
|
|
456
|
-
|
|
385
|
+
// Specify the public inputs path in the case of UH verification.
|
|
386
|
+
// Take proofFullPath and remove the suffix past the / to get the directory.
|
|
387
|
+
const proofDir = proofFullPath.substring(0, proofFullPath.lastIndexOf('/'));
|
|
388
|
+
const publicInputsFullPath = join(proofDir, '/public_inputs');
|
|
389
|
+
logger.debug(`public inputs path: ${publicInputsFullPath}`);
|
|
390
|
+
|
|
391
|
+
const args = [
|
|
392
|
+
'-p',
|
|
457
393
|
proofFullPath,
|
|
394
|
+
'-k',
|
|
458
395
|
verificationKeyPath,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
396
|
+
'-i',
|
|
397
|
+
publicInputsFullPath,
|
|
398
|
+
'--disable_zk',
|
|
399
|
+
...getArgs(ultraHonkFlavor),
|
|
400
|
+
];
|
|
401
|
+
return await verifyProofInternal(pathToBB, `verify`, args, logger);
|
|
463
402
|
}
|
|
464
403
|
|
|
465
404
|
export async function verifyAvmProof(
|
|
@@ -467,7 +406,6 @@ export async function verifyAvmProof(
|
|
|
467
406
|
workingDirectory: string,
|
|
468
407
|
proofFullPath: string,
|
|
469
408
|
publicInputs: AvmCircuitPublicInputs,
|
|
470
|
-
verificationKeyPath: string,
|
|
471
409
|
logger: Logger,
|
|
472
410
|
): Promise<BBFailure | BBSuccess> {
|
|
473
411
|
const inputsBuffer = publicInputs.serializeWithMessagePack();
|
|
@@ -484,26 +422,24 @@ export async function verifyAvmProof(
|
|
|
484
422
|
return { status: BB_RESULT.FAILURE, reason: `Could not write avm inputs to ${avmInputsPath}` };
|
|
485
423
|
}
|
|
486
424
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
avmInputsPath,
|
|
490
|
-
]);
|
|
425
|
+
const args = ['-p', proofFullPath, '--avm-public-inputs', avmInputsPath];
|
|
426
|
+
return await verifyProofInternal(pathToBB, 'avm_verify', args, logger);
|
|
491
427
|
}
|
|
492
428
|
|
|
493
429
|
/**
|
|
494
|
-
* Verifies a
|
|
430
|
+
* Verifies a ChonkProof
|
|
495
431
|
* TODO(#7370) The verification keys should be supplied separately
|
|
496
432
|
* @param pathToBB - The full path to the bb binary
|
|
497
433
|
* @param targetPath - The path to the folder with the proof, accumulator, and verification keys
|
|
498
|
-
* @param
|
|
434
|
+
* @param logger - A logger
|
|
499
435
|
* @param concurrency - The number of threads to use for the verification
|
|
500
436
|
* @returns An object containing a result indication and duration taken
|
|
501
437
|
*/
|
|
502
|
-
export async function
|
|
438
|
+
export async function verifyChonkProof(
|
|
503
439
|
pathToBB: string,
|
|
504
440
|
proofPath: string,
|
|
505
441
|
keyPath: string,
|
|
506
|
-
|
|
442
|
+
logger: Logger,
|
|
507
443
|
concurrency = 1,
|
|
508
444
|
): Promise<BBFailure | BBSuccess> {
|
|
509
445
|
const binaryPresent = await fs
|
|
@@ -514,43 +450,25 @@ export async function verifyClientIvcProof(
|
|
|
514
450
|
return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
|
|
515
451
|
}
|
|
516
452
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
const timer = new Timer();
|
|
520
|
-
const command = 'verify';
|
|
521
|
-
|
|
522
|
-
const result = await executeBB(pathToBB, command, args, log, concurrency);
|
|
523
|
-
const duration = timer.ms();
|
|
524
|
-
if (result.status == BB_RESULT.SUCCESS) {
|
|
525
|
-
return { status: BB_RESULT.SUCCESS, durationMs: duration };
|
|
526
|
-
}
|
|
527
|
-
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
528
|
-
return {
|
|
529
|
-
status: BB_RESULT.FAILURE,
|
|
530
|
-
reason: `Failed to verify proof. Exit code ${result.exitCode}. Signal ${result.signal}.`,
|
|
531
|
-
retry: !!result.signal,
|
|
532
|
-
};
|
|
533
|
-
} catch (error) {
|
|
534
|
-
return { status: BB_RESULT.FAILURE, reason: `${error}` };
|
|
535
|
-
}
|
|
453
|
+
const args = ['--scheme', 'chonk', '-p', proofPath, '-k', keyPath, '-v'];
|
|
454
|
+
return await verifyProofInternal(pathToBB, 'verify', args, logger, concurrency);
|
|
536
455
|
}
|
|
537
456
|
|
|
538
457
|
/**
|
|
539
458
|
* Used for verifying proofs with BB
|
|
540
459
|
* @param pathToBB - The full path to the bb binary
|
|
541
|
-
* @param proofFullPath - The full path to the proof to be verified
|
|
542
|
-
* @param verificationKeyPath - The full path to the circuit verification key
|
|
543
460
|
* @param command - The BB command to execute (verify/avm_verify)
|
|
544
|
-
* @param
|
|
461
|
+
* @param args - The arguments to pass to the command
|
|
462
|
+
* @param logger - A logger
|
|
463
|
+
* @param concurrency - The number of threads to use for the verification
|
|
545
464
|
* @returns An object containing a result indication and duration taken
|
|
546
465
|
*/
|
|
547
466
|
async function verifyProofInternal(
|
|
548
467
|
pathToBB: string,
|
|
549
|
-
proofFullPath: string,
|
|
550
|
-
verificationKeyPath: string,
|
|
551
468
|
command: 'verify' | 'avm_verify',
|
|
469
|
+
args: string[],
|
|
552
470
|
logger: Logger,
|
|
553
|
-
|
|
471
|
+
concurrency?: number,
|
|
554
472
|
): Promise<BBFailure | BBSuccess> {
|
|
555
473
|
const binaryPresent = await fs
|
|
556
474
|
.access(pathToBB, fs.constants.R_OK)
|
|
@@ -565,28 +483,12 @@ async function verifyProofInternal(
|
|
|
565
483
|
};
|
|
566
484
|
|
|
567
485
|
try {
|
|
568
|
-
let args;
|
|
569
|
-
|
|
570
|
-
if (command == 'verify') {
|
|
571
|
-
// Specify the public inputs path in the case of UH verification.
|
|
572
|
-
// Take proofFullPath and remove the suffix past the / to get the directory.
|
|
573
|
-
const proofDir = proofFullPath.substring(0, proofFullPath.lastIndexOf('/'));
|
|
574
|
-
const publicInputsFullPath = join(proofDir, '/public_inputs');
|
|
575
|
-
logger.debug(`public inputs path: ${publicInputsFullPath}`);
|
|
576
|
-
|
|
577
|
-
args = ['-p', proofFullPath, '-k', verificationKeyPath, '-i', publicInputsFullPath, '--disable_zk', ...extraArgs];
|
|
578
|
-
} else {
|
|
579
|
-
args = ['-p', proofFullPath, '-k', verificationKeyPath, ...extraArgs];
|
|
580
|
-
}
|
|
581
|
-
|
|
582
486
|
const loggingArg =
|
|
583
487
|
logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
|
|
584
|
-
|
|
585
|
-
args.push(loggingArg);
|
|
586
|
-
}
|
|
488
|
+
const finalArgs = loggingArg !== '' ? [...args, loggingArg] : args;
|
|
587
489
|
|
|
588
490
|
const timer = new Timer();
|
|
589
|
-
const result = await executeBB(pathToBB, command,
|
|
491
|
+
const result = await executeBB(pathToBB, command, finalArgs, logFunction, concurrency);
|
|
590
492
|
const duration = timer.ms();
|
|
591
493
|
if (result.status == BB_RESULT.SUCCESS) {
|
|
592
494
|
return { status: BB_RESULT.SUCCESS, durationMs: duration };
|
|
@@ -679,7 +581,7 @@ export async function computeGateCountForCircuit(
|
|
|
679
581
|
return { status: BB_RESULT.FAILURE, reason: `Working directory ${workingDirectory} does not exist` };
|
|
680
582
|
}
|
|
681
583
|
|
|
682
|
-
// The bytecode is written to e.g. /workingDirectory/
|
|
584
|
+
// The bytecode is written to e.g. /workingDirectory/ParityBaseArtifact-bytecode
|
|
683
585
|
const bytecodePath = `${workingDirectory}/${circuitName}-bytecode`;
|
|
684
586
|
|
|
685
587
|
const binaryPresent = await fs
|
|
@@ -705,7 +607,7 @@ export async function computeGateCountForCircuit(
|
|
|
705
607
|
const result = await executeBB(
|
|
706
608
|
pathToBB,
|
|
707
609
|
'gates',
|
|
708
|
-
['--scheme', flavor === 'mega_honk' ? '
|
|
610
|
+
['--scheme', flavor === 'mega_honk' ? 'chonk' : 'ultra_honk', '-b', bytecodePath, '-v'],
|
|
709
611
|
logHandler,
|
|
710
612
|
);
|
|
711
613
|
const duration = timer.ms();
|
package/src/honk.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types
|
|
|
3
3
|
export type UltraHonkFlavor = 'ultra_honk' | 'ultra_keccak_honk' | 'ultra_starknet_honk' | 'ultra_rollup_honk';
|
|
4
4
|
|
|
5
5
|
const UltraKeccakHonkCircuits = ['RootRollupArtifact'] as const satisfies ServerProtocolArtifact[];
|
|
6
|
-
const UltraHonkCircuits = ['
|
|
6
|
+
const UltraHonkCircuits = ['ParityBaseArtifact', 'ParityRootArtifact'] as const satisfies ServerProtocolArtifact[];
|
|
7
7
|
|
|
8
8
|
export type UltraKeccakHonkServerProtocolArtifact = (typeof UltraKeccakHonkCircuits)[number];
|
|
9
9
|
export type UltraHonkServerProtocolArtifact = (typeof UltraHonkCircuits)[number];
|
package/src/instrumentation.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
Metrics,
|
|
8
8
|
type TelemetryClient,
|
|
9
9
|
type Tracer,
|
|
10
|
-
ValueType,
|
|
11
10
|
} from '@aztec/telemetry-client';
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -31,51 +30,21 @@ export class ProverInstrumentation {
|
|
|
31
30
|
this.tracer = telemetry.getTracer(name);
|
|
32
31
|
const meter = telemetry.getMeter(name);
|
|
33
32
|
|
|
34
|
-
this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION
|
|
35
|
-
description: 'Records how long it takes to simulate a circuit',
|
|
36
|
-
unit: 'ms',
|
|
37
|
-
valueType: ValueType.INT,
|
|
38
|
-
});
|
|
33
|
+
this.simulationDuration = meter.createHistogram(Metrics.CIRCUIT_SIMULATION_DURATION);
|
|
39
34
|
|
|
40
|
-
this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION
|
|
41
|
-
description: 'Records how long it takes to generate the partial witness for a circuit',
|
|
42
|
-
unit: 's',
|
|
43
|
-
valueType: ValueType.DOUBLE,
|
|
44
|
-
});
|
|
35
|
+
this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION);
|
|
45
36
|
|
|
46
|
-
this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION
|
|
47
|
-
unit: 's',
|
|
48
|
-
description: 'Records how long it takes to prove a circuit',
|
|
49
|
-
valueType: ValueType.DOUBLE,
|
|
50
|
-
});
|
|
37
|
+
this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION);
|
|
51
38
|
|
|
52
|
-
this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE
|
|
53
|
-
unit: 'By',
|
|
54
|
-
description: 'Records the size of the input to the witness generation',
|
|
55
|
-
valueType: ValueType.INT,
|
|
56
|
-
});
|
|
39
|
+
this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE);
|
|
57
40
|
|
|
58
|
-
this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE
|
|
59
|
-
unit: 'By',
|
|
60
|
-
description: 'Records the size of the output of the witness generation',
|
|
61
|
-
valueType: ValueType.INT,
|
|
62
|
-
});
|
|
41
|
+
this.witGenOutputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_OUTPUT_SIZE);
|
|
63
42
|
|
|
64
|
-
this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE
|
|
65
|
-
unit: 'By',
|
|
66
|
-
description: 'Records the size of the proof generated for a circuit',
|
|
67
|
-
valueType: ValueType.INT,
|
|
68
|
-
});
|
|
43
|
+
this.proofSize = meter.createGauge(Metrics.CIRCUIT_PROVING_PROOF_SIZE);
|
|
69
44
|
|
|
70
|
-
this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT
|
|
71
|
-
description: 'Records the number of public inputs in a circuit',
|
|
72
|
-
valueType: ValueType.INT,
|
|
73
|
-
});
|
|
45
|
+
this.circuitPublicInputCount = meter.createGauge(Metrics.CIRCUIT_PUBLIC_INPUTS_COUNT);
|
|
74
46
|
|
|
75
|
-
this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE
|
|
76
|
-
description: 'Records the size of the circuit in gates',
|
|
77
|
-
valueType: ValueType.INT,
|
|
78
|
-
});
|
|
47
|
+
this.circuitSize = meter.createGauge(Metrics.CIRCUIT_SIZE);
|
|
79
48
|
}
|
|
80
49
|
|
|
81
50
|
/**
|
|
@@ -86,13 +55,21 @@ export class ProverInstrumentation {
|
|
|
86
55
|
*/
|
|
87
56
|
recordDuration(
|
|
88
57
|
metric: 'simulationDuration' | 'witGenDuration' | 'provingDuration',
|
|
89
|
-
circuitName: CircuitName
|
|
58
|
+
circuitName: CircuitName,
|
|
90
59
|
timerOrMS: Timer | number,
|
|
91
60
|
) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
61
|
+
// Simulation duration is stored in ms, while the others are stored in seconds
|
|
62
|
+
if (metric === 'simulationDuration') {
|
|
63
|
+
const ms = typeof timerOrMS === 'number' ? timerOrMS : timerOrMS.ms();
|
|
64
|
+
this[metric].record(Math.trunc(ms), {
|
|
65
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
|
|
69
|
+
this[metric].record(s, {
|
|
70
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
96
73
|
}
|
|
97
74
|
|
|
98
75
|
/**
|
|
@@ -116,7 +93,7 @@ export class ProverInstrumentation {
|
|
|
116
93
|
*/
|
|
117
94
|
recordSize(
|
|
118
95
|
metric: 'witGenInputSize' | 'witGenOutputSize' | 'proofSize' | 'circuitSize' | 'circuitPublicInputCount',
|
|
119
|
-
circuitName: CircuitName
|
|
96
|
+
circuitName: CircuitName,
|
|
120
97
|
size: number,
|
|
121
98
|
) {
|
|
122
99
|
this[metric].record(Math.ceil(size), {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AztecClientBackend, type BackendOptions, Barretenberg } from '@aztec/bb.js';
|
|
2
|
+
import { type LogLevel, type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
2
5
|
import {
|
|
3
6
|
convertHidingKernelPublicInputsToWitnessMapWithAbi,
|
|
4
7
|
convertHidingKernelToRollupInputsToWitnessMapWithAbi,
|
|
@@ -16,7 +19,11 @@ import {
|
|
|
16
19
|
getPrivateKernelResetArtifactName,
|
|
17
20
|
updateResetCircuitSampleInputs,
|
|
18
21
|
} from '@aztec/noir-protocol-circuits-types/client';
|
|
19
|
-
import
|
|
22
|
+
import {
|
|
23
|
+
type ArtifactProvider,
|
|
24
|
+
type ClientProtocolArtifact,
|
|
25
|
+
mapProtocolArtifactNameToCircuitName,
|
|
26
|
+
} from '@aztec/noir-protocol-circuits-types/types';
|
|
20
27
|
import type { Abi, WitnessMap } from '@aztec/noir-types';
|
|
21
28
|
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
22
29
|
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
@@ -33,17 +40,22 @@ import type {
|
|
|
33
40
|
PrivateKernelTailCircuitPublicInputs,
|
|
34
41
|
} from '@aztec/stdlib/kernel';
|
|
35
42
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
36
|
-
import
|
|
43
|
+
import { ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
37
44
|
import type { CircuitSimulationStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
38
45
|
|
|
39
|
-
import {
|
|
46
|
+
import { ungzip } from 'pako';
|
|
40
47
|
|
|
48
|
+
export type BBPrivateKernelProverOptions = Omit<BackendOptions, 'logger'> & { logger?: Logger };
|
|
41
49
|
export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
50
|
+
private log: Logger;
|
|
51
|
+
|
|
42
52
|
constructor(
|
|
43
53
|
protected artifactProvider: ArtifactProvider,
|
|
44
54
|
protected simulator: CircuitSimulator,
|
|
45
|
-
protected
|
|
46
|
-
) {
|
|
55
|
+
protected options: BBPrivateKernelProverOptions = {},
|
|
56
|
+
) {
|
|
57
|
+
this.log = options.logger || createLogger('bb-prover:private-kernel');
|
|
58
|
+
}
|
|
47
59
|
|
|
48
60
|
public async generateInitOutput(
|
|
49
61
|
inputs: PrivateKernelInitCircuitPrivateInputs,
|
|
@@ -261,11 +273,39 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
261
273
|
return kernelProofOutput;
|
|
262
274
|
}
|
|
263
275
|
|
|
264
|
-
public
|
|
265
|
-
|
|
276
|
+
public async createChonkProof(executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs> {
|
|
277
|
+
const timer = new Timer();
|
|
278
|
+
this.log.info(`Generating ClientIVC proof...`);
|
|
279
|
+
const barretenberg = await Barretenberg.initSingleton({
|
|
280
|
+
...this.options,
|
|
281
|
+
logger: this.options.logger?.[(process.env.LOG_LEVEL as LogLevel) || 'verbose'],
|
|
282
|
+
});
|
|
283
|
+
const backend = new AztecClientBackend(
|
|
284
|
+
executionSteps.map(step => ungzip(step.bytecode)),
|
|
285
|
+
barretenberg,
|
|
286
|
+
executionSteps.map(step => step.functionName),
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
const [proof] = await backend.prove(
|
|
290
|
+
executionSteps.map(step => ungzip(serializeWitness(step.witness))),
|
|
291
|
+
executionSteps.map(step => step.vk),
|
|
292
|
+
);
|
|
293
|
+
this.log.info(`Generated ClientIVC proof`, {
|
|
294
|
+
eventName: 'client-ivc-proof-generation',
|
|
295
|
+
duration: timer.ms(),
|
|
296
|
+
proofSize: proof.length,
|
|
297
|
+
});
|
|
298
|
+
return ChonkProofWithPublicInputs.fromBufferArray(proof);
|
|
266
299
|
}
|
|
267
300
|
|
|
268
|
-
public computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
269
|
-
|
|
301
|
+
public async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
302
|
+
// Note we do not pass the vk to the backend. This is unneeded for gate counts.
|
|
303
|
+
const barretenberg = await Barretenberg.initSingleton({
|
|
304
|
+
...this.options,
|
|
305
|
+
logger: this.options.logger?.[(process.env.LOG_LEVEL as LogLevel) || 'verbose'],
|
|
306
|
+
});
|
|
307
|
+
const backend = new AztecClientBackend([ungzip(_bytecode)], barretenberg, [_circuitName]);
|
|
308
|
+
const gateCount = await backend.gates();
|
|
309
|
+
return gateCount[0];
|
|
270
310
|
}
|
|
271
311
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
2
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
+
|
|
4
|
+
import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
|
|
5
|
+
|
|
6
|
+
export class BBBundlePrivateKernelProver extends BBPrivateKernelProver {
|
|
7
|
+
constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
|
|
8
|
+
super(new BundleArtifactProvider(), simulator, options);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
|
|
2
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
+
|
|
4
|
+
import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
|
|
5
|
+
|
|
6
|
+
export class BBLazyPrivateKernelProver extends BBPrivateKernelProver {
|
|
7
|
+
constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
|
|
8
|
+
super(new LazyArtifactProvider(), simulator, options);
|
|
9
|
+
}
|
|
10
|
+
}
|