@aztec/bb-prover 0.62.0 → 0.63.1
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/bb/cli.d.ts.map +1 -1
- package/dest/bb/cli.js +3 -2
- package/dest/bb/execute.d.ts +15 -3
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +74 -17
- package/dest/prover/bb_private_kernel_prover.d.ts +1 -0
- package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_private_kernel_prover.js +16 -5
- package/dest/prover/bb_prover.d.ts +5 -7
- package/dest/prover/bb_prover.d.ts.map +1 -1
- package/dest/prover/bb_prover.js +9 -22
- package/dest/stats.d.ts +1 -0
- package/dest/stats.d.ts.map +1 -1
- package/dest/stats.js +24 -1
- package/dest/test/test_avm.d.ts +2 -2
- package/dest/test/test_avm.d.ts.map +1 -1
- package/dest/test/test_avm.js +3 -3
- package/dest/test/test_circuit_prover.d.ts +5 -6
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +5 -12
- package/dest/verification_key/verification_key_data.js +3 -3
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +3 -3
- package/package.json +9 -7
- package/src/bb/cli.ts +2 -0
- package/src/bb/execute.ts +94 -19
- package/src/prover/bb_private_kernel_prover.ts +27 -2
- package/src/prover/bb_prover.ts +15 -55
- package/src/stats.ts +24 -0
- package/src/test/test_avm.ts +4 -4
- package/src/test/test_circuit_prover.ts +9 -52
- package/src/verification_key/verification_key_data.ts +2 -2
- package/src/verifier/bb_verifier.ts +2 -1
|
@@ -6,7 +6,7 @@ import * as fs from 'fs/promises';
|
|
|
6
6
|
import * as path from 'path';
|
|
7
7
|
import { BB_RESULT, PROOF_FILENAME, VK_FILENAME, generateContractForCircuit, generateKeyForNoirCircuit, verifyClientIvcProof, verifyProof, } from '../bb/execute.js';
|
|
8
8
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
9
|
-
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
9
|
+
import { isProtocolArtifactRecursive, mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
10
10
|
import { extractVkData } from '../verification_key/verification_key_data.js';
|
|
11
11
|
export class BBCircuitVerifier {
|
|
12
12
|
constructor(config, verificationKeys = new Map(), logger) {
|
|
@@ -24,7 +24,7 @@ export class BBCircuitVerifier {
|
|
|
24
24
|
return new BBCircuitVerifier(config, keys, logger);
|
|
25
25
|
}
|
|
26
26
|
static async generateVerificationKey(circuit, bbPath, workingDirectory, logFn) {
|
|
27
|
-
return await generateKeyForNoirCircuit(bbPath, workingDirectory, circuit, ProtocolCircuitArtifacts[circuit], getUltraHonkFlavorForCircuit(circuit), logFn).then(result => {
|
|
27
|
+
return await generateKeyForNoirCircuit(bbPath, workingDirectory, circuit, ProtocolCircuitArtifacts[circuit], isProtocolArtifactRecursive(circuit), getUltraHonkFlavorForCircuit(circuit), logFn).then(result => {
|
|
28
28
|
if (result.status === BB_RESULT.FAILURE) {
|
|
29
29
|
throw new Error(`Failed to created verification key for ${circuit}, ${result.reason}`);
|
|
30
30
|
}
|
|
@@ -109,4 +109,4 @@ export class BBCircuitVerifier {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
112
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmJfdmVyaWZpZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpZXIvYmJfdmVyaWZpZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFzQyxFQUFFLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUc5RSxPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sc0JBQXNCLENBQUM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QUFZO2lCQUNXLENBQUMsQ0FBQztZQUN4QyxDQUFDLENBQUM7WUFDRixNQUFNLGNBQWMsQ0FBQyxJQUFJLENBQUMsTUFBTSxDQUFDLGtCQUFrQixFQUFFLFNBQVMsRUFBRSxJQUFJLENBQUMsTUFBTSxDQUFDLGFBQWEsQ0FBQyxDQUFDO1lBQzNGLE9BQU8sSUFBSSxDQUFDO1FBQ2QsQ0FBQztRQUFDLE9BQU8sR0FBRyxFQUFFLENBQUM7WUFDYixJQUFJLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQywyQ0FBMkMsRUFBRSxDQUFDLE9BQU8sQ0FBQyxFQUFFLENBQUMsS0FBSyxNQUFNLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxDQUFDO1lBQzlGLE9BQU8sS0FBSyxDQUFDO1FBQ2YsQ0FBQztJQUNILENBQUM7Q0FDRiJ9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bb-prover",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -65,12 +65,13 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/circuit-types": "0.
|
|
69
|
-
"@aztec/circuits.js": "0.
|
|
70
|
-
"@aztec/foundation": "0.
|
|
71
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
72
|
-
"@aztec/simulator": "0.
|
|
73
|
-
"@aztec/telemetry-client": "0.
|
|
68
|
+
"@aztec/circuit-types": "0.63.1",
|
|
69
|
+
"@aztec/circuits.js": "0.63.1",
|
|
70
|
+
"@aztec/foundation": "0.63.1",
|
|
71
|
+
"@aztec/noir-protocol-circuits-types": "0.63.1",
|
|
72
|
+
"@aztec/simulator": "0.63.1",
|
|
73
|
+
"@aztec/telemetry-client": "0.63.1",
|
|
74
|
+
"@aztec/world-state": "0.63.1",
|
|
74
75
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
75
76
|
"@noir-lang/noirc_abi": "portal:../../noir/packages/noirc_abi",
|
|
76
77
|
"@noir-lang/types": "portal:../../noir/packages/types",
|
|
@@ -80,6 +81,7 @@
|
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
83
|
"@aztec/ethereum": "workspace:^",
|
|
84
|
+
"@aztec/kv-store": "workspace:^",
|
|
83
85
|
"@aztec/types": "workspace:^",
|
|
84
86
|
"@jest/globals": "^29.5.0",
|
|
85
87
|
"@types/jest": "^29.5.0",
|
package/src/bb/cli.ts
CHANGED
|
@@ -36,6 +36,7 @@ export function getProgram(log: LogFn): Command {
|
|
|
36
36
|
.requiredOption('-b, --bb-path <string>', 'The path to the BB binary', BB_BINARY_PATH)
|
|
37
37
|
.requiredOption('-c, --circuit <string>', 'The name of a protocol circuit')
|
|
38
38
|
.requiredOption('-f, --flavor <string>', 'The name of the verification key flavor', 'ultra_honk')
|
|
39
|
+
.option('-r, --recursive', 'Whether a SNARK friendly key should be generated', false)
|
|
39
40
|
.action(async options => {
|
|
40
41
|
const compiledCircuit = ProtocolCircuitArtifacts[options.circuit as ProtocolArtifact];
|
|
41
42
|
if (!compiledCircuit) {
|
|
@@ -53,6 +54,7 @@ export function getProgram(log: LogFn): Command {
|
|
|
53
54
|
options.workingDirectory,
|
|
54
55
|
options.circuit,
|
|
55
56
|
compiledCircuit,
|
|
57
|
+
options.recursive,
|
|
56
58
|
options.flavor,
|
|
57
59
|
// (options.circuit as ServerProtocolArtifact) === 'RootRollupArtifact' ? 'ultra_keccak_honk' : 'ultra_honk',
|
|
58
60
|
log,
|
package/src/bb/execute.ts
CHANGED
|
@@ -36,6 +36,8 @@ export type BBSuccess = {
|
|
|
36
36
|
proofPath?: string;
|
|
37
37
|
/** Full path of the contract. */
|
|
38
38
|
contractPath?: string;
|
|
39
|
+
/** The number of gates in the circuit. */
|
|
40
|
+
circuitSize?: number;
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export type BBFailure = {
|
|
@@ -115,6 +117,7 @@ export async function generateKeyForNoirCircuit(
|
|
|
115
117
|
workingDirectory: string,
|
|
116
118
|
circuitName: string,
|
|
117
119
|
compiledCircuit: NoirCompiledCircuit,
|
|
120
|
+
recursive: boolean,
|
|
118
121
|
flavor: UltraHonkFlavor,
|
|
119
122
|
log: LogFn,
|
|
120
123
|
force = false,
|
|
@@ -148,7 +151,7 @@ export async function generateKeyForNoirCircuit(
|
|
|
148
151
|
await fs.writeFile(bytecodePath, bytecode);
|
|
149
152
|
|
|
150
153
|
// args are the output path and the input bytecode path
|
|
151
|
-
const args = ['-o', `${outputPath}/${VK_FILENAME}`, '-b', bytecodePath];
|
|
154
|
+
const args = ['-o', `${outputPath}/${VK_FILENAME}`, '-b', bytecodePath, recursive ? '--recursive' : ''];
|
|
152
155
|
const timer = new Timer();
|
|
153
156
|
let result = await executeBB(pathToBB, `write_vk_${flavor}`, args, log);
|
|
154
157
|
|
|
@@ -223,7 +226,7 @@ export async function executeBbClientIvcProof(
|
|
|
223
226
|
const args = ['-o', outputPath, '-b', bytecodeStackPath, '-w', witnessStackPath, '-v'];
|
|
224
227
|
const timer = new Timer();
|
|
225
228
|
const logFunction = (message: string) => {
|
|
226
|
-
log(`
|
|
229
|
+
log(`bb - ${message}`);
|
|
227
230
|
};
|
|
228
231
|
|
|
229
232
|
const result = await executeBB(pathToBB, 'client_ivc_prove_output_all_msgpack', args, logFunction);
|
|
@@ -264,6 +267,7 @@ export async function computeVerificationKey(
|
|
|
264
267
|
workingDirectory: string,
|
|
265
268
|
circuitName: string,
|
|
266
269
|
bytecode: Buffer,
|
|
270
|
+
recursive: boolean,
|
|
267
271
|
flavor: UltraHonkFlavor | 'mega_honk',
|
|
268
272
|
log: LogFn,
|
|
269
273
|
): Promise<BBFailure | BBSuccess> {
|
|
@@ -295,12 +299,8 @@ export async function computeVerificationKey(
|
|
|
295
299
|
const logFunction = (message: string) => {
|
|
296
300
|
log(`computeVerificationKey(${circuitName}) BB out - ${message}`);
|
|
297
301
|
};
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
`write_vk_${flavor}`,
|
|
301
|
-
['-o', outputPath, '-b', bytecodePath, '-v'],
|
|
302
|
-
logFunction,
|
|
303
|
-
);
|
|
302
|
+
const args = ['-o', outputPath, '-b', bytecodePath, '-v', recursive ? '--recursive' : ''];
|
|
303
|
+
let result = await executeBB(pathToBB, `write_vk_${flavor}`, args, logFunction);
|
|
304
304
|
if (result.status == BB_RESULT.FAILURE) {
|
|
305
305
|
return { status: BB_RESULT.FAILURE, reason: 'Failed writing VK.' };
|
|
306
306
|
}
|
|
@@ -346,6 +346,7 @@ export async function generateProof(
|
|
|
346
346
|
workingDirectory: string,
|
|
347
347
|
circuitName: string,
|
|
348
348
|
bytecode: Buffer,
|
|
349
|
+
recursive: boolean,
|
|
349
350
|
inputWitnessFile: string,
|
|
350
351
|
flavor: UltraHonkFlavor,
|
|
351
352
|
log: LogFn,
|
|
@@ -374,7 +375,7 @@ export async function generateProof(
|
|
|
374
375
|
try {
|
|
375
376
|
// Write the bytecode to the working directory
|
|
376
377
|
await fs.writeFile(bytecodePath, bytecode);
|
|
377
|
-
const args = ['-o', outputPath, '-b', bytecodePath, '-w', inputWitnessFile, '-v'];
|
|
378
|
+
const args = ['-o', outputPath, '-b', bytecodePath, '-w', inputWitnessFile, '-v', recursive ? '--recursive' : ''];
|
|
378
379
|
const timer = new Timer();
|
|
379
380
|
const logFunction = (message: string) => {
|
|
380
381
|
log(`${circuitName} BB out - ${message}`);
|
|
@@ -425,8 +426,7 @@ export async function generateTubeProof(
|
|
|
425
426
|
}
|
|
426
427
|
|
|
427
428
|
// // Paths for the inputs
|
|
428
|
-
const vkPath = join(workingDirectory, '
|
|
429
|
-
const accPath = join(workingDirectory, 'pg_acc.bin');
|
|
429
|
+
const vkPath = join(workingDirectory, 'mega_vk.bin');
|
|
430
430
|
const proofPath = join(workingDirectory, 'client_ivc_proof.bin');
|
|
431
431
|
const translatorVkPath = join(workingDirectory, 'translator_vk.bin');
|
|
432
432
|
const eccVkPath = join(workingDirectory, 'ecc_vk.bin');
|
|
@@ -445,13 +445,7 @@ export async function generateTubeProof(
|
|
|
445
445
|
}
|
|
446
446
|
|
|
447
447
|
try {
|
|
448
|
-
if (
|
|
449
|
-
!filePresent(vkPath) ||
|
|
450
|
-
!filePresent(accPath) ||
|
|
451
|
-
!filePresent(proofPath) ||
|
|
452
|
-
!filePresent(translatorVkPath) ||
|
|
453
|
-
!filePresent(eccVkPath)
|
|
454
|
-
) {
|
|
448
|
+
if (!filePresent(vkPath) || !filePresent(proofPath) || !filePresent(translatorVkPath) || !filePresent(eccVkPath)) {
|
|
455
449
|
return { status: BB_RESULT.FAILURE, reason: `Client IVC input files not present in ${workingDirectory}` };
|
|
456
450
|
}
|
|
457
451
|
const args = ['-o', outputPath, '-v'];
|
|
@@ -557,7 +551,7 @@ export async function generateAvmProof(
|
|
|
557
551
|
avmHintsPath,
|
|
558
552
|
'-o',
|
|
559
553
|
outputPath,
|
|
560
|
-
currentLogLevel == 'debug' ? '-d' : 'verbose' ? '-v' : '',
|
|
554
|
+
currentLogLevel == 'debug' ? '-d' : currentLogLevel == 'verbose' ? '-v' : '',
|
|
561
555
|
];
|
|
562
556
|
const timer = new Timer();
|
|
563
557
|
const logFunction = (message: string) => {
|
|
@@ -845,11 +839,18 @@ export async function generateContractForCircuit(
|
|
|
845
839
|
log: LogFn,
|
|
846
840
|
force = false,
|
|
847
841
|
) {
|
|
842
|
+
// Verifier contracts are never recursion friendly, because non-recursive proofs are generated using the keccak256 hash function.
|
|
843
|
+
// We need to use the same hash function during verification so proofs generated using keccak256 are cheap to verify on ethereum
|
|
844
|
+
// (where the verifier contract would be deployed) whereas if we want to verify the proof within a snark (for recursion) we want
|
|
845
|
+
// to use a snark-friendly hash function.
|
|
846
|
+
const recursive = false;
|
|
847
|
+
|
|
848
848
|
const vkResult = await generateKeyForNoirCircuit(
|
|
849
849
|
pathToBB,
|
|
850
850
|
workingDirectory,
|
|
851
851
|
circuitName,
|
|
852
852
|
compiledCircuit,
|
|
853
|
+
recursive,
|
|
853
854
|
'ultra_keccak_honk',
|
|
854
855
|
log,
|
|
855
856
|
force,
|
|
@@ -866,6 +867,80 @@ export async function generateContractForCircuit(
|
|
|
866
867
|
);
|
|
867
868
|
}
|
|
868
869
|
|
|
870
|
+
/**
|
|
871
|
+
* Compute bb gate count for a given circuit
|
|
872
|
+
* @param pathToBB - The full path to the bb binary
|
|
873
|
+
* @param workingDirectory - A temporary directory for writing the bytecode
|
|
874
|
+
* @param circuitName - The name of the circuit
|
|
875
|
+
* @param bytecode - The bytecode of the circuit
|
|
876
|
+
* @param flavor - The flavor of the backend - mega_honk or ultra_honk variants
|
|
877
|
+
* @returns An object containing the status, gate count, and time taken
|
|
878
|
+
*/
|
|
879
|
+
export async function computeGateCountForCircuit(
|
|
880
|
+
pathToBB: string,
|
|
881
|
+
workingDirectory: string,
|
|
882
|
+
circuitName: string,
|
|
883
|
+
bytecode: Buffer,
|
|
884
|
+
flavor: UltraHonkFlavor | 'mega_honk',
|
|
885
|
+
): Promise<BBFailure | BBSuccess> {
|
|
886
|
+
// Check that the working directory exists
|
|
887
|
+
try {
|
|
888
|
+
await fs.access(workingDirectory);
|
|
889
|
+
} catch (error) {
|
|
890
|
+
return { status: BB_RESULT.FAILURE, reason: `Working directory ${workingDirectory} does not exist` };
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// The bytecode is written to e.g. /workingDirectory/BaseParityArtifact-bytecode
|
|
894
|
+
const bytecodePath = `${workingDirectory}/${circuitName}-bytecode`;
|
|
895
|
+
|
|
896
|
+
const binaryPresent = await fs
|
|
897
|
+
.access(pathToBB, fs.constants.R_OK)
|
|
898
|
+
.then(_ => true)
|
|
899
|
+
.catch(_ => false);
|
|
900
|
+
if (!binaryPresent) {
|
|
901
|
+
return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// Accumulate the stdout from bb
|
|
905
|
+
let stdout = '';
|
|
906
|
+
const logHandler = (message: string) => {
|
|
907
|
+
stdout += message;
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
try {
|
|
911
|
+
// Write the bytecode to the working directory
|
|
912
|
+
await fs.writeFile(bytecodePath, bytecode);
|
|
913
|
+
const timer = new Timer();
|
|
914
|
+
|
|
915
|
+
const result = await executeBB(
|
|
916
|
+
pathToBB,
|
|
917
|
+
flavor === 'mega_honk' ? `gates_mega_honk` : `gates`,
|
|
918
|
+
['-b', bytecodePath, '-v'],
|
|
919
|
+
logHandler,
|
|
920
|
+
);
|
|
921
|
+
const duration = timer.ms();
|
|
922
|
+
|
|
923
|
+
if (result.status == BB_RESULT.SUCCESS) {
|
|
924
|
+
// Look for "circuit_size" in the stdout and parse the number
|
|
925
|
+
const circuitSizeMatch = stdout.match(/circuit_size": (\d+)/);
|
|
926
|
+
if (!circuitSizeMatch) {
|
|
927
|
+
return { status: BB_RESULT.FAILURE, reason: 'Failed to parse circuit_size from bb gates stdout.' };
|
|
928
|
+
}
|
|
929
|
+
const circuitSize = parseInt(circuitSizeMatch[1]);
|
|
930
|
+
|
|
931
|
+
return {
|
|
932
|
+
status: BB_RESULT.SUCCESS,
|
|
933
|
+
durationMs: duration,
|
|
934
|
+
circuitSize: circuitSize,
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
return { status: BB_RESULT.FAILURE, reason: 'Failed getting the gate count.' };
|
|
939
|
+
} catch (error) {
|
|
940
|
+
return { status: BB_RESULT.FAILURE, reason: `${error}` };
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
869
944
|
const CACHE_FILENAME = '.cache';
|
|
870
945
|
async function fsCache<T>(
|
|
871
946
|
dir: string,
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
BB_RESULT,
|
|
53
53
|
PROOF_FIELDS_FILENAME,
|
|
54
54
|
PROOF_FILENAME,
|
|
55
|
+
computeGateCountForCircuit,
|
|
55
56
|
computeVerificationKey,
|
|
56
57
|
executeBbClientIvcProof,
|
|
57
58
|
verifyProof,
|
|
@@ -189,7 +190,11 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
|
|
|
189
190
|
): Promise<AppCircuitSimulateOutput> {
|
|
190
191
|
const operation = async (directory: string) => {
|
|
191
192
|
this.log.debug(`Proving app circuit`);
|
|
192
|
-
|
|
193
|
+
// App circuits are always recursive; the #[recursive] attribute used to be applied automatically
|
|
194
|
+
// by the `private` comptime macro in noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr
|
|
195
|
+
// Yet, inside `computeVerificationKey` the `mega_honk` flavor is used, which doesn't use the recursive flag.
|
|
196
|
+
const recursive = true;
|
|
197
|
+
return await this.computeVerificationKey(directory, bytecode, recursive, 'App', appCircuitName);
|
|
193
198
|
};
|
|
194
199
|
|
|
195
200
|
return await this.runInDirectory(operation);
|
|
@@ -224,6 +229,21 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
|
|
|
224
229
|
this.log.info(`Successfully verified ${circuitType} proof in ${Math.ceil(result.durationMs)} ms`);
|
|
225
230
|
}
|
|
226
231
|
|
|
232
|
+
public async computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number> {
|
|
233
|
+
const result = await computeGateCountForCircuit(
|
|
234
|
+
this.bbBinaryPath,
|
|
235
|
+
this.bbWorkingDirectory,
|
|
236
|
+
circuitName,
|
|
237
|
+
bytecode,
|
|
238
|
+
'mega_honk',
|
|
239
|
+
);
|
|
240
|
+
if (result.status === BB_RESULT.FAILURE) {
|
|
241
|
+
throw new Error(result.reason);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return result.circuitSize as number;
|
|
245
|
+
}
|
|
246
|
+
|
|
227
247
|
private async verifyProofFromKey(
|
|
228
248
|
flavor: UltraHonkFlavor,
|
|
229
249
|
verificationKey: Buffer,
|
|
@@ -256,7 +276,10 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
|
|
|
256
276
|
return await promise;
|
|
257
277
|
}
|
|
258
278
|
|
|
259
|
-
private async simulate<
|
|
279
|
+
private async simulate<
|
|
280
|
+
I extends { toBuffer: () => Buffer },
|
|
281
|
+
O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs,
|
|
282
|
+
>(
|
|
260
283
|
inputs: I,
|
|
261
284
|
circuitType: ClientProtocolArtifact,
|
|
262
285
|
convertInputs: (inputs: I) => WitnessMap,
|
|
@@ -293,6 +316,7 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
|
|
|
293
316
|
private async computeVerificationKey(
|
|
294
317
|
directory: string,
|
|
295
318
|
bytecode: Buffer,
|
|
319
|
+
recursive: boolean,
|
|
296
320
|
circuitType: ClientProtocolArtifact | 'App',
|
|
297
321
|
appCircuitName?: string,
|
|
298
322
|
): Promise<{
|
|
@@ -308,6 +332,7 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
|
|
|
308
332
|
directory,
|
|
309
333
|
circuitType,
|
|
310
334
|
bytecode,
|
|
335
|
+
recursive,
|
|
311
336
|
circuitType === 'App' ? 'mega_honk' : getUltraHonkFlavorForCircuit(circuitType),
|
|
312
337
|
this.log.debug,
|
|
313
338
|
);
|
package/src/prover/bb_prover.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type KernelCircuitPublicInputs,
|
|
24
24
|
type MergeRollupInputs,
|
|
25
25
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
26
|
+
type ParityPublicInputs,
|
|
26
27
|
type PrivateBaseRollupInputs,
|
|
27
28
|
type PrivateKernelEmptyInputData,
|
|
28
29
|
PrivateKernelEmptyInputs,
|
|
@@ -30,7 +31,6 @@ import {
|
|
|
30
31
|
type PublicBaseRollupInputs,
|
|
31
32
|
RECURSIVE_PROOF_LENGTH,
|
|
32
33
|
RecursiveProof,
|
|
33
|
-
RootParityInput,
|
|
34
34
|
type RootParityInputs,
|
|
35
35
|
type RootRollupInputs,
|
|
36
36
|
type RootRollupPublicInputs,
|
|
@@ -45,7 +45,6 @@ import { createDebugLogger } from '@aztec/foundation/log';
|
|
|
45
45
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
46
46
|
import { Timer } from '@aztec/foundation/timer';
|
|
47
47
|
import {
|
|
48
|
-
ProtocolCircuitVkIndexes,
|
|
49
48
|
ProtocolCircuitVks,
|
|
50
49
|
ServerCircuitArtifacts,
|
|
51
50
|
type ServerProtocolArtifact,
|
|
@@ -69,7 +68,6 @@ import {
|
|
|
69
68
|
convertRootParityOutputsFromWitnessMap,
|
|
70
69
|
convertRootRollupInputsToWitnessMap,
|
|
71
70
|
convertRootRollupOutputsFromWitnessMap,
|
|
72
|
-
getVKSiblingPath,
|
|
73
71
|
} from '@aztec/noir-protocol-circuits-types';
|
|
74
72
|
import { NativeACVMSimulator } from '@aztec/simulator';
|
|
75
73
|
import { Attributes, type TelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
@@ -103,6 +101,9 @@ import { extractAvmVkData, extractVkData } from '../verification_key/verificatio
|
|
|
103
101
|
|
|
104
102
|
const logger = createDebugLogger('aztec:bb-prover');
|
|
105
103
|
|
|
104
|
+
// All `ServerCircuitArtifact` are recursive.
|
|
105
|
+
const SERVER_CIRCUIT_RECURSIVE = true;
|
|
106
|
+
|
|
106
107
|
export interface BBProverConfig extends BBConfig, ACVMConfig {
|
|
107
108
|
// list of circuits supported by this prover. defaults to all circuits if empty
|
|
108
109
|
circuitFilter?: ServerProtocolArtifact[];
|
|
@@ -144,7 +145,9 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
144
145
|
* @returns The public inputs of the parity circuit.
|
|
145
146
|
*/
|
|
146
147
|
@trackSpan('BBNativeRollupProver.getBaseParityProof', { [Attributes.PROTOCOL_CIRCUIT_NAME]: 'base-parity' })
|
|
147
|
-
public async getBaseParityProof(
|
|
148
|
+
public async getBaseParityProof(
|
|
149
|
+
inputs: BaseParityInputs,
|
|
150
|
+
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> {
|
|
148
151
|
const { circuitOutput, proof } = await this.createRecursiveProof(
|
|
149
152
|
inputs,
|
|
150
153
|
'BaseParityArtifact',
|
|
@@ -154,15 +157,9 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
154
157
|
);
|
|
155
158
|
|
|
156
159
|
const verificationKey = await this.getVerificationKeyDataForCircuit('BaseParityArtifact');
|
|
157
|
-
|
|
158
160
|
await this.verifyProof('BaseParityArtifact', proof.binaryProof);
|
|
159
161
|
|
|
160
|
-
return
|
|
161
|
-
proof,
|
|
162
|
-
verificationKey.keyAsFields,
|
|
163
|
-
getVKSiblingPath(ProtocolCircuitVkIndexes.BaseParityArtifact),
|
|
164
|
-
circuitOutput,
|
|
165
|
-
);
|
|
162
|
+
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
166
163
|
}
|
|
167
164
|
|
|
168
165
|
/**
|
|
@@ -173,7 +170,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
173
170
|
@trackSpan('BBNativeRollupProver.getRootParityProof', { [Attributes.PROTOCOL_CIRCUIT_NAME]: 'root-parity' })
|
|
174
171
|
public async getRootParityProof(
|
|
175
172
|
inputs: RootParityInputs,
|
|
176
|
-
): Promise<
|
|
173
|
+
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>> {
|
|
177
174
|
const { circuitOutput, proof } = await this.createRecursiveProof(
|
|
178
175
|
inputs,
|
|
179
176
|
'RootParityArtifact',
|
|
@@ -183,15 +180,9 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
183
180
|
);
|
|
184
181
|
|
|
185
182
|
const verificationKey = await this.getVerificationKeyDataForCircuit('RootParityArtifact');
|
|
186
|
-
|
|
187
183
|
await this.verifyProof('RootParityArtifact', proof.binaryProof);
|
|
188
184
|
|
|
189
|
-
return
|
|
190
|
-
proof,
|
|
191
|
-
verificationKey.keyAsFields,
|
|
192
|
-
getVKSiblingPath(ProtocolCircuitVkIndexes.RootParityArtifact),
|
|
193
|
-
circuitOutput,
|
|
194
|
-
);
|
|
185
|
+
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
195
186
|
}
|
|
196
187
|
|
|
197
188
|
/**
|
|
@@ -204,7 +195,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
204
195
|
}))
|
|
205
196
|
public async getAvmProof(
|
|
206
197
|
inputs: AvmCircuitInputs,
|
|
207
|
-
): Promise<ProofAndVerificationKey<
|
|
198
|
+
): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>> {
|
|
208
199
|
const proofAndVk = await this.createAvmProof(inputs);
|
|
209
200
|
await this.verifyAvmProof(proofAndVk.proof.binaryProof, proofAndVk.verificationKey);
|
|
210
201
|
return proofAndVk;
|
|
@@ -390,20 +381,6 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
390
381
|
return emptyPrivateKernelProof;
|
|
391
382
|
}
|
|
392
383
|
|
|
393
|
-
public async getEmptyTubeProof(
|
|
394
|
-
inputs: PrivateKernelEmptyInputData,
|
|
395
|
-
): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> {
|
|
396
|
-
const emptyNested = await this.getEmptyNestedProof();
|
|
397
|
-
const emptyPrivateKernelProof = await this.getEmptyTubeProofFromEmptyNested(
|
|
398
|
-
PrivateKernelEmptyInputs.from({
|
|
399
|
-
...inputs,
|
|
400
|
-
emptyNested,
|
|
401
|
-
}),
|
|
402
|
-
);
|
|
403
|
-
|
|
404
|
-
return emptyPrivateKernelProof;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
384
|
private async getEmptyNestedProof(): Promise<EmptyNestedData> {
|
|
408
385
|
const inputs = new EmptyNestedCircuitInputs();
|
|
409
386
|
const { proof } = await this.createRecursiveProof(
|
|
@@ -424,23 +401,6 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
424
401
|
return new EmptyNestedData(proof, verificationKey.keyAsFields);
|
|
425
402
|
}
|
|
426
403
|
|
|
427
|
-
private async getEmptyTubeProofFromEmptyNested(
|
|
428
|
-
inputs: PrivateKernelEmptyInputs,
|
|
429
|
-
): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> {
|
|
430
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(
|
|
431
|
-
inputs,
|
|
432
|
-
'PrivateKernelEmptyArtifact',
|
|
433
|
-
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
434
|
-
convertPrivateKernelEmptyInputsToWitnessMap,
|
|
435
|
-
convertPrivateKernelEmptyOutputsFromWitnessMap,
|
|
436
|
-
);
|
|
437
|
-
// info(`proof: ${proof.proof}`);
|
|
438
|
-
const verificationKey = await this.getVerificationKeyDataForCircuit('PrivateKernelEmptyArtifact');
|
|
439
|
-
await this.verifyProof('PrivateKernelEmptyArtifact', proof.binaryProof);
|
|
440
|
-
|
|
441
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
404
|
private async getEmptyPrivateKernelProofFromEmptyNested(
|
|
445
405
|
inputs: PrivateKernelEmptyInputs,
|
|
446
406
|
): Promise<PublicInputsAndRecursiveProof<KernelCircuitPublicInputs>> {
|
|
@@ -509,6 +469,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
509
469
|
workingDirectory,
|
|
510
470
|
circuitType,
|
|
511
471
|
Buffer.from(artifact.bytecode, 'base64'),
|
|
472
|
+
SERVER_CIRCUIT_RECURSIVE,
|
|
512
473
|
outputWitnessFile,
|
|
513
474
|
getUltraHonkFlavorForCircuit(circuitType),
|
|
514
475
|
logger.debug,
|
|
@@ -601,7 +562,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
601
562
|
|
|
602
563
|
private async createAvmProof(
|
|
603
564
|
input: AvmCircuitInputs,
|
|
604
|
-
): Promise<ProofAndVerificationKey<
|
|
565
|
+
): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>> {
|
|
605
566
|
const operation = async (bbWorkingDirectory: string) => {
|
|
606
567
|
const provingResult = await this.generateAvmProofWithBB(input, bbWorkingDirectory);
|
|
607
568
|
|
|
@@ -637,9 +598,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
637
598
|
return await this.runInDirectory(operation);
|
|
638
599
|
}
|
|
639
600
|
|
|
640
|
-
public async getTubeProof(
|
|
641
|
-
input: TubeInputs,
|
|
642
|
-
): Promise<ProofAndVerificationKey<RecursiveProof<typeof TUBE_PROOF_LENGTH>>> {
|
|
601
|
+
public async getTubeProof(input: TubeInputs): Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>> {
|
|
643
602
|
// this probably is gonna need to call client ivc
|
|
644
603
|
const operation = async (bbWorkingDirectory: string) => {
|
|
645
604
|
logger.debug(`createTubeProof: ${bbWorkingDirectory}`);
|
|
@@ -861,6 +820,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
861
820
|
this.config.bbWorkingDirectory,
|
|
862
821
|
circuitType,
|
|
863
822
|
ServerCircuitArtifacts[circuitType],
|
|
823
|
+
SERVER_CIRCUIT_RECURSIVE,
|
|
864
824
|
flavor,
|
|
865
825
|
logger.debug,
|
|
866
826
|
).then(result => {
|
package/src/stats.ts
CHANGED
|
@@ -43,3 +43,27 @@ export function mapProtocolArtifactNameToCircuitName(
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
export function isProtocolArtifactRecursive(artifact: ServerProtocolArtifact | ClientProtocolArtifact): boolean {
|
|
48
|
+
switch (artifact) {
|
|
49
|
+
case 'EmptyNestedArtifact':
|
|
50
|
+
case 'PrivateKernelEmptyArtifact':
|
|
51
|
+
case 'BaseParityArtifact':
|
|
52
|
+
case 'RootParityArtifact':
|
|
53
|
+
case 'PrivateBaseRollupArtifact':
|
|
54
|
+
case 'PublicBaseRollupArtifact':
|
|
55
|
+
case 'MergeRollupArtifact':
|
|
56
|
+
case 'BlockRootRollupArtifact':
|
|
57
|
+
case 'EmptyBlockRootRollupArtifact':
|
|
58
|
+
case 'BlockMergeRollupArtifact':
|
|
59
|
+
case 'RootRollupArtifact':
|
|
60
|
+
return true;
|
|
61
|
+
default: {
|
|
62
|
+
if (artifact.startsWith('PrivateKernel')) {
|
|
63
|
+
// The kernel prover, where these are used, eventually calls `createClientIvcProof`, which is recursive.
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Unknown circuit type: ${artifact}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/test/test_avm.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Header,
|
|
8
8
|
L2ToL1Message,
|
|
9
9
|
LogHash,
|
|
10
|
+
MAX_ENQUEUED_CALLS_PER_CALL,
|
|
10
11
|
MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL,
|
|
11
12
|
MAX_L2_TO_L1_MSGS_PER_CALL,
|
|
12
13
|
MAX_NOTE_HASHES_PER_CALL,
|
|
@@ -14,7 +15,6 @@ import {
|
|
|
14
15
|
MAX_NULLIFIERS_PER_CALL,
|
|
15
16
|
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL,
|
|
16
17
|
MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
|
|
17
|
-
MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL,
|
|
18
18
|
MAX_PUBLIC_DATA_READS_PER_CALL,
|
|
19
19
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
|
|
20
20
|
MAX_UNENCRYPTED_LOGS_PER_CALL,
|
|
@@ -28,10 +28,10 @@ import {
|
|
|
28
28
|
} from '@aztec/circuits.js';
|
|
29
29
|
import { computeVarArgsHash } from '@aztec/circuits.js/hash';
|
|
30
30
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
31
|
-
import { type
|
|
31
|
+
import { type PublicFunctionCallResult } from '@aztec/simulator';
|
|
32
32
|
|
|
33
33
|
// TODO: pub somewhere more usable - copied from abstract phase manager
|
|
34
|
-
export function getPublicInputs(result:
|
|
34
|
+
export function getPublicInputs(result: PublicFunctionCallResult): PublicCircuitPublicInputs {
|
|
35
35
|
return PublicCircuitPublicInputs.from({
|
|
36
36
|
callContext: result.executionRequest.callContext,
|
|
37
37
|
proverAddress: AztecAddress.ZERO,
|
|
@@ -72,7 +72,7 @@ export function getPublicInputs(result: PublicExecutionResult): PublicCircuitPub
|
|
|
72
72
|
ContractStorageUpdateRequest.empty(),
|
|
73
73
|
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
|
|
74
74
|
),
|
|
75
|
-
publicCallRequests: padArrayEnd([], PublicInnerCallRequest.empty(),
|
|
75
|
+
publicCallRequests: padArrayEnd([], PublicInnerCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_CALL),
|
|
76
76
|
unencryptedLogsHashes: padArrayEnd(result.unencryptedLogsHashes, LogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_CALL),
|
|
77
77
|
historicalHeader: Header.empty(),
|
|
78
78
|
globalVariables: GlobalVariables.empty(),
|