@aztec/bb-prover 0.66.0 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bb/cli.js +2 -2
- package/dest/bb/execute.d.ts +3 -3
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +3 -6
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +2 -11
- package/dest/prover/bb_private_kernel_prover.d.ts +2 -2
- package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_private_kernel_prover.js +5 -5
- package/dest/prover/bb_prover.js +8 -8
- package/dest/test/test_avm.d.ts +4 -0
- package/dest/test/test_avm.d.ts.map +1 -0
- package/dest/test/test_avm.js +33 -0
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +3 -3
- package/dest/verification_key/verification_key_data.js +4 -4
- package/dest/verifier/bb_verifier.d.ts +2 -1
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +4 -4
- package/package.json +12 -8
- package/src/bb/cli.ts +1 -1
- package/src/bb/execute.ts +4 -7
- package/src/instrumentation.ts +0 -10
- package/src/prover/bb_private_kernel_prover.ts +5 -5
- package/src/prover/bb_prover.ts +7 -7
- package/src/test/test_avm.ts +85 -0
- package/src/test/test_circuit_prover.ts +2 -2
- package/src/verification_key/verification_key_data.ts +3 -3
- package/src/verifier/bb_verifier.ts +4 -4
package/src/prover/bb_prover.ts
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
makeRecursiveProofFromBinary,
|
|
43
43
|
} from '@aztec/circuits.js';
|
|
44
44
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
45
|
-
import {
|
|
45
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
46
46
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
47
47
|
import { Timer } from '@aztec/foundation/timer';
|
|
48
48
|
import {
|
|
@@ -76,7 +76,7 @@ import { Attributes, type TelemetryClient, trackSpan } from '@aztec/telemetry-cl
|
|
|
76
76
|
import { abiEncode } from '@noir-lang/noirc_abi';
|
|
77
77
|
import { type Abi, type WitnessMap } from '@noir-lang/types';
|
|
78
78
|
import crypto from 'crypto';
|
|
79
|
-
import
|
|
79
|
+
import { promises as fs } from 'fs';
|
|
80
80
|
import * as path from 'path';
|
|
81
81
|
|
|
82
82
|
import {
|
|
@@ -100,7 +100,7 @@ import { ProverInstrumentation } from '../instrumentation.js';
|
|
|
100
100
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
101
101
|
import { extractAvmVkData, extractVkData } from '../verification_key/verification_key_data.js';
|
|
102
102
|
|
|
103
|
-
const logger =
|
|
103
|
+
const logger = createLogger('bb-prover');
|
|
104
104
|
|
|
105
105
|
// All `ServerCircuitArtifact` are recursive.
|
|
106
106
|
const SERVER_CIRCUIT_RECURSIVE = true;
|
|
@@ -795,8 +795,8 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
795
795
|
const json = JSON.parse(proofString);
|
|
796
796
|
const fields = json
|
|
797
797
|
.slice(0, 3)
|
|
798
|
-
.map(Fr.
|
|
799
|
-
.concat(json.slice(3 + numPublicInputs).map(Fr.
|
|
798
|
+
.map(Fr.fromHexString)
|
|
799
|
+
.concat(json.slice(3 + numPublicInputs).map(Fr.fromHexString));
|
|
800
800
|
return new RecursiveProof(
|
|
801
801
|
fields,
|
|
802
802
|
new Proof(proof.binaryProof.buffer, vk.numPublicInputs),
|
|
@@ -877,8 +877,8 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
877
877
|
|
|
878
878
|
const fieldsWithoutPublicInputs = json
|
|
879
879
|
.slice(0, 3)
|
|
880
|
-
.map(Fr.
|
|
881
|
-
.concat(json.slice(3 + numPublicInputs).map(Fr.
|
|
880
|
+
.map(Fr.fromHexString)
|
|
881
|
+
.concat(json.slice(3 + numPublicInputs).map(Fr.fromHexString));
|
|
882
882
|
logger.debug(
|
|
883
883
|
`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProof.length}`,
|
|
884
884
|
);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AztecAddress,
|
|
3
|
+
BlockHeader,
|
|
4
|
+
ContractStorageRead,
|
|
5
|
+
ContractStorageUpdateRequest,
|
|
6
|
+
Gas,
|
|
7
|
+
GlobalVariables,
|
|
8
|
+
L2ToL1Message,
|
|
9
|
+
LogHash,
|
|
10
|
+
MAX_ENQUEUED_CALLS_PER_CALL,
|
|
11
|
+
MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL,
|
|
12
|
+
MAX_L2_TO_L1_MSGS_PER_CALL,
|
|
13
|
+
MAX_NOTE_HASHES_PER_CALL,
|
|
14
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
|
|
15
|
+
MAX_NULLIFIERS_PER_CALL,
|
|
16
|
+
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL,
|
|
17
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
|
|
18
|
+
MAX_PUBLIC_DATA_READS_PER_CALL,
|
|
19
|
+
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
|
|
20
|
+
MAX_UNENCRYPTED_LOGS_PER_CALL,
|
|
21
|
+
NoteHash,
|
|
22
|
+
Nullifier,
|
|
23
|
+
PublicCircuitPublicInputs,
|
|
24
|
+
PublicInnerCallRequest,
|
|
25
|
+
ReadRequest,
|
|
26
|
+
RevertCode,
|
|
27
|
+
TreeLeafReadRequest,
|
|
28
|
+
} from '@aztec/circuits.js';
|
|
29
|
+
import { computeVarArgsHash } from '@aztec/circuits.js/hash';
|
|
30
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
31
|
+
import { type PublicFunctionCallResult } from '@aztec/simulator';
|
|
32
|
+
|
|
33
|
+
// TODO: pub somewhere more usable - copied from abstract phase manager
|
|
34
|
+
export function getPublicInputs(result: PublicFunctionCallResult): PublicCircuitPublicInputs {
|
|
35
|
+
return PublicCircuitPublicInputs.from({
|
|
36
|
+
callContext: result.executionRequest.callContext,
|
|
37
|
+
proverAddress: AztecAddress.ZERO,
|
|
38
|
+
argsHash: computeVarArgsHash(result.executionRequest.args),
|
|
39
|
+
noteHashes: padArrayEnd(result.noteHashes, NoteHash.empty(), MAX_NOTE_HASHES_PER_CALL),
|
|
40
|
+
nullifiers: padArrayEnd(result.nullifiers, Nullifier.empty(), MAX_NULLIFIERS_PER_CALL),
|
|
41
|
+
l2ToL1Msgs: padArrayEnd(result.l2ToL1Messages, L2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_CALL),
|
|
42
|
+
startSideEffectCounter: result.startSideEffectCounter,
|
|
43
|
+
endSideEffectCounter: result.endSideEffectCounter,
|
|
44
|
+
returnsHash: computeVarArgsHash(result.returnValues),
|
|
45
|
+
noteHashReadRequests: padArrayEnd(
|
|
46
|
+
result.noteHashReadRequests,
|
|
47
|
+
TreeLeafReadRequest.empty(),
|
|
48
|
+
MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
|
|
49
|
+
),
|
|
50
|
+
nullifierReadRequests: padArrayEnd(
|
|
51
|
+
result.nullifierReadRequests,
|
|
52
|
+
ReadRequest.empty(),
|
|
53
|
+
MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
|
|
54
|
+
),
|
|
55
|
+
nullifierNonExistentReadRequests: padArrayEnd(
|
|
56
|
+
result.nullifierNonExistentReadRequests,
|
|
57
|
+
ReadRequest.empty(),
|
|
58
|
+
MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL,
|
|
59
|
+
),
|
|
60
|
+
l1ToL2MsgReadRequests: padArrayEnd(
|
|
61
|
+
result.l1ToL2MsgReadRequests,
|
|
62
|
+
TreeLeafReadRequest.empty(),
|
|
63
|
+
MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL,
|
|
64
|
+
),
|
|
65
|
+
contractStorageReads: padArrayEnd(
|
|
66
|
+
result.contractStorageReads,
|
|
67
|
+
ContractStorageRead.empty(),
|
|
68
|
+
MAX_PUBLIC_DATA_READS_PER_CALL,
|
|
69
|
+
),
|
|
70
|
+
contractStorageUpdateRequests: padArrayEnd(
|
|
71
|
+
result.contractStorageUpdateRequests,
|
|
72
|
+
ContractStorageUpdateRequest.empty(),
|
|
73
|
+
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
|
|
74
|
+
),
|
|
75
|
+
publicCallRequests: padArrayEnd([], PublicInnerCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_CALL),
|
|
76
|
+
unencryptedLogsHashes: padArrayEnd(result.unencryptedLogsHashes, LogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_CALL),
|
|
77
|
+
historicalHeader: BlockHeader.empty(),
|
|
78
|
+
globalVariables: GlobalVariables.empty(),
|
|
79
|
+
startGasLeft: Gas.from(result.startGasLeft),
|
|
80
|
+
endGasLeft: Gas.from(result.endGasLeft),
|
|
81
|
+
transactionFee: result.transactionFee,
|
|
82
|
+
// TODO(@just-mitch): need better mapping from simulator to revert code.
|
|
83
|
+
revertCode: result.reverted ? RevertCode.APP_LOGIC_REVERTED : RevertCode.OK,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
makeEmptyRecursiveProof,
|
|
36
36
|
makeRecursiveProof,
|
|
37
37
|
} from '@aztec/circuits.js';
|
|
38
|
-
import {
|
|
38
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
39
39
|
import { sleep } from '@aztec/foundation/sleep';
|
|
40
40
|
import { Timer } from '@aztec/foundation/timer';
|
|
41
41
|
import {
|
|
@@ -78,7 +78,7 @@ import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
|
78
78
|
export class TestCircuitProver implements ServerCircuitProver {
|
|
79
79
|
private wasmSimulator = new WASMSimulator();
|
|
80
80
|
private instrumentation: ProverInstrumentation;
|
|
81
|
-
private logger =
|
|
81
|
+
private logger = createLogger('bb-prover:test-prover');
|
|
82
82
|
|
|
83
83
|
constructor(
|
|
84
84
|
telemetry: TelemetryClient,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { hashVK } from '@aztec/circuits.js/hash';
|
|
8
8
|
|
|
9
9
|
import { strict as assert } from 'assert';
|
|
10
|
-
import
|
|
10
|
+
import { promises as fs } from 'fs';
|
|
11
11
|
import * as path from 'path';
|
|
12
12
|
|
|
13
13
|
import { VK_FIELDS_FILENAME, VK_FILENAME } from '../bb/execute.js';
|
|
@@ -23,7 +23,7 @@ export async function extractVkData(vkDirectoryPath: string): Promise<Verificati
|
|
|
23
23
|
fs.readFile(path.join(vkDirectoryPath, VK_FILENAME)),
|
|
24
24
|
]);
|
|
25
25
|
const fieldsJson = JSON.parse(rawFields);
|
|
26
|
-
const fields = fieldsJson.map(Fr.
|
|
26
|
+
const fields = fieldsJson.map(Fr.fromHexString);
|
|
27
27
|
// The hash is not included in the BB response
|
|
28
28
|
const vkHash = hashVK(fields);
|
|
29
29
|
const vkAsFields = new VerificationKeyAsFields(fields, vkHash);
|
|
@@ -37,7 +37,7 @@ export async function extractAvmVkData(vkDirectoryPath: string): Promise<Verific
|
|
|
37
37
|
fs.readFile(path.join(vkDirectoryPath, VK_FILENAME)),
|
|
38
38
|
]);
|
|
39
39
|
const fieldsJson = JSON.parse(rawFields);
|
|
40
|
-
const fields = fieldsJson.map(Fr.
|
|
40
|
+
const fields = fieldsJson.map(Fr.fromHexString);
|
|
41
41
|
// The first item is the hash, this is not part of the actual VK
|
|
42
42
|
// TODO: is the above actually the case?
|
|
43
43
|
const vkHash = fields[0];
|
|
@@ -2,14 +2,14 @@ import { type ClientProtocolCircuitVerifier, Tx } from '@aztec/circuit-types';
|
|
|
2
2
|
import { type CircuitVerificationStats } from '@aztec/circuit-types/stats';
|
|
3
3
|
import { type Proof, type VerificationKeyData } from '@aztec/circuits.js';
|
|
4
4
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
5
|
-
import { type
|
|
5
|
+
import { type LogFn, type Logger, createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import {
|
|
7
7
|
type ClientProtocolArtifact,
|
|
8
8
|
type ProtocolArtifact,
|
|
9
9
|
ProtocolCircuitArtifacts,
|
|
10
10
|
} from '@aztec/noir-protocol-circuits-types';
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import { promises as fs } from 'fs';
|
|
13
13
|
import * as path from 'path';
|
|
14
14
|
|
|
15
15
|
import {
|
|
@@ -30,13 +30,13 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
30
30
|
private constructor(
|
|
31
31
|
private config: BBConfig,
|
|
32
32
|
private verificationKeys = new Map<ProtocolArtifact, Promise<VerificationKeyData>>(),
|
|
33
|
-
private logger:
|
|
33
|
+
private logger: Logger,
|
|
34
34
|
) {}
|
|
35
35
|
|
|
36
36
|
public static async new(
|
|
37
37
|
config: BBConfig,
|
|
38
38
|
initialCircuits: ProtocolArtifact[] = [],
|
|
39
|
-
logger =
|
|
39
|
+
logger = createLogger('bb-prover:verifier'),
|
|
40
40
|
) {
|
|
41
41
|
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
42
42
|
const keys = new Map<ProtocolArtifact, Promise<VerificationKeyData>>();
|