@aztec/bb-prover 0.0.1-commit.b655e406 → 0.0.1-commit.d1f2d6c
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 +3 -4
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +18 -4
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/execute.d.ts +6 -6
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +59 -84
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +1 -1
- package/dest/honk.d.ts +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/instrumentation.d.ts +1 -1
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +9 -39
- package/dest/prover/client/bb_private_kernel_prover.d.ts +11 -5
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +35 -6
- 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 +1 -1
- package/dest/prover/proof_utils.js +1 -1
- package/dest/prover/server/bb_prover.d.ts +6 -18
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +415 -42
- 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 +29 -27
- 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 +4 -4
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +462 -59
- 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 +1 -1
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +4 -4
- package/dest/verifier/index.d.ts +1 -1
- package/dest/verifier/queued_chonk_verifier.d.ts +1 -1
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -1
- package/dest/verifier/queued_chonk_verifier.js +9 -40
- package/package.json +23 -22
- package/src/avm_proving_tests/avm_proving_tester.ts +19 -19
- package/src/bb/execute.ts +37 -68
- package/src/instrumentation.ts +8 -39
- package/src/prover/client/bb_private_kernel_prover.ts +45 -8
- package/src/prover/client/bundle.ts +10 -0
- package/src/prover/client/lazy.ts +10 -0
- package/src/prover/proof_utils.ts +1 -1
- package/src/prover/server/bb_prover.ts +22 -38
- package/src/test/delay_values.ts +31 -27
- package/src/test/index.ts +1 -0
- package/src/test/test_circuit_prover.ts +10 -13
- package/src/test/test_verifier.ts +8 -0
- package/src/verification_key/verification_key_data.ts +1 -26
- package/src/verifier/bb_verifier.ts +4 -5
- package/src/verifier/queued_chonk_verifier.ts +8 -40
- 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 -46
- 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/src/prover/client/native/bb_native_private_kernel_prover.ts +0 -105
- package/src/prover/client/wasm/bb_wasm_private_kernel_prover.ts +0 -58
- package/src/prover/client/wasm/bundle.ts +0 -11
- package/src/prover/client/wasm/lazy.ts +0 -11
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AztecClientBackend, type BackendOptions, Barretenberg } from '@aztec/bb.js';
|
|
2
|
+
import { type LogLevel, type Logger, createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
2
5
|
import {
|
|
3
6
|
convertHidingKernelPublicInputsToWitnessMapWithAbi,
|
|
4
7
|
convertHidingKernelToRollupInputsToWitnessMapWithAbi,
|
|
@@ -37,15 +40,22 @@ import type {
|
|
|
37
40
|
PrivateKernelTailCircuitPublicInputs,
|
|
38
41
|
} from '@aztec/stdlib/kernel';
|
|
39
42
|
import type { NoirCompiledCircuitWithName } from '@aztec/stdlib/noir';
|
|
40
|
-
import
|
|
43
|
+
import { ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
41
44
|
import type { CircuitSimulationStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
42
45
|
|
|
46
|
+
import { ungzip } from 'pako';
|
|
47
|
+
|
|
48
|
+
export type BBPrivateKernelProverOptions = Omit<BackendOptions, 'logger'> & { logger?: Logger };
|
|
43
49
|
export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
50
|
+
private log: Logger;
|
|
51
|
+
|
|
44
52
|
constructor(
|
|
45
53
|
protected artifactProvider: ArtifactProvider,
|
|
46
54
|
protected simulator: CircuitSimulator,
|
|
47
|
-
protected
|
|
48
|
-
) {
|
|
55
|
+
protected options: BBPrivateKernelProverOptions = {},
|
|
56
|
+
) {
|
|
57
|
+
this.log = options.logger || createLogger('bb-prover:private-kernel');
|
|
58
|
+
}
|
|
49
59
|
|
|
50
60
|
public async generateInitOutput(
|
|
51
61
|
inputs: PrivateKernelInitCircuitPrivateInputs,
|
|
@@ -263,11 +273,38 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
263
273
|
return kernelProofOutput;
|
|
264
274
|
}
|
|
265
275
|
|
|
266
|
-
public createChonkProof(
|
|
267
|
-
|
|
276
|
+
public async createChonkProof(executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs> {
|
|
277
|
+
const timer = new Timer();
|
|
278
|
+
this.log.info(`Generating ClientIVC proof...`);
|
|
279
|
+
const barretenberg = await Barretenberg.initSingleton({
|
|
280
|
+
...this.options,
|
|
281
|
+
logger: this.options.logger?.[(process.env.LOG_LEVEL as LogLevel) || 'verbose'],
|
|
282
|
+
});
|
|
283
|
+
const backend = new AztecClientBackend(
|
|
284
|
+
executionSteps.map(step => ungzip(step.bytecode)),
|
|
285
|
+
barretenberg,
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
const [proof] = await backend.prove(
|
|
289
|
+
executionSteps.map(step => ungzip(serializeWitness(step.witness))),
|
|
290
|
+
executionSteps.map(step => step.vk),
|
|
291
|
+
);
|
|
292
|
+
this.log.info(`Generated ClientIVC proof`, {
|
|
293
|
+
eventName: 'client-ivc-proof-generation',
|
|
294
|
+
duration: timer.ms(),
|
|
295
|
+
proofSize: proof.length,
|
|
296
|
+
});
|
|
297
|
+
return ChonkProofWithPublicInputs.fromBufferArray(proof);
|
|
268
298
|
}
|
|
269
299
|
|
|
270
|
-
public computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
271
|
-
|
|
300
|
+
public async computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
|
|
301
|
+
// Note we do not pass the vk to the backend. This is unneeded for gate counts.
|
|
302
|
+
const barretenberg = await Barretenberg.initSingleton({
|
|
303
|
+
...this.options,
|
|
304
|
+
logger: this.options.logger?.[(process.env.LOG_LEVEL as LogLevel) || 'verbose'],
|
|
305
|
+
});
|
|
306
|
+
const backend = new AztecClientBackend([ungzip(_bytecode)], barretenberg);
|
|
307
|
+
const gateCount = await backend.gates();
|
|
308
|
+
return gateCount[0];
|
|
272
309
|
}
|
|
273
310
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
2
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
+
|
|
4
|
+
import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
|
|
5
|
+
|
|
6
|
+
export class BBBundlePrivateKernelProver extends BBPrivateKernelProver {
|
|
7
|
+
constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
|
|
8
|
+
super(new BundleArtifactProvider(), simulator, options);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
|
|
2
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
+
|
|
4
|
+
import { BBPrivateKernelProver, type BBPrivateKernelProverOptions } from './bb_private_kernel_prover.js';
|
|
5
|
+
|
|
6
|
+
export class BBLazyPrivateKernelProver extends BBPrivateKernelProver {
|
|
7
|
+
constructor(simulator: CircuitSimulator, options: BBPrivateKernelProverOptions = {}) {
|
|
8
|
+
super(new LazyArtifactProvider(), simulator, options);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
PAIRING_POINTS_SIZE,
|
|
8
8
|
ULTRA_KECCAK_PROOF_LENGTH,
|
|
9
9
|
} from '@aztec/constants';
|
|
10
|
-
import { Fr } from '@aztec/foundation/
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
11
|
import type { Logger } from '@aztec/foundation/log';
|
|
12
12
|
import { ChonkProofWithPublicInputs, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
13
13
|
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
RECURSIVE_PROOF_LENGTH,
|
|
7
7
|
ULTRA_KECCAK_PROOF_LENGTH,
|
|
8
8
|
} from '@aztec/constants';
|
|
9
|
-
import { Fr } from '@aztec/foundation/
|
|
9
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
10
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
11
11
|
import { createLogger } from '@aztec/foundation/log';
|
|
12
12
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
@@ -55,10 +55,8 @@ import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
|
55
55
|
import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
56
56
|
import { ProvingError } from '@aztec/stdlib/errors';
|
|
57
57
|
import {
|
|
58
|
-
type ProofAndVerificationKey,
|
|
59
58
|
type PublicInputsAndRecursiveProof,
|
|
60
59
|
type ServerCircuitProver,
|
|
61
|
-
makeProofAndVerificationKey,
|
|
62
60
|
makePublicInputsAndRecursiveProof,
|
|
63
61
|
} from '@aztec/stdlib/interfaces/server';
|
|
64
62
|
import type { ParityBasePrivateInputs, ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
@@ -84,10 +82,9 @@ import {
|
|
|
84
82
|
type RootRollupPublicInputs,
|
|
85
83
|
type TxMergeRollupPrivateInputs,
|
|
86
84
|
type TxRollupPublicInputs,
|
|
87
|
-
enhanceProofWithPiValidationFlag,
|
|
88
85
|
} from '@aztec/stdlib/rollup';
|
|
89
86
|
import type { CircuitProvingStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
90
|
-
import
|
|
87
|
+
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
91
88
|
import { Attributes, type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
92
89
|
|
|
93
90
|
import { promises as fs } from 'fs';
|
|
@@ -106,9 +103,8 @@ import {
|
|
|
106
103
|
verifyProof,
|
|
107
104
|
} from '../../bb/execute.js';
|
|
108
105
|
import type { ACVMConfig, BBConfig } from '../../config.js';
|
|
109
|
-
import {
|
|
106
|
+
import { getUltraHonkFlavorForCircuit } from '../../honk.js';
|
|
110
107
|
import { ProverInstrumentation } from '../../instrumentation.js';
|
|
111
|
-
import { extractAvmVkData } from '../../verification_key/verification_key_data.js';
|
|
112
108
|
import { readProofsFromOutputDirectory } from '../proof_utils.js';
|
|
113
109
|
|
|
114
110
|
const logger = createLogger('bb-prover');
|
|
@@ -192,14 +188,10 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
192
188
|
}))
|
|
193
189
|
public async getAvmProof(
|
|
194
190
|
inputs: AvmCircuitInputs,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
// TODO(#14234)[Unconditional PIs validation]: remove next lines and directly return proofAndVk
|
|
201
|
-
proofAndVk.proof.proof = enhanceProofWithPiValidationFlag(proofAndVk.proof.proof, skipPublicInputsValidation);
|
|
202
|
-
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;
|
|
203
195
|
}
|
|
204
196
|
|
|
205
197
|
public async getPublicChonkVerifierProof(
|
|
@@ -535,11 +527,10 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
535
527
|
|
|
536
528
|
private async createAvmProof(
|
|
537
529
|
input: AvmCircuitInputs,
|
|
538
|
-
): Promise<
|
|
530
|
+
): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
|
|
539
531
|
const operation = async (bbWorkingDirectory: string) => {
|
|
540
532
|
const provingResult = await this.generateAvmProofWithBB(input, bbWorkingDirectory);
|
|
541
533
|
|
|
542
|
-
const avmVK = await extractAvmVkData(provingResult.vkDirectoryPath!);
|
|
543
534
|
const avmProof = await this.readAvmProofAsFields(provingResult.proofPath!);
|
|
544
535
|
|
|
545
536
|
const circuitType = 'avm-circuit' as const;
|
|
@@ -562,7 +553,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
562
553
|
} satisfies CircuitProvingStats,
|
|
563
554
|
);
|
|
564
555
|
|
|
565
|
-
return
|
|
556
|
+
return avmProof;
|
|
566
557
|
};
|
|
567
558
|
return await this.runInDirectory(operation);
|
|
568
559
|
}
|
|
@@ -636,28 +627,19 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
636
627
|
*/
|
|
637
628
|
public async verifyProof(circuitType: ServerProtocolArtifact, proof: Proof) {
|
|
638
629
|
const verificationKey = this.getVerificationKeyDataForCircuit(circuitType);
|
|
639
|
-
return await this.
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
public async verifyAvmProof(
|
|
643
|
-
proof: Proof,
|
|
644
|
-
verificationKey: VerificationKeyData,
|
|
645
|
-
publicInputs: AvmCircuitPublicInputs,
|
|
646
|
-
) {
|
|
647
|
-
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath) =>
|
|
648
|
-
verifyAvmProof(this.config.bbBinaryPath, this.config.bbWorkingDirectory, proofPath, publicInputs, vkPath, logger),
|
|
630
|
+
return await this.verifyInternal(proof, verificationKey, (proofPath, vkPath) =>
|
|
631
|
+
verifyProof(this.config.bbBinaryPath, proofPath, vkPath, getUltraHonkFlavorForCircuit(circuitType), logger),
|
|
649
632
|
);
|
|
650
633
|
}
|
|
651
634
|
|
|
652
|
-
public async
|
|
653
|
-
return await this.
|
|
654
|
-
|
|
635
|
+
public async verifyAvmProof(proof: Proof, publicInputs: AvmCircuitPublicInputs) {
|
|
636
|
+
return await this.verifyInternal(proof, /*verificationKey=*/ undefined, (proofPath, /*unused*/ _vkPath) =>
|
|
637
|
+
verifyAvmProof(this.config.bbBinaryPath, this.config.bbWorkingDirectory, proofPath, publicInputs, logger),
|
|
655
638
|
);
|
|
656
639
|
}
|
|
657
|
-
|
|
658
|
-
private async verifyWithKeyInternal(
|
|
640
|
+
private async verifyInternal(
|
|
659
641
|
proof: Proof,
|
|
660
|
-
verificationKey: { keyAsBytes: Buffer },
|
|
642
|
+
verificationKey: { keyAsBytes: Buffer } | undefined,
|
|
661
643
|
verificationFunction: (proofPath: string, vkPath: string) => Promise<BBFailure | BBSuccess>,
|
|
662
644
|
) {
|
|
663
645
|
const operation = async (bbWorkingDirectory: string) => {
|
|
@@ -665,11 +647,13 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
665
647
|
const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
666
648
|
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
667
649
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/13189): Put this proof parsing logic in the proof class.
|
|
668
|
-
await fs.writeFile(publicInputsFileName, proof.buffer.
|
|
669
|
-
await fs.writeFile(proofFileName, proof.buffer.
|
|
670
|
-
|
|
650
|
+
await fs.writeFile(publicInputsFileName, proof.buffer.subarray(0, proof.numPublicInputs * 32));
|
|
651
|
+
await fs.writeFile(proofFileName, proof.buffer.subarray(proof.numPublicInputs * 32));
|
|
652
|
+
if (verificationKey !== undefined) {
|
|
653
|
+
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
654
|
+
}
|
|
671
655
|
|
|
672
|
-
const result = await verificationFunction(proofFileName, verificationKeyPath
|
|
656
|
+
const result = await verificationFunction(proofFileName, verificationKeyPath);
|
|
673
657
|
|
|
674
658
|
if (result.status === BB_RESULT.FAILURE) {
|
|
675
659
|
const errorMessage = `Failed to verify proof from key!`;
|
package/src/test/delay_values.ts
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
1
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
2
2
|
|
|
3
3
|
export const WITGEN_DELAY_MS: Record<ProvingRequestType, number> = {
|
|
4
|
-
[ProvingRequestType.
|
|
5
|
-
[ProvingRequestType.
|
|
6
|
-
[ProvingRequestType.
|
|
7
|
-
[ProvingRequestType.
|
|
8
|
-
[ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]:
|
|
4
|
+
[ProvingRequestType.PUBLIC_CHONK_VERIFIER]: 60,
|
|
5
|
+
[ProvingRequestType.PARITY_BASE]: 1_600,
|
|
6
|
+
[ProvingRequestType.PARITY_ROOT]: 40,
|
|
7
|
+
[ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: 45,
|
|
8
|
+
[ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: 18,
|
|
9
|
+
[ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: 27,
|
|
10
|
+
[ProvingRequestType.CHECKPOINT_MERGE_ROLLUP]: 30,
|
|
11
|
+
[ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: 36_000,
|
|
12
|
+
[ProvingRequestType.ROOT_ROLLUP]: 35,
|
|
13
|
+
[ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: 2_500,
|
|
14
|
+
[ProvingRequestType.TX_MERGE_ROLLUP]: 25,
|
|
15
|
+
[ProvingRequestType.PUBLIC_VM]: 0,
|
|
16
|
+
|
|
17
|
+
// TBD
|
|
18
|
+
[ProvingRequestType.BLOCK_MERGE_ROLLUP]: 30,
|
|
9
19
|
[ProvingRequestType.BLOCK_ROOT_ROLLUP]: 40_000,
|
|
10
20
|
[ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP]: 20_000,
|
|
11
21
|
[ProvingRequestType.CHECKPOINT_ROOT_ROLLUP]: 40_000,
|
|
12
|
-
[ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: 20_000,
|
|
13
22
|
[ProvingRequestType.CHECKPOINT_PADDING_ROLLUP]: 0,
|
|
14
|
-
[ProvingRequestType.
|
|
15
|
-
[ProvingRequestType.TX_MERGE_ROLLUP]: 0,
|
|
16
|
-
[ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 400_000,
|
|
17
|
-
[ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: 470_000,
|
|
18
|
-
[ProvingRequestType.PARITY_ROOT]: 100,
|
|
19
|
-
[ProvingRequestType.ROOT_ROLLUP]: 650,
|
|
20
|
-
[ProvingRequestType.PUBLIC_CHONK_VERIFIER]: 0,
|
|
21
|
-
[ProvingRequestType.PUBLIC_VM]: 0,
|
|
23
|
+
[ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 2_500, // Guess based on public
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
export const PROOF_DELAY_MS: Record<ProvingRequestType, number> = {
|
|
25
|
-
[ProvingRequestType.
|
|
27
|
+
[ProvingRequestType.PUBLIC_CHONK_VERIFIER]: 16_300,
|
|
28
|
+
[ProvingRequestType.PARITY_BASE]: 15_300,
|
|
29
|
+
[ProvingRequestType.PARITY_ROOT]: 18_600,
|
|
30
|
+
[ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: 17_400,
|
|
31
|
+
[ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: 4_500,
|
|
32
|
+
[ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: 9_200,
|
|
33
|
+
[ProvingRequestType.CHECKPOINT_MERGE_ROLLUP]: 10_200,
|
|
34
|
+
[ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: 37_100,
|
|
35
|
+
[ProvingRequestType.ROOT_ROLLUP]: 93_000,
|
|
36
|
+
[ProvingRequestType.TX_MERGE_ROLLUP]: 10_000,
|
|
37
|
+
[ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: 44_500,
|
|
38
|
+
[ProvingRequestType.PUBLIC_VM]: 10_000,
|
|
39
|
+
|
|
40
|
+
// TBD
|
|
26
41
|
[ProvingRequestType.BLOCK_MERGE_ROLLUP]: 15_000,
|
|
27
|
-
[ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP]: 55_000,
|
|
28
|
-
[ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP]: 35_000,
|
|
29
|
-
[ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP]: 15_000,
|
|
30
42
|
[ProvingRequestType.BLOCK_ROOT_ROLLUP]: 35_000,
|
|
31
43
|
[ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP]: 15_000,
|
|
32
44
|
[ProvingRequestType.CHECKPOINT_ROOT_ROLLUP]: 35_000,
|
|
33
|
-
[ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP]: 15_000,
|
|
34
45
|
[ProvingRequestType.CHECKPOINT_PADDING_ROLLUP]: 0,
|
|
35
|
-
[ProvingRequestType.
|
|
36
|
-
[ProvingRequestType.TX_MERGE_ROLLUP]: 0,
|
|
37
|
-
[ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 145_000,
|
|
38
|
-
[ProvingRequestType.PUBLIC_TX_BASE_ROLLUP]: 160_000,
|
|
39
|
-
[ProvingRequestType.PARITY_ROOT]: 30_000,
|
|
40
|
-
[ProvingRequestType.ROOT_ROLLUP]: 15_000,
|
|
41
|
-
[ProvingRequestType.PUBLIC_CHONK_VERIFIER]: 30_000,
|
|
42
|
-
[ProvingRequestType.PUBLIC_VM]: 0,
|
|
46
|
+
[ProvingRequestType.PRIVATE_TX_BASE_ROLLUP]: 22_000,
|
|
43
47
|
};
|
package/src/test/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
|
|
3
|
-
AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED,
|
|
4
3
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
5
4
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
6
5
|
RECURSIVE_PROOF_LENGTH,
|
|
@@ -51,14 +50,18 @@ import type { WitnessMap } from '@aztec/noir-types';
|
|
|
51
50
|
import { type CircuitSimulator, WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator/server';
|
|
52
51
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
53
52
|
import {
|
|
54
|
-
type ProofAndVerificationKey,
|
|
55
53
|
type PublicInputsAndRecursiveProof,
|
|
56
54
|
type ServerCircuitProver,
|
|
57
|
-
makeProofAndVerificationKey,
|
|
58
55
|
makePublicInputsAndRecursiveProof,
|
|
59
56
|
} from '@aztec/stdlib/interfaces/server';
|
|
60
57
|
import type { ParityBasePrivateInputs, ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
61
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
type Proof,
|
|
60
|
+
ProvingRequestType,
|
|
61
|
+
RecursiveProof,
|
|
62
|
+
makeEmptyRecursiveProof,
|
|
63
|
+
makeRecursiveProof,
|
|
64
|
+
} from '@aztec/stdlib/proofs';
|
|
62
65
|
import {
|
|
63
66
|
type BlockMergeRollupPrivateInputs,
|
|
64
67
|
type BlockRollupPublicInputs,
|
|
@@ -81,7 +84,6 @@ import {
|
|
|
81
84
|
type TxMergeRollupPrivateInputs,
|
|
82
85
|
type TxRollupPublicInputs,
|
|
83
86
|
} from '@aztec/stdlib/rollup';
|
|
84
|
-
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
85
87
|
import { type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
86
88
|
|
|
87
89
|
import { ProverInstrumentation } from '../instrumentation.js';
|
|
@@ -400,17 +402,12 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
400
402
|
);
|
|
401
403
|
}
|
|
402
404
|
|
|
403
|
-
public getAvmProof(
|
|
404
|
-
_inputs: AvmCircuitInputs,
|
|
405
|
-
): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
|
|
405
|
+
public getAvmProof(_inputs: AvmCircuitInputs): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>> {
|
|
406
406
|
// We can't simulate the AVM because we don't have enough context to do so (e.g., DBs).
|
|
407
|
-
// We just return an empty proof
|
|
407
|
+
// We just return an empty proof.
|
|
408
408
|
this.logger.debug('Skipping AVM simulation in TestCircuitProver.');
|
|
409
409
|
return this.applyDelay(ProvingRequestType.PUBLIC_VM, () =>
|
|
410
|
-
|
|
411
|
-
makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
|
|
412
|
-
VerificationKeyData.makeFake(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED),
|
|
413
|
-
),
|
|
410
|
+
makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED),
|
|
414
411
|
);
|
|
415
412
|
}
|
|
416
413
|
|
|
@@ -2,7 +2,15 @@ import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '
|
|
|
2
2
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
|
|
4
4
|
export class TestCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
5
|
+
constructor(private verificationDelayMs?: number) {}
|
|
5
6
|
verifyProof(_tx: Tx): Promise<IVCProofVerificationResult> {
|
|
7
|
+
if (this.verificationDelayMs !== undefined && this.verificationDelayMs > 0) {
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
setTimeout(() => {
|
|
10
|
+
resolve({ valid: true, durationMs: this.verificationDelayMs!, totalDurationMs: this.verificationDelayMs! });
|
|
11
|
+
}, this.verificationDelayMs);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
6
14
|
return Promise.resolve({ valid: true, durationMs: 0, totalDurationMs: 0 });
|
|
7
15
|
}
|
|
8
16
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
4
3
|
import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
|
|
5
4
|
|
|
6
|
-
import { strict as assert } from 'assert';
|
|
7
5
|
import { promises as fs } from 'fs';
|
|
8
6
|
import * as path from 'path';
|
|
9
7
|
|
|
@@ -25,26 +23,3 @@ export async function extractVkData(vkDirectoryPath: string): Promise<Verificati
|
|
|
25
23
|
const vkAsFields = await VerificationKeyAsFields.fromKey(fields);
|
|
26
24
|
return new VerificationKeyData(vkAsFields, rawBinary);
|
|
27
25
|
}
|
|
28
|
-
|
|
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
|
-
*/
|
|
35
|
-
export async function extractAvmVkData(vkDirectoryPath: string): Promise<VerificationKeyData> {
|
|
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.
|
|
48
|
-
const vk = new VerificationKeyData(vkAsFields, rawBinary);
|
|
49
|
-
return vk;
|
|
50
|
-
}
|
|
@@ -40,6 +40,9 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
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
|
+
}
|
|
43
46
|
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
44
47
|
return new BBCircuitVerifier(config, logger);
|
|
45
48
|
}
|
|
@@ -99,10 +102,6 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
99
102
|
|
|
100
103
|
// Block below is almost copy-pasted from verifyProofForCircuit
|
|
101
104
|
const operation = async (bbWorkingDirectory: string) => {
|
|
102
|
-
const logFunction = (message: string) => {
|
|
103
|
-
this.logger.debug(`${proofType} BB out - ${message}`);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
105
|
const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
107
106
|
await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
|
|
108
107
|
|
|
@@ -115,7 +114,7 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
115
114
|
this.config.bbBinaryPath,
|
|
116
115
|
proofPath,
|
|
117
116
|
verificationKeyPath,
|
|
118
|
-
|
|
117
|
+
this.logger,
|
|
119
118
|
this.config.bbIVCConcurrency,
|
|
120
119
|
);
|
|
121
120
|
verificationDuration = timer.ms();
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
type ObservableGauge,
|
|
11
11
|
type TelemetryClient,
|
|
12
12
|
type UpDownCounter,
|
|
13
|
-
ValueType,
|
|
14
13
|
getTelemetryClient,
|
|
15
14
|
} from '@aztec/telemetry-client';
|
|
16
15
|
|
|
@@ -36,49 +35,18 @@ class IVCVerifierMetrics {
|
|
|
36
35
|
constructor(client: TelemetryClient, name = 'QueuedIVCVerifier') {
|
|
37
36
|
const meter = client.getMeter(name);
|
|
38
37
|
|
|
39
|
-
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME
|
|
40
|
-
unit: 'ms',
|
|
41
|
-
description: 'Duration to verify chonk proofs',
|
|
42
|
-
valueType: ValueType.INT,
|
|
43
|
-
});
|
|
38
|
+
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME);
|
|
44
39
|
|
|
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
|
-
});
|
|
40
|
+
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME);
|
|
50
41
|
|
|
51
|
-
this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT
|
|
52
|
-
description: 'Count of failed IVC proof verifications',
|
|
53
|
-
valueType: ValueType.INT,
|
|
54
|
-
});
|
|
42
|
+
this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT);
|
|
55
43
|
|
|
56
44
|
this.aggDurationMetrics = {
|
|
57
|
-
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
}),
|
|
45
|
+
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG),
|
|
46
|
+
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX),
|
|
47
|
+
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN),
|
|
48
|
+
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50),
|
|
49
|
+
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90),
|
|
82
50
|
};
|
|
83
51
|
|
|
84
52
|
meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import type { CircuitSimulator } from '@aztec/simulator/server';
|
|
3
|
-
import { type PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
4
|
-
import type { ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
5
|
-
import type { BBConfig } from '../../../config.js';
|
|
6
|
-
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
7
|
-
/**
|
|
8
|
-
* This proof creator implementation uses the native bb binary.
|
|
9
|
-
*/
|
|
10
|
-
export declare class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
11
|
-
private bbBinaryPath;
|
|
12
|
-
private bbWorkingDirectory;
|
|
13
|
-
private skipCleanup;
|
|
14
|
-
protected simulator: CircuitSimulator;
|
|
15
|
-
protected log: Logger;
|
|
16
|
-
private constructor();
|
|
17
|
-
static new(config: BBConfig, simulator: CircuitSimulator, log?: Logger): Promise<BBNativePrivateKernelProver>;
|
|
18
|
-
private _createChonkProof;
|
|
19
|
-
createChonkProof(executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs>;
|
|
20
|
-
computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number>;
|
|
21
|
-
private runInDirectory;
|
|
22
|
-
}
|
|
23
|
-
//# 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/client/native/bb_native_private_kernel_prover.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,KAAK,oBAAoB,EAAkC,MAAM,sBAAsB,CAAC;AACjG,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAMvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,qBAAqB;IAElE,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,WAAW;cACA,SAAS,EAAE,gBAAgB;cAC3B,GAAG;IALxB,OAAO;WAUa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,CAAC,EAAE,MAAM;YAWrE,iBAAiB;IAuBT,gBAAgB,CAAC,cAAc,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAQ7F,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxG,OAAO,CAAC,cAAc;CAavB"}
|
|
@@ -1,66 +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 { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
|
|
5
|
-
import { promises as fs } from 'fs';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { BB_RESULT, computeGateCountForCircuit, executeBbChonkProof } from '../../../bb/execute.js';
|
|
8
|
-
import { readChonkProofFromOutputDirectory } from '../../proof_utils.js';
|
|
9
|
-
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
10
|
-
/**
|
|
11
|
-
* This proof creator implementation uses the native bb binary.
|
|
12
|
-
*/ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
13
|
-
bbBinaryPath;
|
|
14
|
-
bbWorkingDirectory;
|
|
15
|
-
skipCleanup;
|
|
16
|
-
simulator;
|
|
17
|
-
log;
|
|
18
|
-
constructor(bbBinaryPath, bbWorkingDirectory, skipCleanup, simulator, log = createLogger('bb-prover:native')){
|
|
19
|
-
super(new BundleArtifactProvider(), simulator, log), this.bbBinaryPath = bbBinaryPath, this.bbWorkingDirectory = bbWorkingDirectory, this.skipCleanup = skipCleanup, this.simulator = simulator, this.log = log;
|
|
20
|
-
}
|
|
21
|
-
static async new(config, simulator, log) {
|
|
22
|
-
await fs.mkdir(config.bbWorkingDirectory, {
|
|
23
|
-
recursive: true
|
|
24
|
-
});
|
|
25
|
-
return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, simulator, log);
|
|
26
|
-
}
|
|
27
|
-
async _createChonkProof(directory, executionSteps) {
|
|
28
|
-
const inputsPath = path.join(directory, 'ivc-inputs.msgpack');
|
|
29
|
-
await fs.writeFile(inputsPath, serializePrivateExecutionSteps(executionSteps));
|
|
30
|
-
const provingResult = await executeBbChonkProof(this.bbBinaryPath, directory, inputsPath, this.log.info);
|
|
31
|
-
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
32
|
-
this.log.error(`Failed to generate chonk proof`);
|
|
33
|
-
throw new Error(provingResult.reason);
|
|
34
|
-
}
|
|
35
|
-
const proof = await readChonkProofFromOutputDirectory(directory);
|
|
36
|
-
this.log.info(`Generated Chonk proof`, {
|
|
37
|
-
duration: provingResult.durationMs,
|
|
38
|
-
eventName: 'circuit-proving'
|
|
39
|
-
});
|
|
40
|
-
return proof;
|
|
41
|
-
}
|
|
42
|
-
async createChonkProof(executionSteps) {
|
|
43
|
-
this.log.info(`Generating Chonk proof`);
|
|
44
|
-
const operation = async (directory)=>{
|
|
45
|
-
return await this._createChonkProof(directory, executionSteps);
|
|
46
|
-
};
|
|
47
|
-
return await this.runInDirectory(operation);
|
|
48
|
-
}
|
|
49
|
-
async computeGateCountForCircuit(bytecode, circuitName) {
|
|
50
|
-
const logFunction = (message)=>{
|
|
51
|
-
this.log.debug(`$bb gates ${circuitName} - ${message}`);
|
|
52
|
-
};
|
|
53
|
-
const result = await computeGateCountForCircuit(this.bbBinaryPath, this.bbWorkingDirectory, circuitName, bytecode, 'mega_honk', logFunction);
|
|
54
|
-
if (result.status === BB_RESULT.FAILURE) {
|
|
55
|
-
throw new Error(result.reason);
|
|
56
|
-
}
|
|
57
|
-
return result.circuitSize;
|
|
58
|
-
}
|
|
59
|
-
runInDirectory(fn) {
|
|
60
|
-
const log = this.log;
|
|
61
|
-
return runInDirectory(this.bbWorkingDirectory, (dir)=>fn(dir).catch((err)=>{
|
|
62
|
-
log.error(`Error running operation at ${dir}: ${err}`);
|
|
63
|
-
throw err;
|
|
64
|
-
}), this.skipCleanup, this.log);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
|
|
2
|
-
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
3
|
-
import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
|
|
4
|
-
import { ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
5
|
-
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
6
|
-
export declare abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
7
|
-
protected artifactProvider: ArtifactProvider;
|
|
8
|
-
protected simulator: CircuitSimulator;
|
|
9
|
-
private threads;
|
|
10
|
-
protected log: import("@aztec/foundation/log").Logger;
|
|
11
|
-
constructor(artifactProvider: ArtifactProvider, simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
|
|
12
|
-
createChonkProof(executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs>;
|
|
13
|
-
computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=bb_wasm_private_kernel_prover.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bb_wasm_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/bb_wasm_private_kernel_prover.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAIlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAEvE,8BAAsB,yBAA0B,SAAQ,qBAAqB;cAEtD,gBAAgB,EAAE,gBAAgB;cAClC,SAAS,EAAE,gBAAgB;IAC9C,OAAO,CAAC,OAAO;cACI,GAAG;gBAHH,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,gBAAgB,EACtC,OAAO,GAAE,MAAU,EACR,GAAG,yCAAiC;IAKnC,gBAAgB,CAAC,cAAc,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAqB7F,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAa3G"}
|