@aztec/bb-prover 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9
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
|
@@ -4,74 +4,89 @@ import {
|
|
|
4
4
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
5
5
|
PAIRING_POINTS_SIZE,
|
|
6
6
|
RECURSIVE_PROOF_LENGTH,
|
|
7
|
-
TUBE_PROOF_LENGTH,
|
|
8
7
|
ULTRA_KECCAK_PROOF_LENGTH,
|
|
9
8
|
} from '@aztec/constants';
|
|
10
|
-
import { Fr } from '@aztec/foundation/
|
|
9
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
10
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
12
11
|
import { createLogger } from '@aztec/foundation/log';
|
|
13
12
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
14
13
|
import {
|
|
15
14
|
type ServerProtocolArtifact,
|
|
16
|
-
convertBaseParityInputsToWitnessMap,
|
|
17
|
-
convertBaseParityOutputsFromWitnessMap,
|
|
18
|
-
convertBlockMergeRollupInputsToWitnessMap,
|
|
19
15
|
convertBlockMergeRollupOutputsFromWitnessMap,
|
|
20
|
-
|
|
16
|
+
convertBlockMergeRollupPrivateInputsToWitnessMap,
|
|
17
|
+
convertBlockRootEmptyTxFirstRollupOutputsFromWitnessMap,
|
|
18
|
+
convertBlockRootEmptyTxFirstRollupPrivateInputsToWitnessMap,
|
|
19
|
+
convertBlockRootFirstRollupOutputsFromWitnessMap,
|
|
20
|
+
convertBlockRootFirstRollupPrivateInputsToWitnessMap,
|
|
21
21
|
convertBlockRootRollupOutputsFromWitnessMap,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
convertBlockRootRollupPrivateInputsToWitnessMap,
|
|
23
|
+
convertBlockRootSingleTxFirstRollupOutputsFromWitnessMap,
|
|
24
|
+
convertBlockRootSingleTxFirstRollupPrivateInputsToWitnessMap,
|
|
25
|
+
convertBlockRootSingleTxRollupOutputsFromWitnessMap,
|
|
26
|
+
convertBlockRootSingleTxRollupPrivateInputsToWitnessMap,
|
|
27
|
+
convertCheckpointMergeRollupOutputsFromWitnessMap,
|
|
28
|
+
convertCheckpointMergeRollupPrivateInputsToWitnessMap,
|
|
29
|
+
convertCheckpointPaddingRollupOutputsFromWitnessMap,
|
|
30
|
+
convertCheckpointPaddingRollupPrivateInputsToWitnessMap,
|
|
31
|
+
convertCheckpointRootRollupOutputsFromWitnessMap,
|
|
32
|
+
convertCheckpointRootRollupPrivateInputsToWitnessMap,
|
|
33
|
+
convertCheckpointRootSingleBlockRollupOutputsFromWitnessMap,
|
|
34
|
+
convertCheckpointRootSingleBlockRollupPrivateInputsToWitnessMap,
|
|
35
|
+
convertParityBaseOutputsFromWitnessMap,
|
|
36
|
+
convertParityBasePrivateInputsToWitnessMap,
|
|
37
|
+
convertParityRootOutputsFromWitnessMap,
|
|
38
|
+
convertParityRootPrivateInputsToWitnessMap,
|
|
39
|
+
convertPrivateTxBaseRollupOutputsFromWitnessMap,
|
|
40
|
+
convertPrivateTxBaseRollupPrivateInputsToWitnessMap,
|
|
41
|
+
convertPublicChonkVerifierOutputsFromWitnessMap,
|
|
42
|
+
convertPublicChonkVerifierPrivateInputsToWitnessMap,
|
|
43
|
+
convertPublicTxBaseRollupOutputsFromWitnessMap,
|
|
44
|
+
convertPublicTxBaseRollupPrivateInputsToWitnessMap,
|
|
35
45
|
convertRootRollupOutputsFromWitnessMap,
|
|
36
|
-
|
|
37
|
-
|
|
46
|
+
convertRootRollupPrivateInputsToWitnessMap,
|
|
47
|
+
convertTxMergeRollupOutputsFromWitnessMap,
|
|
48
|
+
convertTxMergeRollupPrivateInputsToWitnessMap,
|
|
38
49
|
getServerCircuitArtifact,
|
|
39
50
|
} from '@aztec/noir-protocol-circuits-types/server';
|
|
40
51
|
import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
52
|
+
import { mapProtocolArtifactNameToCircuitName } from '@aztec/noir-protocol-circuits-types/types';
|
|
41
53
|
import type { WitnessMap } from '@aztec/noir-types';
|
|
42
54
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
43
55
|
import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
44
56
|
import { ProvingError } from '@aztec/stdlib/errors';
|
|
45
57
|
import {
|
|
46
|
-
type ProofAndVerificationKey,
|
|
47
58
|
type PublicInputsAndRecursiveProof,
|
|
48
59
|
type ServerCircuitProver,
|
|
49
|
-
makeProofAndVerificationKey,
|
|
50
60
|
makePublicInputsAndRecursiveProof,
|
|
51
61
|
} from '@aztec/stdlib/interfaces/server';
|
|
52
|
-
import type {
|
|
62
|
+
import type { ParityBasePrivateInputs, ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
53
63
|
import { Proof, RecursiveProof, makeRecursiveProofFromBinary } from '@aztec/stdlib/proofs';
|
|
54
64
|
import {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
BlockMergeRollupPrivateInputs,
|
|
66
|
+
BlockRollupPublicInputs,
|
|
67
|
+
BlockRootEmptyTxFirstRollupPrivateInputs,
|
|
68
|
+
BlockRootFirstRollupPrivateInputs,
|
|
69
|
+
BlockRootRollupPrivateInputs,
|
|
70
|
+
BlockRootSingleTxFirstRollupPrivateInputs,
|
|
71
|
+
BlockRootSingleTxRollupPrivateInputs,
|
|
72
|
+
CheckpointMergeRollupPrivateInputs,
|
|
73
|
+
CheckpointPaddingRollupPrivateInputs,
|
|
74
|
+
CheckpointRollupPublicInputs,
|
|
75
|
+
CheckpointRootRollupPrivateInputs,
|
|
76
|
+
CheckpointRootSingleBlockRollupPrivateInputs,
|
|
77
|
+
type PrivateTxBaseRollupPrivateInputs,
|
|
78
|
+
PublicChonkVerifierPrivateInputs,
|
|
79
|
+
PublicChonkVerifierPublicInputs,
|
|
80
|
+
PublicTxBaseRollupPrivateInputs,
|
|
81
|
+
type RootRollupPrivateInputs,
|
|
65
82
|
type RootRollupPublicInputs,
|
|
66
|
-
type
|
|
67
|
-
type
|
|
68
|
-
enhanceProofWithPiValidationFlag,
|
|
83
|
+
type TxMergeRollupPrivateInputs,
|
|
84
|
+
type TxRollupPublicInputs,
|
|
69
85
|
} from '@aztec/stdlib/rollup';
|
|
70
86
|
import type { CircuitProvingStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
71
|
-
import
|
|
87
|
+
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
72
88
|
import { Attributes, type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
73
89
|
|
|
74
|
-
import crypto from 'crypto';
|
|
75
90
|
import { promises as fs } from 'fs';
|
|
76
91
|
import * as path from 'path';
|
|
77
92
|
|
|
@@ -84,17 +99,13 @@ import {
|
|
|
84
99
|
VK_FILENAME,
|
|
85
100
|
generateAvmProof,
|
|
86
101
|
generateProof,
|
|
87
|
-
generateTubeProof,
|
|
88
102
|
verifyAvmProof,
|
|
89
103
|
verifyProof,
|
|
90
104
|
} from '../../bb/execute.js';
|
|
91
105
|
import type { ACVMConfig, BBConfig } from '../../config.js';
|
|
92
|
-
import {
|
|
106
|
+
import { getUltraHonkFlavorForCircuit } from '../../honk.js';
|
|
93
107
|
import { ProverInstrumentation } from '../../instrumentation.js';
|
|
94
|
-
import {
|
|
95
|
-
import { extractAvmVkData, extractVkData } from '../../verification_key/verification_key_data.js';
|
|
96
|
-
import { PRIVATE_TAIL_CIVC_VK, PUBLIC_TAIL_CIVC_VK } from '../../verifier/bb_verifier.js';
|
|
97
|
-
import { readProofAsFields, writeClientIVCProofToOutputDirectory } from '../proof_utils.js';
|
|
108
|
+
import { readProofsFromOutputDirectory } from '../proof_utils.js';
|
|
98
109
|
|
|
99
110
|
const logger = createLogger('bb-prover');
|
|
100
111
|
|
|
@@ -136,22 +147,17 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
136
147
|
* @param inputs - Inputs to the circuit.
|
|
137
148
|
* @returns The public inputs of the parity circuit.
|
|
138
149
|
*/
|
|
139
|
-
@trackSpan('BBNativeRollupProver.getBaseParityProof', { [Attributes.PROTOCOL_CIRCUIT_NAME]: 'base
|
|
140
|
-
public
|
|
141
|
-
inputs:
|
|
150
|
+
@trackSpan('BBNativeRollupProver.getBaseParityProof', { [Attributes.PROTOCOL_CIRCUIT_NAME]: 'parity-base' })
|
|
151
|
+
public getBaseParityProof(
|
|
152
|
+
inputs: ParityBasePrivateInputs,
|
|
142
153
|
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> {
|
|
143
|
-
|
|
154
|
+
return this.createRecursiveProofAndVerify(
|
|
144
155
|
inputs,
|
|
145
|
-
'
|
|
156
|
+
'ParityBaseArtifact',
|
|
146
157
|
RECURSIVE_PROOF_LENGTH,
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
convertParityBasePrivateInputsToWitnessMap,
|
|
159
|
+
convertParityBaseOutputsFromWitnessMap,
|
|
149
160
|
);
|
|
150
|
-
|
|
151
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('BaseParityArtifact');
|
|
152
|
-
await this.verifyProof('BaseParityArtifact', proof.binaryProof);
|
|
153
|
-
|
|
154
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
155
161
|
}
|
|
156
162
|
|
|
157
163
|
/**
|
|
@@ -159,22 +165,17 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
159
165
|
* @param inputs - Inputs to the circuit.
|
|
160
166
|
* @returns The public inputs of the parity circuit.
|
|
161
167
|
*/
|
|
162
|
-
@trackSpan('BBNativeRollupProver.getRootParityProof', { [Attributes.PROTOCOL_CIRCUIT_NAME]: 'root
|
|
163
|
-
public
|
|
164
|
-
inputs:
|
|
168
|
+
@trackSpan('BBNativeRollupProver.getRootParityProof', { [Attributes.PROTOCOL_CIRCUIT_NAME]: 'parity-root' })
|
|
169
|
+
public getRootParityProof(
|
|
170
|
+
inputs: ParityRootPrivateInputs,
|
|
165
171
|
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>> {
|
|
166
|
-
|
|
172
|
+
return this.createRecursiveProofAndVerify(
|
|
167
173
|
inputs,
|
|
168
|
-
'
|
|
174
|
+
'ParityRootArtifact',
|
|
169
175
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
170
|
-
|
|
171
|
-
|
|
176
|
+
convertParityRootPrivateInputsToWitnessMap,
|
|
177
|
+
convertParityRootOutputsFromWitnessMap,
|
|
172
178
|
);
|
|
173
|
-
|
|
174
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('RootParityArtifact');
|
|
175
|
-
await this.verifyProof('RootParityArtifact', proof.binaryProof);
|
|
176
|
-
|
|
177
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
/**
|
|
@@ -187,34 +188,25 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
187
188
|
}))
|
|
188
189
|
public async getAvmProof(
|
|
189
190
|
inputs: AvmCircuitInputs,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
// TODO(#14234)[Unconditional PIs validation]: remove next lines and directly return proofAndVk
|
|
196
|
-
proofAndVk.proof.proof = enhanceProofWithPiValidationFlag(proofAndVk.proof.proof, skipPublicInputsValidation);
|
|
197
|
-
return proofAndVk;
|
|
191
|
+
): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
|
|
192
|
+
const proof = await this.createAvmProof(inputs);
|
|
193
|
+
await this.verifyAvmProof(proof.binaryProof, inputs.publicInputs);
|
|
194
|
+
return proof;
|
|
198
195
|
}
|
|
199
196
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
* @param inputs - Inputs to the circuit.
|
|
203
|
-
* @returns The public inputs as outputs of the simulation.
|
|
204
|
-
*/
|
|
205
|
-
public async getPrivateBaseRollupProof(
|
|
206
|
-
inputs: PrivateBaseRollupInputs,
|
|
197
|
+
public async getPublicChonkVerifierProof(
|
|
198
|
+
inputs: PublicChonkVerifierPrivateInputs,
|
|
207
199
|
): Promise<
|
|
208
|
-
PublicInputsAndRecursiveProof<
|
|
200
|
+
PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
209
201
|
> {
|
|
210
|
-
const artifactName = '
|
|
202
|
+
const artifactName = 'PublicChonkVerifier';
|
|
211
203
|
|
|
212
204
|
const { circuitOutput, proof } = await this.createRecursiveProof(
|
|
213
205
|
inputs,
|
|
214
206
|
artifactName,
|
|
215
207
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
convertPublicChonkVerifierPrivateInputsToWitnessMap,
|
|
209
|
+
convertPublicChonkVerifierOutputsFromWitnessMap,
|
|
218
210
|
);
|
|
219
211
|
|
|
220
212
|
const verificationKey = this.getVerificationKeyDataForCircuit(artifactName);
|
|
@@ -224,31 +216,38 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
224
216
|
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
225
217
|
}
|
|
226
218
|
|
|
219
|
+
/**
|
|
220
|
+
* Simulates the base rollup circuit from its inputs.
|
|
221
|
+
* @param inputs - Inputs to the circuit.
|
|
222
|
+
* @returns The public inputs as outputs of the simulation.
|
|
223
|
+
*/
|
|
224
|
+
public getPrivateTxBaseRollupProof(
|
|
225
|
+
inputs: PrivateTxBaseRollupPrivateInputs,
|
|
226
|
+
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
227
|
+
return this.createRecursiveProofAndVerify(
|
|
228
|
+
inputs,
|
|
229
|
+
'PrivateTxBaseRollupArtifact',
|
|
230
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
231
|
+
convertPrivateTxBaseRollupPrivateInputsToWitnessMap,
|
|
232
|
+
convertPrivateTxBaseRollupOutputsFromWitnessMap,
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
227
236
|
/**
|
|
228
237
|
* Requests that the public kernel tail circuit be executed and the proof generated
|
|
229
238
|
* @param kernelRequest - The object encapsulating the request for a proof
|
|
230
239
|
* @returns The requested circuit's public inputs and proof
|
|
231
240
|
*/
|
|
232
|
-
public
|
|
233
|
-
inputs:
|
|
234
|
-
): Promise<
|
|
235
|
-
|
|
236
|
-
> {
|
|
237
|
-
const artifactName = 'PublicBaseRollupArtifact';
|
|
238
|
-
|
|
239
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(
|
|
241
|
+
public getPublicTxBaseRollupProof(
|
|
242
|
+
inputs: PublicTxBaseRollupPrivateInputs,
|
|
243
|
+
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
244
|
+
return this.createRecursiveProofAndVerify(
|
|
240
245
|
inputs,
|
|
241
|
-
|
|
246
|
+
'PublicTxBaseRollupArtifact',
|
|
242
247
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
243
|
-
|
|
244
|
-
|
|
248
|
+
convertPublicTxBaseRollupPrivateInputsToWitnessMap,
|
|
249
|
+
convertPublicTxBaseRollupOutputsFromWitnessMap,
|
|
245
250
|
);
|
|
246
|
-
|
|
247
|
-
const verificationKey = this.getVerificationKeyDataForCircuit(artifactName);
|
|
248
|
-
|
|
249
|
-
await this.verifyProof(artifactName, proof.binaryProof);
|
|
250
|
-
|
|
251
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
252
251
|
}
|
|
253
252
|
|
|
254
253
|
/**
|
|
@@ -256,139 +255,144 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
256
255
|
* @param input - Inputs to the circuit.
|
|
257
256
|
* @returns The public inputs as outputs of the simulation.
|
|
258
257
|
*/
|
|
259
|
-
public
|
|
260
|
-
input:
|
|
261
|
-
): Promise<
|
|
262
|
-
|
|
263
|
-
> {
|
|
264
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(
|
|
258
|
+
public getTxMergeRollupProof(
|
|
259
|
+
input: TxMergeRollupPrivateInputs,
|
|
260
|
+
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
261
|
+
return this.createRecursiveProofAndVerify(
|
|
265
262
|
input,
|
|
266
|
-
'
|
|
263
|
+
'TxMergeRollupArtifact',
|
|
267
264
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
convertTxMergeRollupPrivateInputsToWitnessMap,
|
|
266
|
+
convertTxMergeRollupOutputsFromWitnessMap,
|
|
270
267
|
);
|
|
268
|
+
}
|
|
271
269
|
|
|
272
|
-
|
|
270
|
+
public getBlockRootFirstRollupProof(
|
|
271
|
+
input: BlockRootFirstRollupPrivateInputs,
|
|
272
|
+
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
273
|
+
return this.createRecursiveProofAndVerify(
|
|
274
|
+
input,
|
|
275
|
+
'BlockRootFirstRollupArtifact',
|
|
276
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
277
|
+
convertBlockRootFirstRollupPrivateInputsToWitnessMap,
|
|
278
|
+
convertBlockRootFirstRollupOutputsFromWitnessMap,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
273
281
|
|
|
274
|
-
|
|
282
|
+
public getBlockRootSingleTxFirstRollupProof(
|
|
283
|
+
input: BlockRootSingleTxFirstRollupPrivateInputs,
|
|
284
|
+
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
285
|
+
return this.createRecursiveProofAndVerify(
|
|
286
|
+
input,
|
|
287
|
+
'BlockRootSingleTxFirstRollupArtifact',
|
|
288
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
289
|
+
convertBlockRootSingleTxFirstRollupPrivateInputsToWitnessMap,
|
|
290
|
+
convertBlockRootSingleTxFirstRollupOutputsFromWitnessMap,
|
|
291
|
+
);
|
|
292
|
+
}
|
|
275
293
|
|
|
276
|
-
|
|
294
|
+
public getBlockRootEmptyTxFirstRollupProof(
|
|
295
|
+
input: BlockRootEmptyTxFirstRollupPrivateInputs,
|
|
296
|
+
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
297
|
+
return this.createRecursiveProofAndVerify(
|
|
298
|
+
input,
|
|
299
|
+
'BlockRootEmptyTxFirstRollupArtifact',
|
|
300
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
301
|
+
convertBlockRootEmptyTxFirstRollupPrivateInputsToWitnessMap,
|
|
302
|
+
convertBlockRootEmptyTxFirstRollupOutputsFromWitnessMap,
|
|
303
|
+
);
|
|
277
304
|
}
|
|
278
305
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
*/
|
|
284
|
-
public async getBlockRootRollupProof(
|
|
285
|
-
input: BlockRootRollupInputs,
|
|
286
|
-
): Promise<
|
|
287
|
-
PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
288
|
-
> {
|
|
289
|
-
const { circuitOutput, proof } = await this.createRecursiveProof(
|
|
306
|
+
public getBlockRootRollupProof(
|
|
307
|
+
input: BlockRootRollupPrivateInputs,
|
|
308
|
+
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
309
|
+
return this.createRecursiveProofAndVerify(
|
|
290
310
|
input,
|
|
291
311
|
'BlockRootRollupArtifact',
|
|
292
312
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
293
|
-
|
|
313
|
+
convertBlockRootRollupPrivateInputsToWitnessMap,
|
|
294
314
|
convertBlockRootRollupOutputsFromWitnessMap,
|
|
295
315
|
);
|
|
316
|
+
}
|
|
296
317
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
318
|
+
public getBlockRootSingleTxRollupProof(
|
|
319
|
+
input: BlockRootSingleTxRollupPrivateInputs,
|
|
320
|
+
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
321
|
+
return this.createRecursiveProofAndVerify(
|
|
322
|
+
input,
|
|
323
|
+
'BlockRootSingleTxRollupArtifact',
|
|
324
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
325
|
+
convertBlockRootSingleTxRollupPrivateInputsToWitnessMap,
|
|
326
|
+
convertBlockRootSingleTxRollupOutputsFromWitnessMap,
|
|
327
|
+
);
|
|
328
|
+
}
|
|
300
329
|
|
|
301
|
-
|
|
330
|
+
public getBlockMergeRollupProof(
|
|
331
|
+
input: BlockMergeRollupPrivateInputs,
|
|
332
|
+
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
333
|
+
return this.createRecursiveProofAndVerify(
|
|
334
|
+
input,
|
|
335
|
+
'BlockMergeRollupArtifact',
|
|
336
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
337
|
+
convertBlockMergeRollupPrivateInputsToWitnessMap,
|
|
338
|
+
convertBlockMergeRollupOutputsFromWitnessMap,
|
|
339
|
+
);
|
|
302
340
|
}
|
|
303
341
|
|
|
304
|
-
public
|
|
305
|
-
input:
|
|
342
|
+
public getCheckpointRootRollupProof(
|
|
343
|
+
input: CheckpointRootRollupPrivateInputs,
|
|
306
344
|
): Promise<
|
|
307
|
-
PublicInputsAndRecursiveProof<
|
|
345
|
+
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
308
346
|
> {
|
|
309
|
-
|
|
347
|
+
return this.createRecursiveProofAndVerify(
|
|
310
348
|
input,
|
|
311
|
-
'
|
|
349
|
+
'CheckpointRootRollupArtifact',
|
|
312
350
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
313
|
-
|
|
314
|
-
|
|
351
|
+
convertCheckpointRootRollupPrivateInputsToWitnessMap,
|
|
352
|
+
convertCheckpointRootRollupOutputsFromWitnessMap,
|
|
315
353
|
);
|
|
316
|
-
|
|
317
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('SingleTxBlockRootRollupArtifact');
|
|
318
|
-
|
|
319
|
-
await this.verifyProof('SingleTxBlockRootRollupArtifact', proof.binaryProof);
|
|
320
|
-
|
|
321
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
322
354
|
}
|
|
323
355
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
* @param input - Inputs to the circuit.
|
|
327
|
-
* @returns The public inputs as outputs of the simulation.
|
|
328
|
-
*/
|
|
329
|
-
public async getEmptyBlockRootRollupProof(
|
|
330
|
-
input: EmptyBlockRootRollupInputs,
|
|
356
|
+
public getCheckpointRootSingleBlockRollupProof(
|
|
357
|
+
input: CheckpointRootSingleBlockRollupPrivateInputs,
|
|
331
358
|
): Promise<
|
|
332
|
-
PublicInputsAndRecursiveProof<
|
|
359
|
+
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
333
360
|
> {
|
|
334
|
-
|
|
361
|
+
return this.createRecursiveProofAndVerify(
|
|
335
362
|
input,
|
|
336
|
-
'
|
|
363
|
+
'CheckpointRootSingleBlockRollupArtifact',
|
|
337
364
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
338
|
-
|
|
339
|
-
|
|
365
|
+
convertCheckpointRootSingleBlockRollupPrivateInputsToWitnessMap,
|
|
366
|
+
convertCheckpointRootSingleBlockRollupOutputsFromWitnessMap,
|
|
340
367
|
);
|
|
341
|
-
|
|
342
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('EmptyBlockRootRollupArtifact');
|
|
343
|
-
|
|
344
|
-
await this.verifyProof('EmptyBlockRootRollupArtifact', proof.binaryProof);
|
|
345
|
-
|
|
346
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
347
368
|
}
|
|
348
369
|
|
|
349
|
-
public
|
|
350
|
-
input:
|
|
370
|
+
public getCheckpointPaddingRollupProof(
|
|
371
|
+
input: CheckpointPaddingRollupPrivateInputs,
|
|
351
372
|
): Promise<
|
|
352
|
-
PublicInputsAndRecursiveProof<
|
|
373
|
+
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
353
374
|
> {
|
|
354
|
-
|
|
375
|
+
return this.createRecursiveProofAndVerify(
|
|
355
376
|
input,
|
|
356
|
-
'
|
|
377
|
+
'CheckpointPaddingRollupArtifact',
|
|
357
378
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
358
|
-
|
|
359
|
-
|
|
379
|
+
convertCheckpointPaddingRollupPrivateInputsToWitnessMap,
|
|
380
|
+
convertCheckpointPaddingRollupOutputsFromWitnessMap,
|
|
360
381
|
);
|
|
361
|
-
|
|
362
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('PaddingBlockRootRollupArtifact');
|
|
363
|
-
|
|
364
|
-
await this.verifyProof('PaddingBlockRootRollupArtifact', proof.binaryProof);
|
|
365
|
-
|
|
366
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
367
382
|
}
|
|
368
383
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
* @param input - Inputs to the circuit.
|
|
372
|
-
* @returns The public inputs as outputs of the simulation.
|
|
373
|
-
*/
|
|
374
|
-
public async getBlockMergeRollupProof(
|
|
375
|
-
input: BlockMergeRollupInputs,
|
|
384
|
+
public getCheckpointMergeRollupProof(
|
|
385
|
+
input: CheckpointMergeRollupPrivateInputs,
|
|
376
386
|
): Promise<
|
|
377
|
-
PublicInputsAndRecursiveProof<
|
|
387
|
+
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
378
388
|
> {
|
|
379
|
-
|
|
389
|
+
return this.createRecursiveProofAndVerify(
|
|
380
390
|
input,
|
|
381
|
-
'
|
|
391
|
+
'CheckpointMergeRollupArtifact',
|
|
382
392
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
383
|
-
|
|
384
|
-
|
|
393
|
+
convertCheckpointMergeRollupPrivateInputsToWitnessMap,
|
|
394
|
+
convertCheckpointMergeRollupOutputsFromWitnessMap,
|
|
385
395
|
);
|
|
386
|
-
|
|
387
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('BlockMergeRollupArtifact');
|
|
388
|
-
|
|
389
|
-
await this.verifyProof('BlockMergeRollupArtifact', proof.binaryProof);
|
|
390
|
-
|
|
391
|
-
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
392
396
|
}
|
|
393
397
|
|
|
394
398
|
/**
|
|
@@ -397,23 +401,47 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
397
401
|
* @returns The public inputs as outputs of the simulation.
|
|
398
402
|
*/
|
|
399
403
|
public async getRootRollupProof(
|
|
400
|
-
input:
|
|
401
|
-
): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs>> {
|
|
402
|
-
const {
|
|
404
|
+
input: RootRollupPrivateInputs,
|
|
405
|
+
): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>> {
|
|
406
|
+
const { proof, ...output } = await this.createRecursiveProofAndVerify(
|
|
403
407
|
input,
|
|
404
408
|
'RootRollupArtifact',
|
|
405
|
-
|
|
409
|
+
ULTRA_KECCAK_PROOF_LENGTH,
|
|
410
|
+
convertRootRollupPrivateInputsToWitnessMap,
|
|
406
411
|
convertRootRollupOutputsFromWitnessMap,
|
|
407
412
|
);
|
|
408
413
|
|
|
409
|
-
const recursiveProof = makeRecursiveProofFromBinary(proof, NESTED_RECURSIVE_PROOF_LENGTH);
|
|
410
|
-
|
|
411
|
-
const verificationKey = this.getVerificationKeyDataForCircuit('RootRollupArtifact');
|
|
412
|
-
|
|
413
|
-
await this.verifyProof('RootRollupArtifact', proof);
|
|
414
|
+
const recursiveProof = makeRecursiveProofFromBinary(proof.binaryProof, NESTED_RECURSIVE_PROOF_LENGTH);
|
|
414
415
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/13188): Remove this hack.
|
|
415
416
|
recursiveProof.binaryProof.numPublicInputs += PAIRING_POINTS_SIZE;
|
|
416
|
-
|
|
417
|
+
|
|
418
|
+
return { ...output, proof: recursiveProof };
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
private async createRecursiveProofAndVerify<
|
|
422
|
+
PROOF_LENGTH extends number,
|
|
423
|
+
CircuitInputType extends { toBuffer: () => Buffer },
|
|
424
|
+
CircuitOutputType extends { toBuffer: () => Buffer },
|
|
425
|
+
>(
|
|
426
|
+
input: CircuitInputType,
|
|
427
|
+
artifactName: ServerProtocolArtifact,
|
|
428
|
+
proofLength: PROOF_LENGTH,
|
|
429
|
+
convertInput: (input: CircuitInputType) => WitnessMap,
|
|
430
|
+
convertOutput: (outputWitness: WitnessMap) => CircuitOutputType,
|
|
431
|
+
) {
|
|
432
|
+
const { circuitOutput, proof } = await this.createRecursiveProof(
|
|
433
|
+
input,
|
|
434
|
+
artifactName,
|
|
435
|
+
proofLength,
|
|
436
|
+
convertInput,
|
|
437
|
+
convertOutput,
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
await this.verifyProof(artifactName, proof.binaryProof);
|
|
441
|
+
|
|
442
|
+
const verificationKey = this.getVerificationKeyDataForCircuit(artifactName);
|
|
443
|
+
|
|
444
|
+
return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
|
|
417
445
|
}
|
|
418
446
|
|
|
419
447
|
private async generateProofWithBB<
|
|
@@ -435,6 +463,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
435
463
|
this.config.acvmWorkingDirectory,
|
|
436
464
|
this.config.acvmBinaryPath,
|
|
437
465
|
outputWitnessFile,
|
|
466
|
+
logger,
|
|
438
467
|
);
|
|
439
468
|
|
|
440
469
|
const artifact = getServerCircuitArtifact(circuitType);
|
|
@@ -467,6 +496,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
467
496
|
workingDirectory,
|
|
468
497
|
circuitType,
|
|
469
498
|
Buffer.from(artifact.bytecode, 'base64'),
|
|
499
|
+
this.getVerificationKeyDataForCircuit(circuitType).keyAsBytes,
|
|
470
500
|
outputWitnessFile,
|
|
471
501
|
getUltraHonkFlavorForCircuit(circuitType),
|
|
472
502
|
logger,
|
|
@@ -483,49 +513,6 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
483
513
|
};
|
|
484
514
|
}
|
|
485
515
|
|
|
486
|
-
private async createProof<Input extends { toBuffer: () => Buffer }, Output extends { toBuffer: () => Buffer }>(
|
|
487
|
-
input: Input,
|
|
488
|
-
circuitType: ServerProtocolArtifact,
|
|
489
|
-
convertInput: (input: Input) => WitnessMap,
|
|
490
|
-
convertOutput: (outputWitness: WitnessMap) => Output,
|
|
491
|
-
): Promise<{ circuitOutput: Output; proof: Proof }> {
|
|
492
|
-
const operation = async (bbWorkingDirectory: string) => {
|
|
493
|
-
const { provingResult, circuitOutput: output } = await this.generateProofWithBB(
|
|
494
|
-
input,
|
|
495
|
-
circuitType,
|
|
496
|
-
convertInput,
|
|
497
|
-
convertOutput,
|
|
498
|
-
bbWorkingDirectory,
|
|
499
|
-
);
|
|
500
|
-
const vkData = this.getVerificationKeyDataForCircuit(circuitType);
|
|
501
|
-
|
|
502
|
-
const PROOF_LENGTH = circuitType == 'RootRollupArtifact' ? ULTRA_KECCAK_PROOF_LENGTH : RECURSIVE_PROOF_LENGTH;
|
|
503
|
-
const proof = await readProofAsFields(provingResult.proofPath!, vkData, PROOF_LENGTH, logger);
|
|
504
|
-
|
|
505
|
-
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
506
|
-
|
|
507
|
-
this.instrumentation.recordDuration('provingDuration', circuitName, provingResult.durationMs);
|
|
508
|
-
this.instrumentation.recordSize('proofSize', circuitName, proof.binaryProof.buffer.length);
|
|
509
|
-
this.instrumentation.recordSize('circuitPublicInputCount', circuitName, vkData.numPublicInputs);
|
|
510
|
-
this.instrumentation.recordSize('circuitSize', circuitName, vkData.circuitSize);
|
|
511
|
-
|
|
512
|
-
logger.info(`Generated proof for ${circuitType} in ${Math.ceil(provingResult.durationMs)} ms`, {
|
|
513
|
-
circuitName,
|
|
514
|
-
// does not include reading the proof from disk
|
|
515
|
-
duration: provingResult.durationMs,
|
|
516
|
-
proofSize: proof.binaryProof.buffer.length,
|
|
517
|
-
eventName: 'circuit-proving',
|
|
518
|
-
// circuitOutput is the partial witness that became the input to the proof
|
|
519
|
-
inputSize: output.toBuffer().length,
|
|
520
|
-
circuitSize: vkData.circuitSize,
|
|
521
|
-
numPublicInputs: vkData.numPublicInputs,
|
|
522
|
-
} satisfies CircuitProvingStats);
|
|
523
|
-
|
|
524
|
-
return { circuitOutput: output, proof: proof.binaryProof };
|
|
525
|
-
};
|
|
526
|
-
return await this.runInDirectory(operation);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
516
|
private async generateAvmProofWithBB(input: AvmCircuitInputs, workingDirectory: string): Promise<BBSuccess> {
|
|
530
517
|
logger.info(`Proving avm-circuit for TX ${input.hints.tx.hash}...`);
|
|
531
518
|
|
|
@@ -539,35 +526,12 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
539
526
|
return provingResult;
|
|
540
527
|
}
|
|
541
528
|
|
|
542
|
-
private async generateTubeProofWithBB(bbWorkingDirectory: string, input: TubeInputs): Promise<BBSuccess> {
|
|
543
|
-
logger.debug(`Proving tube...`);
|
|
544
|
-
|
|
545
|
-
const hasher = crypto.createHash('sha256');
|
|
546
|
-
hasher.update(input.toBuffer());
|
|
547
|
-
|
|
548
|
-
await writeClientIVCProofToOutputDirectory(input.clientIVCData, bbWorkingDirectory);
|
|
549
|
-
const provingResult = await generateTubeProof(
|
|
550
|
-
this.config.bbBinaryPath,
|
|
551
|
-
bbWorkingDirectory,
|
|
552
|
-
input.usePublicTailVk ? PUBLIC_TAIL_CIVC_VK : PRIVATE_TAIL_CIVC_VK,
|
|
553
|
-
logger.verbose,
|
|
554
|
-
);
|
|
555
|
-
|
|
556
|
-
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
557
|
-
logger.error(`Failed to generate proof for tube circuit: ${provingResult.reason}`);
|
|
558
|
-
throw new ProvingError(provingResult.reason, provingResult, provingResult.retry);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
return provingResult;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
529
|
private async createAvmProof(
|
|
565
530
|
input: AvmCircuitInputs,
|
|
566
|
-
): Promise<
|
|
531
|
+
): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
|
|
567
532
|
const operation = async (bbWorkingDirectory: string) => {
|
|
568
533
|
const provingResult = await this.generateAvmProofWithBB(input, bbWorkingDirectory);
|
|
569
534
|
|
|
570
|
-
const avmVK = await extractAvmVkData(provingResult.vkDirectoryPath!);
|
|
571
535
|
const avmProof = await this.readAvmProofAsFields(provingResult.proofPath!);
|
|
572
536
|
|
|
573
537
|
const circuitType = 'avm-circuit' as const;
|
|
@@ -590,36 +554,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
590
554
|
} satisfies CircuitProvingStats,
|
|
591
555
|
);
|
|
592
556
|
|
|
593
|
-
return
|
|
594
|
-
};
|
|
595
|
-
return await this.runInDirectory(operation);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
public async getTubeProof(input: TubeInputs): Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>> {
|
|
599
|
-
const operation = async (bbWorkingDirectory: string) => {
|
|
600
|
-
logger.debug(`createTubeProof: ${bbWorkingDirectory}`);
|
|
601
|
-
const provingResult = await this.generateTubeProofWithBB(bbWorkingDirectory, input);
|
|
602
|
-
|
|
603
|
-
// Read the proof as fields
|
|
604
|
-
// TODO(AD): this is the only remaining use of extractVkData.
|
|
605
|
-
const tubeVK = await extractVkData(provingResult.vkDirectoryPath!);
|
|
606
|
-
const tubeProof = await readProofAsFields(provingResult.proofPath!, tubeVK, TUBE_PROOF_LENGTH, logger);
|
|
607
|
-
|
|
608
|
-
this.instrumentation.recordDuration('provingDuration', 'tubeCircuit', provingResult.durationMs);
|
|
609
|
-
this.instrumentation.recordSize('proofSize', 'tubeCircuit', tubeProof.binaryProof.buffer.length);
|
|
610
|
-
this.instrumentation.recordSize('circuitPublicInputCount', 'tubeCircuit', tubeVK.numPublicInputs);
|
|
611
|
-
this.instrumentation.recordSize('circuitSize', 'tubeCircuit', tubeVK.circuitSize);
|
|
612
|
-
|
|
613
|
-
// Sanity check the tube proof (can be removed later)
|
|
614
|
-
await this.verifyWithKey('ultra_rollup_honk', tubeVK, tubeProof.binaryProof);
|
|
615
|
-
|
|
616
|
-
logger.info(
|
|
617
|
-
`Generated proof for tubeCircuit in ${Math.ceil(provingResult.durationMs)} ms, size: ${
|
|
618
|
-
tubeProof.proof.length
|
|
619
|
-
} fields`,
|
|
620
|
-
);
|
|
621
|
-
|
|
622
|
-
return makeProofAndVerificationKey(tubeProof, tubeVK);
|
|
557
|
+
return avmProof;
|
|
623
558
|
};
|
|
624
559
|
return await this.runInDirectory(operation);
|
|
625
560
|
}
|
|
@@ -644,7 +579,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
644
579
|
convertInput: (input: CircuitInputType) => WitnessMap,
|
|
645
580
|
convertOutput: (outputWitness: WitnessMap) => CircuitOutputType,
|
|
646
581
|
): Promise<{ circuitOutput: CircuitOutputType; proof: RecursiveProof<PROOF_LENGTH> }> {
|
|
647
|
-
// this probably is gonna need to call
|
|
582
|
+
// this probably is gonna need to call chonk
|
|
648
583
|
const operation = async (bbWorkingDirectory: string) => {
|
|
649
584
|
const { provingResult, circuitOutput: output } = await this.generateProofWithBB(
|
|
650
585
|
input,
|
|
@@ -656,7 +591,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
656
591
|
|
|
657
592
|
const vkData = this.getVerificationKeyDataForCircuit(circuitType);
|
|
658
593
|
// Read the proof as fields
|
|
659
|
-
const proof = await
|
|
594
|
+
const proof = await readProofsFromOutputDirectory(provingResult.proofPath!, vkData, proofLength, logger);
|
|
660
595
|
|
|
661
596
|
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
662
597
|
this.instrumentation.recordDuration('provingDuration', circuitName, provingResult.durationMs);
|
|
@@ -693,28 +628,19 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
693
628
|
*/
|
|
694
629
|
public async verifyProof(circuitType: ServerProtocolArtifact, proof: Proof) {
|
|
695
630
|
const verificationKey = this.getVerificationKeyDataForCircuit(circuitType);
|
|
696
|
-
return await this.
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
public async verifyAvmProof(
|
|
700
|
-
proof: Proof,
|
|
701
|
-
verificationKey: VerificationKeyData,
|
|
702
|
-
publicInputs: AvmCircuitPublicInputs,
|
|
703
|
-
) {
|
|
704
|
-
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath) =>
|
|
705
|
-
verifyAvmProof(this.config.bbBinaryPath, this.config.bbWorkingDirectory, proofPath, publicInputs, vkPath, logger),
|
|
631
|
+
return await this.verifyInternal(proof, verificationKey, (proofPath, vkPath) =>
|
|
632
|
+
verifyProof(this.config.bbBinaryPath, proofPath, vkPath, getUltraHonkFlavorForCircuit(circuitType), logger),
|
|
706
633
|
);
|
|
707
634
|
}
|
|
708
635
|
|
|
709
|
-
public async
|
|
710
|
-
return await this.
|
|
711
|
-
|
|
636
|
+
public async verifyAvmProof(proof: Proof, publicInputs: AvmCircuitPublicInputs) {
|
|
637
|
+
return await this.verifyInternal(proof, /*verificationKey=*/ undefined, (proofPath, /*unused*/ _vkPath) =>
|
|
638
|
+
verifyAvmProof(this.config.bbBinaryPath, this.config.bbWorkingDirectory, proofPath, publicInputs, logger),
|
|
712
639
|
);
|
|
713
640
|
}
|
|
714
|
-
|
|
715
|
-
private async verifyWithKeyInternal(
|
|
641
|
+
private async verifyInternal(
|
|
716
642
|
proof: Proof,
|
|
717
|
-
verificationKey: { keyAsBytes: Buffer },
|
|
643
|
+
verificationKey: { keyAsBytes: Buffer } | undefined,
|
|
718
644
|
verificationFunction: (proofPath: string, vkPath: string) => Promise<BBFailure | BBSuccess>,
|
|
719
645
|
) {
|
|
720
646
|
const operation = async (bbWorkingDirectory: string) => {
|
|
@@ -722,11 +648,13 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
722
648
|
const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
723
649
|
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
724
650
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/13189): Put this proof parsing logic in the proof class.
|
|
725
|
-
await fs.writeFile(publicInputsFileName, proof.buffer.
|
|
726
|
-
await fs.writeFile(proofFileName, proof.buffer.
|
|
727
|
-
|
|
651
|
+
await fs.writeFile(publicInputsFileName, proof.buffer.subarray(0, proof.numPublicInputs * 32));
|
|
652
|
+
await fs.writeFile(proofFileName, proof.buffer.subarray(proof.numPublicInputs * 32));
|
|
653
|
+
if (verificationKey !== undefined) {
|
|
654
|
+
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
655
|
+
}
|
|
728
656
|
|
|
729
|
-
const result = await verificationFunction(proofFileName, verificationKeyPath
|
|
657
|
+
const result = await verificationFunction(proofFileName, verificationKeyPath);
|
|
730
658
|
|
|
731
659
|
if (result.status === BB_RESULT.FAILURE) {
|
|
732
660
|
const errorMessage = `Failed to verify proof from key!`;
|