@aztec/bb-prover 0.0.1-fake-ceab37513c → 0.0.2-commit.217f559981
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 +7 -6
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +38 -15
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/execute.d.ts +9 -17
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +74 -165
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +1 -1
- package/dest/honk.d.ts +2 -2
- package/dest/honk.js +2 -2
- package/dest/index.d.ts +1 -1
- package/dest/instrumentation.d.ts +3 -3
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +21 -43
- package/dest/prover/client/bb_private_kernel_prover.d.ts +12 -6
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +38 -7
- package/dest/prover/client/bundle.d.ts +6 -0
- package/dest/prover/client/bundle.d.ts.map +1 -0
- package/dest/prover/client/bundle.js +7 -0
- package/dest/prover/client/lazy.d.ts +6 -0
- package/dest/prover/client/lazy.d.ts.map +1 -0
- package/dest/prover/client/lazy.js +7 -0
- package/dest/prover/index.d.ts +1 -1
- package/dest/prover/proof_utils.d.ts +9 -9
- package/dest/prover/proof_utils.d.ts.map +1 -1
- package/dest/prover/proof_utils.js +42 -25
- package/dest/prover/server/bb_prover.d.ts +27 -50
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +478 -182
- package/dest/test/delay_values.d.ts +1 -1
- package/dest/test/delay_values.d.ts.map +1 -1
- package/dest/test/delay_values.js +37 -25
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -0
- package/dest/test/test_circuit_prover.d.ts +24 -34
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +506 -85
- package/dest/test/test_verifier.d.ts +3 -1
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +15 -0
- package/dest/verification_key/verification_key_data.d.ts +1 -8
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +1 -20
- package/dest/verifier/bb_verifier.d.ts +3 -5
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +23 -28
- package/dest/verifier/index.d.ts +2 -2
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -1
- package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/{queued_ivc_verifier.js → queued_chonk_verifier.js} +10 -41
- package/package.json +23 -23
- package/src/avm_proving_tests/avm_proving_tester.ts +49 -35
- package/src/bb/execute.ts +50 -148
- package/src/honk.ts +1 -1
- package/src/instrumentation.ts +22 -45
- package/src/prover/client/bb_private_kernel_prover.ts +50 -10
- package/src/prover/client/bundle.ts +10 -0
- package/src/prover/client/lazy.ts +10 -0
- package/src/prover/proof_utils.ts +53 -31
- package/src/prover/server/bb_prover.ts +252 -324
- package/src/test/delay_values.ts +38 -24
- package/src/test/index.ts +1 -0
- package/src/test/test_circuit_prover.ts +229 -155
- package/src/test/test_verifier.ts +8 -0
- package/src/verification_key/verification_key_data.ts +1 -26
- package/src/verifier/bb_verifier.ts +33 -36
- package/src/verifier/index.ts +1 -1
- package/src/verifier/{queued_ivc_verifier.ts → queued_chonk_verifier.ts} +10 -41
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts +0 -23
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/client/native/bb_native_private_kernel_prover.js +0 -66
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts +0 -15
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.js +0 -48
- package/dest/prover/client/wasm/bundle.d.ts +0 -6
- package/dest/prover/client/wasm/bundle.d.ts.map +0 -1
- package/dest/prover/client/wasm/bundle.js +0 -8
- package/dest/prover/client/wasm/lazy.d.ts +0 -6
- package/dest/prover/client/wasm/lazy.d.ts.map +0 -1
- package/dest/prover/client/wasm/lazy.js +0 -8
- package/dest/stats.d.ts +0 -4
- package/dest/stats.d.ts.map +0 -1
- package/dest/stats.js +0 -45
- package/dest/verifier/queued_ivc_verifier.d.ts +0 -15
- package/dest/verifier/queued_ivc_verifier.d.ts.map +0 -1
- package/src/prover/client/native/bb_native_private_kernel_prover.ts +0 -105
- package/src/prover/client/wasm/bb_wasm_private_kernel_prover.ts +0 -60
- package/src/prover/client/wasm/bundle.ts +0 -11
- package/src/prover/client/wasm/lazy.ts +0 -11
- package/src/stats.ts +0 -47
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
export declare class TestCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
4
|
+
private verificationDelayMs?;
|
|
5
|
+
constructor(verificationDelayMs?: number | undefined);
|
|
4
6
|
verifyProof(_tx: Tx): Promise<IVCProofVerificationResult>;
|
|
5
7
|
stop(): Promise<void>;
|
|
6
8
|
}
|
|
7
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF92ZXJpZmllci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvdGVzdF92ZXJpZmllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSw2QkFBNkIsRUFBRSwwQkFBMEIsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pILE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTNDLHFCQUFhLG1CQUFvQixZQUFXLDZCQUE2QjtJQUMzRCxPQUFPLENBQUMsbUJBQW1CLENBQUM7SUFBeEMsWUFBb0IsbUJBQW1CLENBQUMsb0JBQVEsRUFBSTtJQUNwRCxXQUFXLENBQUMsR0FBRyxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsMEJBQTBCLENBQUMsQ0FTeEQ7SUFFTSxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUUzQjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_verifier.d.ts","sourceRoot":"","sources":["../../src/test/test_verifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,mBAAoB,YAAW,6BAA6B;
|
|
1
|
+
{"version":3,"file":"test_verifier.d.ts","sourceRoot":"","sources":["../../src/test/test_verifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,mBAAoB,YAAW,6BAA6B;IAC3D,OAAO,CAAC,mBAAmB,CAAC;IAAxC,YAAoB,mBAAmB,CAAC,oBAAQ,EAAI;IACpD,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CASxD;IAEM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;CACF"}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
export class TestCircuitVerifier {
|
|
2
|
+
verificationDelayMs;
|
|
3
|
+
constructor(verificationDelayMs){
|
|
4
|
+
this.verificationDelayMs = verificationDelayMs;
|
|
5
|
+
}
|
|
2
6
|
verifyProof(_tx) {
|
|
7
|
+
if (this.verificationDelayMs !== undefined && this.verificationDelayMs > 0) {
|
|
8
|
+
return new Promise((resolve)=>{
|
|
9
|
+
setTimeout(()=>{
|
|
10
|
+
resolve({
|
|
11
|
+
valid: true,
|
|
12
|
+
durationMs: this.verificationDelayMs,
|
|
13
|
+
totalDurationMs: this.verificationDelayMs
|
|
14
|
+
});
|
|
15
|
+
}, this.verificationDelayMs);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
3
18
|
return Promise.resolve({
|
|
4
19
|
valid: true,
|
|
5
20
|
durationMs: 0,
|
|
@@ -5,11 +5,4 @@ import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
|
5
5
|
* @returns The verification key data
|
|
6
6
|
*/
|
|
7
7
|
export declare function extractVkData(vkDirectoryPath: string): Promise<VerificationKeyData>;
|
|
8
|
-
|
|
9
|
-
* Reads the verification key data stored in a binary file at the specified directory location and parses into a VerificationKeyData.
|
|
10
|
-
* We do not assume any JSON file available but only the binary version, contrary to the above extractVkData() method.
|
|
11
|
-
* @param vkDirectoryPath - The directory containing the verification key binary data file.
|
|
12
|
-
* @returns The verification key data
|
|
13
|
-
*/
|
|
14
|
-
export declare function extractAvmVkData(vkDirectoryPath: string): Promise<VerificationKeyData>;
|
|
15
|
-
//# sourceMappingURL=verification_key_data.d.ts.map
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyaWZpY2F0aW9uX2tleV9kYXRhLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpY2F0aW9uX2tleS92ZXJpZmljYXRpb25fa2V5X2RhdGEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUEyQixtQkFBbUIsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBT2pGOzs7O0dBSUc7QUFDSCx3QkFBc0IsYUFBYSxDQUFDLGVBQWUsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBVXpGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification_key_data.d.ts","sourceRoot":"","sources":["../../src/verification_key/verification_key_data.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verification_key_data.d.ts","sourceRoot":"","sources":["../../src/verification_key/verification_key_data.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAOjF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAUzF"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
4
3
|
import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
|
|
5
|
-
import { strict as assert } from 'assert';
|
|
6
4
|
import { promises as fs } from 'fs';
|
|
7
5
|
import * as path from 'path';
|
|
8
6
|
import { VK_FILENAME } from '../bb/execute.js';
|
|
@@ -19,20 +17,3 @@ import { VK_FILENAME } from '../bb/execute.js';
|
|
|
19
17
|
const vkAsFields = await VerificationKeyAsFields.fromKey(fields);
|
|
20
18
|
return new VerificationKeyData(vkAsFields, rawBinary);
|
|
21
19
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Reads the verification key data stored in a binary file at the specified directory location and parses into a VerificationKeyData.
|
|
24
|
-
* We do not assume any JSON file available but only the binary version, contrary to the above extractVkData() method.
|
|
25
|
-
* @param vkDirectoryPath - The directory containing the verification key binary data file.
|
|
26
|
-
* @returns The verification key data
|
|
27
|
-
*/ export async function extractAvmVkData(vkDirectoryPath) {
|
|
28
|
-
const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
|
|
29
|
-
const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
|
|
30
|
-
assert(numFields <= AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED, 'Invalid AVM verification key length');
|
|
31
|
-
const reader = BufferReader.asReader(rawBinary);
|
|
32
|
-
const fieldsArray = reader.readArray(numFields, Fr);
|
|
33
|
-
const fieldsArrayPadded = fieldsArray.concat(Array(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED - fieldsArray.length).fill(new Fr(0)));
|
|
34
|
-
const vkAsFields = await VerificationKeyAsFields.fromKey(fieldsArrayPadded);
|
|
35
|
-
// TODO(#16644): We should have a different type for AVM verification keys since we don't have circuit size or num public inputs in AVM VKs.
|
|
36
|
-
const vk = new VerificationKeyData(vkAsFields, rawBinary);
|
|
37
|
-
return vk;
|
|
38
|
-
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import type
|
|
2
|
+
import { type ProtocolArtifact, type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
3
3
|
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
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;
|
|
10
8
|
export declare class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
11
9
|
private config;
|
|
12
10
|
private logger;
|
|
13
11
|
private constructor();
|
|
14
12
|
stop(): Promise<void>;
|
|
15
13
|
static new(config: BBConfig, logger?: Logger): Promise<BBCircuitVerifier>;
|
|
16
|
-
getVerificationKeyData(
|
|
14
|
+
getVerificationKeyData(circuit: ProtocolArtifact): VerificationKeyData;
|
|
17
15
|
verifyProofForCircuit(circuit: ServerProtocolArtifact, proof: Proof): Promise<void>;
|
|
18
16
|
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
19
17
|
}
|
|
20
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmJfdmVyaWZpZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9iYl92ZXJpZmllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFHbEUsT0FBTyxFQUVMLEtBQUssZ0JBQWdCLEVBQ3JCLEtBQUssc0JBQXNCLEVBRTVCLE1BQU0sMkNBQTJDLENBQUM7QUFDbkQsT0FBTyxLQUFLLEVBQUUsNkJBQTZCLEVBQUUsMEJBQTBCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqSCxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUVsRCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDdEMsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQWE3RCxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFJN0MscUJBQWEsaUJBQWtCLFlBQVcsNkJBQTZCO0lBRW5FLE9BQU8sQ0FBQyxNQUFNO0lBQ2QsT0FBTyxDQUFDLE1BQU07SUFGaEIsT0FBTyxlQUdIO0lBRUcsSUFBSSxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFM0I7SUFFRCxPQUFvQixHQUFHLENBQUMsTUFBTSxFQUFFLFFBQVEsRUFBRSxNQUFNLFNBQXFDLDhCQU1wRjtJQUVNLHNCQUFzQixDQUFDLE9BQU8sRUFBRSxnQkFBZ0IsR0FBRyxtQkFBbUIsQ0FNNUU7SUFFWSxxQkFBcUIsQ0FBQyxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsS0FBSyxFQUFFLEtBQUssaUJBbUMvRTtJQUVZLFdBQVcsQ0FBQyxFQUFFLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQywwQkFBMEIsQ0FBQyxDQTZDcEU7Q0FDRiJ9
|
|
@@ -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;AAGlE,OAAO,KAAK,
|
|
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;AAGlE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,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;AAa7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAI7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAEnE,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IAFhB,OAAO,eAGH;IAEG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED,OAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAqC,8BAMpF;IAEM,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,CAM5E;IAEY,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK,iBAmC/E;IAEY,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA6CpE;CACF"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
-
import {
|
|
4
|
+
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
5
|
+
import { mapProtocolArtifactNameToCircuitName } from '@aztec/noir-protocol-circuits-types/types';
|
|
5
6
|
import { promises as fs } from 'fs';
|
|
6
7
|
import * as path from 'path';
|
|
7
|
-
import {
|
|
8
|
-
import { BB_RESULT, PROOF_FILENAME, PUBLIC_INPUTS_FILENAME, VK_FILENAME, verifyClientIvcProof, verifyProof } from '../bb/execute.js';
|
|
8
|
+
import { BB_RESULT, PROOF_FILENAME, PUBLIC_INPUTS_FILENAME, VK_FILENAME, verifyChonkProof, verifyProof } from '../bb/execute.js';
|
|
9
9
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
10
|
-
import {
|
|
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');
|
|
10
|
+
import { writeChonkProofToPath } from '../prover/proof_utils.js';
|
|
16
11
|
export class BBCircuitVerifier {
|
|
17
12
|
config;
|
|
18
13
|
logger;
|
|
@@ -24,15 +19,18 @@ export class BBCircuitVerifier {
|
|
|
24
19
|
return Promise.resolve();
|
|
25
20
|
}
|
|
26
21
|
static async new(config, logger = createLogger('bb-prover:verifier')) {
|
|
22
|
+
if (!config.bbWorkingDirectory) {
|
|
23
|
+
throw new Error(`Barretenberg working directory (BB_WORKING_DIRECTORY) is not set`);
|
|
24
|
+
}
|
|
27
25
|
await fs.mkdir(config.bbWorkingDirectory, {
|
|
28
26
|
recursive: true
|
|
29
27
|
});
|
|
30
28
|
return new BBCircuitVerifier(config, logger);
|
|
31
29
|
}
|
|
32
|
-
getVerificationKeyData(
|
|
33
|
-
const vk =
|
|
30
|
+
getVerificationKeyData(circuit) {
|
|
31
|
+
const vk = ProtocolCircuitVks[circuit];
|
|
34
32
|
if (vk === undefined) {
|
|
35
|
-
throw new Error(
|
|
33
|
+
throw new Error(`Could not find VK for artifact ${circuit}`);
|
|
36
34
|
}
|
|
37
35
|
return vk;
|
|
38
36
|
}
|
|
@@ -62,33 +60,30 @@ export class BBCircuitVerifier {
|
|
|
62
60
|
await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
|
|
63
61
|
}
|
|
64
62
|
async verifyProof(tx) {
|
|
63
|
+
const proofType = 'Chonk';
|
|
65
64
|
try {
|
|
66
65
|
const totalTimer = new Timer();
|
|
67
66
|
let verificationDuration = 0;
|
|
68
|
-
|
|
69
|
-
// rather than read from the tx object itself. We also need the vks for the translator and ecc, which
|
|
70
|
-
// are not being saved along the other vks yet. Reuse the 'verifyProofForCircuit' method above once
|
|
71
|
-
// we have all the verification keys available.
|
|
72
|
-
const expectedCircuit = tx.data.forPublic ? 'PrivateKernelTailToPublicArtifact' : 'PrivateKernelTailArtifact';
|
|
73
|
-
const circuit = 'ClientIVC';
|
|
67
|
+
const circuit = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
|
|
74
68
|
// Block below is almost copy-pasted from verifyProofForCircuit
|
|
75
69
|
const operation = async (bbWorkingDirectory)=>{
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
71
|
+
await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
|
|
72
|
+
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
73
|
+
const verificationKey = this.getVerificationKeyData(circuit);
|
|
74
|
+
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
80
75
|
const timer = new Timer();
|
|
81
|
-
const result = await
|
|
76
|
+
const result = await verifyChonkProof(this.config.bbBinaryPath, proofPath, verificationKeyPath, this.logger, this.config.bbIVCConcurrency);
|
|
82
77
|
verificationDuration = timer.ms();
|
|
83
78
|
if (result.status === BB_RESULT.FAILURE) {
|
|
84
|
-
const errorMessage = `Failed to verify ${
|
|
79
|
+
const errorMessage = `Failed to verify ${proofType} proof for ${circuit}!`;
|
|
85
80
|
throw new Error(errorMessage);
|
|
86
81
|
}
|
|
87
|
-
this.logger.debug(`${
|
|
88
|
-
circuitName: mapProtocolArtifactNameToCircuitName(
|
|
82
|
+
this.logger.debug(`${proofType} verification successful`, {
|
|
83
|
+
circuitName: mapProtocolArtifactNameToCircuitName(circuit),
|
|
89
84
|
duration: result.durationMs,
|
|
90
85
|
eventName: 'circuit-verification',
|
|
91
|
-
proofType: '
|
|
86
|
+
proofType: 'chonk'
|
|
92
87
|
});
|
|
93
88
|
};
|
|
94
89
|
await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
|
|
@@ -98,7 +93,7 @@ export class BBCircuitVerifier {
|
|
|
98
93
|
totalDurationMs: totalTimer.ms()
|
|
99
94
|
};
|
|
100
95
|
} catch (err) {
|
|
101
|
-
this.logger.warn(`Failed to verify
|
|
96
|
+
this.logger.warn(`Failed to verify ${proofType} proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
|
|
102
97
|
return {
|
|
103
98
|
valid: false,
|
|
104
99
|
durationMs: 0,
|
package/dest/verifier/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from './bb_verifier.js';
|
|
2
|
-
export * from './
|
|
3
|
-
//# sourceMappingURL=
|
|
2
|
+
export * from './queued_chonk_verifier.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLGNBQWMsNEJBQTRCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
|
package/dest/verifier/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './bb_verifier.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './queued_chonk_verifier.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import type { BBConfig } from '../config.js';
|
|
5
|
+
export declare class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
6
|
+
private verifier;
|
|
7
|
+
private telemetry;
|
|
8
|
+
private logger;
|
|
9
|
+
private queue;
|
|
10
|
+
private metrics;
|
|
11
|
+
constructor(config: BBConfig, verifier: ClientProtocolCircuitVerifier, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
|
|
12
|
+
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
13
|
+
stop(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVldWVkX2Nob25rX3ZlcmlmaWVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpZXIvcXVldWVkX2Nob25rX3ZlcmlmaWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLDZCQUE2QixFQUFFLDBCQUEwQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakgsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDM0MsT0FBTyxFQU1MLEtBQUssZUFBZSxFQUlyQixNQUFNLHlCQUF5QixDQUFDO0FBSWpDLE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGNBQWMsQ0FBQztBQWlFN0MscUJBQWEsaUJBQWtCLFlBQVcsNkJBQTZCO0lBTW5FLE9BQU8sQ0FBQyxRQUFRO0lBQ2hCLE9BQU8sQ0FBQyxTQUFTO0lBQ2pCLE9BQU8sQ0FBQyxNQUFNO0lBUGhCLE9BQU8sQ0FBQyxLQUFLLENBQWM7SUFDM0IsT0FBTyxDQUFDLE9BQU8sQ0FBcUI7SUFFcEMsWUFDRSxNQUFNLEVBQUUsUUFBUSxFQUNSLFFBQVEsRUFBRSw2QkFBNkIsRUFDdkMsU0FBUyxHQUFFLGVBQXNDLEVBQ2pELE1BQU0seUNBQWtELEVBTWpFO0lBRVksV0FBVyxDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLDBCQUEwQixDQUFDLENBSXBFO0lBRUQsSUFBSSxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFcEI7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queued_chonk_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_chonk_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAiE7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAMnE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IAPhB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAqB;IAEpC,YACE,MAAM,EAAE,QAAQ,EACR,QAAQ,EAAE,6BAA6B,EACvC,SAAS,GAAE,eAAsC,EACjD,MAAM,yCAAkD,EAMjE;IAEY,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAIpE;IAED,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpB;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
|
-
import { Attributes, Metrics,
|
|
3
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault, getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
import { createHistogram } from 'node:perf_hooks';
|
|
5
5
|
class IVCVerifierMetrics {
|
|
6
6
|
ivcVerificationHistogram;
|
|
@@ -17,46 +17,15 @@ class IVCVerifierMetrics {
|
|
|
17
17
|
aggDurationMetrics;
|
|
18
18
|
constructor(client, name = 'QueuedIVCVerifier'){
|
|
19
19
|
const meter = client.getMeter(name);
|
|
20
|
-
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
valueType: ValueType.INT
|
|
24
|
-
});
|
|
25
|
-
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
|
|
26
|
-
unit: 'ms',
|
|
27
|
-
description: 'Total duration to verify client IVC proofs, including serde',
|
|
28
|
-
valueType: ValueType.INT
|
|
29
|
-
});
|
|
30
|
-
this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT, {
|
|
31
|
-
description: 'Count of failed IVC proof verifications',
|
|
32
|
-
valueType: ValueType.INT
|
|
33
|
-
});
|
|
20
|
+
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME);
|
|
21
|
+
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME);
|
|
22
|
+
this.ivcFailureCount = createUpDownCounterWithDefault(meter, Metrics.IVC_VERIFIER_FAILURE_COUNT);
|
|
34
23
|
this.aggDurationMetrics = {
|
|
35
|
-
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX, {
|
|
41
|
-
valueType: ValueType.DOUBLE,
|
|
42
|
-
description: 'MAX ivc verification',
|
|
43
|
-
unit: 'ms'
|
|
44
|
-
}),
|
|
45
|
-
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN, {
|
|
46
|
-
valueType: ValueType.DOUBLE,
|
|
47
|
-
description: 'MIN ivc verification',
|
|
48
|
-
unit: 'ms'
|
|
49
|
-
}),
|
|
50
|
-
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50, {
|
|
51
|
-
valueType: ValueType.DOUBLE,
|
|
52
|
-
description: 'P50 ivc verification',
|
|
53
|
-
unit: 'ms'
|
|
54
|
-
}),
|
|
55
|
-
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90, {
|
|
56
|
-
valueType: ValueType.DOUBLE,
|
|
57
|
-
description: 'P90 ivc verification',
|
|
58
|
-
unit: 'ms'
|
|
59
|
-
})
|
|
24
|
+
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG),
|
|
25
|
+
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX),
|
|
26
|
+
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN),
|
|
27
|
+
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50),
|
|
28
|
+
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90)
|
|
60
29
|
};
|
|
61
30
|
meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));
|
|
62
31
|
}
|
|
@@ -112,7 +81,7 @@ export class QueuedIVCVerifier {
|
|
|
112
81
|
logger;
|
|
113
82
|
queue;
|
|
114
83
|
metrics;
|
|
115
|
-
constructor(config, verifier, telemetry = getTelemetryClient(), logger = createLogger('bb-prover:
|
|
84
|
+
constructor(config, verifier, telemetry = getTelemetryClient(), logger = createLogger('bb-prover:queued_chonk_verifier')){
|
|
116
85
|
this.verifier = verifier;
|
|
117
86
|
this.telemetry = telemetry;
|
|
118
87
|
this.logger = logger;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bb-prover",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-commit.217f559981",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
-
"./client/
|
|
8
|
-
"./client/
|
|
9
|
-
"./client
|
|
7
|
+
"./client/bundle": "./dest/prover/client/bundle.js",
|
|
8
|
+
"./client/lazy": "./dest/prover/client/lazy.js",
|
|
9
|
+
"./client": "./dest/prover/client/bb_private_kernel_prover.js",
|
|
10
10
|
"./verifier": "./dest/verifier/index.js",
|
|
11
11
|
"./test": "./dest/test/index.js",
|
|
12
12
|
"./config": "./dest/config.js"
|
|
@@ -25,10 +25,9 @@
|
|
|
25
25
|
"../package.common.json"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"build": "yarn clean && tsc
|
|
29
|
-
"build:dev": "tsc
|
|
28
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
29
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
30
30
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
31
|
-
"generate": "scripts/copy_ivc_hiding_circuit_vks.sh",
|
|
32
31
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
33
32
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
34
33
|
},
|
|
@@ -70,36 +69,37 @@
|
|
|
70
69
|
]
|
|
71
70
|
},
|
|
72
71
|
"dependencies": {
|
|
73
|
-
"@aztec/bb.js": "0.0.
|
|
74
|
-
"@aztec/constants": "0.0.
|
|
75
|
-
"@aztec/foundation": "0.0.
|
|
76
|
-
"@aztec/noir-noirc_abi": "0.0.
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "0.0.
|
|
78
|
-
"@aztec/noir-types": "0.0.
|
|
79
|
-
"@aztec/simulator": "0.0.
|
|
80
|
-
"@aztec/stdlib": "0.0.
|
|
81
|
-
"@aztec/telemetry-client": "0.0.
|
|
82
|
-
"@aztec/world-state": "0.0.
|
|
72
|
+
"@aztec/bb.js": "0.0.2-commit.217f559981",
|
|
73
|
+
"@aztec/constants": "0.0.2-commit.217f559981",
|
|
74
|
+
"@aztec/foundation": "0.0.2-commit.217f559981",
|
|
75
|
+
"@aztec/noir-noirc_abi": "0.0.2-commit.217f559981",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.2-commit.217f559981",
|
|
77
|
+
"@aztec/noir-types": "0.0.2-commit.217f559981",
|
|
78
|
+
"@aztec/simulator": "0.0.2-commit.217f559981",
|
|
79
|
+
"@aztec/stdlib": "0.0.2-commit.217f559981",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.2-commit.217f559981",
|
|
81
|
+
"@aztec/world-state": "0.0.2-commit.217f559981",
|
|
83
82
|
"commander": "^12.1.0",
|
|
84
83
|
"pako": "^2.1.0",
|
|
85
84
|
"source-map-support": "^0.5.21",
|
|
86
85
|
"tslib": "^2.4.0"
|
|
87
86
|
},
|
|
88
87
|
"devDependencies": {
|
|
89
|
-
"@aztec/ethereum": "0.0.
|
|
90
|
-
"@aztec/kv-store": "0.0.
|
|
91
|
-
"@aztec/noir-contracts.js": "0.0.
|
|
92
|
-
"@aztec/noir-test-contracts.js": "0.0.
|
|
93
|
-
"@aztec/protocol-contracts": "0.0.
|
|
88
|
+
"@aztec/ethereum": "0.0.2-commit.217f559981",
|
|
89
|
+
"@aztec/kv-store": "0.0.2-commit.217f559981",
|
|
90
|
+
"@aztec/noir-contracts.js": "0.0.2-commit.217f559981",
|
|
91
|
+
"@aztec/noir-test-contracts.js": "0.0.2-commit.217f559981",
|
|
92
|
+
"@aztec/protocol-contracts": "0.0.2-commit.217f559981",
|
|
94
93
|
"@jest/globals": "^30.0.0",
|
|
95
94
|
"@types/jest": "^30.0.0",
|
|
96
95
|
"@types/node": "^22.15.17",
|
|
97
96
|
"@types/source-map-support": "^0.5.10",
|
|
97
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
98
98
|
"jest": "^30.0.0",
|
|
99
99
|
"jest-mock-extended": "^4.0.0",
|
|
100
100
|
"ts-node": "^10.9.1",
|
|
101
101
|
"typescript": "^5.3.3",
|
|
102
|
-
"viem": "npm:@
|
|
102
|
+
"viem": "npm:@aztec/viem@2.38.2"
|
|
103
103
|
},
|
|
104
104
|
"files": [
|
|
105
105
|
"dest",
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type TestPrivateInsertions,
|
|
9
9
|
} from '@aztec/simulator/public/fixtures';
|
|
10
10
|
import type { PublicTxResult } from '@aztec/simulator/server';
|
|
11
|
-
import {
|
|
11
|
+
import { AvmCircuitInputs, AvmCircuitPublicInputs, PublicSimulatorConfig } from '@aztec/stdlib/avm';
|
|
12
12
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
13
13
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
14
14
|
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
@@ -18,16 +18,9 @@ import fs from 'node:fs/promises';
|
|
|
18
18
|
import { tmpdir } from 'node:os';
|
|
19
19
|
import path from 'path';
|
|
20
20
|
|
|
21
|
-
import {
|
|
22
|
-
type BBResult,
|
|
23
|
-
type BBSuccess,
|
|
24
|
-
BB_RESULT,
|
|
25
|
-
VK_FILENAME,
|
|
26
|
-
generateAvmProof,
|
|
27
|
-
verifyAvmProof,
|
|
28
|
-
} from '../bb/execute.js';
|
|
21
|
+
import { type BBResult, type BBSuccess, BB_RESULT, generateAvmProof, verifyAvmProof } from '../bb/execute.js';
|
|
29
22
|
|
|
30
|
-
const BB_PATH = path.resolve('../../barretenberg/cpp/build/bin/bb');
|
|
23
|
+
const BB_PATH = path.resolve('../../barretenberg/cpp/build/bin/bb-avm');
|
|
31
24
|
|
|
32
25
|
// An InterceptingLogger that records all log messages and forwards them to a wrapped logger.
|
|
33
26
|
class InterceptingLogger implements Logger {
|
|
@@ -51,6 +44,10 @@ class InterceptingLogger implements Logger {
|
|
|
51
44
|
throw new Error('Not implemented');
|
|
52
45
|
}
|
|
53
46
|
|
|
47
|
+
getBindings() {
|
|
48
|
+
return this.logger.getBindings();
|
|
49
|
+
}
|
|
50
|
+
|
|
54
51
|
private intercept(level: LogLevel, msg: string, ...args: any[]) {
|
|
55
52
|
this.logs.push(...msg.split('\n'));
|
|
56
53
|
// Forward to the wrapped logger
|
|
@@ -88,34 +85,45 @@ class InterceptingLogger implements Logger {
|
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
|
|
88
|
+
// Config with collectHints enabled for proving tests
|
|
89
|
+
const provingConfig: PublicSimulatorConfig = PublicSimulatorConfig.from({
|
|
90
|
+
skipFeeEnforcement: false,
|
|
91
|
+
collectCallMetadata: true, // For results.
|
|
92
|
+
collectDebugLogs: false,
|
|
93
|
+
collectHints: true, // Required for proving!
|
|
94
|
+
collectPublicInputs: true, // Required for proving!
|
|
95
|
+
collectStatistics: false,
|
|
96
|
+
});
|
|
97
|
+
|
|
91
98
|
export class AvmProvingTester extends PublicTxSimulationTester {
|
|
99
|
+
private bbWorkingDirectory: string = '';
|
|
100
|
+
|
|
92
101
|
constructor(
|
|
93
|
-
private bbWorkingDirectory: string,
|
|
94
102
|
private checkCircuitOnly: boolean,
|
|
95
103
|
contractDataSource: SimpleContractDataSource,
|
|
96
104
|
merkleTrees: MerkleTreeWriteOperations,
|
|
97
105
|
globals?: GlobalVariables,
|
|
98
106
|
metrics?: TestExecutorMetrics,
|
|
99
107
|
) {
|
|
100
|
-
|
|
108
|
+
// simulator factory is undefined because for proving, we use the default C++ simulator
|
|
109
|
+
super(merkleTrees, contractDataSource, globals, metrics, /*simulatorFactory=*/ undefined, provingConfig);
|
|
101
110
|
}
|
|
102
111
|
|
|
103
|
-
static async new(
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
static async new(
|
|
113
|
+
worldStateService: NativeWorldStateService, // make sure to close this later
|
|
114
|
+
checkCircuitOnly: boolean = false,
|
|
115
|
+
globals?: GlobalVariables,
|
|
116
|
+
metrics?: TestExecutorMetrics,
|
|
117
|
+
) {
|
|
106
118
|
const contractDataSource = new SimpleContractDataSource();
|
|
107
|
-
const merkleTrees = await
|
|
108
|
-
return new AvmProvingTester(
|
|
109
|
-
bbWorkingDirectory,
|
|
110
|
-
checkCircuitOnly,
|
|
111
|
-
contractDataSource,
|
|
112
|
-
merkleTrees,
|
|
113
|
-
globals,
|
|
114
|
-
metrics,
|
|
115
|
-
);
|
|
119
|
+
const merkleTrees = await worldStateService.fork();
|
|
120
|
+
return new AvmProvingTester(checkCircuitOnly, contractDataSource, merkleTrees, globals, metrics);
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
async prove(avmCircuitInputs: AvmCircuitInputs, txLabel: string = 'unlabeledTx'): Promise<BBResult> {
|
|
124
|
+
// We use a new working directory for each proof.
|
|
125
|
+
this.bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
126
|
+
|
|
119
127
|
const interceptingLogger = new InterceptingLogger(this.logger);
|
|
120
128
|
|
|
121
129
|
// Then we prove.
|
|
@@ -151,6 +159,11 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
151
159
|
}
|
|
152
160
|
});
|
|
153
161
|
|
|
162
|
+
// Throw if logs did not contain any times.
|
|
163
|
+
if (Object.keys(times).length === 0) {
|
|
164
|
+
throw new Error('AVM stdout did not contain any proving times in the stats!');
|
|
165
|
+
}
|
|
166
|
+
|
|
154
167
|
// Hack to make labels match.
|
|
155
168
|
const txLabelWithCount = `${txLabel}/${this.txCount - 1}`;
|
|
156
169
|
// I need to cast because TS doesnt realize metrics is protected not private.
|
|
@@ -177,14 +190,7 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
177
190
|
return proofRes;
|
|
178
191
|
}
|
|
179
192
|
|
|
180
|
-
return await verifyAvmProof(
|
|
181
|
-
BB_PATH,
|
|
182
|
-
this.bbWorkingDirectory,
|
|
183
|
-
proofRes.proofPath!,
|
|
184
|
-
publicInputs,
|
|
185
|
-
path.join(proofRes.vkDirectoryPath!, VK_FILENAME),
|
|
186
|
-
this.logger,
|
|
187
|
-
);
|
|
193
|
+
return await verifyAvmProof(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath!, publicInputs, this.logger);
|
|
188
194
|
}
|
|
189
195
|
|
|
190
196
|
public async proveVerify(avmCircuitInputs: AvmCircuitInputs, txLabel: string = 'unlabeledTx') {
|
|
@@ -204,7 +210,9 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
204
210
|
feePayer = sender,
|
|
205
211
|
privateInsertions?: TestPrivateInsertions,
|
|
206
212
|
txLabel: string = 'unlabeledTx',
|
|
213
|
+
disableRevertCheck: boolean = false,
|
|
207
214
|
): Promise<PublicTxResult> {
|
|
215
|
+
const simTimer = new Timer();
|
|
208
216
|
const simRes = await this.simulateTx(
|
|
209
217
|
sender,
|
|
210
218
|
setupCalls,
|
|
@@ -214,11 +222,16 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
214
222
|
privateInsertions,
|
|
215
223
|
txLabel,
|
|
216
224
|
);
|
|
217
|
-
|
|
225
|
+
const simDuration = simTimer.ms();
|
|
226
|
+
this.logger.info(`Simulation took ${simDuration} ms for tx ${txLabel}`);
|
|
227
|
+
|
|
228
|
+
if (!disableRevertCheck) {
|
|
229
|
+
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
230
|
+
}
|
|
218
231
|
|
|
219
232
|
const opString = this.checkCircuitOnly ? 'Check circuit' : 'Proving and verification';
|
|
220
233
|
|
|
221
|
-
const avmCircuitInputs = simRes.
|
|
234
|
+
const avmCircuitInputs = new AvmCircuitInputs(simRes.hints!, simRes.publicInputs!);
|
|
222
235
|
const timer = new Timer();
|
|
223
236
|
await this.proveVerify(avmCircuitInputs, txLabel);
|
|
224
237
|
this.logger.info(`${opString} took ${timer.ms()} ms for tx ${txLabel}`);
|
|
@@ -240,10 +253,11 @@ export class AvmProvingTester extends PublicTxSimulationTester {
|
|
|
240
253
|
setupCalls ?? [],
|
|
241
254
|
appCalls ?? [],
|
|
242
255
|
teardownCall,
|
|
243
|
-
|
|
256
|
+
undefined,
|
|
244
257
|
feePayer,
|
|
245
258
|
privateInsertions,
|
|
246
259
|
txLabel,
|
|
260
|
+
true,
|
|
247
261
|
);
|
|
248
262
|
}
|
|
249
263
|
|