@aztec/bb-prover 0.71.0 → 0.72.1
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.d.ts.map +1 -1
- package/dest/bb/cli.js +1 -52
- package/dest/bb/execute.d.ts +0 -16
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +1 -91
- package/dest/prover/bb_prover.d.ts +2 -15
- package/dest/prover/bb_prover.d.ts.map +1 -1
- package/dest/prover/bb_prover.js +25 -57
- package/dest/test/test_avm.d.ts.map +1 -1
- package/dest/test/test_avm.js +3 -3
- package/dest/verifier/bb_verifier.d.ts +2 -6
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +13 -37
- package/package.json +10 -10
- package/src/bb/cli.ts +0 -76
- package/src/bb/execute.ts +0 -135
- package/src/prover/bb_prover.ts +36 -89
- package/src/test/test_avm.ts +3 -3
- package/src/verifier/bb_verifier.ts +16 -94
|
@@ -2,101 +2,40 @@ 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
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
type ClientProtocolArtifact,
|
|
9
|
-
type ProtocolArtifact,
|
|
10
|
-
type ServerProtocolArtifact,
|
|
11
|
-
} from '@aztec/noir-protocol-circuits-types/types';
|
|
5
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { type ClientProtocolArtifact, type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
7
|
+
import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/vks';
|
|
12
8
|
|
|
13
9
|
import { promises as fs } from 'fs';
|
|
14
10
|
import * as path from 'path';
|
|
15
11
|
|
|
16
|
-
import {
|
|
17
|
-
BB_RESULT,
|
|
18
|
-
PROOF_FILENAME,
|
|
19
|
-
VK_FILENAME,
|
|
20
|
-
generateContractForCircuit,
|
|
21
|
-
generateKeyForNoirCircuit,
|
|
22
|
-
verifyClientIvcProof,
|
|
23
|
-
verifyProof,
|
|
24
|
-
} from '../bb/execute.js';
|
|
12
|
+
import { BB_RESULT, PROOF_FILENAME, VK_FILENAME, verifyClientIvcProof, verifyProof } from '../bb/execute.js';
|
|
25
13
|
import { type BBConfig } from '../config.js';
|
|
26
|
-
import {
|
|
14
|
+
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
27
15
|
import { writeToOutputDirectory } from '../prover/client_ivc_proof_utils.js';
|
|
28
|
-
import {
|
|
29
|
-
import { extractVkData } from '../verification_key/verification_key_data.js';
|
|
16
|
+
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
30
17
|
|
|
31
18
|
export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
32
|
-
private constructor(
|
|
33
|
-
private config: BBConfig,
|
|
34
|
-
private verificationKeys = new Map<ProtocolArtifact, Promise<VerificationKeyData>>(),
|
|
35
|
-
private logger: Logger,
|
|
36
|
-
) {}
|
|
37
|
-
|
|
38
|
-
public static async new(
|
|
39
|
-
config: BBConfig,
|
|
40
|
-
initialCircuits: ServerProtocolArtifact[] = [],
|
|
41
|
-
logger = createLogger('bb-prover:verifier'),
|
|
42
|
-
) {
|
|
43
|
-
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
44
|
-
const keys = new Map<ProtocolArtifact, Promise<VerificationKeyData>>();
|
|
45
|
-
for (const circuit of initialCircuits) {
|
|
46
|
-
const vkData = await this.generateVerificationKey(
|
|
47
|
-
circuit,
|
|
48
|
-
config.bbBinaryPath,
|
|
49
|
-
config.bbWorkingDirectory,
|
|
50
|
-
logger.debug,
|
|
51
|
-
);
|
|
52
|
-
keys.set(circuit, Promise.resolve(vkData));
|
|
53
|
-
}
|
|
54
|
-
return new BBCircuitVerifier(config, keys, logger);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private static async generateVerificationKey(
|
|
58
|
-
circuit: ServerProtocolArtifact,
|
|
59
|
-
bbPath: string,
|
|
60
|
-
workingDirectory: string,
|
|
61
|
-
logFn: LogFn,
|
|
62
|
-
) {
|
|
63
|
-
return await generateKeyForNoirCircuit(
|
|
64
|
-
bbPath,
|
|
65
|
-
workingDirectory,
|
|
66
|
-
circuit,
|
|
67
|
-
ServerCircuitArtifacts[circuit],
|
|
68
|
-
isProtocolArtifactRecursive(circuit),
|
|
69
|
-
getUltraHonkFlavorForCircuit(circuit),
|
|
70
|
-
logFn,
|
|
71
|
-
).then(result => {
|
|
72
|
-
if (result.status === BB_RESULT.FAILURE) {
|
|
73
|
-
throw new Error(`Failed to created verification key for ${circuit}, ${result.reason}`);
|
|
74
|
-
}
|
|
19
|
+
private constructor(private config: BBConfig, private logger: Logger) {}
|
|
75
20
|
|
|
76
|
-
|
|
77
|
-
});
|
|
21
|
+
public static async new(config: BBConfig, logger = createLogger('bb-prover:verifier')) {
|
|
22
|
+
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
23
|
+
return new BBCircuitVerifier(config, logger);
|
|
78
24
|
}
|
|
79
25
|
|
|
80
|
-
public
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
circuit,
|
|
85
|
-
this.config.bbBinaryPath,
|
|
86
|
-
this.config.bbWorkingDirectory,
|
|
87
|
-
this.logger.debug,
|
|
88
|
-
);
|
|
26
|
+
public getVerificationKeyData(circuitType: ServerProtocolArtifact): VerificationKeyData {
|
|
27
|
+
const vk = ServerCircuitVks[circuitType];
|
|
28
|
+
if (vk === undefined) {
|
|
29
|
+
throw new Error('Could not find VK for server artifact ' + circuitType);
|
|
89
30
|
}
|
|
90
|
-
|
|
91
|
-
const vk = await promise;
|
|
92
|
-
return vk.clone();
|
|
31
|
+
return vk;
|
|
93
32
|
}
|
|
94
33
|
|
|
95
34
|
public async verifyProofForCircuit(circuit: ServerProtocolArtifact, proof: Proof) {
|
|
96
35
|
const operation = async (bbWorkingDirectory: string) => {
|
|
97
36
|
const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
98
37
|
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
99
|
-
const verificationKey =
|
|
38
|
+
const verificationKey = this.getVerificationKeyData(circuit);
|
|
100
39
|
|
|
101
40
|
this.logger.debug(`${circuit} Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
|
|
102
41
|
|
|
@@ -126,23 +65,6 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
126
65
|
await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup);
|
|
127
66
|
}
|
|
128
67
|
|
|
129
|
-
public async generateSolidityContract(circuit: UltraKeccakHonkServerProtocolArtifact, contractName: string) {
|
|
130
|
-
const result = await generateContractForCircuit(
|
|
131
|
-
this.config.bbBinaryPath,
|
|
132
|
-
this.config.bbWorkingDirectory,
|
|
133
|
-
circuit,
|
|
134
|
-
ServerCircuitArtifacts[circuit],
|
|
135
|
-
contractName,
|
|
136
|
-
this.logger.debug,
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
if (result.status === BB_RESULT.FAILURE) {
|
|
140
|
-
throw new Error(`Failed to create verifier contract for ${circuit}, ${result.reason}`);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return fs.readFile(result.contractPath!, 'utf-8');
|
|
144
|
-
}
|
|
145
|
-
|
|
146
68
|
public async verifyProof(tx: Tx): Promise<boolean> {
|
|
147
69
|
try {
|
|
148
70
|
// TODO(#7370) The verification keys should be supplied separately and based on the expectedCircuit
|