@aztec/bb-prover 0.87.2 → 0.87.3-nightly.20250529
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 +3 -10
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +18 -62
- package/dest/bb/execute.d.ts +5 -24
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +31 -106
- package/dest/prover/server/bb_prover.d.ts +5 -5
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +22 -13
- package/dest/test/test_circuit_prover.d.ts +2 -2
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +2 -2
- package/dest/verification_key/verification_key_data.d.ts +6 -0
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +16 -16
- package/package.json +18 -16
- package/src/avm_proving_tests/avm_proving_tester.ts +30 -87
- package/src/bb/execute.ts +37 -125
- package/src/prover/server/bb_prover.ts +48 -30
- package/src/test/test_circuit_prover.ts +7 -5
- package/src/verification_key/verification_key_data.ts +20 -13
|
@@ -7,19 +7,12 @@ import { type BBResult, type BBSuccess } from '../bb/execute.js';
|
|
|
7
7
|
export declare class AvmProvingTester extends PublicTxSimulationTester {
|
|
8
8
|
private bbWorkingDirectory;
|
|
9
9
|
private checkCircuitOnly;
|
|
10
|
-
constructor(bbWorkingDirectory: string, checkCircuitOnly: boolean,
|
|
10
|
+
constructor(bbWorkingDirectory: string, checkCircuitOnly: boolean, contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations, globals?: GlobalVariables);
|
|
11
11
|
static new(checkCircuitOnly?: boolean, globals?: GlobalVariables): Promise<AvmProvingTester>;
|
|
12
12
|
prove(avmCircuitInputs: AvmCircuitInputs): Promise<BBResult>;
|
|
13
|
-
verify(proofRes: BBSuccess): Promise<BBResult>;
|
|
13
|
+
verify(proofRes: BBSuccess, publicInputs: AvmCircuitPublicInputs): Promise<BBResult>;
|
|
14
|
+
proveVerify(avmCircuitInputs: AvmCircuitInputs): Promise<void>;
|
|
14
15
|
simProveVerify(sender: AztecAddress, setupCalls: TestEnqueuedCall[], appCalls: TestEnqueuedCall[], teardownCall: TestEnqueuedCall | undefined, expectRevert: boolean | undefined, feePayer?: AztecAddress): Promise<void>;
|
|
15
16
|
simProveVerifyAppLogic(appCall: TestEnqueuedCall, expectRevert?: boolean): Promise<void>;
|
|
16
17
|
}
|
|
17
|
-
export declare class AvmProvingTesterV2 extends PublicTxSimulationTester {
|
|
18
|
-
private bbWorkingDirectory;
|
|
19
|
-
constructor(bbWorkingDirectory: string, contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations, globals?: GlobalVariables);
|
|
20
|
-
static new(globals?: GlobalVariables): Promise<AvmProvingTesterV2>;
|
|
21
|
-
proveV2(avmCircuitInputs: AvmCircuitInputs): Promise<BBResult>;
|
|
22
|
-
verifyV2(proofRes: BBSuccess, publicInputs: AvmCircuitPublicInputs): Promise<BBResult>;
|
|
23
|
-
simProveVerifyV2(sender: AztecAddress, setupCalls: TestEnqueuedCall[], appCalls: TestEnqueuedCall[], teardownCall: TestEnqueuedCall | undefined, expectRevert: boolean | undefined, feePayer?: AztecAddress): Promise<void>;
|
|
24
|
-
}
|
|
25
18
|
//# sourceMappingURL=avm_proving_tester.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_proving_tester.d.ts","sourceRoot":"","sources":["../../src/avm_proving_tests/avm_proving_tester.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,gBAAgB,EACtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,KAAK,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,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AAgB,EAAE,EAC9B,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,YAAY,EAAE,gBAAgB,GAAG,SAAS,EAC1C,YAAY,EAAE,OAAO,GAAG,SAAS,EACjC,QAAQ,eAAS;IASN,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAAE,OAAO;CAStF"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import { PublicTxSimulationTester, SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
|
|
2
2
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
4
3
|
import { NativeWorldStateService } from '@aztec/world-state';
|
|
5
4
|
import fs from 'node:fs/promises';
|
|
6
5
|
import { tmpdir } from 'node:os';
|
|
7
6
|
import path from 'path';
|
|
8
|
-
import { BB_RESULT,
|
|
9
|
-
import { extractAvmVkData } from '../verification_key/verification_key_data.js';
|
|
7
|
+
import { BB_RESULT, VK_FILENAME, generateAvmProof, verifyAvmProof } from '../bb/execute.js';
|
|
10
8
|
const BB_PATH = path.resolve('../../barretenberg/cpp/build/bin/bb');
|
|
11
9
|
export class AvmProvingTester extends PublicTxSimulationTester {
|
|
12
10
|
bbWorkingDirectory;
|
|
13
11
|
checkCircuitOnly;
|
|
14
|
-
constructor(bbWorkingDirectory, checkCircuitOnly,
|
|
15
|
-
super(
|
|
12
|
+
constructor(bbWorkingDirectory, checkCircuitOnly, contractDataSource, merkleTrees, globals){
|
|
13
|
+
super(merkleTrees, contractDataSource, globals), this.bbWorkingDirectory = bbWorkingDirectory, this.checkCircuitOnly = checkCircuitOnly;
|
|
16
14
|
}
|
|
17
|
-
// overriding parent class' create is a pain, so we use a different nam
|
|
18
15
|
static async new(checkCircuitOnly = false, globals) {
|
|
19
16
|
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
20
17
|
const contractDataSource = new SimpleContractDataSource();
|
|
21
18
|
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
22
|
-
return new AvmProvingTester(bbWorkingDirectory, checkCircuitOnly,
|
|
19
|
+
return new AvmProvingTester(bbWorkingDirectory, checkCircuitOnly, contractDataSource, merkleTrees, globals);
|
|
23
20
|
}
|
|
24
21
|
async prove(avmCircuitInputs) {
|
|
25
22
|
// Then we prove.
|
|
@@ -27,73 +24,32 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
27
24
|
if (proofRes.status === BB_RESULT.FAILURE) {
|
|
28
25
|
this.logger.error(`Proof generation failed: ${proofRes.reason}`);
|
|
29
26
|
}
|
|
27
|
+
expect(proofRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
30
28
|
return proofRes;
|
|
31
29
|
}
|
|
32
|
-
async verify(proofRes) {
|
|
30
|
+
async verify(proofRes, publicInputs) {
|
|
33
31
|
if (this.checkCircuitOnly) {
|
|
34
|
-
// Skip verification if we
|
|
35
|
-
// Check-circuit
|
|
32
|
+
// Skip verification if we are only checking the circuit.
|
|
33
|
+
// Check-circuit does not generate a proof to verify.
|
|
36
34
|
return proofRes;
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
const succeededRes = proofRes;
|
|
40
|
-
const vkData = await extractAvmVkData(succeededRes.vkPath);
|
|
41
|
-
VerificationKeyData.fromBuffer(vkData.toBuffer());
|
|
42
|
-
// Then we verify.
|
|
43
|
-
const rawVkPath = path.join(succeededRes.vkPath, 'vk');
|
|
44
|
-
return await verifyAvmProof(BB_PATH, succeededRes.proofPath, rawVkPath, this.logger);
|
|
36
|
+
return await verifyAvmProof(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath, publicInputs, path.join(proofRes.vkDirectoryPath, VK_FILENAME), this.logger);
|
|
45
37
|
}
|
|
46
|
-
async
|
|
47
|
-
const simRes = await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer);
|
|
48
|
-
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
49
|
-
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
38
|
+
async proveVerify(avmCircuitInputs) {
|
|
50
39
|
const provingRes = await this.prove(avmCircuitInputs);
|
|
51
40
|
expect(provingRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
52
|
-
const verificationRes = await this.verify(provingRes);
|
|
41
|
+
const verificationRes = await this.verify(provingRes, avmCircuitInputs.publicInputs);
|
|
53
42
|
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
|
|
54
43
|
}
|
|
55
|
-
async
|
|
56
|
-
const simRes = await this.simulateTx(/*sender=*/ AztecAddress.fromNumber(42), /*setupCalls=*/ [], [
|
|
57
|
-
appCall
|
|
58
|
-
]);
|
|
59
|
-
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
60
|
-
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
61
|
-
const provingRes = await this.prove(avmCircuitInputs);
|
|
62
|
-
expect(provingRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
63
|
-
const verificationRes = await this.verify(provingRes);
|
|
64
|
-
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
export class AvmProvingTesterV2 extends PublicTxSimulationTester {
|
|
68
|
-
bbWorkingDirectory;
|
|
69
|
-
constructor(bbWorkingDirectory, contractDataSource, merkleTrees, globals){
|
|
70
|
-
super(merkleTrees, contractDataSource, globals), this.bbWorkingDirectory = bbWorkingDirectory;
|
|
71
|
-
}
|
|
72
|
-
static async new(globals) {
|
|
73
|
-
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
74
|
-
const contractDataSource = new SimpleContractDataSource();
|
|
75
|
-
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
76
|
-
return new AvmProvingTesterV2(bbWorkingDirectory, contractDataSource, merkleTrees, globals);
|
|
77
|
-
}
|
|
78
|
-
async proveV2(avmCircuitInputs) {
|
|
79
|
-
// Then we prove.
|
|
80
|
-
const proofRes = await generateAvmProofV2(BB_PATH, this.bbWorkingDirectory, avmCircuitInputs, this.logger);
|
|
81
|
-
if (proofRes.status === BB_RESULT.FAILURE) {
|
|
82
|
-
this.logger.error(`Proof generation failed: ${proofRes.reason}`);
|
|
83
|
-
}
|
|
84
|
-
expect(proofRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
85
|
-
return proofRes;
|
|
86
|
-
}
|
|
87
|
-
async verifyV2(proofRes, publicInputs) {
|
|
88
|
-
return await verifyAvmProofV2(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath, publicInputs, proofRes.vkPath, this.logger);
|
|
89
|
-
}
|
|
90
|
-
async simProveVerifyV2(sender, setupCalls, appCalls, teardownCall, expectRevert, feePayer = sender) {
|
|
44
|
+
async simProveVerify(sender, setupCalls, appCalls, teardownCall, expectRevert, feePayer = sender) {
|
|
91
45
|
const simRes = await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer);
|
|
92
46
|
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
93
47
|
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
48
|
+
await this.proveVerify(avmCircuitInputs);
|
|
49
|
+
}
|
|
50
|
+
async simProveVerifyAppLogic(appCall, expectRevert) {
|
|
51
|
+
await this.simProveVerify(/*sender=*/ AztecAddress.fromNumber(42), /*setupCalls=*/ [], [
|
|
52
|
+
appCall
|
|
53
|
+
], undefined, expectRevert);
|
|
98
54
|
}
|
|
99
55
|
}
|
package/dest/bb/execute.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type BBSuccess = {
|
|
|
22
22
|
/** Full path of the public key. */
|
|
23
23
|
pkPath?: string;
|
|
24
24
|
/** Base directory for the VKs (raw, fields). */
|
|
25
|
-
|
|
25
|
+
vkDirectoryPath?: string;
|
|
26
26
|
/** Full path of the proof. */
|
|
27
27
|
proofPath?: string;
|
|
28
28
|
/** Full path of the contract. */
|
|
@@ -36,7 +36,6 @@ export type BBFailure = {
|
|
|
36
36
|
retry?: boolean;
|
|
37
37
|
};
|
|
38
38
|
export type BBResult = BBSuccess | BBFailure;
|
|
39
|
-
export type VerificationFunction = typeof verifyProof | typeof verifyAvmProof;
|
|
40
39
|
type BBExecResult = {
|
|
41
40
|
status: BB_RESULT;
|
|
42
41
|
exitCode: number;
|
|
@@ -79,20 +78,11 @@ export declare function generateTubeProof(pathToBB: string, workingDirectory: st
|
|
|
79
78
|
* @param pathToBB - The full path to the bb binary
|
|
80
79
|
* @param workingDirectory - A working directory for use by bb
|
|
81
80
|
* @param input - The inputs for the public function to be proven
|
|
82
|
-
* @param
|
|
83
|
-
* @
|
|
84
|
-
*/
|
|
85
|
-
export declare function generateAvmProofV2(pathToBB: string, workingDirectory: string, input: AvmCircuitInputs, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
86
|
-
/**
|
|
87
|
-
* Used for generating AVM proofs (or doing check-circuit).
|
|
88
|
-
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
89
|
-
* @param pathToBB - The full path to the bb binary
|
|
90
|
-
* @param workingDirectory - A working directory for use by bb
|
|
91
|
-
* @param bytecode - The AVM bytecode for the public function to be proven (expected to be decompressed)
|
|
92
|
-
* @param log - A logging function
|
|
81
|
+
* @param logger - A logging function
|
|
82
|
+
* @param checkCircuitOnly - A boolean to toggle a "check-circuit only" operation instead of proving.
|
|
93
83
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
94
84
|
*/
|
|
95
|
-
export declare function generateAvmProof(pathToBB: string, workingDirectory: string,
|
|
85
|
+
export declare function generateAvmProof(pathToBB: string, workingDirectory: string, input: AvmCircuitInputs, logger: Logger, checkCircuitOnly?: boolean): Promise<BBFailure | BBSuccess>;
|
|
96
86
|
/**
|
|
97
87
|
* Used for verifying proofs of noir circuits
|
|
98
88
|
* @param pathToBB - The full path to the bb binary
|
|
@@ -102,16 +92,7 @@ export declare function generateAvmProof(pathToBB: string, workingDirectory: str
|
|
|
102
92
|
* @returns An object containing a result indication and duration taken
|
|
103
93
|
*/
|
|
104
94
|
export declare function verifyProof(pathToBB: string, proofFullPath: string, verificationKeyPath: string, ultraHonkFlavor: UltraHonkFlavor, log: Logger): Promise<BBFailure | BBSuccess>;
|
|
105
|
-
|
|
106
|
-
* Used for verifying proofs of the AVM
|
|
107
|
-
* @param pathToBB - The full path to the bb binary
|
|
108
|
-
* @param proofFullPath - The full path to the proof to be verified
|
|
109
|
-
* @param verificationKeyPath - The full path to the circuit verification key
|
|
110
|
-
* @param log - A logging function
|
|
111
|
-
* @returns An object containing a result indication and duration taken
|
|
112
|
-
*/
|
|
113
|
-
export declare function verifyAvmProof(pathToBB: string, proofFullPath: string, verificationKeyPath: string, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
114
|
-
export declare function verifyAvmProofV2(pathToBB: string, workingDirectory: string, proofFullPath: string, publicInputs: AvmCircuitPublicInputs, verificationKeyPath: string, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
95
|
+
export declare function verifyAvmProof(pathToBB: string, workingDirectory: string, proofFullPath: string, publicInputs: AvmCircuitPublicInputs, verificationKeyPath: string, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
115
96
|
/**
|
|
116
97
|
* Verifies a ClientIvcProof
|
|
117
98
|
* TODO(#7370) The verification keys should be supplied separately
|
package/dest/bb/execute.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/bb/execute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/bb/execute.ts"],"names":[],"mappings":"AACA,O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d,gBAAgB,GAAE,OAAe,GAChC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAiEhC;AAED;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,MAAM,EAC3B,eAAe,EAAE,eAAe,EAChC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAShC;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,sBAAsB,EACpC,mBAAmB,EAAE,MAAM,EAC3B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAmBhC;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CA2BhC;AAqED,wBAAsB,kCAAkC,CACtD,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CA8ChC;AAED;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAC9C,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,eAAe,GAAG,WAAW,EACrC,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CA0DhC"}
|
package/dest/bb/execute.js
CHANGED
|
@@ -3,6 +3,7 @@ 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 pidusage from 'pidusage';
|
|
6
7
|
export const VK_FILENAME = 'vk';
|
|
7
8
|
export const VK_FIELDS_FILENAME = 'vk_fields.json';
|
|
8
9
|
export const PUBLIC_INPUTS_FILENAME = 'public_inputs';
|
|
@@ -56,11 +57,23 @@ export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
|
|
|
56
57
|
}
|
|
57
58
|
bb.stdout.on('data', (data)=>{
|
|
58
59
|
const message = data.toString('utf-8').replace(/\n$/, '');
|
|
59
|
-
|
|
60
|
+
pidusage(bb.pid, (err, stats)=>{
|
|
61
|
+
if (err) {
|
|
62
|
+
logger(message);
|
|
63
|
+
} else {
|
|
64
|
+
logger(`${message} (mem: ${(stats.memory / 1024 / 1024).toFixed(2)}MiB)`);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
60
67
|
});
|
|
61
68
|
bb.stderr.on('data', (data)=>{
|
|
62
69
|
const message = data.toString('utf-8').replace(/\n$/, '');
|
|
63
|
-
|
|
70
|
+
pidusage(bb.pid, (err, stats)=>{
|
|
71
|
+
if (err) {
|
|
72
|
+
logger(message);
|
|
73
|
+
} else {
|
|
74
|
+
logger(`${message} (mem: ${(stats.memory / 1024 / 1024).toFixed(2)}MiB)`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
64
77
|
});
|
|
65
78
|
bb.on('close', (exitCode, signal)=>{
|
|
66
79
|
if (timeoutId) {
|
|
@@ -132,7 +145,7 @@ export async function executeBbClientIvcProof(pathToBB, workingDirectory, inputs
|
|
|
132
145
|
durationMs,
|
|
133
146
|
proofPath: `${outputPath}`,
|
|
134
147
|
pkPath: undefined,
|
|
135
|
-
|
|
148
|
+
vkDirectoryPath: `${outputPath}`
|
|
136
149
|
};
|
|
137
150
|
}
|
|
138
151
|
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
@@ -250,7 +263,7 @@ function getArgs(flavor) {
|
|
|
250
263
|
durationMs: duration,
|
|
251
264
|
proofPath: `${outputPath}`,
|
|
252
265
|
pkPath: undefined,
|
|
253
|
-
|
|
266
|
+
vkDirectoryPath: `${outputPath}`
|
|
254
267
|
};
|
|
255
268
|
}
|
|
256
269
|
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
@@ -319,7 +332,7 @@ function getArgs(flavor) {
|
|
|
319
332
|
durationMs,
|
|
320
333
|
proofPath: outputPath,
|
|
321
334
|
pkPath: undefined,
|
|
322
|
-
|
|
335
|
+
vkDirectoryPath: outputPath
|
|
323
336
|
};
|
|
324
337
|
}
|
|
325
338
|
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
@@ -341,9 +354,10 @@ function getArgs(flavor) {
|
|
|
341
354
|
* @param pathToBB - The full path to the bb binary
|
|
342
355
|
* @param workingDirectory - A working directory for use by bb
|
|
343
356
|
* @param input - The inputs for the public function to be proven
|
|
344
|
-
* @param
|
|
357
|
+
* @param logger - A logging function
|
|
358
|
+
* @param checkCircuitOnly - A boolean to toggle a "check-circuit only" operation instead of proving.
|
|
345
359
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
346
|
-
*/ export async function
|
|
360
|
+
*/ export async function generateAvmProof(pathToBB, workingDirectory, input, logger, checkCircuitOnly = false) {
|
|
347
361
|
// Check that the working directory exists
|
|
348
362
|
try {
|
|
349
363
|
await fs.access(workingDirectory);
|
|
@@ -385,90 +399,11 @@ function getArgs(flavor) {
|
|
|
385
399
|
args.push(loggingArg);
|
|
386
400
|
}
|
|
387
401
|
const timer = new Timer();
|
|
388
|
-
const
|
|
389
|
-
logger.verbose(`AvmCircuit (prove) BB out - ${message}`);
|
|
390
|
-
};
|
|
391
|
-
const result = await executeBB(pathToBB, 'avm2_prove', args, logFunction);
|
|
392
|
-
const duration = timer.ms();
|
|
393
|
-
if (result.status == 0) {
|
|
394
|
-
return {
|
|
395
|
-
status: 0,
|
|
396
|
-
durationMs: duration,
|
|
397
|
-
proofPath: join(outputPath, PROOF_FILENAME),
|
|
398
|
-
pkPath: undefined,
|
|
399
|
-
vkPath: join(outputPath, VK_FILENAME)
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
403
|
-
return {
|
|
404
|
-
status: 1,
|
|
405
|
-
reason: `Failed to generate proof. Exit code ${result.exitCode}. Signal ${result.signal}.`,
|
|
406
|
-
retry: !!result.signal
|
|
407
|
-
};
|
|
408
|
-
} catch (error) {
|
|
409
|
-
return {
|
|
410
|
-
status: 1,
|
|
411
|
-
reason: `${error}`
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
/**
|
|
416
|
-
* Used for generating AVM proofs (or doing check-circuit).
|
|
417
|
-
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
418
|
-
* @param pathToBB - The full path to the bb binary
|
|
419
|
-
* @param workingDirectory - A working directory for use by bb
|
|
420
|
-
* @param bytecode - The AVM bytecode for the public function to be proven (expected to be decompressed)
|
|
421
|
-
* @param log - A logging function
|
|
422
|
-
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
423
|
-
*/ export async function generateAvmProof(pathToBB, workingDirectory, _input, logger, checkCircuitOnly = false) {
|
|
424
|
-
// Check that the working directory exists
|
|
425
|
-
try {
|
|
426
|
-
await fs.access(workingDirectory);
|
|
427
|
-
} catch {
|
|
428
|
-
return {
|
|
429
|
-
status: 1,
|
|
430
|
-
reason: `Working directory ${workingDirectory} does not exist`
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
// Paths for the inputs
|
|
434
|
-
const publicInputsPath = join(workingDirectory, AVM_PUBLIC_INPUTS_FILENAME);
|
|
435
|
-
// The proof is written to e.g. /workingDirectory/proof
|
|
436
|
-
const outputPath = workingDirectory;
|
|
437
|
-
const filePresent = async (file)=>await fs.access(file, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
|
|
438
|
-
const binaryPresent = await filePresent(pathToBB);
|
|
439
|
-
if (!binaryPresent) {
|
|
440
|
-
return {
|
|
441
|
-
status: 1,
|
|
442
|
-
reason: `Failed to find bb binary at ${pathToBB}`
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
try {
|
|
446
|
-
// Write the inputs to the working directory.
|
|
447
|
-
// WARNING: Not writing the inputs since VM1 is disabled!
|
|
448
|
-
// await fs.writeFile(publicInputsPath, input.publicInputs.toBuffer());
|
|
449
|
-
// if (!(await filePresent(publicInputsPath))) {
|
|
450
|
-
// return { status: BB_RESULT.FAILURE, reason: `Could not write publicInputs at ${publicInputsPath}` };
|
|
451
|
-
// }
|
|
452
|
-
// await fs.writeFile(avmHintsPath, input.avmHints.toBuffer());
|
|
453
|
-
// if (!(await filePresent(avmHintsPath))) {
|
|
454
|
-
// return { status: BB_RESULT.FAILURE, reason: `Could not write avmHints at ${avmHintsPath}` };
|
|
455
|
-
// }
|
|
456
|
-
const args = [
|
|
457
|
-
'--avm-public-inputs',
|
|
458
|
-
publicInputsPath,
|
|
459
|
-
'-o',
|
|
460
|
-
outputPath
|
|
461
|
-
];
|
|
462
|
-
const loggingArg = logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
|
|
463
|
-
if (loggingArg !== '') {
|
|
464
|
-
args.push(loggingArg);
|
|
465
|
-
}
|
|
466
|
-
const timer = new Timer();
|
|
467
|
-
const cmd = checkCircuitOnly ? 'check_circuit' : 'prove';
|
|
402
|
+
const cmd = checkCircuitOnly ? 'avm_check_circuit' : 'avm_prove';
|
|
468
403
|
const logFunction = (message)=>{
|
|
469
404
|
logger.verbose(`AvmCircuit (${cmd}) BB out - ${message}`);
|
|
470
405
|
};
|
|
471
|
-
const result = await executeBB(pathToBB,
|
|
406
|
+
const result = await executeBB(pathToBB, cmd, args, logFunction);
|
|
472
407
|
const duration = timer.ms();
|
|
473
408
|
if (result.status == 0) {
|
|
474
409
|
return {
|
|
@@ -476,7 +411,7 @@ function getArgs(flavor) {
|
|
|
476
411
|
durationMs: duration,
|
|
477
412
|
proofPath: join(outputPath, PROOF_FILENAME),
|
|
478
413
|
pkPath: undefined,
|
|
479
|
-
|
|
414
|
+
vkDirectoryPath: outputPath
|
|
480
415
|
};
|
|
481
416
|
}
|
|
482
417
|
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
@@ -502,17 +437,7 @@ function getArgs(flavor) {
|
|
|
502
437
|
*/ export async function verifyProof(pathToBB, proofFullPath, verificationKeyPath, ultraHonkFlavor, log) {
|
|
503
438
|
return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, `verify`, log, getArgs(ultraHonkFlavor));
|
|
504
439
|
}
|
|
505
|
-
|
|
506
|
-
* Used for verifying proofs of the AVM
|
|
507
|
-
* @param pathToBB - The full path to the bb binary
|
|
508
|
-
* @param proofFullPath - The full path to the proof to be verified
|
|
509
|
-
* @param verificationKeyPath - The full path to the circuit verification key
|
|
510
|
-
* @param log - A logging function
|
|
511
|
-
* @returns An object containing a result indication and duration taken
|
|
512
|
-
*/ export async function verifyAvmProof(pathToBB, proofFullPath, verificationKeyPath, logger) {
|
|
513
|
-
return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, 'avm_verify', logger);
|
|
514
|
-
}
|
|
515
|
-
export async function verifyAvmProofV2(pathToBB, workingDirectory, proofFullPath, publicInputs, verificationKeyPath, logger) {
|
|
440
|
+
export async function verifyAvmProof(pathToBB, workingDirectory, proofFullPath, publicInputs, verificationKeyPath, logger) {
|
|
516
441
|
const inputsBuffer = publicInputs.serializeWithMessagePack();
|
|
517
442
|
// Write the inputs to the working directory.
|
|
518
443
|
const filePresent = async (file)=>await fs.access(file, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
|
|
@@ -524,7 +449,7 @@ export async function verifyAvmProofV2(pathToBB, workingDirectory, proofFullPath
|
|
|
524
449
|
reason: `Could not write avm inputs to ${avmInputsPath}`
|
|
525
450
|
};
|
|
526
451
|
}
|
|
527
|
-
return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, '
|
|
452
|
+
return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, 'avm_verify', logger, [
|
|
528
453
|
'--avm-public-inputs',
|
|
529
454
|
avmInputsPath
|
|
530
455
|
]);
|
|
@@ -596,14 +521,14 @@ export async function verifyAvmProofV2(pathToBB, workingDirectory, proofFullPath
|
|
|
596
521
|
const logFunction = (message)=>{
|
|
597
522
|
logger.verbose(`bb-prover (verify) BB out - ${message}`);
|
|
598
523
|
};
|
|
599
|
-
// take proofFullPath and remove the suffix past the / to get the directory
|
|
600
|
-
const proofDir = proofFullPath.substring(0, proofFullPath.lastIndexOf('/'));
|
|
601
|
-
const publicInputsFullPath = join(proofDir, '/public_inputs');
|
|
602
|
-
logger.debug(`public inputs path: ${publicInputsFullPath}`);
|
|
603
524
|
try {
|
|
604
525
|
let args;
|
|
605
|
-
// Specify the public inputs path in the case of UH verification.
|
|
606
526
|
if (command == 'verify') {
|
|
527
|
+
// Specify the public inputs path in the case of UH verification.
|
|
528
|
+
// Take proofFullPath and remove the suffix past the / to get the directory.
|
|
529
|
+
const proofDir = proofFullPath.substring(0, proofFullPath.lastIndexOf('/'));
|
|
530
|
+
const publicInputsFullPath = join(proofDir, '/public_inputs');
|
|
531
|
+
logger.debug(`public inputs path: ${publicInputsFullPath}`);
|
|
607
532
|
args = [
|
|
608
533
|
'-p',
|
|
609
534
|
proofFullPath,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
|
|
2
2
|
import { type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
3
|
-
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
3
|
+
import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
4
4
|
import { type ProofAndVerificationKey, type PublicInputsAndRecursiveProof, type ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
5
5
|
import type { BaseParityInputs, ParityPublicInputs, RootParityInputs } from '@aztec/stdlib/parity';
|
|
6
6
|
import { Proof } from '@aztec/stdlib/proofs';
|
|
7
|
-
import type
|
|
7
|
+
import { type BaseOrMergeRollupPublicInputs, type BlockMergeRollupInputs, type BlockRootOrBlockMergePublicInputs, type BlockRootRollupInputs, type EmptyBlockRootRollupInputs, type MergeRollupInputs, type PrivateBaseRollupInputs, PublicBaseRollupInputs, type RootRollupInputs, type RootRollupPublicInputs, type SingleTxBlockRootRollupInputs, type TubeInputs } from '@aztec/stdlib/rollup';
|
|
8
8
|
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
9
9
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
10
10
|
import type { ACVMConfig, BBConfig } from '../../config.js';
|
|
@@ -38,7 +38,7 @@ export declare class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
38
38
|
* @param inputs - The inputs to the AVM circuit.
|
|
39
39
|
* @returns The proof.
|
|
40
40
|
*/
|
|
41
|
-
getAvmProof(inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<typeof
|
|
41
|
+
getAvmProof(inputs: AvmCircuitInputs, skipPublicInputsValidation?: boolean): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>>;
|
|
42
42
|
/**
|
|
43
43
|
* Simulates the base rollup circuit from its inputs.
|
|
44
44
|
* @param inputs - Inputs to the circuit.
|
|
@@ -104,7 +104,7 @@ export declare class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
104
104
|
* @param proof - The proof to be verified
|
|
105
105
|
*/
|
|
106
106
|
verifyProof(circuitType: ServerProtocolArtifact, proof: Proof): Promise<void>;
|
|
107
|
-
verifyAvmProof(proof: Proof, verificationKey: VerificationKeyData): Promise<void>;
|
|
107
|
+
verifyAvmProof(proof: Proof, verificationKey: VerificationKeyData, publicInputs: AvmCircuitPublicInputs): Promise<void>;
|
|
108
108
|
verifyWithKey(flavor: UltraHonkFlavor, verificationKey: VerificationKeyData, proof: Proof): Promise<void>;
|
|
109
109
|
private verifyWithKeyInternal;
|
|
110
110
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_prover.d.ts","sourceRoot":"","sources":["../../../src/prover/server/bb_prover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"bb_prover.d.ts","sourceRoot":"","sources":["../../../src/prover/server/bb_prover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,6BAA6B,EAC7B,yCAAyC,EAEzC,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,KAAK,sBAAsB,EAsB5B,MAAM,4CAA4C,CAAC;AAIpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAElF,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EAGzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,KAAK,EAAgD,MAAM,sBAAsB,CAAC;AAC3F,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,sBAAsB,EAC3B,KAAK,iCAAiC,EACtC,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAC/B,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,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IG;IACH,OAAO,CAAC,gCAAgC;YAQ1B,oBAAoB;IAwBlC,OAAO,CAAC,cAAc;CAYvB"}
|
|
@@ -4,7 +4,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
4
4
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
}
|
|
7
|
-
import {
|
|
7
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, PAIRING_POINTS_SIZE, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
|
|
8
8
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
9
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
10
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -15,6 +15,7 @@ import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
|
15
15
|
import { ProvingError } from '@aztec/stdlib/errors';
|
|
16
16
|
import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
17
17
|
import { Proof, RecursiveProof, makeRecursiveProofFromBinary } from '@aztec/stdlib/proofs';
|
|
18
|
+
import { enhanceProofWithPiValidationFlag } from '@aztec/stdlib/rollup';
|
|
18
19
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
19
20
|
import crypto from 'crypto';
|
|
20
21
|
import { promises as fs } from 'fs';
|
|
@@ -78,9 +79,11 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
78
79
|
* Creates an AVM proof and verifies it.
|
|
79
80
|
* @param inputs - The inputs to the AVM circuit.
|
|
80
81
|
* @returns The proof.
|
|
81
|
-
*/ async getAvmProof(inputs) {
|
|
82
|
+
*/ async getAvmProof(inputs, skipPublicInputsValidation = false) {
|
|
82
83
|
const proofAndVk = await this.createAvmProof(inputs);
|
|
83
|
-
await this.verifyAvmProof(proofAndVk.proof.binaryProof, proofAndVk.verificationKey);
|
|
84
|
+
await this.verifyAvmProof(proofAndVk.proof.binaryProof, proofAndVk.verificationKey, inputs.publicInputs);
|
|
85
|
+
// TODO(#14234)[Unconditional PIs validation]: remove next lines and directly return proofAndVk
|
|
86
|
+
proofAndVk.proof.proof = enhanceProofWithPiValidationFlag(proofAndVk.proof.proof, skipPublicInputsValidation);
|
|
84
87
|
return proofAndVk;
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
@@ -253,7 +256,7 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
253
256
|
const provingResult = await this.generateAvmProofWithBB(input, bbWorkingDirectory);
|
|
254
257
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/6773): this VK data format is wrong.
|
|
255
258
|
// In particular, the number of public inputs, etc will be wrong.
|
|
256
|
-
const verificationKey = await extractAvmVkData(provingResult.
|
|
259
|
+
const verificationKey = await extractAvmVkData(provingResult.vkDirectoryPath);
|
|
257
260
|
const avmProof = await this.readAvmProofAsFields(provingResult.proofPath, verificationKey);
|
|
258
261
|
const circuitType = 'avm-circuit';
|
|
259
262
|
const appCircuitName = 'unknown';
|
|
@@ -282,7 +285,7 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
282
285
|
const provingResult = await this.generateTubeProofWithBB(bbWorkingDirectory, input);
|
|
283
286
|
// Read the proof as fields
|
|
284
287
|
// TODO(AD): this is the only remaining use of extractVkData.
|
|
285
|
-
const tubeVK = await extractVkData(provingResult.
|
|
288
|
+
const tubeVK = await extractVkData(provingResult.vkDirectoryPath);
|
|
286
289
|
const tubeProof = await readProofAsFields(provingResult.proofPath, tubeVK, TUBE_PROOF_LENGTH, logger);
|
|
287
290
|
this.instrumentation.recordDuration('provingDuration', 'tubeCircuit', provingResult.durationMs);
|
|
288
291
|
this.instrumentation.recordSize('proofSize', 'tubeCircuit', tubeProof.binaryProof.buffer.length);
|
|
@@ -339,8 +342,8 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
339
342
|
const verificationKey = this.getVerificationKeyDataForCircuit(circuitType);
|
|
340
343
|
return await this.verifyWithKey(getUltraHonkFlavorForCircuit(circuitType), verificationKey, proof);
|
|
341
344
|
}
|
|
342
|
-
async verifyAvmProof(proof, verificationKey) {
|
|
343
|
-
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath)=>verifyAvmProof(this.config.bbBinaryPath, proofPath, vkPath, logger));
|
|
345
|
+
async verifyAvmProof(proof, verificationKey, publicInputs) {
|
|
346
|
+
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath)=>verifyAvmProof(this.config.bbBinaryPath, this.config.bbWorkingDirectory, proofPath, publicInputs, vkPath, logger));
|
|
344
347
|
}
|
|
345
348
|
async verifyWithKey(flavor, verificationKey, proof) {
|
|
346
349
|
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath)=>verifyProof(this.config.bbBinaryPath, proofPath, vkPath, flavor, logger));
|
|
@@ -375,12 +378,18 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
375
378
|
return vk;
|
|
376
379
|
}
|
|
377
380
|
async readAvmProofAsFields(proofFilename, vkData) {
|
|
378
|
-
const
|
|
379
|
-
const reader = BufferReader.asReader(
|
|
380
|
-
const
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
const rawProofBuffer = await fs.readFile(proofFilename);
|
|
382
|
+
const reader = BufferReader.asReader(rawProofBuffer);
|
|
383
|
+
const proofFields = reader.readArray(rawProofBuffer.length / Fr.SIZE_IN_BYTES, Fr);
|
|
384
|
+
// We extend to a fixed-size padded proof as during development any new AVM circuit column changes the
|
|
385
|
+
// proof length and we do not have a mechanism to feedback a cpp constant to noir/TS.
|
|
386
|
+
// TODO(#13390): Revive a non-padded AVM proof
|
|
387
|
+
if (proofFields.length > AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED) {
|
|
388
|
+
throw new Error(`Proof has ${proofFields.length} fields, expected no more than ${AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED}.`);
|
|
389
|
+
}
|
|
390
|
+
const proofFieldsPadded = proofFields.concat(Array(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED - proofFields.length).fill(new Fr(0)));
|
|
391
|
+
const proof = new Proof(rawProofBuffer, vkData.numPublicInputs);
|
|
392
|
+
return new RecursiveProof(proofFieldsPadded, proof, true, AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED);
|
|
384
393
|
}
|
|
385
394
|
runInDirectory(fn) {
|
|
386
395
|
return runInDirectory(this.config.bbWorkingDirectory, (dir)=>fn(dir).catch((err)=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
|
|
2
2
|
import { type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
3
3
|
import { type SimulationProvider } from '@aztec/simulator/server';
|
|
4
4
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
@@ -72,7 +72,7 @@ export declare class TestCircuitProver implements ServerCircuitProver {
|
|
|
72
72
|
* @returns The public inputs as outputs of the simulation.
|
|
73
73
|
*/
|
|
74
74
|
getRootRollupProof(input: RootRollupInputs): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs>>;
|
|
75
|
-
getAvmProof(_inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<typeof
|
|
75
|
+
getAvmProof(_inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>>;
|
|
76
76
|
private applyDelay;
|
|
77
77
|
verifyProof(_1: ServerProtocolArtifact, _2: Proof): Promise<void>;
|
|
78
78
|
private simulate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_circuit_prover.d.ts","sourceRoot":"","sources":["../../src/test/test_circuit_prover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"test_circuit_prover.d.ts","sourceRoot":"","sources":["../../src/test/test_circuit_prover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EAEpC,6BAA6B,EAC7B,yCAAyC,EACzC,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EACL,KAAK,sBAAsB,EAuB5B,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EAAE,KAAK,kBAAkB,EAAsD,MAAM,yBAAyB,CAAC;AACtH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EAGzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,KAAK,KAAK,EAAmE,MAAM,sBAAsB,CAAC;AACnH,OAAO,KAAK,EACV,6BAA6B,EAC7B,sBAAsB,EACtB,iCAAiC,EACjC,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,6BAA6B,EAC7B,UAAU,EACX,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,KAAK,eAAe,EAAiC,MAAM,yBAAyB,CAAC;AAM9F,KAAK,SAAS,GACV;IACE,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B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