@aztec/bb-prover 0.84.0 → 0.85.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.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +1 -2
- package/dest/bb/execute.d.ts +2 -2
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +7 -9
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/prover/bb_native_private_kernel_prover.js +2 -2
- package/dest/prover/bb_prover.d.ts +0 -1
- package/dest/prover/bb_prover.d.ts.map +1 -1
- package/dest/prover/bb_prover.js +12 -42
- package/dest/prover/index.d.ts +1 -1
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/prover/index.js +1 -1
- package/dest/prover/proof_utils.d.ts +19 -0
- package/dest/prover/proof_utils.d.ts.map +1 -0
- package/dest/prover/proof_utils.js +54 -0
- package/dest/verifier/bb_verifier.js +2 -2
- package/package.json +15 -16
- package/src/avm_proving_tests/avm_proving_tester.ts +1 -2
- package/src/bb/execute.ts +7 -6
- package/src/index.ts +1 -0
- package/src/prover/bb_native_private_kernel_prover.ts +2 -2
- package/src/prover/bb_prover.ts +10 -61
- package/src/prover/index.ts +1 -1
- package/src/prover/proof_utils.ts +92 -0
- package/src/verifier/bb_verifier.ts +2 -2
- package/dest/prover/client_ivc_proof_utils.d.ts +0 -17
- package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
- package/dest/prover/client_ivc_proof_utils.js +0 -22
- package/src/prover/client_ivc_proof_utils.ts +0 -28
|
@@ -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,OA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,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,EACtC,OAAO,CAAC,EAAE,eAAe;WAKd,GAAG,CAAC,OAAO,CAAC,EAAE,eAAe;IAQpC,OAAO,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAU9D,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;IAczC,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"}
|
|
@@ -89,8 +89,7 @@ export class AvmProvingTesterV2 extends PublicTxSimulationTester {
|
|
|
89
89
|
async verifyV2(proofRes) {
|
|
90
90
|
// TODO: Placeholder for now. They get ignored in C++.
|
|
91
91
|
const inputs = await makeAvmCircuitInputs();
|
|
92
|
-
|
|
93
|
-
return await verifyAvmProofV2(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath, inputs.publicInputs, rawVkPath, this.logger);
|
|
92
|
+
return await verifyAvmProofV2(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath, inputs.publicInputs, proofRes.vkPath, this.logger);
|
|
94
93
|
}
|
|
95
94
|
async simProveVerifyV2(sender, setupCalls, appCalls, teardownCall, expectRevert, feePayer = sender) {
|
|
96
95
|
const simRes = await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer);
|
package/dest/bb/execute.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare const PROOF_FIELDS_FILENAME = "proof_fields.json";
|
|
|
12
12
|
export declare const AVM_INPUTS_FILENAME = "avm_inputs.bin";
|
|
13
13
|
export declare const AVM_BYTECODE_FILENAME = "avm_bytecode.bin";
|
|
14
14
|
export declare const AVM_PUBLIC_INPUTS_FILENAME = "avm_public_inputs.bin";
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const CLIENT_IVC_PROOF_FILE_NAME = "proof";
|
|
16
16
|
export declare enum BB_RESULT {
|
|
17
17
|
SUCCESS = 0,
|
|
18
18
|
FAILURE = 1,
|
|
@@ -55,7 +55,7 @@ type BBExecResult = {
|
|
|
55
55
|
* @returns The completed partial witness outputted from the circuit
|
|
56
56
|
*/
|
|
57
57
|
export declare function executeBB(pathToBB: string, command: string, args: string[], logger: LogFn, timeout?: number, resultParser?: (code: number) => boolean): Promise<BBExecResult>;
|
|
58
|
-
export declare function executeBbClientIvcProof(pathToBB: string, workingDirectory: string, bytecodeStackPath: string, witnessStackPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
58
|
+
export declare function executeBbClientIvcProof(pathToBB: string, workingDirectory: string, bytecodeStackPath: string, witnessStackPath: string, log: LogFn, writeVk?: boolean): Promise<BBFailure | BBSuccess>;
|
|
59
59
|
/**
|
|
60
60
|
* Used for generating proofs of noir circuits.
|
|
61
61
|
* 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,EAA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E,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,KAAK,GACT,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CA2BhC;AAkED,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,6 @@ 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 } from '../prover/client_ivc_proof_utils.js';
|
|
7
6
|
export const VK_FILENAME = 'vk';
|
|
8
7
|
export const VK_FIELDS_FILENAME = 'vk_fields.json';
|
|
9
8
|
export const PUBLIC_INPUTS_FILENAME = 'public_inputs';
|
|
@@ -13,7 +12,7 @@ export const PROOF_FIELDS_FILENAME = 'proof_fields.json';
|
|
|
13
12
|
export const AVM_INPUTS_FILENAME = 'avm_inputs.bin';
|
|
14
13
|
export const AVM_BYTECODE_FILENAME = 'avm_bytecode.bin';
|
|
15
14
|
export const AVM_PUBLIC_INPUTS_FILENAME = 'avm_public_inputs.bin';
|
|
16
|
-
export const
|
|
15
|
+
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
17
16
|
export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
|
|
18
17
|
BB_RESULT[BB_RESULT["SUCCESS"] = 0] = "SUCCESS";
|
|
19
18
|
BB_RESULT[BB_RESULT["FAILURE"] = 1] = "FAILURE";
|
|
@@ -87,7 +86,7 @@ export var BB_RESULT = /*#__PURE__*/ function(BB_RESULT) {
|
|
|
87
86
|
signal: undefined
|
|
88
87
|
}));
|
|
89
88
|
}
|
|
90
|
-
export async function executeBbClientIvcProof(pathToBB, workingDirectory, bytecodeStackPath, witnessStackPath, log) {
|
|
89
|
+
export async function executeBbClientIvcProof(pathToBB, workingDirectory, bytecodeStackPath, witnessStackPath, log, writeVk = false) {
|
|
91
90
|
// Check that the working directory exists
|
|
92
91
|
try {
|
|
93
92
|
await fs.access(workingDirectory);
|
|
@@ -121,9 +120,11 @@ export async function executeBbClientIvcProof(pathToBB, workingDirectory, byteco
|
|
|
121
120
|
'--scheme',
|
|
122
121
|
'client_ivc',
|
|
123
122
|
'--input_type',
|
|
124
|
-
'runtime_stack'
|
|
125
|
-
'--write_vk'
|
|
123
|
+
'runtime_stack'
|
|
126
124
|
];
|
|
125
|
+
if (writeVk) {
|
|
126
|
+
args.push('--write_vk');
|
|
127
|
+
}
|
|
127
128
|
const timer = new Timer();
|
|
128
129
|
const logFunction = (message)=>{
|
|
129
130
|
log(`bb - ${message}`);
|
|
@@ -391,7 +392,7 @@ function getArgs(flavor) {
|
|
|
391
392
|
durationMs: duration,
|
|
392
393
|
proofPath: join(outputPath, PROOF_FILENAME),
|
|
393
394
|
pkPath: undefined,
|
|
394
|
-
vkPath: outputPath
|
|
395
|
+
vkPath: join(outputPath, VK_FILENAME)
|
|
395
396
|
};
|
|
396
397
|
}
|
|
397
398
|
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
@@ -427,7 +428,6 @@ function getArgs(flavor) {
|
|
|
427
428
|
}
|
|
428
429
|
// Paths for the inputs
|
|
429
430
|
const publicInputsPath = join(workingDirectory, AVM_PUBLIC_INPUTS_FILENAME);
|
|
430
|
-
const avmHintsPath = join(workingDirectory, AVM_HINTS_FILENAME);
|
|
431
431
|
// The proof is written to e.g. /workingDirectory/proof
|
|
432
432
|
const outputPath = workingDirectory;
|
|
433
433
|
const filePresent = async (file)=>await fs.access(file, fs.constants.R_OK).then((_)=>true).catch((_)=>false);
|
|
@@ -452,8 +452,6 @@ function getArgs(flavor) {
|
|
|
452
452
|
const args = [
|
|
453
453
|
'--avm-public-inputs',
|
|
454
454
|
publicInputsPath,
|
|
455
|
-
'--avm-hints',
|
|
456
|
-
avmHintsPath,
|
|
457
455
|
'-o',
|
|
458
456
|
outputPath
|
|
459
457
|
];
|
package/dest/index.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export * from './verifier/index.js';
|
|
|
4
4
|
export * from './config.js';
|
|
5
5
|
export * from './bb/execute.js';
|
|
6
6
|
export * from './honk.js';
|
|
7
|
+
export * from './verification_key/verification_key_data.js';
|
|
7
8
|
export { type ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dest/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,6CAA6C,CAAC;AAE5D,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,iCAAiC,CAAC"}
|
package/dest/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { promises as fs } from 'fs';
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../bb/execute.js';
|
|
9
9
|
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
10
|
-
import {
|
|
10
|
+
import { readClientIVCProofFromOutputDirectory } from './proof_utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* This proof creator implementation uses the native bb binary.
|
|
13
13
|
*/ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
@@ -46,7 +46,7 @@ import { readFromOutputDirectory } from './client_ivc_proof_utils.js';
|
|
|
46
46
|
this.log.error(`Failed to generate client ivc proof`);
|
|
47
47
|
throw new Error(provingResult.reason);
|
|
48
48
|
}
|
|
49
|
-
const proof = await
|
|
49
|
+
const proof = await readClientIVCProofFromOutputDirectory(directory);
|
|
50
50
|
this.log.info(`Generated IVC proof`, {
|
|
51
51
|
duration: provingResult.durationMs,
|
|
52
52
|
eventName: 'circuit-proving'
|
|
@@ -113,7 +113,6 @@ export declare class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
113
113
|
* @returns The verification key data
|
|
114
114
|
*/
|
|
115
115
|
private getVerificationKeyDataForCircuit;
|
|
116
|
-
private readProofAsFields;
|
|
117
116
|
private readAvmProofAsFields;
|
|
118
117
|
private runInDirectory;
|
|
119
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,0BAA0B,
|
|
1
|
+
{"version":3,"file":"bb_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,0BAA0B,EAC1B,6BAA6B,EAC7B,yCAAyC,EACzC,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,k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D;;;;OAIG;IACU,kBAAkB,CAC7B,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,6BAA6B,CAAC,sBAAsB,CAAC,CAAC;YAkBnD,mBAAmB;YAqEnB,WAAW;YAyCX,sBAAsB;YAatB,uBAAuB;YAsBvB,cAAc;IAsCf,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,uBAAuB,CAAC,OAAO,iBAAiB,CAAC,CAAC;IA6BxG;;;;;;;;OAQG;YACW,oBAAoB;IAqDlC;;;;OAIG;IACU,WAAW,CAAC,WAAW,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK;IAK7D,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,mBAAmB;IAMjE,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK;YAMxF,qBAAqB;IA2BnC;;;;OAIG;IACH,OAAO,CAAC,gCAAgC;YAQ1B,oBAAoB;IAelC,OAAO,CAAC,cAAc;CAYvB"}
|
package/dest/prover/bb_prover.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
}
|
|
7
|
-
import { AGGREGATION_OBJECT_LENGTH, AVM_PROOF_LENGTH_IN_FIELDS,
|
|
7
|
+
import { AGGREGATION_OBJECT_LENGTH, AVM_PROOF_LENGTH_IN_FIELDS, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
|
|
8
8
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
9
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
10
10
|
import { createLogger } from '@aztec/foundation/log';
|
|
@@ -17,17 +17,16 @@ import { ProvingError } from '@aztec/stdlib/errors';
|
|
|
17
17
|
import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
18
18
|
import { Proof, RecursiveProof, makeRecursiveProofFromBinary } from '@aztec/stdlib/proofs';
|
|
19
19
|
import { Attributes, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
20
|
-
import assert from 'assert';
|
|
21
20
|
import crypto from 'crypto';
|
|
22
21
|
import { promises as fs } from 'fs';
|
|
23
22
|
import * as path from 'path';
|
|
24
|
-
import { BB_RESULT,
|
|
23
|
+
import { BB_RESULT, PROOF_FILENAME, PUBLIC_INPUTS_FILENAME, VK_FILENAME, generateAvmProof, generateProof, generateTubeProof, verifyAvmProof, verifyProof } from '../bb/execute.js';
|
|
25
24
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
26
25
|
import { ProverInstrumentation } from '../instrumentation.js';
|
|
27
26
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
28
27
|
import { extractAvmVkData, extractVkData } from '../verification_key/verification_key_data.js';
|
|
29
28
|
import { PRIVATE_TAIL_CIVC_VK, PUBLIC_TAIL_CIVC_VK } from '../verifier/bb_verifier.js';
|
|
30
|
-
import {
|
|
29
|
+
import { readProofAsFields, writeClientIVCProofToOutputDirectory } from './proof_utils.js';
|
|
31
30
|
const logger = createLogger('bb-prover');
|
|
32
31
|
// All `ServerCircuitArtifact` are recursive.
|
|
33
32
|
const SERVER_CIRCUIT_RECURSIVE = true;
|
|
@@ -206,7 +205,7 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
206
205
|
const operation = async (bbWorkingDirectory)=>{
|
|
207
206
|
const { provingResult, circuitOutput: output } = await this.generateProofWithBB(input, circuitType, convertInput, convertOutput, bbWorkingDirectory);
|
|
208
207
|
const vkData = this.getVerificationKeyDataForCircuit(circuitType);
|
|
209
|
-
const proof = await
|
|
208
|
+
const proof = await readProofAsFields(provingResult.proofPath, vkData, RECURSIVE_PROOF_LENGTH, logger);
|
|
210
209
|
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
211
210
|
this.instrumentation.recordDuration('provingDuration', circuitName, provingResult.durationMs);
|
|
212
211
|
this.instrumentation.recordSize('proofSize', circuitName, proof.binaryProof.buffer.length);
|
|
@@ -231,10 +230,10 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
231
230
|
return await this.runInDirectory(operation);
|
|
232
231
|
}
|
|
233
232
|
async generateAvmProofWithBB(input, workingDirectory) {
|
|
234
|
-
logger.info(`Proving avm-circuit for ${input.
|
|
233
|
+
logger.info(`Proving avm-circuit for TX ${input.hints.tx.hash}...`);
|
|
235
234
|
const provingResult = await generateAvmProof(this.config.bbBinaryPath, workingDirectory, input, logger);
|
|
236
235
|
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
237
|
-
logger.error(`Failed to generate AVM proof for ${input.
|
|
236
|
+
logger.error(`Failed to generate AVM proof for TX ${input.hints.tx.hash}: ${provingResult.reason}`);
|
|
238
237
|
throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
|
|
239
238
|
}
|
|
240
239
|
return provingResult;
|
|
@@ -243,7 +242,7 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
243
242
|
logger.debug(`Proving tube...`);
|
|
244
243
|
const hasher = crypto.createHash('sha256');
|
|
245
244
|
hasher.update(input.toBuffer());
|
|
246
|
-
await
|
|
245
|
+
await writeClientIVCProofToOutputDirectory(input.clientIVCData, bbWorkingDirectory);
|
|
247
246
|
const provingResult = await generateTubeProof(this.config.bbBinaryPath, bbWorkingDirectory, input.usePublicTailVk ? PUBLIC_TAIL_CIVC_VK : PRIVATE_TAIL_CIVC_VK, logger.verbose);
|
|
248
247
|
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
249
248
|
logger.error(`Failed to generate proof for tube circuit: ${provingResult.reason}`);
|
|
@@ -264,9 +263,9 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
264
263
|
this.instrumentation.recordAvmSize('proofSize', appCircuitName, avmProof.binaryProof.buffer.length);
|
|
265
264
|
this.instrumentation.recordAvmSize('circuitPublicInputCount', appCircuitName, verificationKey.numPublicInputs);
|
|
266
265
|
this.instrumentation.recordAvmSize('circuitSize', appCircuitName, verificationKey.circuitSize);
|
|
267
|
-
logger.info(`Generated proof for ${circuitType}(${input.
|
|
266
|
+
logger.info(`Generated proof for ${circuitType}(${input.hints.tx.hash}) in ${Math.ceil(provingResult.durationMs)} ms`, {
|
|
268
267
|
circuitName: circuitType,
|
|
269
|
-
appCircuitName: input.
|
|
268
|
+
appCircuitName: input.hints.tx.hash,
|
|
270
269
|
// does not include reading the proof from disk
|
|
271
270
|
duration: provingResult.durationMs,
|
|
272
271
|
proofSize: avmProof.binaryProof.buffer.length,
|
|
@@ -286,7 +285,7 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
286
285
|
// Read the proof as fields
|
|
287
286
|
// TODO(AD): this is the only remaining use of extractVkData.
|
|
288
287
|
const tubeVK = await extractVkData(provingResult.vkPath);
|
|
289
|
-
const tubeProof = await
|
|
288
|
+
const tubeProof = await readProofAsFields(provingResult.proofPath, tubeVK, TUBE_PROOF_LENGTH, logger);
|
|
290
289
|
this.instrumentation.recordDuration('provingDuration', 'tubeCircuit', provingResult.durationMs);
|
|
291
290
|
this.instrumentation.recordSize('proofSize', 'tubeCircuit', tubeProof.binaryProof.buffer.length);
|
|
292
291
|
this.instrumentation.recordSize('circuitPublicInputCount', 'tubeCircuit', tubeVK.numPublicInputs);
|
|
@@ -312,7 +311,7 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
312
311
|
const { provingResult, circuitOutput: output } = await this.generateProofWithBB(input, circuitType, convertInput, convertOutput, bbWorkingDirectory);
|
|
313
312
|
const vkData = this.getVerificationKeyDataForCircuit(circuitType);
|
|
314
313
|
// Read the proof as fields
|
|
315
|
-
const proof = await
|
|
314
|
+
const proof = await readProofAsFields(provingResult.proofPath, vkData, proofLength, logger);
|
|
316
315
|
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
317
316
|
this.instrumentation.recordDuration('provingDuration', circuitName, provingResult.durationMs);
|
|
318
317
|
this.instrumentation.recordSize('proofSize', circuitName, proof.binaryProof.buffer.length);
|
|
@@ -377,35 +376,6 @@ const SERVER_CIRCUIT_RECURSIVE = true;
|
|
|
377
376
|
}
|
|
378
377
|
return vk;
|
|
379
378
|
}
|
|
380
|
-
async readProofAsFields(filePath, vkData, proofLength) {
|
|
381
|
-
const publicInputsFilename = path.join(filePath, PUBLIC_INPUTS_FILENAME);
|
|
382
|
-
const proofFilename = path.join(filePath, PROOF_FILENAME);
|
|
383
|
-
const proofFieldsFilename = path.join(filePath, PROOF_FIELDS_FILENAME);
|
|
384
|
-
const [binaryPublicInputs, binaryProof, proofString] = await Promise.all([
|
|
385
|
-
fs.readFile(publicInputsFilename),
|
|
386
|
-
fs.readFile(proofFilename),
|
|
387
|
-
fs.readFile(proofFieldsFilename, {
|
|
388
|
-
encoding: 'utf-8'
|
|
389
|
-
})
|
|
390
|
-
]);
|
|
391
|
-
const json = JSON.parse(proofString);
|
|
392
|
-
let numPublicInputs = vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
393
|
-
assert(proofLength == NESTED_RECURSIVE_PROOF_LENGTH || proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, `Proof length must be one of the expected proof lengths, received ${proofLength}`);
|
|
394
|
-
if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
|
|
395
|
-
numPublicInputs -= IPA_CLAIM_LENGTH;
|
|
396
|
-
}
|
|
397
|
-
assert(json.length == proofLength, `Proof length mismatch: ${json.length} != ${proofLength}`);
|
|
398
|
-
const fieldsWithoutPublicInputs = json.map(Fr.fromHexString);
|
|
399
|
-
// Concat binary public inputs and binary proof
|
|
400
|
-
// This buffer will have the form: [binary public inputs, binary proof]
|
|
401
|
-
const binaryProofWithPublicInputs = Buffer.concat([
|
|
402
|
-
binaryPublicInputs,
|
|
403
|
-
binaryProof
|
|
404
|
-
]);
|
|
405
|
-
logger.debug(`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProofWithPublicInputs.length}`);
|
|
406
|
-
assert(binaryProofWithPublicInputs.length == numPublicInputs * 32 + proofLength * 32, `Proof length mismatch: ${binaryProofWithPublicInputs.length} != ${numPublicInputs * 32 + proofLength * 32}`);
|
|
407
|
-
return new RecursiveProof(fieldsWithoutPublicInputs, new Proof(binaryProofWithPublicInputs, numPublicInputs), true, proofLength);
|
|
408
|
-
}
|
|
409
379
|
async readAvmProofAsFields(proofFilename, vkData) {
|
|
410
380
|
const rawProof = await fs.readFile(proofFilename);
|
|
411
381
|
const reader = BufferReader.asReader(rawProof);
|
|
@@ -433,6 +403,6 @@ _ts_decorate([
|
|
|
433
403
|
], BBNativeRollupProver.prototype, "getRootParityProof", null);
|
|
434
404
|
_ts_decorate([
|
|
435
405
|
trackSpan('BBNativeRollupProver.getAvmProof', (inputs)=>({
|
|
436
|
-
[Attributes.APP_CIRCUIT_NAME]: inputs.
|
|
406
|
+
[Attributes.APP_CIRCUIT_NAME]: inputs.hints.tx.hash
|
|
437
407
|
}))
|
|
438
408
|
], BBNativeRollupProver.prototype, "getAvmProof", null);
|
package/dest/prover/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prover/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sCAAsC,CAAC;AACrD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prover/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sCAAsC,CAAC;AACrD,cAAc,kBAAkB,CAAC"}
|
package/dest/prover/index.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { ClientIvcProof, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
3
|
+
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
4
|
+
/**
|
|
5
|
+
* Create a ClientIvcProof proof file.
|
|
6
|
+
*
|
|
7
|
+
* @param directory the directory to read the proof from.
|
|
8
|
+
* @returns the encapsulated client ivc proof
|
|
9
|
+
*/
|
|
10
|
+
export declare function readClientIVCProofFromOutputDirectory(directory: string): Promise<ClientIvcProof>;
|
|
11
|
+
/**
|
|
12
|
+
* Serialize a ClientIvcProof to a proof file.
|
|
13
|
+
*
|
|
14
|
+
* @param proof the ClientIvcProof from object
|
|
15
|
+
* @param directory the directory to write in
|
|
16
|
+
*/
|
|
17
|
+
export declare function writeClientIVCProofToOutputDirectory(clientIvcProof: ClientIvcProof, directory: string): Promise<void>;
|
|
18
|
+
export declare function readProofAsFields<PROOF_LENGTH extends number>(filePath: string, vkData: VerificationKeyData, proofLength: PROOF_LENGTH, logger: Logger): Promise<RecursiveProof<PROOF_LENGTH>>;
|
|
19
|
+
//# sourceMappingURL=proof_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof_utils.d.ts","sourceRoot":"","sources":["../../src/prover/proof_utils.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAS,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAa7D;;;;;GAKG;AACH,wBAAsB,qCAAqC,CAAC,SAAS,EAAE,MAAM,2BAG5E;AAED;;;;;GAKG;AACH,wBAAsB,oCAAoC,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,iBAG3G;AAED,wBAAsB,iBAAiB,CAAC,YAAY,SAAS,MAAM,EACjE,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CA0CvC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AGGREGATION_OBJECT_LENGTH, IPA_CLAIM_LENGTH, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { ClientIvcProof, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
4
|
+
import assert from 'assert';
|
|
5
|
+
import { promises as fs } from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { CLIENT_IVC_PROOF_FILE_NAME, PROOF_FIELDS_FILENAME, PROOF_FILENAME, PUBLIC_INPUTS_FILENAME } from '../bb/execute.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a ClientIvcProof proof file.
|
|
10
|
+
*
|
|
11
|
+
* @param directory the directory to read the proof from.
|
|
12
|
+
* @returns the encapsulated client ivc proof
|
|
13
|
+
*/ export async function readClientIVCProofFromOutputDirectory(directory) {
|
|
14
|
+
const clientIvcProofBuffer = await fs.readFile(path.join(directory, CLIENT_IVC_PROOF_FILE_NAME));
|
|
15
|
+
return new ClientIvcProof(clientIvcProofBuffer);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Serialize a ClientIvcProof to a proof file.
|
|
19
|
+
*
|
|
20
|
+
* @param proof the ClientIvcProof from object
|
|
21
|
+
* @param directory the directory to write in
|
|
22
|
+
*/ export async function writeClientIVCProofToOutputDirectory(clientIvcProof, directory) {
|
|
23
|
+
const { clientIvcProofBuffer } = clientIvcProof;
|
|
24
|
+
await fs.writeFile(path.join(directory, CLIENT_IVC_PROOF_FILE_NAME), clientIvcProofBuffer);
|
|
25
|
+
}
|
|
26
|
+
export async function readProofAsFields(filePath, vkData, proofLength, logger) {
|
|
27
|
+
const publicInputsFilename = path.join(filePath, PUBLIC_INPUTS_FILENAME);
|
|
28
|
+
const proofFilename = path.join(filePath, PROOF_FILENAME);
|
|
29
|
+
const proofFieldsFilename = path.join(filePath, PROOF_FIELDS_FILENAME);
|
|
30
|
+
const [binaryPublicInputs, binaryProof, proofString] = await Promise.all([
|
|
31
|
+
fs.readFile(publicInputsFilename),
|
|
32
|
+
fs.readFile(proofFilename),
|
|
33
|
+
fs.readFile(proofFieldsFilename, {
|
|
34
|
+
encoding: 'utf-8'
|
|
35
|
+
})
|
|
36
|
+
]);
|
|
37
|
+
const json = JSON.parse(proofString);
|
|
38
|
+
let numPublicInputs = vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
39
|
+
assert(proofLength == NESTED_RECURSIVE_PROOF_LENGTH || proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, `Proof length must be one of the expected proof lengths, received ${proofLength}`);
|
|
40
|
+
if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
|
|
41
|
+
numPublicInputs -= IPA_CLAIM_LENGTH;
|
|
42
|
+
}
|
|
43
|
+
assert(json.length == proofLength, `Proof length mismatch: ${json.length} != ${proofLength}`);
|
|
44
|
+
const fieldsWithoutPublicInputs = json.map(Fr.fromHexString);
|
|
45
|
+
// Concat binary public inputs and binary proof
|
|
46
|
+
// This buffer will have the form: [binary public inputs, binary proof]
|
|
47
|
+
const binaryProofWithPublicInputs = Buffer.concat([
|
|
48
|
+
binaryPublicInputs,
|
|
49
|
+
binaryProof
|
|
50
|
+
]);
|
|
51
|
+
logger.debug(`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProofWithPublicInputs.length}`);
|
|
52
|
+
assert(binaryProofWithPublicInputs.length == numPublicInputs * 32 + proofLength * 32, `Proof length mismatch: ${binaryProofWithPublicInputs.length} != ${numPublicInputs * 32 + proofLength * 32}`);
|
|
53
|
+
return new RecursiveProof(fieldsWithoutPublicInputs, new Proof(binaryProofWithPublicInputs, numPublicInputs), true, proofLength);
|
|
54
|
+
}
|
|
@@ -7,7 +7,7 @@ import * as path from 'path';
|
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { BB_RESULT, PROOF_FILENAME, VK_FILENAME, verifyClientIvcProof, verifyProof } from '../bb/execute.js';
|
|
9
9
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
10
|
-
import {
|
|
10
|
+
import { writeClientIVCProofToOutputDirectory } from '../prover/proof_utils.js';
|
|
11
11
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
12
12
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
13
|
// Built by yarn generate
|
|
@@ -68,7 +68,7 @@ export class BBCircuitVerifier {
|
|
|
68
68
|
const logFunction = (message)=>{
|
|
69
69
|
this.logger.debug(`${circuit} BB out - ${message}`);
|
|
70
70
|
};
|
|
71
|
-
await
|
|
71
|
+
await writeClientIVCProofToOutputDirectory(tx.clientIvcProof, bbWorkingDirectory);
|
|
72
72
|
const result = await verifyClientIvcProof(this.config.bbBinaryPath, bbWorkingDirectory.concat('/proof'), tx.data.forPublic ? PUBLIC_TAIL_CIVC_VK : PRIVATE_TAIL_CIVC_VK, logFunction);
|
|
73
73
|
if (result.status === BB_RESULT.FAILURE) {
|
|
74
74
|
const errorMessage = `Failed to verify ${circuit} proof!`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bb-prover",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -68,16 +68,16 @@
|
|
|
68
68
|
]
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@aztec/bb.js": "0.
|
|
72
|
-
"@aztec/constants": "0.
|
|
73
|
-
"@aztec/foundation": "0.
|
|
74
|
-
"@aztec/noir-noirc_abi": "0.
|
|
75
|
-
"@aztec/noir-protocol-circuits-types": "0.
|
|
76
|
-
"@aztec/noir-types": "0.
|
|
77
|
-
"@aztec/simulator": "0.
|
|
78
|
-
"@aztec/stdlib": "0.
|
|
79
|
-
"@aztec/telemetry-client": "0.
|
|
80
|
-
"@aztec/world-state": "0.
|
|
71
|
+
"@aztec/bb.js": "0.85.0",
|
|
72
|
+
"@aztec/constants": "0.85.0",
|
|
73
|
+
"@aztec/foundation": "0.85.0",
|
|
74
|
+
"@aztec/noir-noirc_abi": "0.85.0",
|
|
75
|
+
"@aztec/noir-protocol-circuits-types": "0.85.0",
|
|
76
|
+
"@aztec/noir-types": "0.85.0",
|
|
77
|
+
"@aztec/simulator": "0.85.0",
|
|
78
|
+
"@aztec/stdlib": "0.85.0",
|
|
79
|
+
"@aztec/telemetry-client": "0.85.0",
|
|
80
|
+
"@aztec/world-state": "0.85.0",
|
|
81
81
|
"@msgpack/msgpack": "^3.0.0-beta2",
|
|
82
82
|
"commander": "^12.1.0",
|
|
83
83
|
"pako": "^2.1.0",
|
|
@@ -85,13 +85,12 @@
|
|
|
85
85
|
"tslib": "^2.4.0"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
|
-
"@aztec/ethereum": "0.
|
|
89
|
-
"@aztec/kv-store": "0.
|
|
90
|
-
"@aztec/noir-contracts.js": "0.
|
|
91
|
-
"@aztec/protocol-contracts": "0.
|
|
88
|
+
"@aztec/ethereum": "0.85.0",
|
|
89
|
+
"@aztec/kv-store": "0.85.0",
|
|
90
|
+
"@aztec/noir-contracts.js": "0.85.0",
|
|
91
|
+
"@aztec/protocol-contracts": "0.85.0",
|
|
92
92
|
"@jest/globals": "^29.5.0",
|
|
93
93
|
"@types/jest": "^29.5.0",
|
|
94
|
-
"@types/memdown": "^3.0.0",
|
|
95
94
|
"@types/node": "^18.7.23",
|
|
96
95
|
"@types/source-map-support": "^0.5.10",
|
|
97
96
|
"jest": "^29.5.0",
|
|
@@ -138,13 +138,12 @@ export class AvmProvingTesterV2 extends PublicTxSimulationTester {
|
|
|
138
138
|
// TODO: Placeholder for now. They get ignored in C++.
|
|
139
139
|
const inputs = await makeAvmCircuitInputs();
|
|
140
140
|
|
|
141
|
-
const rawVkPath = path.join(proofRes.vkPath!, 'vk');
|
|
142
141
|
return await verifyAvmProofV2(
|
|
143
142
|
BB_PATH,
|
|
144
143
|
this.bbWorkingDirectory,
|
|
145
144
|
proofRes.proofPath!,
|
|
146
145
|
inputs.publicInputs,
|
|
147
|
-
|
|
146
|
+
proofRes.vkPath!,
|
|
148
147
|
this.logger,
|
|
149
148
|
);
|
|
150
149
|
}
|
package/src/bb/execute.ts
CHANGED
|
@@ -8,7 +8,6 @@ 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 } from '../prover/client_ivc_proof_utils.js';
|
|
12
11
|
|
|
13
12
|
export const VK_FILENAME = 'vk';
|
|
14
13
|
export const VK_FIELDS_FILENAME = 'vk_fields.json';
|
|
@@ -19,7 +18,7 @@ export const PROOF_FIELDS_FILENAME = 'proof_fields.json';
|
|
|
19
18
|
export const AVM_INPUTS_FILENAME = 'avm_inputs.bin';
|
|
20
19
|
export const AVM_BYTECODE_FILENAME = 'avm_bytecode.bin';
|
|
21
20
|
export const AVM_PUBLIC_INPUTS_FILENAME = 'avm_public_inputs.bin';
|
|
22
|
-
export const
|
|
21
|
+
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
23
22
|
|
|
24
23
|
export enum BB_RESULT {
|
|
25
24
|
SUCCESS,
|
|
@@ -123,6 +122,7 @@ export async function executeBbClientIvcProof(
|
|
|
123
122
|
bytecodeStackPath: string,
|
|
124
123
|
witnessStackPath: string,
|
|
125
124
|
log: LogFn,
|
|
125
|
+
writeVk = false,
|
|
126
126
|
): Promise<BBFailure | BBSuccess> {
|
|
127
127
|
// Check that the working directory exists
|
|
128
128
|
try {
|
|
@@ -158,8 +158,10 @@ export async function executeBbClientIvcProof(
|
|
|
158
158
|
'client_ivc',
|
|
159
159
|
'--input_type',
|
|
160
160
|
'runtime_stack',
|
|
161
|
-
'--write_vk',
|
|
162
161
|
];
|
|
162
|
+
if (writeVk) {
|
|
163
|
+
args.push('--write_vk');
|
|
164
|
+
}
|
|
163
165
|
|
|
164
166
|
const timer = new Timer();
|
|
165
167
|
const logFunction = (message: string) => {
|
|
@@ -423,7 +425,7 @@ export async function generateAvmProofV2(
|
|
|
423
425
|
durationMs: duration,
|
|
424
426
|
proofPath: join(outputPath, PROOF_FILENAME),
|
|
425
427
|
pkPath: undefined,
|
|
426
|
-
vkPath: outputPath,
|
|
428
|
+
vkPath: join(outputPath, VK_FILENAME),
|
|
427
429
|
};
|
|
428
430
|
}
|
|
429
431
|
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
@@ -462,7 +464,6 @@ export async function generateAvmProof(
|
|
|
462
464
|
|
|
463
465
|
// Paths for the inputs
|
|
464
466
|
const publicInputsPath = join(workingDirectory, AVM_PUBLIC_INPUTS_FILENAME);
|
|
465
|
-
const avmHintsPath = join(workingDirectory, AVM_HINTS_FILENAME);
|
|
466
467
|
|
|
467
468
|
// The proof is written to e.g. /workingDirectory/proof
|
|
468
469
|
const outputPath = workingDirectory;
|
|
@@ -492,7 +493,7 @@ export async function generateAvmProof(
|
|
|
492
493
|
// return { status: BB_RESULT.FAILURE, reason: `Could not write avmHints at ${avmHintsPath}` };
|
|
493
494
|
// }
|
|
494
495
|
|
|
495
|
-
const args = ['--avm-public-inputs', publicInputsPath, '
|
|
496
|
+
const args = ['--avm-public-inputs', publicInputsPath, '-o', outputPath];
|
|
496
497
|
const loggingArg =
|
|
497
498
|
logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '';
|
|
498
499
|
if (loggingArg !== '') {
|
package/src/index.ts
CHANGED
|
@@ -4,5 +4,6 @@ export * from './verifier/index.js';
|
|
|
4
4
|
export * from './config.js';
|
|
5
5
|
export * from './bb/execute.js';
|
|
6
6
|
export * from './honk.js';
|
|
7
|
+
export * from './verification_key/verification_key_data.js';
|
|
7
8
|
|
|
8
9
|
export { type ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
@@ -13,7 +13,7 @@ import path from 'path';
|
|
|
13
13
|
import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../bb/execute.js';
|
|
14
14
|
import type { BBConfig } from '../config.js';
|
|
15
15
|
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
16
|
-
import {
|
|
16
|
+
import { readClientIVCProofFromOutputDirectory } from './proof_utils.js';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* This proof creator implementation uses the native bb binary.
|
|
@@ -73,7 +73,7 @@ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
|
73
73
|
throw new Error(provingResult.reason);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
const proof = await
|
|
76
|
+
const proof = await readClientIVCProofFromOutputDirectory(directory);
|
|
77
77
|
|
|
78
78
|
this.log.info(`Generated IVC proof`, {
|
|
79
79
|
duration: provingResult.durationMs,
|
package/src/prover/bb_prover.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import {
|
|
3
3
|
AGGREGATION_OBJECT_LENGTH,
|
|
4
4
|
AVM_PROOF_LENGTH_IN_FIELDS,
|
|
5
|
-
IPA_CLAIM_LENGTH,
|
|
6
5
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
7
6
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
8
7
|
RECURSIVE_PROOF_LENGTH,
|
|
@@ -69,7 +68,6 @@ import type { CircuitProvingStats, CircuitWitnessGenerationStats } from '@aztec/
|
|
|
69
68
|
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
70
69
|
import { Attributes, type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
71
70
|
|
|
72
|
-
import assert from 'assert';
|
|
73
71
|
import crypto from 'crypto';
|
|
74
72
|
import { promises as fs } from 'fs';
|
|
75
73
|
import * as path from 'path';
|
|
@@ -78,7 +76,6 @@ import {
|
|
|
78
76
|
type BBFailure,
|
|
79
77
|
type BBSuccess,
|
|
80
78
|
BB_RESULT,
|
|
81
|
-
PROOF_FIELDS_FILENAME,
|
|
82
79
|
PROOF_FILENAME,
|
|
83
80
|
PUBLIC_INPUTS_FILENAME,
|
|
84
81
|
VK_FILENAME,
|
|
@@ -94,7 +91,7 @@ import { ProverInstrumentation } from '../instrumentation.js';
|
|
|
94
91
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
95
92
|
import { extractAvmVkData, extractVkData } from '../verification_key/verification_key_data.js';
|
|
96
93
|
import { PRIVATE_TAIL_CIVC_VK, PUBLIC_TAIL_CIVC_VK } from '../verifier/bb_verifier.js';
|
|
97
|
-
import {
|
|
94
|
+
import { readProofAsFields, writeClientIVCProofToOutputDirectory } from './proof_utils.js';
|
|
98
95
|
|
|
99
96
|
const logger = createLogger('bb-prover');
|
|
100
97
|
|
|
@@ -183,7 +180,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
183
180
|
* @returns The proof.
|
|
184
181
|
*/
|
|
185
182
|
@trackSpan('BBNativeRollupProver.getAvmProof', inputs => ({
|
|
186
|
-
[Attributes.APP_CIRCUIT_NAME]: inputs.
|
|
183
|
+
[Attributes.APP_CIRCUIT_NAME]: inputs.hints.tx.hash,
|
|
187
184
|
}))
|
|
188
185
|
public async getAvmProof(
|
|
189
186
|
inputs: AvmCircuitInputs,
|
|
@@ -476,7 +473,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
476
473
|
bbWorkingDirectory,
|
|
477
474
|
);
|
|
478
475
|
const vkData = this.getVerificationKeyDataForCircuit(circuitType);
|
|
479
|
-
const proof = await
|
|
476
|
+
const proof = await readProofAsFields(provingResult.proofPath!, vkData, RECURSIVE_PROOF_LENGTH, logger);
|
|
480
477
|
|
|
481
478
|
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
482
479
|
|
|
@@ -503,12 +500,12 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
503
500
|
}
|
|
504
501
|
|
|
505
502
|
private async generateAvmProofWithBB(input: AvmCircuitInputs, workingDirectory: string): Promise<BBSuccess> {
|
|
506
|
-
logger.info(`Proving avm-circuit for ${input.
|
|
503
|
+
logger.info(`Proving avm-circuit for TX ${input.hints.tx.hash}...`);
|
|
507
504
|
|
|
508
505
|
const provingResult = await generateAvmProof(this.config.bbBinaryPath, workingDirectory, input, logger);
|
|
509
506
|
|
|
510
507
|
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
511
|
-
logger.error(`Failed to generate AVM proof for ${input.
|
|
508
|
+
logger.error(`Failed to generate AVM proof for TX ${input.hints.tx.hash}: ${provingResult.reason}`);
|
|
512
509
|
throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
|
|
513
510
|
}
|
|
514
511
|
|
|
@@ -521,7 +518,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
521
518
|
const hasher = crypto.createHash('sha256');
|
|
522
519
|
hasher.update(input.toBuffer());
|
|
523
520
|
|
|
524
|
-
await
|
|
521
|
+
await writeClientIVCProofToOutputDirectory(input.clientIVCData, bbWorkingDirectory);
|
|
525
522
|
const provingResult = await generateTubeProof(
|
|
526
523
|
this.config.bbBinaryPath,
|
|
527
524
|
bbWorkingDirectory,
|
|
@@ -556,10 +553,10 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
556
553
|
this.instrumentation.recordAvmSize('circuitSize', appCircuitName, verificationKey.circuitSize);
|
|
557
554
|
|
|
558
555
|
logger.info(
|
|
559
|
-
`Generated proof for ${circuitType}(${input.
|
|
556
|
+
`Generated proof for ${circuitType}(${input.hints.tx.hash}) in ${Math.ceil(provingResult.durationMs)} ms`,
|
|
560
557
|
{
|
|
561
558
|
circuitName: circuitType,
|
|
562
|
-
appCircuitName: input.
|
|
559
|
+
appCircuitName: input.hints.tx.hash,
|
|
563
560
|
// does not include reading the proof from disk
|
|
564
561
|
duration: provingResult.durationMs,
|
|
565
562
|
proofSize: avmProof.binaryProof.buffer.length,
|
|
@@ -583,7 +580,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
583
580
|
// Read the proof as fields
|
|
584
581
|
// TODO(AD): this is the only remaining use of extractVkData.
|
|
585
582
|
const tubeVK = await extractVkData(provingResult.vkPath!);
|
|
586
|
-
const tubeProof = await
|
|
583
|
+
const tubeProof = await readProofAsFields(provingResult.proofPath!, tubeVK, TUBE_PROOF_LENGTH, logger);
|
|
587
584
|
|
|
588
585
|
this.instrumentation.recordDuration('provingDuration', 'tubeCircuit', provingResult.durationMs);
|
|
589
586
|
this.instrumentation.recordSize('proofSize', 'tubeCircuit', tubeProof.binaryProof.buffer.length);
|
|
@@ -636,7 +633,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
636
633
|
|
|
637
634
|
const vkData = this.getVerificationKeyDataForCircuit(circuitType);
|
|
638
635
|
// Read the proof as fields
|
|
639
|
-
const proof = await
|
|
636
|
+
const proof = await readProofAsFields(provingResult.proofPath!, vkData, proofLength, logger);
|
|
640
637
|
|
|
641
638
|
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
642
639
|
this.instrumentation.recordDuration('provingDuration', circuitName, provingResult.durationMs);
|
|
@@ -728,54 +725,6 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
728
725
|
return vk;
|
|
729
726
|
}
|
|
730
727
|
|
|
731
|
-
private async readProofAsFields<PROOF_LENGTH extends number>(
|
|
732
|
-
filePath: string,
|
|
733
|
-
vkData: VerificationKeyData,
|
|
734
|
-
proofLength: PROOF_LENGTH,
|
|
735
|
-
): Promise<RecursiveProof<PROOF_LENGTH>> {
|
|
736
|
-
const publicInputsFilename = path.join(filePath, PUBLIC_INPUTS_FILENAME);
|
|
737
|
-
const proofFilename = path.join(filePath, PROOF_FILENAME);
|
|
738
|
-
const proofFieldsFilename = path.join(filePath, PROOF_FIELDS_FILENAME);
|
|
739
|
-
|
|
740
|
-
const [binaryPublicInputs, binaryProof, proofString] = await Promise.all([
|
|
741
|
-
fs.readFile(publicInputsFilename),
|
|
742
|
-
fs.readFile(proofFilename),
|
|
743
|
-
fs.readFile(proofFieldsFilename, { encoding: 'utf-8' }),
|
|
744
|
-
]);
|
|
745
|
-
|
|
746
|
-
const json = JSON.parse(proofString);
|
|
747
|
-
|
|
748
|
-
let numPublicInputs = vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
749
|
-
assert(
|
|
750
|
-
proofLength == NESTED_RECURSIVE_PROOF_LENGTH || proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
751
|
-
`Proof length must be one of the expected proof lengths, received ${proofLength}`,
|
|
752
|
-
);
|
|
753
|
-
if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
|
|
754
|
-
numPublicInputs -= IPA_CLAIM_LENGTH;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
assert(json.length == proofLength, `Proof length mismatch: ${json.length} != ${proofLength}`);
|
|
758
|
-
|
|
759
|
-
const fieldsWithoutPublicInputs = json.map(Fr.fromHexString);
|
|
760
|
-
|
|
761
|
-
// Concat binary public inputs and binary proof
|
|
762
|
-
// This buffer will have the form: [binary public inputs, binary proof]
|
|
763
|
-
const binaryProofWithPublicInputs = Buffer.concat([binaryPublicInputs, binaryProof]);
|
|
764
|
-
logger.debug(
|
|
765
|
-
`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProofWithPublicInputs.length}`,
|
|
766
|
-
);
|
|
767
|
-
assert(
|
|
768
|
-
binaryProofWithPublicInputs.length == numPublicInputs * 32 + proofLength * 32,
|
|
769
|
-
`Proof length mismatch: ${binaryProofWithPublicInputs.length} != ${numPublicInputs * 32 + proofLength * 32}`,
|
|
770
|
-
);
|
|
771
|
-
return new RecursiveProof(
|
|
772
|
-
fieldsWithoutPublicInputs,
|
|
773
|
-
new Proof(binaryProofWithPublicInputs, numPublicInputs),
|
|
774
|
-
true,
|
|
775
|
-
proofLength,
|
|
776
|
-
);
|
|
777
|
-
}
|
|
778
|
-
|
|
779
728
|
private async readAvmProofAsFields(
|
|
780
729
|
proofFilename: string,
|
|
781
730
|
vkData: VerificationKeyData,
|
package/src/prover/index.ts
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AGGREGATION_OBJECT_LENGTH,
|
|
3
|
+
IPA_CLAIM_LENGTH,
|
|
4
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
5
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
6
|
+
} from '@aztec/constants';
|
|
7
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
8
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
9
|
+
import { ClientIvcProof, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
10
|
+
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
11
|
+
|
|
12
|
+
import assert from 'assert';
|
|
13
|
+
import { promises as fs } from 'fs';
|
|
14
|
+
import * as path from 'path';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
CLIENT_IVC_PROOF_FILE_NAME,
|
|
18
|
+
PROOF_FIELDS_FILENAME,
|
|
19
|
+
PROOF_FILENAME,
|
|
20
|
+
PUBLIC_INPUTS_FILENAME,
|
|
21
|
+
} from '../bb/execute.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a ClientIvcProof proof file.
|
|
25
|
+
*
|
|
26
|
+
* @param directory the directory to read the proof from.
|
|
27
|
+
* @returns the encapsulated client ivc proof
|
|
28
|
+
*/
|
|
29
|
+
export async function readClientIVCProofFromOutputDirectory(directory: string) {
|
|
30
|
+
const clientIvcProofBuffer = await fs.readFile(path.join(directory, CLIENT_IVC_PROOF_FILE_NAME));
|
|
31
|
+
return new ClientIvcProof(clientIvcProofBuffer);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Serialize a ClientIvcProof to a proof file.
|
|
36
|
+
*
|
|
37
|
+
* @param proof the ClientIvcProof from object
|
|
38
|
+
* @param directory the directory to write in
|
|
39
|
+
*/
|
|
40
|
+
export async function writeClientIVCProofToOutputDirectory(clientIvcProof: ClientIvcProof, directory: string) {
|
|
41
|
+
const { clientIvcProofBuffer } = clientIvcProof;
|
|
42
|
+
await fs.writeFile(path.join(directory, CLIENT_IVC_PROOF_FILE_NAME), clientIvcProofBuffer);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function readProofAsFields<PROOF_LENGTH extends number>(
|
|
46
|
+
filePath: string,
|
|
47
|
+
vkData: VerificationKeyData,
|
|
48
|
+
proofLength: PROOF_LENGTH,
|
|
49
|
+
logger: Logger,
|
|
50
|
+
): Promise<RecursiveProof<PROOF_LENGTH>> {
|
|
51
|
+
const publicInputsFilename = path.join(filePath, PUBLIC_INPUTS_FILENAME);
|
|
52
|
+
const proofFilename = path.join(filePath, PROOF_FILENAME);
|
|
53
|
+
const proofFieldsFilename = path.join(filePath, PROOF_FIELDS_FILENAME);
|
|
54
|
+
|
|
55
|
+
const [binaryPublicInputs, binaryProof, proofString] = await Promise.all([
|
|
56
|
+
fs.readFile(publicInputsFilename),
|
|
57
|
+
fs.readFile(proofFilename),
|
|
58
|
+
fs.readFile(proofFieldsFilename, { encoding: 'utf-8' }),
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
const json = JSON.parse(proofString);
|
|
62
|
+
|
|
63
|
+
let numPublicInputs = vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
64
|
+
assert(
|
|
65
|
+
proofLength == NESTED_RECURSIVE_PROOF_LENGTH || proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
66
|
+
`Proof length must be one of the expected proof lengths, received ${proofLength}`,
|
|
67
|
+
);
|
|
68
|
+
if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
|
|
69
|
+
numPublicInputs -= IPA_CLAIM_LENGTH;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
assert(json.length == proofLength, `Proof length mismatch: ${json.length} != ${proofLength}`);
|
|
73
|
+
|
|
74
|
+
const fieldsWithoutPublicInputs = json.map(Fr.fromHexString);
|
|
75
|
+
|
|
76
|
+
// Concat binary public inputs and binary proof
|
|
77
|
+
// This buffer will have the form: [binary public inputs, binary proof]
|
|
78
|
+
const binaryProofWithPublicInputs = Buffer.concat([binaryPublicInputs, binaryProof]);
|
|
79
|
+
logger.debug(
|
|
80
|
+
`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProofWithPublicInputs.length}`,
|
|
81
|
+
);
|
|
82
|
+
assert(
|
|
83
|
+
binaryProofWithPublicInputs.length == numPublicInputs * 32 + proofLength * 32,
|
|
84
|
+
`Proof length mismatch: ${binaryProofWithPublicInputs.length} != ${numPublicInputs * 32 + proofLength * 32}`,
|
|
85
|
+
);
|
|
86
|
+
return new RecursiveProof(
|
|
87
|
+
fieldsWithoutPublicInputs,
|
|
88
|
+
new Proof(binaryProofWithPublicInputs, numPublicInputs),
|
|
89
|
+
true,
|
|
90
|
+
proofLength,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
@@ -15,7 +15,7 @@ import { fileURLToPath } from 'url';
|
|
|
15
15
|
import { BB_RESULT, PROOF_FILENAME, VK_FILENAME, verifyClientIvcProof, verifyProof } from '../bb/execute.js';
|
|
16
16
|
import type { BBConfig } from '../config.js';
|
|
17
17
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
18
|
-
import {
|
|
18
|
+
import { writeClientIVCProofToOutputDirectory } from '../prover/proof_utils.js';
|
|
19
19
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
20
20
|
|
|
21
21
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -91,7 +91,7 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
91
91
|
this.logger.debug(`${circuit} BB out - ${message}`);
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
await
|
|
94
|
+
await writeClientIVCProofToOutputDirectory(tx.clientIvcProof, bbWorkingDirectory);
|
|
95
95
|
const result = await verifyClientIvcProof(
|
|
96
96
|
this.config.bbBinaryPath,
|
|
97
97
|
bbWorkingDirectory.concat('/proof'),
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
2
|
-
export declare const CLIENT_IVC_PROOF_FILE_NAME = "proof";
|
|
3
|
-
/**
|
|
4
|
-
* Create a ClientIvcProof proof file.
|
|
5
|
-
*
|
|
6
|
-
* @param directory the directory to read the proof from.
|
|
7
|
-
* @returns the encapsulated client ivc proof
|
|
8
|
-
*/
|
|
9
|
-
export declare function readFromOutputDirectory(directory: string): Promise<ClientIvcProof>;
|
|
10
|
-
/**
|
|
11
|
-
* Serialize a ClientIvcProof to a proof file.
|
|
12
|
-
*
|
|
13
|
-
* @param proof the ClientIvcProof from object
|
|
14
|
-
* @param directory the directory to write in
|
|
15
|
-
*/
|
|
16
|
-
export declare function writeToOutputDirectory(clientIvcProof: ClientIvcProof, directory: string): Promise<void>;
|
|
17
|
-
//# sourceMappingURL=client_ivc_proof_utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,22 +0,0 @@
|
|
|
1
|
-
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
2
|
-
import { promises as fs } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
5
|
-
/**
|
|
6
|
-
* Create a ClientIvcProof proof file.
|
|
7
|
-
*
|
|
8
|
-
* @param directory the directory to read the proof from.
|
|
9
|
-
* @returns the encapsulated client ivc proof
|
|
10
|
-
*/ export async function readFromOutputDirectory(directory) {
|
|
11
|
-
const clientIvcProofBuffer = await fs.readFile(join(directory, CLIENT_IVC_PROOF_FILE_NAME));
|
|
12
|
-
return new ClientIvcProof(clientIvcProofBuffer);
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Serialize a ClientIvcProof to a proof file.
|
|
16
|
-
*
|
|
17
|
-
* @param proof the ClientIvcProof from object
|
|
18
|
-
* @param directory the directory to write in
|
|
19
|
-
*/ export async function writeToOutputDirectory(clientIvcProof, directory) {
|
|
20
|
-
const { clientIvcProofBuffer } = clientIvcProof;
|
|
21
|
-
await fs.writeFile(join(directory, CLIENT_IVC_PROOF_FILE_NAME), clientIvcProofBuffer);
|
|
22
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
2
|
-
|
|
3
|
-
import { promises as fs } from 'fs';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
|
|
6
|
-
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Create a ClientIvcProof proof file.
|
|
10
|
-
*
|
|
11
|
-
* @param directory the directory to read the proof from.
|
|
12
|
-
* @returns the encapsulated client ivc proof
|
|
13
|
-
*/
|
|
14
|
-
export async function readFromOutputDirectory(directory: string) {
|
|
15
|
-
const clientIvcProofBuffer = await fs.readFile(join(directory, CLIENT_IVC_PROOF_FILE_NAME));
|
|
16
|
-
return new ClientIvcProof(clientIvcProofBuffer);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Serialize a ClientIvcProof to a proof file.
|
|
21
|
-
*
|
|
22
|
-
* @param proof the ClientIvcProof from object
|
|
23
|
-
* @param directory the directory to write in
|
|
24
|
-
*/
|
|
25
|
-
export async function writeToOutputDirectory(clientIvcProof: ClientIvcProof, directory: string) {
|
|
26
|
-
const { clientIvcProofBuffer } = clientIvcProof;
|
|
27
|
-
await fs.writeFile(join(directory, CLIENT_IVC_PROOF_FILE_NAME), clientIvcProofBuffer);
|
|
28
|
-
}
|