@aztec/bb-prover 0.0.0-test.1 → 0.0.1-commit.21caa21
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 +14 -18
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +130 -79
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/execute.d.ts +14 -47
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +132 -236
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +3 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/honk.d.ts +3 -3
- package/dest/honk.d.ts.map +1 -1
- package/dest/honk.js +3 -2
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/instrumentation.d.ts +3 -3
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +2 -4
- package/dest/prover/client/bb_private_kernel_prover.d.ts +32 -0
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/{bb_private_kernel_prover.js → client/bb_private_kernel_prover.js} +42 -20
- 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 +8 -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 +8 -0
- package/dest/prover/index.d.ts +3 -4
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/prover/index.js +2 -3
- 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 +72 -0
- package/dest/prover/server/bb_prover.d.ts +100 -0
- package/dest/prover/server/bb_prover.d.ts.map +1 -0
- package/dest/prover/server/bb_prover.js +339 -0
- 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 +33 -21
- package/dest/test/index.d.ts +1 -1
- package/dest/test/test_circuit_prover.d.ts +25 -34
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +85 -59
- package/dest/test/test_verifier.d.ts +6 -3
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +23 -1
- package/dest/verification_key/verification_key_data.d.ts +7 -1
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +23 -29
- package/dest/verifier/bb_verifier.d.ts +6 -5
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +46 -25
- package/dest/verifier/index.d.ts +2 -1
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -0
- 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_chonk_verifier.js +132 -0
- package/package.json +35 -33
- package/src/avm_proving_tests/avm_proving_tester.ts +210 -104
- package/src/bb/execute.ts +103 -250
- package/src/config.ts +2 -0
- package/src/honk.ts +3 -2
- package/src/index.ts +1 -0
- package/src/instrumentation.ts +2 -4
- package/src/prover/{bb_private_kernel_prover.ts → client/bb_private_kernel_prover.ts} +78 -30
- package/src/prover/client/bundle.ts +11 -0
- package/src/prover/client/lazy.ts +11 -0
- package/src/prover/index.ts +2 -3
- package/src/prover/proof_utils.ts +115 -0
- package/src/prover/server/bb_prover.ts +733 -0
- package/src/test/delay_values.ts +33 -21
- package/src/test/test_circuit_prover.ts +260 -147
- package/src/test/test_verifier.ts +15 -3
- package/src/verification_key/verification_key_data.ts +29 -24
- package/src/verifier/bb_verifier.ts +63 -32
- package/src/verifier/index.ts +1 -0
- package/src/verifier/queued_chonk_verifier.ts +140 -0
- package/dest/prover/bb_native_private_kernel_prover.d.ts +0 -25
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_native_private_kernel_prover.js +0 -69
- package/dest/prover/bb_private_kernel_prover.d.ts +0 -32
- package/dest/prover/bb_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.d.ts +0 -120
- package/dest/prover/bb_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.js +0 -423
- package/dest/prover/client_ivc_proof_utils.d.ts +0 -25
- package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
- package/dest/prover/client_ivc_proof_utils.js +0 -43
- package/dest/stats.d.ts +0 -5
- package/dest/stats.d.ts.map +0 -1
- package/dest/stats.js +0 -62
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +0 -17
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.js +0 -46
- package/dest/wasm/bundle.d.ts +0 -6
- package/dest/wasm/bundle.d.ts.map +0 -1
- package/dest/wasm/bundle.js +0 -8
- package/dest/wasm/lazy.d.ts +0 -6
- package/dest/wasm/lazy.d.ts.map +0 -1
- package/dest/wasm/lazy.js +0 -8
- package/src/prover/bb_native_private_kernel_prover.ts +0 -119
- package/src/prover/bb_prover.ts +0 -781
- package/src/prover/client_ivc_proof_utils.ts +0 -42
- package/src/stats.ts +0 -64
- package/src/wasm/bb_wasm_private_kernel_prover.ts +0 -55
- package/src/wasm/bundle.ts +0 -11
- package/src/wasm/lazy.ts +0 -11
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import {
|
|
3
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
4
4
|
import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
|
|
5
5
|
|
|
6
6
|
import { strict as assert } from 'assert';
|
|
7
7
|
import { promises as fs } from 'fs';
|
|
8
8
|
import * as path from 'path';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { VK_FILENAME } from '../bb/execute.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Reads the verification key data stored at the specified location and parses into a VerificationKeyData
|
|
@@ -15,31 +15,36 @@ import { VK_FIELDS_FILENAME, VK_FILENAME } from '../bb/execute.js';
|
|
|
15
15
|
* @returns The verification key data
|
|
16
16
|
*/
|
|
17
17
|
export async function extractVkData(vkDirectoryPath: string): Promise<VerificationKeyData> {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const fields =
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const vkAsFields = new VerificationKeyAsFields(fields, vkHash);
|
|
18
|
+
const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
|
|
19
|
+
|
|
20
|
+
// Convert binary to field elements (32 bytes per field)
|
|
21
|
+
const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
|
|
22
|
+
const reader = BufferReader.asReader(rawBinary);
|
|
23
|
+
const fields = reader.readArray(numFields, Fr);
|
|
24
|
+
|
|
25
|
+
const vkAsFields = await VerificationKeyAsFields.fromKey(fields);
|
|
27
26
|
return new VerificationKeyData(vkAsFields, rawBinary);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Reads the verification key data stored in a binary file at the specified directory location and parses into a VerificationKeyData.
|
|
31
|
+
* We do not assume any JSON file available but only the binary version, contrary to the above extractVkData() method.
|
|
32
|
+
* @param vkDirectoryPath - The directory containing the verification key binary data file.
|
|
33
|
+
* @returns The verification key data
|
|
34
|
+
*/
|
|
31
35
|
export async function extractAvmVkData(vkDirectoryPath: string): Promise<VerificationKeyData> {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const vkAsFields =
|
|
36
|
+
const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
|
|
37
|
+
|
|
38
|
+
const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
|
|
39
|
+
assert(numFields <= AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED, 'Invalid AVM verification key length');
|
|
40
|
+
const reader = BufferReader.asReader(rawBinary);
|
|
41
|
+
const fieldsArray = reader.readArray(numFields, Fr);
|
|
42
|
+
|
|
43
|
+
const fieldsArrayPadded = fieldsArray.concat(
|
|
44
|
+
Array(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED - fieldsArray.length).fill(new Fr(0)),
|
|
45
|
+
);
|
|
46
|
+
const vkAsFields = await VerificationKeyAsFields.fromKey(fieldsArrayPadded);
|
|
47
|
+
// 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.
|
|
43
48
|
const vk = new VerificationKeyData(vkAsFields, rawBinary);
|
|
44
49
|
return vk;
|
|
45
50
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
2
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
5
|
+
import {
|
|
6
|
+
type ClientProtocolArtifact,
|
|
7
|
+
type ProtocolArtifact,
|
|
8
|
+
type ServerProtocolArtifact,
|
|
9
|
+
mapProtocolArtifactNameToCircuitName,
|
|
10
|
+
} from '@aztec/noir-protocol-circuits-types/types';
|
|
11
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
6
12
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
7
13
|
import type { CircuitVerificationStats } from '@aztec/stdlib/stats';
|
|
8
14
|
import { Tx } from '@aztec/stdlib/tx';
|
|
@@ -11,37 +17,56 @@ import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
|
11
17
|
import { promises as fs } from 'fs';
|
|
12
18
|
import * as path from 'path';
|
|
13
19
|
|
|
14
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
BB_RESULT,
|
|
22
|
+
PROOF_FILENAME,
|
|
23
|
+
PUBLIC_INPUTS_FILENAME,
|
|
24
|
+
VK_FILENAME,
|
|
25
|
+
verifyChonkProof,
|
|
26
|
+
verifyProof,
|
|
27
|
+
} from '../bb/execute.js';
|
|
15
28
|
import type { BBConfig } from '../config.js';
|
|
16
29
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
17
|
-
import {
|
|
18
|
-
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
30
|
+
import { writeChonkProofToPath } from '../prover/proof_utils.js';
|
|
19
31
|
|
|
20
32
|
export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
21
|
-
private constructor(
|
|
33
|
+
private constructor(
|
|
34
|
+
private config: BBConfig,
|
|
35
|
+
private logger: Logger,
|
|
36
|
+
) {}
|
|
37
|
+
|
|
38
|
+
public stop(): Promise<void> {
|
|
39
|
+
return Promise.resolve();
|
|
40
|
+
}
|
|
22
41
|
|
|
23
42
|
public static async new(config: BBConfig, logger = createLogger('bb-prover:verifier')) {
|
|
43
|
+
if (!config.bbWorkingDirectory) {
|
|
44
|
+
throw new Error(`Barretenberg working directory (BB_WORKING_DIRECTORY) is not set`);
|
|
45
|
+
}
|
|
24
46
|
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
25
47
|
return new BBCircuitVerifier(config, logger);
|
|
26
48
|
}
|
|
27
49
|
|
|
28
|
-
public getVerificationKeyData(
|
|
29
|
-
const vk =
|
|
50
|
+
public getVerificationKeyData(circuit: ProtocolArtifact): VerificationKeyData {
|
|
51
|
+
const vk = ProtocolCircuitVks[circuit];
|
|
30
52
|
if (vk === undefined) {
|
|
31
|
-
throw new Error(
|
|
53
|
+
throw new Error(`Could not find VK for artifact ${circuit}`);
|
|
32
54
|
}
|
|
33
55
|
return vk;
|
|
34
56
|
}
|
|
35
57
|
|
|
36
58
|
public async verifyProofForCircuit(circuit: ServerProtocolArtifact, proof: Proof) {
|
|
37
59
|
const operation = async (bbWorkingDirectory: string) => {
|
|
60
|
+
const publicInputsFileName = path.join(bbWorkingDirectory, PUBLIC_INPUTS_FILENAME);
|
|
38
61
|
const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
39
62
|
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
40
63
|
const verificationKey = this.getVerificationKeyData(circuit);
|
|
41
64
|
|
|
42
65
|
this.logger.debug(`${circuit} Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
|
|
43
66
|
|
|
44
|
-
|
|
67
|
+
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/13189): Put this proof parsing logic in the proof class.
|
|
68
|
+
await fs.writeFile(publicInputsFileName, proof.buffer.slice(0, proof.numPublicInputs * 32));
|
|
69
|
+
await fs.writeFile(proofFileName, proof.buffer.slice(proof.numPublicInputs * 32));
|
|
45
70
|
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
46
71
|
|
|
47
72
|
const result = await verifyProof(
|
|
@@ -67,48 +92,54 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
67
92
|
await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
|
|
68
93
|
}
|
|
69
94
|
|
|
70
|
-
public async verifyProof(tx: Tx): Promise<
|
|
95
|
+
public async verifyProof(tx: Tx): Promise<IVCProofVerificationResult> {
|
|
96
|
+
const proofType = 'Chonk';
|
|
71
97
|
try {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const expectedCircuit: ClientProtocolArtifact = tx.data.forPublic
|
|
77
|
-
? 'PrivateKernelTailToPublicArtifact'
|
|
78
|
-
: 'PrivateKernelTailArtifact';
|
|
79
|
-
const circuit = 'ClientIVC';
|
|
98
|
+
const totalTimer = new Timer();
|
|
99
|
+
let verificationDuration = 0;
|
|
100
|
+
|
|
101
|
+
const circuit: ClientProtocolArtifact = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
|
|
80
102
|
|
|
81
103
|
// Block below is almost copy-pasted from verifyProofForCircuit
|
|
82
104
|
const operation = async (bbWorkingDirectory: string) => {
|
|
83
105
|
const logFunction = (message: string) => {
|
|
84
|
-
this.logger.debug(`${
|
|
106
|
+
this.logger.debug(`${proofType} BB out - ${message}`);
|
|
85
107
|
};
|
|
86
108
|
|
|
87
|
-
|
|
88
|
-
|
|
109
|
+
const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
110
|
+
await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
|
|
111
|
+
|
|
112
|
+
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
113
|
+
const verificationKey = this.getVerificationKeyData(circuit);
|
|
114
|
+
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
115
|
+
|
|
116
|
+
const timer = new Timer();
|
|
117
|
+
const result = await verifyChonkProof(
|
|
89
118
|
this.config.bbBinaryPath,
|
|
90
|
-
|
|
91
|
-
|
|
119
|
+
proofPath,
|
|
120
|
+
verificationKeyPath,
|
|
92
121
|
logFunction,
|
|
122
|
+
this.config.bbIVCConcurrency,
|
|
93
123
|
);
|
|
124
|
+
verificationDuration = timer.ms();
|
|
94
125
|
|
|
95
126
|
if (result.status === BB_RESULT.FAILURE) {
|
|
96
|
-
const errorMessage = `Failed to verify ${
|
|
127
|
+
const errorMessage = `Failed to verify ${proofType} proof for ${circuit}!`;
|
|
97
128
|
throw new Error(errorMessage);
|
|
98
129
|
}
|
|
99
130
|
|
|
100
|
-
this.logger.debug(`${
|
|
101
|
-
circuitName: mapProtocolArtifactNameToCircuitName(
|
|
131
|
+
this.logger.debug(`${proofType} verification successful`, {
|
|
132
|
+
circuitName: mapProtocolArtifactNameToCircuitName(circuit),
|
|
102
133
|
duration: result.durationMs,
|
|
103
134
|
eventName: 'circuit-verification',
|
|
104
|
-
proofType: '
|
|
135
|
+
proofType: 'chonk',
|
|
105
136
|
} satisfies CircuitVerificationStats);
|
|
106
137
|
};
|
|
107
138
|
await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
|
|
108
|
-
return true;
|
|
139
|
+
return { valid: true, durationMs: verificationDuration, totalDurationMs: totalTimer.ms() };
|
|
109
140
|
} catch (err) {
|
|
110
|
-
this.logger.warn(`Failed to verify
|
|
111
|
-
return false;
|
|
141
|
+
this.logger.warn(`Failed to verify ${proofType} proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
|
|
142
|
+
return { valid: false, durationMs: 0, totalDurationMs: 0 };
|
|
112
143
|
}
|
|
113
144
|
}
|
|
114
145
|
}
|
package/src/verifier/index.ts
CHANGED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
4
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
5
|
+
import {
|
|
6
|
+
Attributes,
|
|
7
|
+
type BatchObservableResult,
|
|
8
|
+
type Histogram,
|
|
9
|
+
Metrics,
|
|
10
|
+
type ObservableGauge,
|
|
11
|
+
type TelemetryClient,
|
|
12
|
+
type UpDownCounter,
|
|
13
|
+
ValueType,
|
|
14
|
+
getTelemetryClient,
|
|
15
|
+
} from '@aztec/telemetry-client';
|
|
16
|
+
|
|
17
|
+
import { createHistogram } from 'node:perf_hooks';
|
|
18
|
+
|
|
19
|
+
import type { BBConfig } from '../config.js';
|
|
20
|
+
|
|
21
|
+
class IVCVerifierMetrics {
|
|
22
|
+
private ivcVerificationHistogram: Histogram;
|
|
23
|
+
private ivcTotalVerificationHistogram: Histogram;
|
|
24
|
+
private ivcFailureCount: UpDownCounter;
|
|
25
|
+
private localHistogramOk = createHistogram({
|
|
26
|
+
min: 1,
|
|
27
|
+
max: 5 * 60 * 1000, // 5 min
|
|
28
|
+
});
|
|
29
|
+
private localHistogramFails = createHistogram({
|
|
30
|
+
min: 1,
|
|
31
|
+
max: 5 * 60 * 1000, // 5 min
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
private aggDurationMetrics: Record<'min' | 'max' | 'p50' | 'p90' | 'avg', ObservableGauge>;
|
|
35
|
+
|
|
36
|
+
constructor(client: TelemetryClient, name = 'QueuedIVCVerifier') {
|
|
37
|
+
const meter = client.getMeter(name);
|
|
38
|
+
|
|
39
|
+
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME, {
|
|
40
|
+
unit: 'ms',
|
|
41
|
+
description: 'Duration to verify chonk proofs',
|
|
42
|
+
valueType: ValueType.INT,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
|
|
46
|
+
unit: 'ms',
|
|
47
|
+
description: 'Total duration to verify chonk proofs, including serde',
|
|
48
|
+
valueType: ValueType.INT,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT, {
|
|
52
|
+
description: 'Count of failed IVC proof verifications',
|
|
53
|
+
valueType: ValueType.INT,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
this.aggDurationMetrics = {
|
|
57
|
+
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG, {
|
|
58
|
+
valueType: ValueType.DOUBLE,
|
|
59
|
+
description: 'AVG ivc verification',
|
|
60
|
+
unit: 'ms',
|
|
61
|
+
}),
|
|
62
|
+
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX, {
|
|
63
|
+
valueType: ValueType.DOUBLE,
|
|
64
|
+
description: 'MAX ivc verification',
|
|
65
|
+
unit: 'ms',
|
|
66
|
+
}),
|
|
67
|
+
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN, {
|
|
68
|
+
valueType: ValueType.DOUBLE,
|
|
69
|
+
description: 'MIN ivc verification',
|
|
70
|
+
unit: 'ms',
|
|
71
|
+
}),
|
|
72
|
+
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50, {
|
|
73
|
+
valueType: ValueType.DOUBLE,
|
|
74
|
+
description: 'P50 ivc verification',
|
|
75
|
+
unit: 'ms',
|
|
76
|
+
}),
|
|
77
|
+
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90, {
|
|
78
|
+
valueType: ValueType.DOUBLE,
|
|
79
|
+
description: 'P90 ivc verification',
|
|
80
|
+
unit: 'ms',
|
|
81
|
+
}),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
recordIVCVerification(result: IVCProofVerificationResult) {
|
|
88
|
+
this.ivcVerificationHistogram.record(Math.ceil(result.durationMs), { [Attributes.OK]: result.valid });
|
|
89
|
+
this.ivcTotalVerificationHistogram.record(Math.ceil(result.totalDurationMs), { [Attributes.OK]: result.valid });
|
|
90
|
+
if (!result.valid) {
|
|
91
|
+
this.ivcFailureCount.add(1);
|
|
92
|
+
this.localHistogramFails.record(Math.max(Math.ceil(result.durationMs), 1));
|
|
93
|
+
} else {
|
|
94
|
+
this.localHistogramOk.record(Math.max(Math.ceil(result.durationMs), 1));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private aggregate = (res: BatchObservableResult) => {
|
|
99
|
+
for (const [histogram, ok] of [
|
|
100
|
+
[this.localHistogramOk, true],
|
|
101
|
+
[this.localHistogramFails, false],
|
|
102
|
+
] as const) {
|
|
103
|
+
if (histogram.count === 0) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
res.observe(this.aggDurationMetrics.avg, histogram.mean, { [Attributes.OK]: ok });
|
|
107
|
+
res.observe(this.aggDurationMetrics.max, histogram.max, { [Attributes.OK]: ok });
|
|
108
|
+
res.observe(this.aggDurationMetrics.min, histogram.min, { [Attributes.OK]: ok });
|
|
109
|
+
res.observe(this.aggDurationMetrics.p50, histogram.percentile(50), { [Attributes.OK]: ok });
|
|
110
|
+
res.observe(this.aggDurationMetrics.p90, histogram.percentile(90), { [Attributes.OK]: ok });
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
116
|
+
private queue: SerialQueue;
|
|
117
|
+
private metrics: IVCVerifierMetrics;
|
|
118
|
+
|
|
119
|
+
public constructor(
|
|
120
|
+
config: BBConfig,
|
|
121
|
+
private verifier: ClientProtocolCircuitVerifier,
|
|
122
|
+
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
123
|
+
private logger = createLogger('bb-prover:queued_chonk_verifier'),
|
|
124
|
+
) {
|
|
125
|
+
this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
|
|
126
|
+
this.queue = new SerialQueue();
|
|
127
|
+
this.logger.info(`Starting QueuedIVCVerifier with ${config.numConcurrentIVCVerifiers} concurrent verifiers`);
|
|
128
|
+
this.queue.start(config.numConcurrentIVCVerifiers);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public async verifyProof(tx: Tx): Promise<IVCProofVerificationResult> {
|
|
132
|
+
const result = await this.queue.put(() => this.verifier.verifyProof(tx));
|
|
133
|
+
this.metrics.recordIVCVerification(result);
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
stop(): Promise<void> {
|
|
138
|
+
return this.queue.end();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
4
|
-
import type { SimulationProvider } from '@aztec/simulator/server';
|
|
5
|
-
import type { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
6
|
-
import type { WitnessMap } from '@noir-lang/types';
|
|
7
|
-
import type { BBConfig } from '../config.js';
|
|
8
|
-
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
9
|
-
/**
|
|
10
|
-
* This proof creator implementation uses the native bb binary.
|
|
11
|
-
*/
|
|
12
|
-
export declare class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
13
|
-
private bbBinaryPath;
|
|
14
|
-
private bbWorkingDirectory;
|
|
15
|
-
private skipCleanup;
|
|
16
|
-
protected simulationProvider: SimulationProvider;
|
|
17
|
-
protected log: Logger;
|
|
18
|
-
private constructor();
|
|
19
|
-
static new(config: BBConfig, simulationProvider: SimulationProvider, log?: Logger): Promise<BBNativePrivateKernelProver>;
|
|
20
|
-
private _createClientIvcProof;
|
|
21
|
-
createClientIvcProof(acirs: Buffer[], witnessStack: WitnessMap[]): Promise<ClientIvcProof>;
|
|
22
|
-
computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number>;
|
|
23
|
-
private runInDirectory;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=bb_native_private_kernel_prover.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bb_native_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_native_private_kernel_prover.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAKnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,qBAAqB;IAElE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,WAAW;cACA,kBAAkB,EAAE,kBAAkB;cACtC,GAAG;IALxB,OAAO;WAUa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,GAAG,CAAC,EAAE,MAAM;YAWhF,qBAAqB;IAmCb,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ1F,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxG,OAAO,CAAC,cAAc;CAavB"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
4
|
-
import { encode } from '@msgpack/msgpack';
|
|
5
|
-
import { serializeWitness } from '@noir-lang/noirc_abi';
|
|
6
|
-
import { promises as fs } from 'fs';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof } from '../bb/execute.js';
|
|
9
|
-
import { BBPrivateKernelProver } from './bb_private_kernel_prover.js';
|
|
10
|
-
import { readFromOutputDirectory } from './client_ivc_proof_utils.js';
|
|
11
|
-
/**
|
|
12
|
-
* This proof creator implementation uses the native bb binary.
|
|
13
|
-
*/ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
14
|
-
bbBinaryPath;
|
|
15
|
-
bbWorkingDirectory;
|
|
16
|
-
skipCleanup;
|
|
17
|
-
simulationProvider;
|
|
18
|
-
log;
|
|
19
|
-
constructor(bbBinaryPath, bbWorkingDirectory, skipCleanup, simulationProvider, log = createLogger('bb-prover:native')){
|
|
20
|
-
super(new BundleArtifactProvider(), simulationProvider, log), this.bbBinaryPath = bbBinaryPath, this.bbWorkingDirectory = bbWorkingDirectory, this.skipCleanup = skipCleanup, this.simulationProvider = simulationProvider, this.log = log;
|
|
21
|
-
}
|
|
22
|
-
static async new(config, simulationProvider, log) {
|
|
23
|
-
await fs.mkdir(config.bbWorkingDirectory, {
|
|
24
|
-
recursive: true
|
|
25
|
-
});
|
|
26
|
-
return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, simulationProvider, log);
|
|
27
|
-
}
|
|
28
|
-
async _createClientIvcProof(directory, acirs, witnessStack) {
|
|
29
|
-
// TODO(#7371): Longer term we won't use this hacked together msgpack format
|
|
30
|
-
// and instead properly create the bincode serialization from rust
|
|
31
|
-
await fs.writeFile(path.join(directory, 'acir.msgpack'), encode(acirs));
|
|
32
|
-
await fs.writeFile(path.join(directory, 'witnesses.msgpack'), encode(witnessStack.map((map)=>serializeWitness(map))));
|
|
33
|
-
const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, path.join(directory, 'acir.msgpack'), path.join(directory, 'witnesses.msgpack'), this.log.info);
|
|
34
|
-
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
35
|
-
this.log.error(`Failed to generate client ivc proof`);
|
|
36
|
-
throw new Error(provingResult.reason);
|
|
37
|
-
}
|
|
38
|
-
const proof = await readFromOutputDirectory(directory);
|
|
39
|
-
this.log.info(`Generated IVC proof`, {
|
|
40
|
-
duration: provingResult.durationMs,
|
|
41
|
-
eventName: 'circuit-proving'
|
|
42
|
-
});
|
|
43
|
-
return proof;
|
|
44
|
-
}
|
|
45
|
-
async createClientIvcProof(acirs, witnessStack) {
|
|
46
|
-
this.log.info(`Generating Client IVC proof`);
|
|
47
|
-
const operation = async (directory)=>{
|
|
48
|
-
return await this._createClientIvcProof(directory, acirs, witnessStack);
|
|
49
|
-
};
|
|
50
|
-
return await this.runInDirectory(operation);
|
|
51
|
-
}
|
|
52
|
-
async computeGateCountForCircuit(bytecode, circuitName) {
|
|
53
|
-
const logFunction = (message)=>{
|
|
54
|
-
this.log.debug(`$bb gates ${circuitName} - ${message}`);
|
|
55
|
-
};
|
|
56
|
-
const result = await computeGateCountForCircuit(this.bbBinaryPath, this.bbWorkingDirectory, circuitName, bytecode, 'mega_honk', logFunction);
|
|
57
|
-
if (result.status === BB_RESULT.FAILURE) {
|
|
58
|
-
throw new Error(result.reason);
|
|
59
|
-
}
|
|
60
|
-
return result.circuitSize;
|
|
61
|
-
}
|
|
62
|
-
runInDirectory(fn) {
|
|
63
|
-
const log = this.log;
|
|
64
|
-
return runInDirectory(this.bbWorkingDirectory, (dir)=>fn(dir).catch((err)=>{
|
|
65
|
-
log.error(`Error running operation at ${dir}: ${err}`);
|
|
66
|
-
throw err;
|
|
67
|
-
}), this.skipCleanup, this.log);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
import type { ArtifactProvider, ClientProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
4
|
-
import type { SimulationProvider } from '@aztec/simulator/client';
|
|
5
|
-
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
6
|
-
import type { PrivateKernelCircuitPublicInputs, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelResetCircuitPrivateInputs, PrivateKernelSimulateOutput, PrivateKernelTailCircuitPrivateInputs, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
7
|
-
import type { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
8
|
-
import type { Abi, WitnessMap } from '@noir-lang/types';
|
|
9
|
-
export declare abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
10
|
-
protected artifactProvider: ArtifactProvider;
|
|
11
|
-
protected simulationProvider: SimulationProvider;
|
|
12
|
-
protected log: import("@aztec/foundation/log").Logger;
|
|
13
|
-
constructor(artifactProvider: ArtifactProvider, simulationProvider: SimulationProvider, log?: import("@aztec/foundation/log").Logger);
|
|
14
|
-
generateInitOutput(inputs: PrivateKernelInitCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
15
|
-
simulateInit(inputs: PrivateKernelInitCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
16
|
-
generateInnerOutput(inputs: PrivateKernelInnerCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
17
|
-
simulateInner(inputs: PrivateKernelInnerCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
18
|
-
generateResetOutput(inputs: PrivateKernelResetCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
19
|
-
simulateReset(inputs: PrivateKernelResetCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
20
|
-
generateTailOutput(inputs: PrivateKernelTailCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
21
|
-
simulateTail(inputs: PrivateKernelTailCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
22
|
-
simulateCircuitOutput<I extends {
|
|
23
|
-
toBuffer: () => Buffer;
|
|
24
|
-
}, O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs>(inputs: I, circuitType: ClientProtocolArtifact, convertInputs: (inputs: I, abi: Abi) => WitnessMap, convertOutputs: (outputs: WitnessMap, abi: Abi) => O): Promise<PrivateKernelSimulateOutput<O>>;
|
|
25
|
-
generateCircuitOutput<I extends {
|
|
26
|
-
toBuffer: () => Buffer;
|
|
27
|
-
}, O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs>(inputs: I, circuitType: ClientProtocolArtifact, convertInputs: (inputs: I, abi: Abi) => WitnessMap, convertOutputs: (outputs: WitnessMap, abi: Abi) => O): Promise<PrivateKernelSimulateOutput<O>>;
|
|
28
|
-
makeEmptyKernelSimulateOutput<PublicInputsType extends PrivateKernelTailCircuitPublicInputs | PrivateKernelCircuitPublicInputs>(publicInputs: PublicInputsType, circuitType: ClientProtocolArtifact): Promise<PrivateKernelSimulateOutput<PublicInputsType>>;
|
|
29
|
-
createClientIvcProof(_acirs: Buffer[], _witnessStack: WitnessMap[]): Promise<ClientIvcProof>;
|
|
30
|
-
computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=bb_private_kernel_prover.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bb_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../src/prover/bb_private_kernel_prover.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { AVM_PROOF_LENGTH_IN_FIELDS, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
|
|
2
|
-
import { type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
3
|
-
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
4
|
-
import { type ProofAndVerificationKey, type PublicInputsAndRecursiveProof, type ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
import type { BaseParityInputs, ParityPublicInputs, RootParityInputs } from '@aztec/stdlib/parity';
|
|
6
|
-
import { Proof } from '@aztec/stdlib/proofs';
|
|
7
|
-
import type { BaseOrMergeRollupPublicInputs, BlockMergeRollupInputs, BlockRootOrBlockMergePublicInputs, BlockRootRollupInputs, EmptyBlockRootRollupInputs, MergeRollupInputs, PrivateBaseRollupInputs, PublicBaseRollupInputs, RootRollupInputs, RootRollupPublicInputs, SingleTxBlockRootRollupInputs, TubeInputs } from '@aztec/stdlib/rollup';
|
|
8
|
-
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
9
|
-
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
-
import type { ACVMConfig, BBConfig } from '../config.js';
|
|
11
|
-
import { type UltraHonkFlavor } from '../honk.js';
|
|
12
|
-
export interface BBProverConfig extends BBConfig, ACVMConfig {
|
|
13
|
-
circuitFilter?: ServerProtocolArtifact[];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Prover implementation that uses barretenberg native proving
|
|
17
|
-
*/
|
|
18
|
-
export declare class BBNativeRollupProver implements ServerCircuitProver {
|
|
19
|
-
private config;
|
|
20
|
-
private instrumentation;
|
|
21
|
-
constructor(config: BBProverConfig, telemetry: TelemetryClient);
|
|
22
|
-
get tracer(): import("@aztec/telemetry-client").Tracer;
|
|
23
|
-
static new(config: BBProverConfig, telemetry?: TelemetryClient): Promise<BBNativeRollupProver>;
|
|
24
|
-
/**
|
|
25
|
-
* Simulates the base parity circuit from its inputs.
|
|
26
|
-
* @param inputs - Inputs to the circuit.
|
|
27
|
-
* @returns The public inputs of the parity circuit.
|
|
28
|
-
*/
|
|
29
|
-
getBaseParityProof(inputs: BaseParityInputs): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>>;
|
|
30
|
-
/**
|
|
31
|
-
* Simulates the root parity circuit from its inputs.
|
|
32
|
-
* @param inputs - Inputs to the circuit.
|
|
33
|
-
* @returns The public inputs of the parity circuit.
|
|
34
|
-
*/
|
|
35
|
-
getRootParityProof(inputs: RootParityInputs): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>>;
|
|
36
|
-
/**
|
|
37
|
-
* Creates an AVM proof and verifies it.
|
|
38
|
-
* @param inputs - The inputs to the AVM circuit.
|
|
39
|
-
* @returns The proof.
|
|
40
|
-
*/
|
|
41
|
-
getAvmProof(inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>>;
|
|
42
|
-
/**
|
|
43
|
-
* Simulates the base rollup circuit from its inputs.
|
|
44
|
-
* @param inputs - Inputs to the circuit.
|
|
45
|
-
* @returns The public inputs as outputs of the simulation.
|
|
46
|
-
*/
|
|
47
|
-
getPrivateBaseRollupProof(inputs: PrivateBaseRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
48
|
-
/**
|
|
49
|
-
* Requests that the public kernel tail circuit be executed and the proof generated
|
|
50
|
-
* @param kernelRequest - The object encapsulating the request for a proof
|
|
51
|
-
* @returns The requested circuit's public inputs and proof
|
|
52
|
-
*/
|
|
53
|
-
getPublicBaseRollupProof(inputs: PublicBaseRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
54
|
-
/**
|
|
55
|
-
* Simulates the merge rollup circuit from its inputs.
|
|
56
|
-
* @param input - Inputs to the circuit.
|
|
57
|
-
* @returns The public inputs as outputs of the simulation.
|
|
58
|
-
*/
|
|
59
|
-
getMergeRollupProof(input: MergeRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
60
|
-
/**
|
|
61
|
-
* Simulates the block root rollup circuit from its inputs.
|
|
62
|
-
* @param input - Inputs to the circuit.
|
|
63
|
-
* @returns The public inputs as outputs of the simulation.
|
|
64
|
-
*/
|
|
65
|
-
getBlockRootRollupProof(input: BlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
66
|
-
getSingleTxBlockRootRollupProof(input: SingleTxBlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
67
|
-
/**
|
|
68
|
-
* Simulates the empty block root rollup circuit from its inputs.
|
|
69
|
-
* @param input - Inputs to the circuit.
|
|
70
|
-
* @returns The public inputs as outputs of the simulation.
|
|
71
|
-
*/
|
|
72
|
-
getEmptyBlockRootRollupProof(input: EmptyBlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
73
|
-
/**
|
|
74
|
-
* Simulates the block merge rollup circuit from its inputs.
|
|
75
|
-
* @param input - Inputs to the circuit.
|
|
76
|
-
* @returns The public inputs as outputs of the simulation.
|
|
77
|
-
*/
|
|
78
|
-
getBlockMergeRollupProof(input: BlockMergeRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
79
|
-
/**
|
|
80
|
-
* Simulates the root rollup circuit from its inputs.
|
|
81
|
-
* @param input - Inputs to the circuit.
|
|
82
|
-
* @returns The public inputs as outputs of the simulation.
|
|
83
|
-
*/
|
|
84
|
-
getRootRollupProof(input: RootRollupInputs): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs>>;
|
|
85
|
-
private generateProofWithBB;
|
|
86
|
-
private createProof;
|
|
87
|
-
private generateAvmProofWithBB;
|
|
88
|
-
private generateTubeProofWithBB;
|
|
89
|
-
private createAvmProof;
|
|
90
|
-
getTubeProof(input: TubeInputs): Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>>;
|
|
91
|
-
/**
|
|
92
|
-
* Executes a circuit and returns its outputs and corresponding proof with embedded aggregation object
|
|
93
|
-
* @param witnessMap - The input witness
|
|
94
|
-
* @param circuitType - The type of circuit to be executed
|
|
95
|
-
* @param proofLength - The length of the proof to be generated. This is a dummy parameter to aid in type checking
|
|
96
|
-
* @param convertInput - Function for mapping the input object to a witness map.
|
|
97
|
-
* @param convertOutput - Function for parsing the output witness to it's corresponding object
|
|
98
|
-
* @returns The circuits output object and it's proof
|
|
99
|
-
*/
|
|
100
|
-
private createRecursiveProof;
|
|
101
|
-
/**
|
|
102
|
-
* Verifies a proof, will generate the verification key if one is not cached internally
|
|
103
|
-
* @param circuitType - The type of circuit whose proof is to be verified
|
|
104
|
-
* @param proof - The proof to be verified
|
|
105
|
-
*/
|
|
106
|
-
verifyProof(circuitType: ServerProtocolArtifact, proof: Proof): Promise<void>;
|
|
107
|
-
verifyAvmProof(proof: Proof, verificationKey: VerificationKeyData): Promise<void>;
|
|
108
|
-
verifyWithKey(flavor: UltraHonkFlavor, verificationKey: VerificationKeyData, proof: Proof): Promise<void>;
|
|
109
|
-
private verifyWithKeyInternal;
|
|
110
|
-
/**
|
|
111
|
-
* Returns the verification key data for a circuit.
|
|
112
|
-
* @param circuitType - The type of circuit for which the verification key is required
|
|
113
|
-
* @returns The verification key data
|
|
114
|
-
*/
|
|
115
|
-
private getVerificationKeyDataForCircuit;
|
|
116
|
-
private readProofAsFields;
|
|
117
|
-
private readAvmProofAsFields;
|
|
118
|
-
private runInDirectory;
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=bb_prover.d.ts.map
|