@aztec/bb-prover 0.81.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/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 +6 -4
- 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 +6 -1
- 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/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 +12 -4
- 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 +8 -1
- package/src/wasm/bb_wasm_private_kernel_prover.ts +7 -6
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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AmBhC;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,GAAG;gBAFH,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,E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A;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,sBAAsB,EACtB,iCAAiC,EACjC,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EAC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E,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);
|
|
@@ -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,sB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AAC,iCAAiC,EAAE,OAAO,yCAAyC,CAAC,CACnH;IAYD;;;;OAIG;IAEI,wBAAwB,CAC7B,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CACR,6BAA6B,CAAC,iCAAiC,EAAE,OAAO,yCAAyC,CAAC,CACnH;IAYD;;;;OAIG;IAEI,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,6BAA6B,CAAC,sBAAsB,CAAC,CAAC;IAY3G,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,OAAO,0BAA0B,CAAC,CAAC;YAYpG,UAAU;IAejB,WAAW,CAAC,EAAE,EAAE,sBAAsB,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;YAI1D,QAAQ;CA0CvB"}
|
|
@@ -8,7 +8,7 @@ import { AVM_PROOF_LENGTH_IN_FIELDS, AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, NEST
|
|
|
8
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
9
|
import { sleep } from '@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);
|
|
@@ -5,6 +5,8 @@ import type { Proof } from '@aztec/stdlib/proofs';
|
|
|
5
5
|
import { Tx } from '@aztec/stdlib/tx';
|
|
6
6
|
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
7
7
|
import type { BBConfig } from '../config.js';
|
|
8
|
+
export declare const PRIVATE_TAIL_CIVC_VK: string;
|
|
9
|
+
export declare const PUBLIC_TAIL_CIVC_VK: string;
|
|
8
10
|
export declare class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
9
11
|
private config;
|
|
10
12
|
private logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/bb_verifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAA0B,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAChH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"bb_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/bb_verifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAA0B,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAChH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAO7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAQ7C,eAAO,MAAM,oBAAoB,QAA0D,CAAC;AAC5F,eAAO,MAAM,mBAAmB,QAAyD,CAAC;AAE1F,qBAAa,iBAAkB,YAAW,6BAA6B;IACjD,OAAO,CAAC,MAAM;IAAY,OAAO,CAAC,MAAM;IAA5D,OAAO;WAEa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAqC;IAK9E,sBAAsB,CAAC,WAAW,EAAE,sBAAsB,GAAG,mBAAmB;IAQ1E,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK;IAkCnE,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CA4CnD"}
|
|
@@ -4,10 +4,15 @@ import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks
|
|
|
4
4
|
import { Tx } from '@aztec/stdlib/tx';
|
|
5
5
|
import { promises as fs } from 'fs';
|
|
6
6
|
import * as path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
7
8
|
import { BB_RESULT, PROOF_FILENAME, VK_FILENAME, verifyClientIvcProof, verifyProof } from '../bb/execute.js';
|
|
8
9
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
9
10
|
import { writeToOutputDirectory } from '../prover/client_ivc_proof_utils.js';
|
|
10
11
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
12
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
// Built by yarn generate
|
|
14
|
+
export const PRIVATE_TAIL_CIVC_VK = path.join(__dirname, '../../artifacts/private-civc-vk');
|
|
15
|
+
export const PUBLIC_TAIL_CIVC_VK = path.join(__dirname, '../../artifacts/public-civc-vk');
|
|
11
16
|
export class BBCircuitVerifier {
|
|
12
17
|
config;
|
|
13
18
|
logger;
|
|
@@ -64,7 +69,7 @@ export class BBCircuitVerifier {
|
|
|
64
69
|
this.logger.debug(`${circuit} BB out - ${message}`);
|
|
65
70
|
};
|
|
66
71
|
await writeToOutputDirectory(tx.clientIvcProof, bbWorkingDirectory);
|
|
67
|
-
const result = await verifyClientIvcProof(this.config.bbBinaryPath, bbWorkingDirectory.concat('/proof'),
|
|
72
|
+
const result = await verifyClientIvcProof(this.config.bbBinaryPath, bbWorkingDirectory.concat('/proof'), tx.data.forPublic ? PUBLIC_TAIL_CIVC_VK : PRIVATE_TAIL_CIVC_VK, logFunction);
|
|
68
73
|
if (result.status === BB_RESULT.FAILURE) {
|
|
69
74
|
const errorMessage = `Failed to verify ${circuit} proof!`;
|
|
70
75
|
throw new Error(errorMessage);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
3
|
import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
|
|
4
|
-
import type { WitnessMap } from '@aztec/noir-types';
|
|
5
4
|
import type { SimulationProvider } from '@aztec/simulator/client';
|
|
5
|
+
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
6
6
|
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
7
7
|
import { BBPrivateKernelProver } from '../prover/bb_private_kernel_prover.js';
|
|
8
8
|
export declare abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
@@ -11,7 +11,7 @@ export declare abstract class BBWASMPrivateKernelProver extends BBPrivateKernelP
|
|
|
11
11
|
private threads;
|
|
12
12
|
protected log: import("@aztec/foundation/log").Logger;
|
|
13
13
|
constructor(artifactProvider: ArtifactProvider, simulationProvider: SimulationProvider, threads?: number, log?: import("@aztec/foundation/log").Logger);
|
|
14
|
-
createClientIvcProof(
|
|
14
|
+
createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof>;
|
|
15
15
|
computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=bb_wasm_private_kernel_prover.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_wasm_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/wasm/bb_wasm_private_kernel_prover.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"bb_wasm_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/wasm/bb_wasm_private_kernel_prover.ts"],"names":[],"mappings":";;AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,8BAAsB,yBAA0B,SAAQ,qBAAqB;cAEtD,gBAAgB,EAAE,gBAAgB;cAClC,kBAAkB,EAAE,kBAAkB;IACzD,OAAO,CAAC,OAAO;cACI,GAAG;gBAHH,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,EACjD,OAAO,GAAE,MAAU,EACR,GAAG,yCAAiC;IAKnC,oBAAoB,CAAC,cAAc,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAoBrF,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAY3G"}
|
|
@@ -13,23 +13,24 @@ export class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
|
13
13
|
constructor(artifactProvider, simulationProvider, threads = 1, log = createLogger('bb-prover:wasm')){
|
|
14
14
|
super(artifactProvider, simulationProvider, log), this.artifactProvider = artifactProvider, this.simulationProvider = simulationProvider, this.threads = threads, this.log = log;
|
|
15
15
|
}
|
|
16
|
-
async createClientIvcProof(
|
|
16
|
+
async createClientIvcProof(executionSteps) {
|
|
17
17
|
const timer = new Timer();
|
|
18
18
|
this.log.info(`Generating ClientIVC proof...`);
|
|
19
|
-
const backend = new AztecClientBackend(
|
|
19
|
+
const backend = new AztecClientBackend(executionSteps.map((step)=>ungzip(step.bytecode)), {
|
|
20
20
|
threads: this.threads,
|
|
21
21
|
logger: this.log.verbose,
|
|
22
22
|
wasmPath: process.env.BB_WASM_PATH
|
|
23
23
|
});
|
|
24
|
-
|
|
24
|
+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1297): the vk is not provided to the network anymore.
|
|
25
|
+
// Move this sanity check inside the wasm code and remove the vk from the return value.
|
|
26
|
+
const [proof, _vk] = await backend.prove(executionSteps.map((step)=>ungzip(serializeWitness(step.witness))));
|
|
25
27
|
await backend.destroy();
|
|
26
28
|
this.log.info(`Generated ClientIVC proof`, {
|
|
27
29
|
eventName: 'client-ivc-proof-generation',
|
|
28
30
|
duration: timer.ms(),
|
|
29
|
-
proofSize: proof.length
|
|
30
|
-
vkSize: vk.length
|
|
31
|
+
proofSize: proof.length
|
|
31
32
|
});
|
|
32
|
-
return new ClientIvcProof(Buffer.from(proof)
|
|
33
|
+
return new ClientIvcProof(Buffer.from(proof));
|
|
33
34
|
}
|
|
34
35
|
async computeGateCountForCircuit(_bytecode, _circuitName) {
|
|
35
36
|
const backend = new AztecClientBackend([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bb-prover",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
31
31
|
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
32
32
|
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
33
|
+
"generate": "scripts/generate_civc_vks.sh",
|
|
33
34
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
34
35
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
35
36
|
},
|
|
@@ -67,16 +68,16 @@
|
|
|
67
68
|
]
|
|
68
69
|
},
|
|
69
70
|
"dependencies": {
|
|
70
|
-
"@aztec/bb.js": "0.
|
|
71
|
-
"@aztec/constants": "0.
|
|
72
|
-
"@aztec/foundation": "0.
|
|
73
|
-
"@aztec/noir-noirc_abi": "0.
|
|
74
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
75
|
-
"@aztec/noir-types": "0.
|
|
76
|
-
"@aztec/simulator": "0.
|
|
77
|
-
"@aztec/stdlib": "0.
|
|
78
|
-
"@aztec/telemetry-client": "0.
|
|
79
|
-
"@aztec/world-state": "0.
|
|
71
|
+
"@aztec/bb.js": "0.82.0",
|
|
72
|
+
"@aztec/constants": "0.82.0",
|
|
73
|
+
"@aztec/foundation": "0.82.0",
|
|
74
|
+
"@aztec/noir-noirc_abi": "0.82.0",
|
|
75
|
+
"@aztec/noir-protocol-circuits-types": "0.82.0",
|
|
76
|
+
"@aztec/noir-types": "0.82.0",
|
|
77
|
+
"@aztec/simulator": "0.82.0",
|
|
78
|
+
"@aztec/stdlib": "0.82.0",
|
|
79
|
+
"@aztec/telemetry-client": "0.82.0",
|
|
80
|
+
"@aztec/world-state": "0.82.0",
|
|
80
81
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
81
82
|
"commander": "^12.1.0",
|
|
82
83
|
"pako": "^2.1.0",
|
|
@@ -84,10 +85,10 @@
|
|
|
84
85
|
"tslib": "^2.4.0"
|
|
85
86
|
},
|
|
86
87
|
"devDependencies": {
|
|
87
|
-
"@aztec/ethereum": "0.
|
|
88
|
-
"@aztec/kv-store": "0.
|
|
89
|
-
"@aztec/noir-contracts.js": "0.
|
|
90
|
-
"@aztec/protocol-contracts": "0.
|
|
88
|
+
"@aztec/ethereum": "0.82.0",
|
|
89
|
+
"@aztec/kv-store": "0.82.0",
|
|
90
|
+
"@aztec/noir-contracts.js": "0.82.0",
|
|
91
|
+
"@aztec/protocol-contracts": "0.82.0",
|
|
91
92
|
"@jest/globals": "^29.5.0",
|
|
92
93
|
"@types/jest": "^29.5.0",
|
|
93
94
|
"@types/memdown": "^3.0.0",
|
package/src/bb/execute.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { promises as fs } from 'fs';
|
|
|
8
8
|
import { basename, dirname, join } from 'path';
|
|
9
9
|
|
|
10
10
|
import type { UltraHonkFlavor } from '../honk.js';
|
|
11
|
-
import { CLIENT_IVC_PROOF_FILE_NAME
|
|
11
|
+
import { CLIENT_IVC_PROOF_FILE_NAME } from '../prover/client_ivc_proof_utils.js';
|
|
12
12
|
|
|
13
13
|
export const VK_FILENAME = 'vk';
|
|
14
14
|
export const VK_FIELDS_FILENAME = 'vk_fields.json';
|
|
@@ -62,6 +62,7 @@ type BBExecResult = {
|
|
|
62
62
|
* @param command - The command to execute
|
|
63
63
|
* @param args - The arguments to pass
|
|
64
64
|
* @param logger - A log function
|
|
65
|
+
* @param timeout - An optional timeout before killing the BB process
|
|
65
66
|
* @param resultParser - An optional handler for detecting success or failure
|
|
66
67
|
* @returns The completed partial witness outputted from the circuit
|
|
67
68
|
*/
|
|
@@ -70,6 +71,7 @@ export function executeBB(
|
|
|
70
71
|
command: string,
|
|
71
72
|
args: string[],
|
|
72
73
|
logger: LogFn,
|
|
74
|
+
timeout?: number,
|
|
73
75
|
resultParser = (code: number) => code === 0,
|
|
74
76
|
): Promise<BBExecResult> {
|
|
75
77
|
return new Promise<BBExecResult>(resolve => {
|
|
@@ -80,6 +82,18 @@ export function executeBB(
|
|
|
80
82
|
const bb = proc.spawn(pathToBB, [command, ...args], {
|
|
81
83
|
env,
|
|
82
84
|
});
|
|
85
|
+
|
|
86
|
+
let timeoutId: NodeJS.Timeout | undefined;
|
|
87
|
+
if (timeout !== undefined) {
|
|
88
|
+
timeoutId = setTimeout(() => {
|
|
89
|
+
logger(`BB execution timed out after ${timeout}ms, killing process`);
|
|
90
|
+
if (bb.pid) {
|
|
91
|
+
bb.kill('SIGKILL');
|
|
92
|
+
}
|
|
93
|
+
resolve({ status: BB_RESULT.FAILURE, exitCode: -1, signal: 'TIMEOUT' });
|
|
94
|
+
}, timeout);
|
|
95
|
+
}
|
|
96
|
+
|
|
83
97
|
bb.stdout.on('data', data => {
|
|
84
98
|
const message = data.toString('utf-8').replace(/\n$/, '');
|
|
85
99
|
logger(message);
|
|
@@ -89,6 +103,9 @@ export function executeBB(
|
|
|
89
103
|
logger(message);
|
|
90
104
|
});
|
|
91
105
|
bb.on('close', (exitCode: number, signal?: string) => {
|
|
106
|
+
if (timeoutId) {
|
|
107
|
+
clearTimeout(timeoutId);
|
|
108
|
+
}
|
|
92
109
|
if (resultParser(exitCode)) {
|
|
93
110
|
resolve({ status: BB_RESULT.SUCCESS, exitCode, signal });
|
|
94
111
|
} else {
|
|
@@ -98,7 +115,6 @@ export function executeBB(
|
|
|
98
115
|
}).catch(_ => ({ status: BB_RESULT.FAILURE, exitCode: -1, signal: undefined }));
|
|
99
116
|
}
|
|
100
117
|
|
|
101
|
-
// TODO(#7369) comment this etc (really just take inspiration from this and rewrite it all O:))
|
|
102
118
|
export async function executeBbClientIvcProof(
|
|
103
119
|
pathToBB: string,
|
|
104
120
|
workingDirectory: string,
|
|
@@ -275,17 +291,13 @@ export async function generateProof(
|
|
|
275
291
|
/**
|
|
276
292
|
* Used for generating proofs of the tube circuit
|
|
277
293
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
278
|
-
*
|
|
279
|
-
* @param workingDirectory - A working directory for use by bb
|
|
280
|
-
* @param circuitName - An identifier for the circuit
|
|
281
|
-
* @param bytecode - The compiled circuit bytecode
|
|
282
|
-
* @param inputWitnessFile - The circuit input witness
|
|
283
|
-
* @param log - A logging function
|
|
294
|
+
*
|
|
284
295
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
285
296
|
*/
|
|
286
297
|
export async function generateTubeProof(
|
|
287
298
|
pathToBB: string,
|
|
288
299
|
workingDirectory: string,
|
|
300
|
+
vkPath: string,
|
|
289
301
|
log: LogFn,
|
|
290
302
|
): Promise<BBFailure | BBSuccess> {
|
|
291
303
|
// Check that the working directory exists
|
|
@@ -295,8 +307,7 @@ export async function generateTubeProof(
|
|
|
295
307
|
return { status: BB_RESULT.FAILURE, reason: `Working directory ${workingDirectory} does not exist` };
|
|
296
308
|
}
|
|
297
309
|
|
|
298
|
-
//
|
|
299
|
-
const vkPath = join(workingDirectory, CLIENT_IVC_VK_FILE_NAME);
|
|
310
|
+
// Paths for the inputs
|
|
300
311
|
const proofPath = join(workingDirectory, CLIENT_IVC_PROOF_FILE_NAME);
|
|
301
312
|
|
|
302
313
|
// The proof is written to e.g. /workingDirectory/proof
|
|
@@ -313,10 +324,10 @@ export async function generateTubeProof(
|
|
|
313
324
|
}
|
|
314
325
|
|
|
315
326
|
try {
|
|
316
|
-
if (!(await filePresent(
|
|
327
|
+
if (!(await filePresent(proofPath))) {
|
|
317
328
|
return { status: BB_RESULT.FAILURE, reason: `Client IVC input files not present in ${workingDirectory}` };
|
|
318
329
|
}
|
|
319
|
-
const args = ['-o', outputPath, '-v'];
|
|
330
|
+
const args = ['-o', outputPath, '-k', vkPath, '-v'];
|
|
320
331
|
|
|
321
332
|
const timer = new Timer();
|
|
322
333
|
const logFunction = (message: string) => {
|
|
@@ -610,7 +621,8 @@ export async function verifyClientIvcProof(
|
|
|
610
621
|
const args = ['--scheme', 'client_ivc', '-p', proofPath, '-k', keyPath];
|
|
611
622
|
const timer = new Timer();
|
|
612
623
|
const command = 'verify';
|
|
613
|
-
const
|
|
624
|
+
const timeout = 1000; // 1s verification timeout for invalid proofs
|
|
625
|
+
const result = await executeBB(pathToBB, command, args, log, timeout);
|
|
614
626
|
const duration = timer.ms();
|
|
615
627
|
if (result.status == BB_RESULT.SUCCESS) {
|
|
616
628
|
return { status: BB_RESULT.SUCCESS, durationMs: duration };
|
|
@@ -2,8 +2,8 @@ import { runInDirectory } from '@aztec/foundation/fs';
|
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
4
4
|
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
5
|
-
import type { WitnessMap } from '@aztec/noir-types';
|
|
6
5
|
import type { SimulationProvider } from '@aztec/simulator/server';
|
|
6
|
+
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
7
7
|
import type { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
8
8
|
|
|
9
9
|
import { encode } from '@msgpack/msgpack';
|
|
@@ -40,18 +40,26 @@ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// TODO(#7371): This is duplicated.
|
|
44
|
+
// Longer term we won't use this hacked together msgpack format
|
|
45
|
+
// Leaving duplicated as this eventually bb will provide a serialization
|
|
46
|
+
// helper for passing to a generic msgpack RPC endpoint.
|
|
47
|
+
private async _createClientIvcProofFiles(directory: string, executionSteps: PrivateExecutionStep[]) {
|
|
48
|
+
const acirPath = path.join(directory, 'acir.msgpack');
|
|
49
|
+
const witnessPath = path.join(directory, 'witnesses.msgpack');
|
|
50
|
+
await fs.writeFile(acirPath, encode(executionSteps.map(map => map.bytecode)));
|
|
51
|
+
await fs.writeFile(witnessPath, encode(executionSteps.map(map => serializeWitness(map.witness))));
|
|
52
|
+
return {
|
|
53
|
+
acirPath,
|
|
54
|
+
witnessPath,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
43
58
|
private async _createClientIvcProof(
|
|
44
59
|
directory: string,
|
|
45
|
-
|
|
46
|
-
witnessStack: WitnessMap[],
|
|
60
|
+
executionSteps: PrivateExecutionStep[],
|
|
47
61
|
): Promise<ClientIvcProof> {
|
|
48
|
-
|
|
49
|
-
// and instead properly create the bincode serialization from rust
|
|
50
|
-
await fs.writeFile(path.join(directory, 'acir.msgpack'), encode(acirs));
|
|
51
|
-
await fs.writeFile(
|
|
52
|
-
path.join(directory, 'witnesses.msgpack'),
|
|
53
|
-
encode(witnessStack.map(map => serializeWitness(map))),
|
|
54
|
-
);
|
|
62
|
+
await this._createClientIvcProofFiles(directory, executionSteps);
|
|
55
63
|
const provingResult = await executeBbClientIvcProof(
|
|
56
64
|
this.bbBinaryPath,
|
|
57
65
|
directory,
|
|
@@ -75,10 +83,10 @@ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
|
75
83
|
return proof;
|
|
76
84
|
}
|
|
77
85
|
|
|
78
|
-
public override async createClientIvcProof(
|
|
86
|
+
public override async createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof> {
|
|
79
87
|
this.log.info(`Generating Client IVC proof`);
|
|
80
88
|
const operation = async (directory: string) => {
|
|
81
|
-
return await this._createClientIvcProof(directory,
|
|
89
|
+
return await this._createClientIvcProof(directory, executionSteps);
|
|
82
90
|
};
|
|
83
91
|
return await this.runInDirectory(operation);
|
|
84
92
|
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
convertPrivateKernelTailInputsToWitnessMapWithAbi,
|
|
12
12
|
convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
|
|
13
13
|
convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi,
|
|
14
|
+
foreignCallHandler,
|
|
14
15
|
getPrivateKernelResetArtifactName,
|
|
15
16
|
updateResetCircuitSampleInputs,
|
|
16
17
|
} from '@aztec/noir-protocol-circuits-types/client';
|
|
@@ -19,6 +20,7 @@ import type { Abi, WitnessMap } from '@aztec/noir-types';
|
|
|
19
20
|
import type { SimulationProvider } from '@aztec/simulator/client';
|
|
20
21
|
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
21
22
|
import type {
|
|
23
|
+
PrivateExecutionStep,
|
|
22
24
|
PrivateKernelCircuitPublicInputs,
|
|
23
25
|
PrivateKernelInitCircuitPrivateInputs,
|
|
24
26
|
PrivateKernelInnerCircuitPrivateInputs,
|
|
@@ -27,7 +29,7 @@ import type {
|
|
|
27
29
|
PrivateKernelTailCircuitPrivateInputs,
|
|
28
30
|
PrivateKernelTailCircuitPublicInputs,
|
|
29
31
|
} from '@aztec/stdlib/kernel';
|
|
30
|
-
import type {
|
|
32
|
+
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
31
33
|
import type { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
32
34
|
import type { CircuitSimulationStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
33
35
|
|
|
@@ -158,15 +160,14 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
158
160
|
convertInputs: (inputs: I, abi: Abi) => WitnessMap,
|
|
159
161
|
convertOutputs: (outputs: WitnessMap, abi: Abi) => O,
|
|
160
162
|
): Promise<PrivateKernelSimulateOutput<O>> {
|
|
161
|
-
const compiledCircuit:
|
|
162
|
-
circuitType
|
|
163
|
-
);
|
|
163
|
+
const compiledCircuit: NoirCompiledCircuitWithName =
|
|
164
|
+
await this.artifactProvider.getSimulatedClientCircuitArtifactByName(circuitType);
|
|
164
165
|
|
|
165
166
|
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
166
167
|
|
|
167
168
|
const timer = new Timer();
|
|
168
169
|
const outputWitness = await this.simulationProvider
|
|
169
|
-
.executeProtocolCircuit(witnessMap, compiledCircuit)
|
|
170
|
+
.executeProtocolCircuit(witnessMap, compiledCircuit, foreignCallHandler)
|
|
170
171
|
.catch((err: Error) => {
|
|
171
172
|
this.log.debug(`Failed to simulate ${circuitType}`, {
|
|
172
173
|
circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
|
|
@@ -197,13 +198,17 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
197
198
|
convertOutputs: (outputs: WitnessMap, abi: Abi) => O,
|
|
198
199
|
): Promise<PrivateKernelSimulateOutput<O>> {
|
|
199
200
|
this.log.debug(`Generating witness for ${circuitType}`);
|
|
200
|
-
const compiledCircuit:
|
|
201
|
+
const compiledCircuit: NoirCompiledCircuitWithName = await this.artifactProvider.getClientCircuitArtifactByName(
|
|
201
202
|
circuitType,
|
|
202
203
|
);
|
|
203
204
|
|
|
204
205
|
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
205
206
|
const timer = new Timer();
|
|
206
|
-
const outputWitness = await this.simulationProvider.executeProtocolCircuit(
|
|
207
|
+
const outputWitness = await this.simulationProvider.executeProtocolCircuit(
|
|
208
|
+
witnessMap,
|
|
209
|
+
compiledCircuit,
|
|
210
|
+
foreignCallHandler,
|
|
211
|
+
);
|
|
207
212
|
const output = convertOutputs(outputWitness, compiledCircuit.abi);
|
|
208
213
|
|
|
209
214
|
this.log.debug(`Generated witness for ${circuitType}`, {
|
|
@@ -238,7 +243,7 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
238
243
|
return kernelProofOutput;
|
|
239
244
|
}
|
|
240
245
|
|
|
241
|
-
public createClientIvcProof(
|
|
246
|
+
public createClientIvcProof(_executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof> {
|
|
242
247
|
throw new Error('Not implemented');
|
|
243
248
|
}
|
|
244
249
|
|
package/src/prover/bb_prover.ts
CHANGED
|
@@ -14,7 +14,6 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
14
14
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
15
15
|
import { Timer } from '@aztec/foundation/timer';
|
|
16
16
|
import {
|
|
17
|
-
ServerCircuitArtifacts,
|
|
18
17
|
type ServerProtocolArtifact,
|
|
19
18
|
convertBaseParityInputsToWitnessMap,
|
|
20
19
|
convertBaseParityOutputsFromWitnessMap,
|
|
@@ -36,6 +35,7 @@ import {
|
|
|
36
35
|
convertRootRollupOutputsFromWitnessMap,
|
|
37
36
|
convertSingleTxBlockRootRollupInputsToWitnessMap,
|
|
38
37
|
convertSingleTxBlockRootRollupOutputsFromWitnessMap,
|
|
38
|
+
getServerCircuitArtifact,
|
|
39
39
|
} from '@aztec/noir-protocol-circuits-types/server';
|
|
40
40
|
import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
41
41
|
import type { WitnessMap } from '@aztec/noir-types';
|
|
@@ -92,6 +92,7 @@ import { type UltraHonkFlavor, getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
|
92
92
|
import { ProverInstrumentation } from '../instrumentation.js';
|
|
93
93
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
94
94
|
import { extractAvmVkData, extractVkData } from '../verification_key/verification_key_data.js';
|
|
95
|
+
import { PRIVATE_TAIL_CIVC_VK, PUBLIC_TAIL_CIVC_VK } from '../verifier/bb_verifier.js';
|
|
95
96
|
import { writeToOutputDirectory } from './client_ivc_proof_utils.js';
|
|
96
97
|
|
|
97
98
|
const logger = createLogger('bb-prover');
|
|
@@ -410,13 +411,14 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
410
411
|
outputWitnessFile,
|
|
411
412
|
);
|
|
412
413
|
|
|
413
|
-
const artifact =
|
|
414
|
+
const artifact = getServerCircuitArtifact(circuitType);
|
|
414
415
|
|
|
415
416
|
logger.debug(`Generating witness data for ${circuitType}`);
|
|
416
417
|
|
|
417
418
|
const inputWitness = convertInput(input);
|
|
418
419
|
const timer = new Timer();
|
|
419
|
-
const
|
|
420
|
+
const foreignCallHandler = undefined; // We don't handle foreign calls in the native ACVM simulator
|
|
421
|
+
const outputWitness = await simulator.executeProtocolCircuit(inputWitness, artifact, foreignCallHandler);
|
|
420
422
|
const output = convertOutput(outputWitness);
|
|
421
423
|
|
|
422
424
|
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
@@ -520,12 +522,18 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
520
522
|
hasher.update(input.toBuffer());
|
|
521
523
|
|
|
522
524
|
await writeToOutputDirectory(input.clientIVCData, bbWorkingDirectory);
|
|
523
|
-
const provingResult = await generateTubeProof(
|
|
525
|
+
const provingResult = await generateTubeProof(
|
|
526
|
+
this.config.bbBinaryPath,
|
|
527
|
+
bbWorkingDirectory,
|
|
528
|
+
input.usePublicTailVk ? PUBLIC_TAIL_CIVC_VK : PRIVATE_TAIL_CIVC_VK,
|
|
529
|
+
logger.verbose,
|
|
530
|
+
);
|
|
524
531
|
|
|
525
532
|
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
526
533
|
logger.error(`Failed to generate proof for tube circuit: ${provingResult.reason}`);
|
|
527
534
|
throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
|
|
528
535
|
}
|
|
536
|
+
|
|
529
537
|
return provingResult;
|
|
530
538
|
}
|
|
531
539
|
|
|
@@ -3,40 +3,26 @@ import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
|
3
3
|
import { promises as fs } from 'fs';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
|
|
6
|
-
export const CLIENT_IVC_VK_FILE_NAME = 'vk';
|
|
7
6
|
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param directory the directory
|
|
9
|
+
* Create a ClientIvcProof proof file.
|
|
10
|
+
*
|
|
11
|
+
* @param directory the directory to read the proof from.
|
|
13
12
|
* @returns the encapsulated client ivc proof
|
|
14
13
|
*/
|
|
15
14
|
export async function readFromOutputDirectory(directory: string) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
return new ClientIvcProof(clientIvcProofBuffer, clientIvcVkBuffer);
|
|
15
|
+
const clientIvcProofBuffer = await fs.readFile(join(directory, CLIENT_IVC_PROOF_FILE_NAME));
|
|
16
|
+
return new ClientIvcProof(clientIvcProofBuffer);
|
|
20
17
|
}
|
|
21
18
|
|
|
22
19
|
/**
|
|
23
|
-
*
|
|
24
|
-
* Serialize a ClientIvcProof to the files expected by prove_tube
|
|
20
|
+
* Serialize a ClientIvcProof to a proof file.
|
|
25
21
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* await privateTx.clientIvcProof!.writeToOutputDirectory(bbWorkingDirectory);
|
|
29
|
-
* const result = await generateTubeProof(bbPath, dir, logger.info)
|
|
30
|
-
* expect(result.status).toBe(BB_RESULT.SUCCESS)
|
|
31
|
-
* });
|
|
32
|
-
* @param proof the ClientIvcProof from readFromOutputDirectory
|
|
33
|
-
* @param directory the directory of results
|
|
22
|
+
* @param proof the ClientIvcProof from object
|
|
23
|
+
* @param directory the directory to write in
|
|
34
24
|
*/
|
|
35
25
|
export async function writeToOutputDirectory(clientIvcProof: ClientIvcProof, directory: string) {
|
|
36
|
-
const { clientIvcProofBuffer
|
|
37
|
-
|
|
38
|
-
[CLIENT_IVC_PROOF_FILE_NAME, clientIvcProofBuffer],
|
|
39
|
-
[CLIENT_IVC_VK_FILE_NAME, clientIvcVkBuffer],
|
|
40
|
-
] as const;
|
|
41
|
-
await Promise.all(fileData.map(([fileName, buffer]) => fs.writeFile(join(directory, fileName), buffer)));
|
|
26
|
+
const { clientIvcProofBuffer } = clientIvcProof;
|
|
27
|
+
await fs.writeFile(join(directory, CLIENT_IVC_PROOF_FILE_NAME), clientIvcProofBuffer);
|
|
42
28
|
}
|
|
@@ -11,7 +11,6 @@ import { sleep } from '@aztec/foundation/sleep';
|
|
|
11
11
|
import { Timer } from '@aztec/foundation/timer';
|
|
12
12
|
import {
|
|
13
13
|
type ServerProtocolArtifact,
|
|
14
|
-
SimulatedServerCircuitArtifacts,
|
|
15
14
|
convertBaseParityInputsToWitnessMap,
|
|
16
15
|
convertBaseParityOutputsFromWitnessMap,
|
|
17
16
|
convertBlockMergeRollupInputsToWitnessMap,
|
|
@@ -32,6 +31,8 @@ import {
|
|
|
32
31
|
convertSimulatedPublicBaseRollupOutputsFromWitnessMap,
|
|
33
32
|
convertSimulatedSingleTxBlockRootRollupInputsToWitnessMap,
|
|
34
33
|
convertSimulatedSingleTxBlockRootRollupOutputsFromWitnessMap,
|
|
34
|
+
foreignCallHandler,
|
|
35
|
+
getSimulatedServerCircuitArtifact,
|
|
35
36
|
} from '@aztec/noir-protocol-circuits-types/server';
|
|
36
37
|
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
37
38
|
import type { WitnessMap } from '@aztec/noir-types';
|
|
@@ -347,16 +348,26 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
347
348
|
const witnessMap = convertInput(input);
|
|
348
349
|
const circuitName = mapProtocolArtifactNameToCircuitName(artifactName);
|
|
349
350
|
|
|
350
|
-
let
|
|
351
|
-
if (
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
351
|
+
let witness: WitnessMap;
|
|
352
|
+
if (
|
|
353
|
+
['BlockRootRollupArtifact', 'SingleTxBlockRootRollupArtifact'].includes(artifactName) ||
|
|
354
|
+
this.simulationProvider == undefined
|
|
355
|
+
) {
|
|
356
|
+
// TODO(#10323): Native ACVM simulator does not support foreign call handler so we use the wasm simulator
|
|
357
|
+
// when simulating block root rollup and single tx block root rollup circuits or when the native ACVM simulator
|
|
358
|
+
// is not provided.
|
|
359
|
+
witness = await this.wasmSimulator.executeProtocolCircuit(
|
|
360
|
+
witnessMap,
|
|
361
|
+
getSimulatedServerCircuitArtifact(artifactName),
|
|
362
|
+
foreignCallHandler,
|
|
363
|
+
);
|
|
364
|
+
} else {
|
|
365
|
+
witness = await this.simulationProvider.executeProtocolCircuit(
|
|
366
|
+
witnessMap,
|
|
367
|
+
getSimulatedServerCircuitArtifact(artifactName),
|
|
368
|
+
undefined, // Native ACM simulator does not support foreign call handler
|
|
369
|
+
);
|
|
355
370
|
}
|
|
356
|
-
const witness = await simulationProvider.executeProtocolCircuit(
|
|
357
|
-
witnessMap,
|
|
358
|
-
SimulatedServerCircuitArtifacts[artifactName],
|
|
359
|
-
);
|
|
360
371
|
|
|
361
372
|
const result = convertOutput(witness);
|
|
362
373
|
|
|
@@ -10,6 +10,7 @@ import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
|
10
10
|
|
|
11
11
|
import { promises as fs } from 'fs';
|
|
12
12
|
import * as path from 'path';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
13
14
|
|
|
14
15
|
import { BB_RESULT, PROOF_FILENAME, VK_FILENAME, verifyClientIvcProof, verifyProof } from '../bb/execute.js';
|
|
15
16
|
import type { BBConfig } from '../config.js';
|
|
@@ -17,6 +18,12 @@ import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
|
17
18
|
import { writeToOutputDirectory } from '../prover/client_ivc_proof_utils.js';
|
|
18
19
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
19
20
|
|
|
21
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
|
|
23
|
+
// Built by yarn generate
|
|
24
|
+
export const PRIVATE_TAIL_CIVC_VK = path.join(__dirname, '../../artifacts/private-civc-vk');
|
|
25
|
+
export const PUBLIC_TAIL_CIVC_VK = path.join(__dirname, '../../artifacts/public-civc-vk');
|
|
26
|
+
|
|
20
27
|
export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
21
28
|
private constructor(private config: BBConfig, private logger: Logger) {}
|
|
22
29
|
|
|
@@ -88,7 +95,7 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
88
95
|
const result = await verifyClientIvcProof(
|
|
89
96
|
this.config.bbBinaryPath,
|
|
90
97
|
bbWorkingDirectory.concat('/proof'),
|
|
91
|
-
|
|
98
|
+
tx.data.forPublic ? PUBLIC_TAIL_CIVC_VK : PRIVATE_TAIL_CIVC_VK,
|
|
92
99
|
logFunction,
|
|
93
100
|
);
|
|
94
101
|
|
|
@@ -3,8 +3,8 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
4
|
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
5
5
|
import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
|
|
6
|
-
import type { WitnessMap } from '@aztec/noir-types';
|
|
7
6
|
import type { SimulationProvider } from '@aztec/simulator/client';
|
|
7
|
+
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
8
8
|
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
9
9
|
|
|
10
10
|
import { ungzip } from 'pako';
|
|
@@ -21,23 +21,24 @@ export abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
|
21
21
|
super(artifactProvider, simulationProvider, log);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
public override async createClientIvcProof(
|
|
24
|
+
public override async createClientIvcProof(executionSteps: PrivateExecutionStep[]): Promise<ClientIvcProof> {
|
|
25
25
|
const timer = new Timer();
|
|
26
26
|
this.log.info(`Generating ClientIVC proof...`);
|
|
27
27
|
const backend = new AztecClientBackend(
|
|
28
|
-
|
|
28
|
+
executionSteps.map(step => ungzip(step.bytecode)),
|
|
29
29
|
{ threads: this.threads, logger: this.log.verbose, wasmPath: process.env.BB_WASM_PATH },
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1297): the vk is not provided to the network anymore.
|
|
33
|
+
// Move this sanity check inside the wasm code and remove the vk from the return value.
|
|
34
|
+
const [proof, _vk] = await backend.prove(executionSteps.map(step => ungzip(serializeWitness(step.witness))));
|
|
33
35
|
await backend.destroy();
|
|
34
36
|
this.log.info(`Generated ClientIVC proof`, {
|
|
35
37
|
eventName: 'client-ivc-proof-generation',
|
|
36
38
|
duration: timer.ms(),
|
|
37
39
|
proofSize: proof.length,
|
|
38
|
-
vkSize: vk.length,
|
|
39
40
|
});
|
|
40
|
-
return new ClientIvcProof(Buffer.from(proof)
|
|
41
|
+
return new ClientIvcProof(Buffer.from(proof));
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
public override async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|