@aztec/bb-prover 0.80.0 → 0.82.0
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 -3
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +7 -9
- package/dest/bb/execute.d.ts +4 -8
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +28 -14
- package/dest/prover/bb_native_private_kernel_prover.d.ts +3 -2
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_native_private_kernel_prover.js +18 -7
- package/dest/prover/bb_private_kernel_prover.d.ts +2 -2
- package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_private_kernel_prover.js +4 -4
- package/dest/prover/bb_prover.d.ts.map +1 -1
- package/dest/prover/bb_prover.js +7 -5
- package/dest/prover/client_ivc_proof_utils.d.ts +6 -14
- package/dest/prover/client_ivc_proof_utils.d.ts.map +1 -1
- package/dest/prover/client_ivc_proof_utils.js +10 -31
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +9 -7
- package/dest/verifier/bb_verifier.d.ts +2 -0
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +7 -2
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +2 -2
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.js +7 -6
- package/package.json +16 -15
- package/src/avm_proving_tests/avm_proving_tester.ts +6 -10
- package/src/bb/execute.ts +25 -13
- package/src/prover/bb_native_private_kernel_prover.ts +20 -12
- package/src/prover/bb_private_kernel_prover.ts +13 -8
- package/src/prover/bb_prover.ts +13 -8
- package/src/prover/client_ivc_proof_utils.ts +10 -24
- package/src/test/test_circuit_prover.ts +21 -10
- package/src/verifier/bb_verifier.ts +9 -2
- package/src/wasm/bb_wasm_private_kernel_prover.ts +7 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicTxSimulationTester, type TestEnqueuedCall } from '@aztec/simulator/public/fixtures';
|
|
2
|
-
import { SimpleContractDataSource
|
|
2
|
+
import { SimpleContractDataSource } from '@aztec/simulator/server';
|
|
3
3
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
@@ -7,7 +7,7 @@ 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, merkleTree: MerkleTreeWriteOperations, contractDataSource: SimpleContractDataSource);
|
|
11
11
|
static create(checkCircuitOnly?: boolean): Promise<AvmProvingTester>;
|
|
12
12
|
prove(avmCircuitInputs: AvmCircuitInputs): Promise<BBResult>;
|
|
13
13
|
verify(proofRes: BBSuccess): Promise<BBResult>;
|
|
@@ -16,7 +16,7 @@ export declare class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
16
16
|
}
|
|
17
17
|
export declare class AvmProvingTesterV2 extends PublicTxSimulationTester {
|
|
18
18
|
private bbWorkingDirectory;
|
|
19
|
-
constructor(bbWorkingDirectory: string,
|
|
19
|
+
constructor(bbWorkingDirectory: string, contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations);
|
|
20
20
|
static create(): Promise<AvmProvingTesterV2>;
|
|
21
21
|
proveV2(avmCircuitInputs: AvmCircuitInputs): Promise<BBResult>;
|
|
22
22
|
verifyV2(proofRes: BBSuccess): Promise<BBResult>;
|
|
@@ -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,EAAE,wBAAwB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"avm_proving_tester.d.ts","sourceRoot":"","sources":["../../src/avm_proving_tests/avm_proving_tester.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AASjF,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,EAMf,MAAM,kBAAkB,CAAC;AAK1B,qBAAa,gBAAiB,SAAQ,wBAAwB;IAE1D,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,gBAAgB;gBADhB,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,OAAO,EACjC,UAAU,EAAE,yBAAyB,EACrC,kBAAkB,EAAE,wBAAwB;WAKxB,MAAM,CAAC,gBAAgB,GAAE,OAAe;IAQxD,KAAK,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAe5D,MAAM,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IAgBvC,cAAc,CACzB,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,gBAAgB,EAAE,EAC9B,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,YAAY,EAAE,gBAAgB,GAAG,SAAS,EAC1C,YAAY,EAAE,OAAO,GAAG,SAAS,EACjC,QAAQ,eAAS;IAWN,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,EAAE,YAAY,CAAC,EAAE,OAAO;CAWtF;AAED,qBAAa,kBAAmB,SAAQ,wBAAwB;IAE5D,OAAO,CAAC,kBAAkB;gBAAlB,kBAAkB,EAAE,MAAM,EAClC,kBAAkB,EAAE,wBAAwB,EAC5C,WAAW,EAAE,yBAAyB;WAKlB,MAAM;IAQtB,OAAO,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU9D,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IAezC,gBAAgB,CAC3B,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,gBAAgB,EAAE,EAC9B,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,YAAY,EAAE,gBAAgB,GAAG,SAAS,EAC1C,YAAY,EAAE,OAAO,GAAG,SAAS,EACjC,QAAQ,eAAS;CAYpB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicTxSimulationTester } from '@aztec/simulator/public/fixtures';
|
|
2
|
-
import { SimpleContractDataSource
|
|
2
|
+
import { SimpleContractDataSource } from '@aztec/simulator/server';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { makeAvmCircuitInputs } from '@aztec/stdlib/testing';
|
|
5
5
|
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
@@ -13,15 +13,14 @@ const BB_PATH = path.resolve('../../barretenberg/cpp/build/bin/bb');
|
|
|
13
13
|
export class AvmProvingTester extends PublicTxSimulationTester {
|
|
14
14
|
bbWorkingDirectory;
|
|
15
15
|
checkCircuitOnly;
|
|
16
|
-
constructor(bbWorkingDirectory, checkCircuitOnly,
|
|
17
|
-
super(
|
|
16
|
+
constructor(bbWorkingDirectory, checkCircuitOnly, merkleTree, contractDataSource){
|
|
17
|
+
super(merkleTree, contractDataSource), this.bbWorkingDirectory = bbWorkingDirectory, this.checkCircuitOnly = checkCircuitOnly;
|
|
18
18
|
}
|
|
19
19
|
static async create(checkCircuitOnly = false) {
|
|
20
20
|
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
21
21
|
const contractDataSource = new SimpleContractDataSource();
|
|
22
22
|
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
23
|
-
|
|
24
|
-
return new AvmProvingTester(bbWorkingDirectory, checkCircuitOnly, worldStateDB, contractDataSource, merkleTrees);
|
|
23
|
+
return new AvmProvingTester(bbWorkingDirectory, checkCircuitOnly, merkleTrees, contractDataSource);
|
|
25
24
|
}
|
|
26
25
|
async prove(avmCircuitInputs) {
|
|
27
26
|
// Then we prove.
|
|
@@ -68,15 +67,14 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
68
67
|
}
|
|
69
68
|
export class AvmProvingTesterV2 extends PublicTxSimulationTester {
|
|
70
69
|
bbWorkingDirectory;
|
|
71
|
-
constructor(bbWorkingDirectory,
|
|
72
|
-
super(
|
|
70
|
+
constructor(bbWorkingDirectory, contractDataSource, merkleTrees){
|
|
71
|
+
super(merkleTrees, contractDataSource), this.bbWorkingDirectory = bbWorkingDirectory;
|
|
73
72
|
}
|
|
74
73
|
static async create() {
|
|
75
74
|
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
76
75
|
const contractDataSource = new SimpleContractDataSource();
|
|
77
76
|
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
78
|
-
|
|
79
|
-
return new AvmProvingTesterV2(bbWorkingDirectory, worldStateDB, contractDataSource, merkleTrees);
|
|
77
|
+
return new AvmProvingTesterV2(bbWorkingDirectory, contractDataSource, merkleTrees);
|
|
80
78
|
}
|
|
81
79
|
async proveV2(avmCircuitInputs) {
|
|
82
80
|
// Then we prove.
|
package/dest/bb/execute.d.ts
CHANGED
|
@@ -48,10 +48,11 @@ type BBExecResult = {
|
|
|
48
48
|
* @param command - The command to execute
|
|
49
49
|
* @param args - The arguments to pass
|
|
50
50
|
* @param logger - A log function
|
|
51
|
+
* @param timeout - An optional timeout before killing the BB process
|
|
51
52
|
* @param resultParser - An optional handler for detecting success or failure
|
|
52
53
|
* @returns The completed partial witness outputted from the circuit
|
|
53
54
|
*/
|
|
54
|
-
export declare function executeBB(pathToBB: string, command: string, args: string[], logger: LogFn, resultParser?: (code: number) => boolean): Promise<BBExecResult>;
|
|
55
|
+
export declare function executeBB(pathToBB: string, command: string, args: string[], logger: LogFn, timeout?: number, resultParser?: (code: number) => boolean): Promise<BBExecResult>;
|
|
55
56
|
export declare function executeBbClientIvcProof(pathToBB: string, workingDirectory: string, bytecodeStackPath: string, witnessStackPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
56
57
|
/**
|
|
57
58
|
* Used for generating proofs of noir circuits.
|
|
@@ -68,15 +69,10 @@ export declare function generateProof(pathToBB: string, workingDirectory: string
|
|
|
68
69
|
/**
|
|
69
70
|
* Used for generating proofs of the tube circuit
|
|
70
71
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
71
|
-
*
|
|
72
|
-
* @param workingDirectory - A working directory for use by bb
|
|
73
|
-
* @param circuitName - An identifier for the circuit
|
|
74
|
-
* @param bytecode - The compiled circuit bytecode
|
|
75
|
-
* @param inputWitnessFile - The circuit input witness
|
|
76
|
-
* @param log - A logging function
|
|
72
|
+
*
|
|
77
73
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
78
74
|
*/
|
|
79
|
-
export declare function generateTubeProof(pathToBB: string, workingDirectory: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
75
|
+
export declare function generateTubeProof(pathToBB: string, workingDirectory: string, vkPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
80
76
|
/**
|
|
81
77
|
* Used for generating AVM proofs.
|
|
82
78
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
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;AAMlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,kBAAkB,mBAAmB,CAAC;AACnD,eAAO,MAAM,cAAc,UAAU,CAAC;AACtC,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AACxD,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAClE,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD,oBAAY,SAAS;IACnB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,eAAe,IAAA;CAChB;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,eAAe,CAAC;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC;IAC1B,MAAM,EA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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,CA4BhC;AAuDD,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,7 +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 { CLIENT_IVC_PROOF_FILE_NAME
|
|
6
|
+
import { CLIENT_IVC_PROOF_FILE_NAME } from '../prover/client_ivc_proof_utils.js';
|
|
7
7
|
export const VK_FILENAME = 'vk';
|
|
8
8
|
export const VK_FIELDS_FILENAME = 'vk_fields.json';
|
|
9
9
|
export const PROOF_FILENAME = 'proof';
|
|
@@ -24,9 +24,10 @@ export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
|
|
|
24
24
|
* @param command - The command to execute
|
|
25
25
|
* @param args - The arguments to pass
|
|
26
26
|
* @param logger - A log function
|
|
27
|
+
* @param timeout - An optional timeout before killing the BB process
|
|
27
28
|
* @param resultParser - An optional handler for detecting success or failure
|
|
28
29
|
* @returns The completed partial witness outputted from the circuit
|
|
29
|
-
*/ export function executeBB(pathToBB, command, args, logger, resultParser = (code)=>code === 0) {
|
|
30
|
+
*/ export function executeBB(pathToBB, command, args, logger, timeout, resultParser = (code)=>code === 0) {
|
|
30
31
|
return new Promise((resolve)=>{
|
|
31
32
|
// spawn the bb process
|
|
32
33
|
const { HARDWARE_CONCURRENCY: _, ...envWithoutConcurrency } = process.env;
|
|
@@ -38,6 +39,20 @@ export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
|
|
|
38
39
|
], {
|
|
39
40
|
env
|
|
40
41
|
});
|
|
42
|
+
let timeoutId;
|
|
43
|
+
if (timeout !== undefined) {
|
|
44
|
+
timeoutId = setTimeout(()=>{
|
|
45
|
+
logger(`BB execution timed out after ${timeout}ms, killing process`);
|
|
46
|
+
if (bb.pid) {
|
|
47
|
+
bb.kill('SIGKILL');
|
|
48
|
+
}
|
|
49
|
+
resolve({
|
|
50
|
+
status: 1,
|
|
51
|
+
exitCode: -1,
|
|
52
|
+
signal: 'TIMEOUT'
|
|
53
|
+
});
|
|
54
|
+
}, timeout);
|
|
55
|
+
}
|
|
41
56
|
bb.stdout.on('data', (data)=>{
|
|
42
57
|
const message = data.toString('utf-8').replace(/\n$/, '');
|
|
43
58
|
logger(message);
|
|
@@ -47,6 +62,9 @@ export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
|
|
|
47
62
|
logger(message);
|
|
48
63
|
});
|
|
49
64
|
bb.on('close', (exitCode, signal)=>{
|
|
65
|
+
if (timeoutId) {
|
|
66
|
+
clearTimeout(timeoutId);
|
|
67
|
+
}
|
|
50
68
|
if (resultParser(exitCode)) {
|
|
51
69
|
resolve({
|
|
52
70
|
status: 0,
|
|
@@ -67,7 +85,6 @@ export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
|
|
|
67
85
|
signal: undefined
|
|
68
86
|
}));
|
|
69
87
|
}
|
|
70
|
-
// TODO(#7369) comment this etc (really just take inspiration from this and rewrite it all O:))
|
|
71
88
|
export async function executeBbClientIvcProof(pathToBB, workingDirectory, bytecodeStackPath, witnessStackPath, log) {
|
|
72
89
|
// Check that the working directory exists
|
|
73
90
|
try {
|
|
@@ -245,14 +262,9 @@ function getArgs(flavor) {
|
|
|
245
262
|
/**
|
|
246
263
|
* Used for generating proofs of the tube circuit
|
|
247
264
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
248
|
-
*
|
|
249
|
-
* @param workingDirectory - A working directory for use by bb
|
|
250
|
-
* @param circuitName - An identifier for the circuit
|
|
251
|
-
* @param bytecode - The compiled circuit bytecode
|
|
252
|
-
* @param inputWitnessFile - The circuit input witness
|
|
253
|
-
* @param log - A logging function
|
|
265
|
+
*
|
|
254
266
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
255
|
-
*/ export async function generateTubeProof(pathToBB, workingDirectory, log) {
|
|
267
|
+
*/ export async function generateTubeProof(pathToBB, workingDirectory, vkPath, log) {
|
|
256
268
|
// Check that the working directory exists
|
|
257
269
|
try {
|
|
258
270
|
await fs.access(workingDirectory);
|
|
@@ -262,8 +274,7 @@ function getArgs(flavor) {
|
|
|
262
274
|
reason: `Working directory ${workingDirectory} does not exist`
|
|
263
275
|
};
|
|
264
276
|
}
|
|
265
|
-
//
|
|
266
|
-
const vkPath = join(workingDirectory, CLIENT_IVC_VK_FILE_NAME);
|
|
277
|
+
// Paths for the inputs
|
|
267
278
|
const proofPath = join(workingDirectory, CLIENT_IVC_PROOF_FILE_NAME);
|
|
268
279
|
// The proof is written to e.g. /workingDirectory/proof
|
|
269
280
|
const outputPath = workingDirectory;
|
|
@@ -276,7 +287,7 @@ function getArgs(flavor) {
|
|
|
276
287
|
};
|
|
277
288
|
}
|
|
278
289
|
try {
|
|
279
|
-
if (!await filePresent(
|
|
290
|
+
if (!await filePresent(proofPath)) {
|
|
280
291
|
return {
|
|
281
292
|
status: 1,
|
|
282
293
|
reason: `Client IVC input files not present in ${workingDirectory}`
|
|
@@ -285,6 +296,8 @@ function getArgs(flavor) {
|
|
|
285
296
|
const args = [
|
|
286
297
|
'-o',
|
|
287
298
|
outputPath,
|
|
299
|
+
'-k',
|
|
300
|
+
vkPath,
|
|
288
301
|
'-v'
|
|
289
302
|
];
|
|
290
303
|
const timer = new Timer();
|
|
@@ -538,7 +551,8 @@ export async function verifyAvmProofV2(pathToBB, workingDirectory, proofFullPath
|
|
|
538
551
|
];
|
|
539
552
|
const timer = new Timer();
|
|
540
553
|
const command = 'verify';
|
|
541
|
-
const
|
|
554
|
+
const timeout = 1000; // 1s verification timeout for invalid proofs
|
|
555
|
+
const result = await executeBB(pathToBB, command, args, log, timeout);
|
|
542
556
|
const duration = timer.ms();
|
|
543
557
|
if (result.status == 0) {
|
|
544
558
|
return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import { type Logger } from '@aztec/foundation/log';
|
|
4
|
-
import type { WitnessMap } from '@aztec/noir-types';
|
|
5
4
|
import type { SimulationProvider } from '@aztec/simulator/server';
|
|
5
|
+
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
6
6
|
import type { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
7
7
|
import type { BBConfig } from '../config.js';
|
|
8
8
|
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
@@ -17,8 +17,9 @@ export declare class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
|
17
17
|
protected log: Logger;
|
|
18
18
|
private constructor();
|
|
19
19
|
static new(config: BBConfig, simulationProvider: SimulationProvider, log?: Logger): Promise<BBNativePrivateKernelProver>;
|
|
20
|
+
private _createClientIvcProofFiles;
|
|
20
21
|
private _createClientIvcProof;
|
|
21
|
-
createClientIvcProof(
|
|
22
|
+
createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof>;
|
|
22
23
|
computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number>;
|
|
23
24
|
private runInDirectory;
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_native_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_native_private_kernel_prover.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"bb_native_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_native_private_kernel_prover.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAO3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,qBAAqB;IAElE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,WAAW;cACA,kBAAkB,EAAE,kBAAkB;cACtC,GAAG;IALxB,OAAO;WAUa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,GAAG,CAAC,EAAE,MAAM;YAehF,0BAA0B;YAW1B,qBAAqB;IA4Bb,oBAAoB,CAAC,cAAc,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAQrF,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxG,OAAO,CAAC,cAAc;CAavB"}
|
|
@@ -25,11 +25,22 @@ import { readFromOutputDirectory } from './client_ivc_proof_utils.js';
|
|
|
25
25
|
});
|
|
26
26
|
return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, simulationProvider, log);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
// TODO(#7371): This is duplicated.
|
|
29
|
+
// Longer term we won't use this hacked together msgpack format
|
|
30
|
+
// Leaving duplicated as this eventually bb will provide a serialization
|
|
31
|
+
// helper for passing to a generic msgpack RPC endpoint.
|
|
32
|
+
async _createClientIvcProofFiles(directory, executionSteps) {
|
|
33
|
+
const acirPath = path.join(directory, 'acir.msgpack');
|
|
34
|
+
const witnessPath = path.join(directory, 'witnesses.msgpack');
|
|
35
|
+
await fs.writeFile(acirPath, encode(executionSteps.map((map)=>map.bytecode)));
|
|
36
|
+
await fs.writeFile(witnessPath, encode(executionSteps.map((map)=>serializeWitness(map.witness))));
|
|
37
|
+
return {
|
|
38
|
+
acirPath,
|
|
39
|
+
witnessPath
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
async _createClientIvcProof(directory, executionSteps) {
|
|
43
|
+
await this._createClientIvcProofFiles(directory, executionSteps);
|
|
33
44
|
const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, path.join(directory, 'acir.msgpack'), path.join(directory, 'witnesses.msgpack'), this.log.info);
|
|
34
45
|
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
35
46
|
this.log.error(`Failed to generate client ivc proof`);
|
|
@@ -42,10 +53,10 @@ import { readFromOutputDirectory } from './client_ivc_proof_utils.js';
|
|
|
42
53
|
});
|
|
43
54
|
return proof;
|
|
44
55
|
}
|
|
45
|
-
async createClientIvcProof(
|
|
56
|
+
async createClientIvcProof(executionSteps) {
|
|
46
57
|
this.log.info(`Generating Client IVC proof`);
|
|
47
58
|
const operation = async (directory)=>{
|
|
48
|
-
return await this._createClientIvcProof(directory,
|
|
59
|
+
return await this._createClientIvcProof(directory, executionSteps);
|
|
49
60
|
};
|
|
50
61
|
return await this.runInDirectory(operation);
|
|
51
62
|
}
|
|
@@ -4,7 +4,7 @@ import type { ArtifactProvider, ClientProtocolArtifact } from '@aztec/noir-proto
|
|
|
4
4
|
import type { Abi, WitnessMap } from '@aztec/noir-types';
|
|
5
5
|
import type { SimulationProvider } from '@aztec/simulator/client';
|
|
6
6
|
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
7
|
-
import type { PrivateKernelCircuitPublicInputs, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelResetCircuitPrivateInputs, PrivateKernelSimulateOutput, PrivateKernelTailCircuitPrivateInputs, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
7
|
+
import type { PrivateExecutionStep, PrivateKernelCircuitPublicInputs, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelResetCircuitPrivateInputs, PrivateKernelSimulateOutput, PrivateKernelTailCircuitPrivateInputs, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
8
8
|
import type { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
9
9
|
export declare abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
10
10
|
protected artifactProvider: ArtifactProvider;
|
|
@@ -26,7 +26,7 @@ export declare abstract class BBPrivateKernelProver implements PrivateKernelProv
|
|
|
26
26
|
toBuffer: () => Buffer;
|
|
27
27
|
}, O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs>(inputs: I, circuitType: ClientProtocolArtifact, convertInputs: (inputs: I, abi: Abi) => WitnessMap, convertOutputs: (outputs: WitnessMap, abi: Abi) => O): Promise<PrivateKernelSimulateOutput<O>>;
|
|
28
28
|
makeEmptyKernelSimulateOutput<PublicInputsType extends PrivateKernelTailCircuitPublicInputs | PrivateKernelCircuitPublicInputs>(publicInputs: PublicInputsType, circuitType: ClientProtocolArtifact): Promise<PrivateKernelSimulateOutput<PublicInputsType>>;
|
|
29
|
-
createClientIvcProof(
|
|
29
|
+
createClientIvcProof(_executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof>;
|
|
30
30
|
computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=bb_private_kernel_prover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_private_kernel_prover.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"bb_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_private_kernel_prover.ts"],"names":[],"mappings":";;AAiBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAC1G,OAAO,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gCAAgC,EAChC,qCAAqC,EACrC,sCAAsC,EACtC,sCAAsC,EACtC,2BAA2B,EAC3B,qCAAqC,EACrC,oCAAoC,EACrC,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAK3D,8BAAsB,qBAAsB,YAAW,mBAAmB;IAEtE,SAAS,CAAC,gBAAgB,EAAE,gBAAgB;IAC5C,SAAS,CAAC,kBAAkB,EAAE,kBAAkB;IAChD,SAAS,CAAC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6B7B,qBAAqB,CAChC,CAAC,SAAS;QAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;KAAE,EACpC,CAAC,SAAS,gCAAgC,GAAG,oCAAoC,EAEjF,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,sBAAsB,EACnC,aAAa,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,UAAU,EAClD,cAAc,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,GACnD,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC;IAmC7B,6BAA6B,CACxC,gBAAgB,SAAS,oCAAoC,GAAG,gCAAgC,EAChG,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,sBAAsB;IAU9D,oBAAoB,CAAC,eAAe,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAItF,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5F"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { Timer } from '@aztec/foundation/timer';
|
|
3
|
-
import { convertPrivateKernelInitInputsToWitnessMapWithAbi, convertPrivateKernelInitOutputsFromWitnessMapWithAbi, convertPrivateKernelInnerInputsToWitnessMapWithAbi, convertPrivateKernelInnerOutputsFromWitnessMapWithAbi, convertPrivateKernelResetInputsToWitnessMapWithAbi, convertPrivateKernelResetOutputsFromWitnessMapWithAbi, convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi, convertPrivateKernelTailInputsToWitnessMapWithAbi, convertPrivateKernelTailOutputsFromWitnessMapWithAbi, convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi, getPrivateKernelResetArtifactName, updateResetCircuitSampleInputs } from '@aztec/noir-protocol-circuits-types/client';
|
|
3
|
+
import { convertPrivateKernelInitInputsToWitnessMapWithAbi, convertPrivateKernelInitOutputsFromWitnessMapWithAbi, convertPrivateKernelInnerInputsToWitnessMapWithAbi, convertPrivateKernelInnerOutputsFromWitnessMapWithAbi, convertPrivateKernelResetInputsToWitnessMapWithAbi, convertPrivateKernelResetOutputsFromWitnessMapWithAbi, convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi, convertPrivateKernelTailInputsToWitnessMapWithAbi, convertPrivateKernelTailOutputsFromWitnessMapWithAbi, convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi, foreignCallHandler, getPrivateKernelResetArtifactName, updateResetCircuitSampleInputs } from '@aztec/noir-protocol-circuits-types/client';
|
|
4
4
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
5
5
|
export class BBPrivateKernelProver {
|
|
6
6
|
artifactProvider;
|
|
@@ -50,7 +50,7 @@ export class BBPrivateKernelProver {
|
|
|
50
50
|
const compiledCircuit = await this.artifactProvider.getSimulatedClientCircuitArtifactByName(circuitType);
|
|
51
51
|
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
52
52
|
const timer = new Timer();
|
|
53
|
-
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit).catch((err)=>{
|
|
53
|
+
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit, foreignCallHandler).catch((err)=>{
|
|
54
54
|
this.log.debug(`Failed to simulate ${circuitType}`, {
|
|
55
55
|
circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
|
|
56
56
|
error: err
|
|
@@ -72,7 +72,7 @@ export class BBPrivateKernelProver {
|
|
|
72
72
|
const compiledCircuit = await this.artifactProvider.getClientCircuitArtifactByName(circuitType);
|
|
73
73
|
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
74
74
|
const timer = new Timer();
|
|
75
|
-
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit);
|
|
75
|
+
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit, foreignCallHandler);
|
|
76
76
|
const output = convertOutputs(outputWitness, compiledCircuit.abi);
|
|
77
77
|
this.log.debug(`Generated witness for ${circuitType}`, {
|
|
78
78
|
eventName: 'circuit-witness-generation',
|
|
@@ -100,7 +100,7 @@ export class BBPrivateKernelProver {
|
|
|
100
100
|
};
|
|
101
101
|
return kernelProofOutput;
|
|
102
102
|
}
|
|
103
|
-
createClientIvcProof(
|
|
103
|
+
createClientIvcProof(_executionSteps) {
|
|
104
104
|
throw new Error('Not implemented');
|
|
105
105
|
}
|
|
106
106
|
computeGateCountForCircuit(_bytecode, _circuitName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,0BAA0B,EAE1B,6BAA6B,EAC7B,yCAAyC,EACzC,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAM1B,OAAO,
|
|
1
|
+
{"version":3,"file":"bb_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,0BAA0B,EAE1B,6BAA6B,EAC7B,yCAAyC,EACzC,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EACL,KAAK,sBAAsB,EAsB5B,MAAM,4CAA4C,CAAC;AAIpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,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,KAAK,EACV,6BAA6B,EAC7B,sB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EAAE,KAAK,EAAE,eAAe,EAAE,mBAAmB;IAMjE,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK;YAMxF,qBAAqB;IAyBnC;;;;OAIG;IACH,OAAO,CAAC,gCAAgC;YAQ1B,iBAAiB;YA8BjB,oBAAoB;IAelC,OAAO,CAAC,cAAc;CAYvB"}
|
package/dest/prover/bb_prover.js
CHANGED
|
@@ -10,7 +10,7 @@ import { runInDirectory } from '@aztec/foundation/fs';
|
|
|
10
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
11
11
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
12
12
|
import { Timer } from '@aztec/foundation/timer';
|
|
13
|
-
import {
|
|
13
|
+
import { convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap, convertBlockMergeRollupInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap, convertBlockRootRollupInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap, convertEmptyBlockRootRollupInputsToWitnessMap, convertEmptyBlockRootRollupOutputsFromWitnessMap, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap, convertPrivateBaseRollupInputsToWitnessMap, convertPrivateBaseRollupOutputsFromWitnessMap, convertPublicBaseRollupInputsToWitnessMap, convertPublicBaseRollupOutputsFromWitnessMap, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertSingleTxBlockRootRollupInputsToWitnessMap, convertSingleTxBlockRootRollupOutputsFromWitnessMap, getServerCircuitArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
14
14
|
import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
15
15
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
16
16
|
import { ProvingError } from '@aztec/stdlib/errors';
|
|
@@ -26,6 +26,7 @@ import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
|
26
26
|
import { ProverInstrumentation } from '../instrumentation.js';
|
|
27
27
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
28
28
|
import { extractAvmVkData, extractVkData } from '../verification_key/verification_key_data.js';
|
|
29
|
+
import { PRIVATE_TAIL_CIVC_VK, PUBLIC_TAIL_CIVC_VK } from '../verifier/bb_verifier.js';
|
|
29
30
|
import { writeToOutputDirectory } from './client_ivc_proof_utils.js';
|
|
30
31
|
const logger = createLogger('bb-prover');
|
|
31
32
|
// All `ServerCircuitArtifact` are recursive.
|
|
@@ -169,11 +170,12 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
169
170
|
// Generate the partial witness using the ACVM
|
|
170
171
|
// A further temp directory will be created beneath ours and then cleaned up after the partial witness has been copied to our specified location
|
|
171
172
|
const simulator = new NativeACVMSimulator(this.config.acvmWorkingDirectory, this.config.acvmBinaryPath, outputWitnessFile);
|
|
172
|
-
const artifact =
|
|
173
|
+
const artifact = getServerCircuitArtifact(circuitType);
|
|
173
174
|
logger.debug(`Generating witness data for ${circuitType}`);
|
|
174
175
|
const inputWitness = convertInput(input);
|
|
175
176
|
const timer = new Timer();
|
|
176
|
-
const
|
|
177
|
+
const foreignCallHandler = undefined; // We don't handle foreign calls in the native ACVM simulator
|
|
178
|
+
const outputWitness = await simulator.executeProtocolCircuit(inputWitness, artifact, foreignCallHandler);
|
|
177
179
|
const output = convertOutput(outputWitness);
|
|
178
180
|
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
179
181
|
this.instrumentation.recordDuration('witGenDuration', circuitName, timer);
|
|
@@ -242,7 +244,7 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
242
244
|
const hasher = crypto.createHash('sha256');
|
|
243
245
|
hasher.update(input.toBuffer());
|
|
244
246
|
await writeToOutputDirectory(input.clientIVCData, bbWorkingDirectory);
|
|
245
|
-
const provingResult = await generateTubeProof(this.config.bbBinaryPath, bbWorkingDirectory, logger.verbose);
|
|
247
|
+
const provingResult = await generateTubeProof(this.config.bbBinaryPath, bbWorkingDirectory, input.usePublicTailVk ? PUBLIC_TAIL_CIVC_VK : PRIVATE_TAIL_CIVC_VK, logger.verbose);
|
|
246
248
|
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
247
249
|
logger.error(`Failed to generate proof for tube circuit: ${provingResult.reason}`);
|
|
248
250
|
throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
|
|
@@ -387,7 +389,7 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
387
389
|
numPublicInputs -= IPA_CLAIM_LENGTH;
|
|
388
390
|
}
|
|
389
391
|
assert(json.length - numPublicInputs == proofLength, 'Proof length mismatch');
|
|
390
|
-
const fieldsWithoutPublicInputs = json.slice(
|
|
392
|
+
const fieldsWithoutPublicInputs = json.slice(numPublicInputs).map(Fr.fromHexString);
|
|
391
393
|
logger.debug(`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProof.length}`);
|
|
392
394
|
return new RecursiveProof(fieldsWithoutPublicInputs, new Proof(binaryProof, numPublicInputs), true, proofLength);
|
|
393
395
|
}
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
2
|
-
export declare const CLIENT_IVC_VK_FILE_NAME = "vk";
|
|
3
2
|
export declare const CLIENT_IVC_PROOF_FILE_NAME = "proof";
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @param directory the directory
|
|
4
|
+
* Create a ClientIvcProof proof file.
|
|
5
|
+
*
|
|
6
|
+
* @param directory the directory to read the proof from.
|
|
8
7
|
* @returns the encapsulated client ivc proof
|
|
9
8
|
*/
|
|
10
9
|
export declare function readFromOutputDirectory(directory: string): Promise<ClientIvcProof>;
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
13
|
-
* Serialize a ClientIvcProof to the files expected by prove_tube
|
|
11
|
+
* Serialize a ClientIvcProof to a proof file.
|
|
14
12
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* await privateTx.clientIvcProof!.writeToOutputDirectory(bbWorkingDirectory);
|
|
18
|
-
* const result = await generateTubeProof(bbPath, dir, logger.info)
|
|
19
|
-
* expect(result.status).toBe(BB_RESULT.SUCCESS)
|
|
20
|
-
* });
|
|
21
|
-
* @param proof the ClientIvcProof from readFromOutputDirectory
|
|
22
|
-
* @param directory the directory of results
|
|
13
|
+
* @param proof the ClientIvcProof from object
|
|
14
|
+
* @param directory the directory to write in
|
|
23
15
|
*/
|
|
24
16
|
export declare function writeToOutputDirectory(clientIvcProof: ClientIvcProof, directory: string): Promise<void>;
|
|
25
17
|
//# sourceMappingURL=client_ivc_proof_utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client_ivc_proof_utils.d.ts","sourceRoot":"","sources":["../../src/prover/client_ivc_proof_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"client_ivc_proof_utils.d.ts","sourceRoot":"","sources":["../../src/prover/client_ivc_proof_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,eAAO,MAAM,0BAA0B,UAAU,CAAC;AAElD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAAC,SAAS,EAAE,MAAM,2BAG9D;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAG7F"}
|
|
@@ -1,43 +1,22 @@
|
|
|
1
1
|
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
2
2
|
import { promises as fs } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
export const CLIENT_IVC_VK_FILE_NAME = 'vk';
|
|
5
4
|
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param directory the directory
|
|
6
|
+
* Create a ClientIvcProof proof file.
|
|
7
|
+
*
|
|
8
|
+
* @param directory the directory to read the proof from.
|
|
10
9
|
* @returns the encapsulated client ivc proof
|
|
11
10
|
*/ export async function readFromOutputDirectory(directory) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
CLIENT_IVC_PROOF_FILE_NAME
|
|
15
|
-
].map((fileName)=>fs.readFile(join(directory, fileName))));
|
|
16
|
-
return new ClientIvcProof(clientIvcProofBuffer, clientIvcVkBuffer);
|
|
11
|
+
const clientIvcProofBuffer = await fs.readFile(join(directory, CLIENT_IVC_PROOF_FILE_NAME));
|
|
12
|
+
return new ClientIvcProof(clientIvcProofBuffer);
|
|
17
13
|
}
|
|
18
14
|
/**
|
|
19
|
-
*
|
|
20
|
-
* Serialize a ClientIvcProof to the files expected by prove_tube
|
|
15
|
+
* Serialize a ClientIvcProof to a proof file.
|
|
21
16
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* await privateTx.clientIvcProof!.writeToOutputDirectory(bbWorkingDirectory);
|
|
25
|
-
* const result = await generateTubeProof(bbPath, dir, logger.info)
|
|
26
|
-
* expect(result.status).toBe(BB_RESULT.SUCCESS)
|
|
27
|
-
* });
|
|
28
|
-
* @param proof the ClientIvcProof from readFromOutputDirectory
|
|
29
|
-
* @param directory the directory of results
|
|
17
|
+
* @param proof the ClientIvcProof from object
|
|
18
|
+
* @param directory the directory to write in
|
|
30
19
|
*/ export async function writeToOutputDirectory(clientIvcProof, directory) {
|
|
31
|
-
const { clientIvcProofBuffer
|
|
32
|
-
|
|
33
|
-
[
|
|
34
|
-
CLIENT_IVC_PROOF_FILE_NAME,
|
|
35
|
-
clientIvcProofBuffer
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
CLIENT_IVC_VK_FILE_NAME,
|
|
39
|
-
clientIvcVkBuffer
|
|
40
|
-
]
|
|
41
|
-
];
|
|
42
|
-
await Promise.all(fileData.map(([fileName, buffer])=>fs.writeFile(join(directory, fileName), buffer)));
|
|
20
|
+
const { clientIvcProofBuffer } = clientIvcProof;
|
|
21
|
+
await fs.writeFile(join(directory, CLIENT_IVC_PROOF_FILE_NAME), clientIvcProofBuffer);
|
|
43
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_circuit_prover.d.ts","sourceRoot":"","sources":["../../src/test/test_circuit_prover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAE1B,6BAA6B,EAC7B,yCAAyC,EACzC,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EACL,KAAK,sBAAsB,
|
|
1
|
+
{"version":3,"file":"test_circuit_prover.d.ts","sourceRoot":"","sources":["../../src/test/test_circuit_prover.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAE1B,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,E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'@aztec/foundation/sleep';
|
|
10
10
|
import { Timer } from '@aztec/foundation/timer';
|
|
11
|
-
import {
|
|
11
|
+
import { convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap, convertBlockMergeRollupInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap, convertEmptyBlockRootRollupInputsToWitnessMap, convertEmptyBlockRootRollupOutputsFromWitnessMap, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertSimulatedBlockRootRollupInputsToWitnessMap, convertSimulatedBlockRootRollupOutputsFromWitnessMap, convertSimulatedPrivateBaseRollupInputsToWitnessMap, convertSimulatedPrivateBaseRollupOutputsFromWitnessMap, convertSimulatedPublicBaseRollupInputsToWitnessMap, convertSimulatedPublicBaseRollupOutputsFromWitnessMap, convertSimulatedSingleTxBlockRootRollupInputsToWitnessMap, convertSimulatedSingleTxBlockRootRollupOutputsFromWitnessMap, foreignCallHandler, getSimulatedServerCircuitArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
12
12
|
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
13
13
|
import { WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator/server';
|
|
14
14
|
import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
@@ -127,16 +127,18 @@ import { PROOF_DELAY_MS, WITGEN_DELAY_MS } from './delay_values.js';
|
|
|
127
127
|
const timer = new Timer();
|
|
128
128
|
const witnessMap = convertInput(input);
|
|
129
129
|
const circuitName = mapProtocolArtifactNameToCircuitName(artifactName);
|
|
130
|
-
let
|
|
130
|
+
let witness;
|
|
131
131
|
if ([
|
|
132
132
|
'BlockRootRollupArtifact',
|
|
133
133
|
'SingleTxBlockRootRollupArtifact'
|
|
134
|
-
].includes(artifactName)) {
|
|
135
|
-
// TODO(#10323):
|
|
136
|
-
//
|
|
137
|
-
|
|
134
|
+
].includes(artifactName) || this.simulationProvider == undefined) {
|
|
135
|
+
// TODO(#10323): Native ACVM simulator does not support foreign call handler so we use the wasm simulator
|
|
136
|
+
// when simulating block root rollup and single tx block root rollup circuits or when the native ACVM simulator
|
|
137
|
+
// is not provided.
|
|
138
|
+
witness = await this.wasmSimulator.executeProtocolCircuit(witnessMap, getSimulatedServerCircuitArtifact(artifactName), foreignCallHandler);
|
|
139
|
+
} else {
|
|
140
|
+
witness = await this.simulationProvider.executeProtocolCircuit(witnessMap, getSimulatedServerCircuitArtifact(artifactName), undefined);
|
|
138
141
|
}
|
|
139
|
-
const witness = await simulationProvider.executeProtocolCircuit(witnessMap, SimulatedServerCircuitArtifacts[artifactName]);
|
|
140
142
|
const result = convertOutput(witness);
|
|
141
143
|
this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
|
|
142
144
|
emitCircuitSimulationStats(circuitName, timer.ms(), input.toBuffer().length, result.toBuffer().length, this.logger);
|