@aztec/bb-prover 0.69.1-devnet → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/bb/execute.d.ts +14 -3
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +108 -10
- package/dest/prover/bb_native_private_kernel_prover.d.ts +3 -1
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_native_private_kernel_prover.js +6 -5
- package/dest/prover/bb_private_kernel_prover.d.ts +3 -3
- package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_private_kernel_prover.js +5 -6
- package/dest/prover/bb_prover.js +5 -5
- package/dest/test/test_avm.d.ts +1 -1
- package/dest/test/test_avm.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.d.ts +1 -1
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +3 -3
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +2 -5
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +3 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.js +4 -3
- package/dest/wasm/bundle.d.ts +2 -1
- package/dest/wasm/bundle.d.ts.map +1 -1
- package/dest/wasm/bundle.js +3 -3
- package/dest/wasm/lazy.d.ts +2 -1
- package/dest/wasm/lazy.d.ts.map +1 -1
- package/dest/wasm/lazy.js +3 -3
- package/package.json +9 -9
- package/src/bb/execute.ts +134 -11
- package/src/prover/bb_native_private_kernel_prover.ts +11 -3
- package/src/prover/bb_private_kernel_prover.ts +8 -6
- package/src/prover/bb_prover.ts +4 -4
- package/src/test/test_avm.ts +1 -1
- package/src/test/test_circuit_prover.ts +5 -2
- package/src/verifier/bb_verifier.ts +1 -5
- package/src/wasm/bb_wasm_private_kernel_prover.ts +3 -1
- package/src/wasm/bundle.ts +3 -2
- package/src/wasm/lazy.ts +3 -2
package/src/bb/execute.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AvmCircuitInputs } from '@aztec/circuits.js';
|
|
1
|
+
import { type AvmCircuitInputs, serializeWithMessagePack } from '@aztec/circuits.js';
|
|
2
2
|
import { sha256 } from '@aztec/foundation/crypto';
|
|
3
3
|
import { type LogFn, type Logger } from '@aztec/foundation/log';
|
|
4
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -75,7 +75,7 @@ export function executeBB(
|
|
|
75
75
|
// spawn the bb process
|
|
76
76
|
const { HARDWARE_CONCURRENCY: _, ...envWithoutConcurrency } = process.env;
|
|
77
77
|
const env = process.env.HARDWARE_CONCURRENCY ? process.env : envWithoutConcurrency;
|
|
78
|
-
logger(`Executing BB with: ${command} ${args.join(' ')}`);
|
|
78
|
+
logger(`Executing BB with: ${pathToBB} ${command} ${args.join(' ')}`);
|
|
79
79
|
const bb = proc.spawn(pathToBB, [command, ...args], {
|
|
80
80
|
env,
|
|
81
81
|
});
|
|
@@ -497,6 +497,86 @@ export async function generateTubeProof(
|
|
|
497
497
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
498
498
|
* @param pathToBB - The full path to the bb binary
|
|
499
499
|
* @param workingDirectory - A working directory for use by bb
|
|
500
|
+
* @param input - The inputs for the public function to be proven
|
|
501
|
+
* @param log - A logging function
|
|
502
|
+
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
503
|
+
*/
|
|
504
|
+
export async function generateAvmProofV2(
|
|
505
|
+
pathToBB: string,
|
|
506
|
+
workingDirectory: string,
|
|
507
|
+
input: AvmCircuitInputs,
|
|
508
|
+
logger: Logger,
|
|
509
|
+
): Promise<BBFailure | BBSuccess> {
|
|
510
|
+
// Check that the working directory exists
|
|
511
|
+
try {
|
|
512
|
+
await fs.access(workingDirectory);
|
|
513
|
+
} catch (error) {
|
|
514
|
+
return { status: BB_RESULT.FAILURE, reason: `Working directory ${workingDirectory} does not exist` };
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// The proof is written to e.g. /workingDirectory/proof
|
|
518
|
+
const outputPath = workingDirectory;
|
|
519
|
+
|
|
520
|
+
const filePresent = async (file: string) =>
|
|
521
|
+
await fs
|
|
522
|
+
.access(file, fs.constants.R_OK)
|
|
523
|
+
.then(_ => true)
|
|
524
|
+
.catch(_ => false);
|
|
525
|
+
|
|
526
|
+
const binaryPresent = await filePresent(pathToBB);
|
|
527
|
+
if (!binaryPresent) {
|
|
528
|
+
return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
const inputsBuffer = input.serializeForAvm2();
|
|
532
|
+
|
|
533
|
+
try {
|
|
534
|
+
// Write the inputs to the working directory.
|
|
535
|
+
const avmInputsPath = join(workingDirectory, 'avm_inputs.bin');
|
|
536
|
+
await fs.writeFile(avmInputsPath, inputsBuffer);
|
|
537
|
+
if (!filePresent(avmInputsPath)) {
|
|
538
|
+
return { status: BB_RESULT.FAILURE, reason: `Could not write avm inputs to ${avmInputsPath}` };
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
const args = [
|
|
542
|
+
'--avm-inputs',
|
|
543
|
+
avmInputsPath,
|
|
544
|
+
'-o',
|
|
545
|
+
outputPath,
|
|
546
|
+
logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '',
|
|
547
|
+
];
|
|
548
|
+
const timer = new Timer();
|
|
549
|
+
const logFunction = (message: string) => {
|
|
550
|
+
logger.verbose(`AvmCircuit (prove) BB out - ${message}`);
|
|
551
|
+
};
|
|
552
|
+
const result = await executeBB(pathToBB, 'avm2_prove', args, logFunction);
|
|
553
|
+
const duration = timer.ms();
|
|
554
|
+
|
|
555
|
+
if (result.status == BB_RESULT.SUCCESS) {
|
|
556
|
+
return {
|
|
557
|
+
status: BB_RESULT.SUCCESS,
|
|
558
|
+
durationMs: duration,
|
|
559
|
+
proofPath: join(outputPath, PROOF_FILENAME),
|
|
560
|
+
pkPath: undefined,
|
|
561
|
+
vkPath: outputPath,
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
// Not a great error message here but it is difficult to decipher what comes from bb
|
|
565
|
+
return {
|
|
566
|
+
status: BB_RESULT.FAILURE,
|
|
567
|
+
reason: `Failed to generate proof. Exit code ${result.exitCode}. Signal ${result.signal}.`,
|
|
568
|
+
retry: !!result.signal,
|
|
569
|
+
};
|
|
570
|
+
} catch (error) {
|
|
571
|
+
return { status: BB_RESULT.FAILURE, reason: `${error}` };
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Used for generating AVM proofs (or doing check-circuit).
|
|
577
|
+
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
578
|
+
* @param pathToBB - The full path to the bb binary
|
|
579
|
+
* @param workingDirectory - A working directory for use by bb
|
|
500
580
|
* @param bytecode - The AVM bytecode for the public function to be proven (expected to be decompressed)
|
|
501
581
|
* @param log - A logging function
|
|
502
582
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
@@ -506,6 +586,7 @@ export async function generateAvmProof(
|
|
|
506
586
|
workingDirectory: string,
|
|
507
587
|
input: AvmCircuitInputs,
|
|
508
588
|
logger: Logger,
|
|
589
|
+
checkCircuitOnly: boolean = false,
|
|
509
590
|
): Promise<BBFailure | BBSuccess> {
|
|
510
591
|
// Check that the working directory exists
|
|
511
592
|
try {
|
|
@@ -553,12 +634,14 @@ export async function generateAvmProof(
|
|
|
553
634
|
'-o',
|
|
554
635
|
outputPath,
|
|
555
636
|
logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '',
|
|
637
|
+
checkCircuitOnly ? '--check-circuit-only' : '',
|
|
556
638
|
];
|
|
557
639
|
const timer = new Timer();
|
|
640
|
+
const cmd = checkCircuitOnly ? 'check_circuit' : 'prove';
|
|
558
641
|
const logFunction = (message: string) => {
|
|
559
|
-
logger.verbose(`AvmCircuit (
|
|
642
|
+
logger.verbose(`AvmCircuit (${cmd}) BB out - ${message}`);
|
|
560
643
|
};
|
|
561
|
-
const result = await executeBB(pathToBB,
|
|
644
|
+
const result = await executeBB(pathToBB, `avm_${cmd}`, args, logFunction);
|
|
562
645
|
const duration = timer.ms();
|
|
563
646
|
|
|
564
647
|
if (result.status == BB_RESULT.SUCCESS) {
|
|
@@ -594,7 +677,7 @@ export async function verifyProof(
|
|
|
594
677
|
proofFullPath: string,
|
|
595
678
|
verificationKeyPath: string,
|
|
596
679
|
ultraHonkFlavor: UltraHonkFlavor,
|
|
597
|
-
log:
|
|
680
|
+
log: Logger,
|
|
598
681
|
): Promise<BBFailure | BBSuccess> {
|
|
599
682
|
return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, `verify_${ultraHonkFlavor}`, log);
|
|
600
683
|
}
|
|
@@ -611,9 +694,37 @@ export async function verifyAvmProof(
|
|
|
611
694
|
pathToBB: string,
|
|
612
695
|
proofFullPath: string,
|
|
613
696
|
verificationKeyPath: string,
|
|
614
|
-
|
|
697
|
+
logger: Logger,
|
|
615
698
|
): Promise<BBFailure | BBSuccess> {
|
|
616
|
-
return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, 'avm_verify',
|
|
699
|
+
return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, 'avm_verify', logger);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export async function verifyAvmProofV2(
|
|
703
|
+
pathToBB: string,
|
|
704
|
+
workingDirectory: string,
|
|
705
|
+
proofFullPath: string,
|
|
706
|
+
publicInputs: any,
|
|
707
|
+
verificationKeyPath: string,
|
|
708
|
+
logger: Logger,
|
|
709
|
+
): Promise<BBFailure | BBSuccess> {
|
|
710
|
+
const inputsBuffer = serializeWithMessagePack(publicInputs);
|
|
711
|
+
|
|
712
|
+
// Write the inputs to the working directory.
|
|
713
|
+
const filePresent = async (file: string) =>
|
|
714
|
+
await fs
|
|
715
|
+
.access(file, fs.constants.R_OK)
|
|
716
|
+
.then(_ => true)
|
|
717
|
+
.catch(_ => false);
|
|
718
|
+
const avmInputsPath = join(workingDirectory, 'avm_public_inputs.bin');
|
|
719
|
+
await fs.writeFile(avmInputsPath, inputsBuffer);
|
|
720
|
+
if (!filePresent(avmInputsPath)) {
|
|
721
|
+
return { status: BB_RESULT.FAILURE, reason: `Could not write avm inputs to ${avmInputsPath}` };
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
return await verifyProofInternal(pathToBB, proofFullPath, verificationKeyPath, 'avm2_verify', logger, [
|
|
725
|
+
'--avm-public-inputs',
|
|
726
|
+
avmInputsPath,
|
|
727
|
+
]);
|
|
617
728
|
}
|
|
618
729
|
|
|
619
730
|
/**
|
|
@@ -670,8 +781,9 @@ async function verifyProofInternal(
|
|
|
670
781
|
pathToBB: string,
|
|
671
782
|
proofFullPath: string,
|
|
672
783
|
verificationKeyPath: string,
|
|
673
|
-
command: 'verify_ultra_honk' | 'verify_ultra_rollup_honk' | 'verify_ultra_keccak_honk' | 'avm_verify',
|
|
674
|
-
|
|
784
|
+
command: 'verify_ultra_honk' | 'verify_ultra_rollup_honk' | 'verify_ultra_keccak_honk' | 'avm_verify' | 'avm2_verify',
|
|
785
|
+
logger: Logger,
|
|
786
|
+
extraArgs: string[] = [],
|
|
675
787
|
): Promise<BBFailure | BBSuccess> {
|
|
676
788
|
const binaryPresent = await fs
|
|
677
789
|
.access(pathToBB, fs.constants.R_OK)
|
|
@@ -681,10 +793,21 @@ async function verifyProofInternal(
|
|
|
681
793
|
return { status: BB_RESULT.FAILURE, reason: `Failed to find bb binary at ${pathToBB}` };
|
|
682
794
|
}
|
|
683
795
|
|
|
796
|
+
const logFunction = (message: string) => {
|
|
797
|
+
logger.verbose(`AvmCircuit (verify) BB out - ${message}`);
|
|
798
|
+
};
|
|
799
|
+
|
|
684
800
|
try {
|
|
685
|
-
const args = [
|
|
801
|
+
const args = [
|
|
802
|
+
'-p',
|
|
803
|
+
proofFullPath,
|
|
804
|
+
'-k',
|
|
805
|
+
verificationKeyPath,
|
|
806
|
+
logger.level === 'debug' || logger.level === 'trace' ? '-d' : logger.level === 'verbose' ? '-v' : '',
|
|
807
|
+
...extraArgs,
|
|
808
|
+
];
|
|
686
809
|
const timer = new Timer();
|
|
687
|
-
const result = await executeBB(pathToBB, command, args,
|
|
810
|
+
const result = await executeBB(pathToBB, command, args, logFunction);
|
|
688
811
|
const duration = timer.ms();
|
|
689
812
|
if (result.status == BB_RESULT.SUCCESS) {
|
|
690
813
|
return { status: BB_RESULT.SUCCESS, durationMs: duration };
|
|
@@ -2,6 +2,7 @@ import { type ClientIvcProof } from '@aztec/circuits.js';
|
|
|
2
2
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
5
|
+
import { type SimulationProvider } from '@aztec/simulator/server';
|
|
5
6
|
|
|
6
7
|
import { encode } from '@msgpack/msgpack';
|
|
7
8
|
import { serializeWitness } from '@noir-lang/noirc_abi';
|
|
@@ -22,14 +23,21 @@ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
|
22
23
|
private bbBinaryPath: string,
|
|
23
24
|
private bbWorkingDirectory: string,
|
|
24
25
|
private skipCleanup: boolean,
|
|
26
|
+
protected override simulationProvider: SimulationProvider,
|
|
25
27
|
protected override log = createLogger('bb-prover:native'),
|
|
26
28
|
) {
|
|
27
|
-
super(new BundleArtifactProvider(), log);
|
|
29
|
+
super(new BundleArtifactProvider(), simulationProvider, log);
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
public static async new(config: BBConfig, log?: Logger) {
|
|
32
|
+
public static async new(config: BBConfig, simulationProvider: SimulationProvider, log?: Logger) {
|
|
31
33
|
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
32
|
-
return new BBNativePrivateKernelProver(
|
|
34
|
+
return new BBNativePrivateKernelProver(
|
|
35
|
+
config.bbBinaryPath,
|
|
36
|
+
config.bbWorkingDirectory,
|
|
37
|
+
!!config.bbSkipCleanup,
|
|
38
|
+
simulationProvider,
|
|
39
|
+
log,
|
|
40
|
+
);
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
private async _createClientIvcProof(
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from '@aztec/noir-protocol-circuits-types/client';
|
|
28
28
|
import { type ArtifactProvider, type ClientProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
29
29
|
import { ClientCircuitVks } from '@aztec/noir-protocol-circuits-types/vks';
|
|
30
|
-
import {
|
|
30
|
+
import { type SimulationProvider } from '@aztec/simulator/client';
|
|
31
31
|
import { type NoirCompiledCircuit } from '@aztec/types/noir';
|
|
32
32
|
|
|
33
33
|
import { type Abi, type WitnessMap } from '@noir-lang/types';
|
|
@@ -35,9 +35,11 @@ import { type Abi, type WitnessMap } from '@noir-lang/types';
|
|
|
35
35
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
36
36
|
|
|
37
37
|
export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
constructor(
|
|
39
|
+
protected artifactProvider: ArtifactProvider,
|
|
40
|
+
protected simulationProvider: SimulationProvider,
|
|
41
|
+
protected log = createLogger('bb-prover'),
|
|
42
|
+
) {}
|
|
41
43
|
|
|
42
44
|
public async generateInitOutput(
|
|
43
45
|
inputs: PrivateKernelInitCircuitPrivateInputs,
|
|
@@ -164,7 +166,7 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
164
166
|
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
165
167
|
|
|
166
168
|
const timer = new Timer();
|
|
167
|
-
const outputWitness = await this.
|
|
169
|
+
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit);
|
|
168
170
|
const output = convertOutputs(outputWitness, compiledCircuit.abi);
|
|
169
171
|
|
|
170
172
|
this.log.debug(`Simulated ${circuitType}`, {
|
|
@@ -194,7 +196,7 @@ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
|
194
196
|
|
|
195
197
|
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
196
198
|
const timer = new Timer();
|
|
197
|
-
const outputWitness = await this.
|
|
199
|
+
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit);
|
|
198
200
|
const output = convertOutputs(outputWitness, compiledCircuit.abi);
|
|
199
201
|
|
|
200
202
|
this.log.debug(`Generated witness for ${circuitType}`, {
|
package/src/prover/bb_prover.ts
CHANGED
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
convertSingleTxBlockRootRollupInputsToWitnessMap,
|
|
70
70
|
convertSingleTxBlockRootRollupOutputsFromWitnessMap,
|
|
71
71
|
} from '@aztec/noir-protocol-circuits-types/server';
|
|
72
|
-
import { NativeACVMSimulator } from '@aztec/simulator';
|
|
72
|
+
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
73
73
|
import { Attributes, type TelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
74
74
|
|
|
75
75
|
import { type WitnessMap } from '@noir-lang/types';
|
|
@@ -427,7 +427,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
427
427
|
|
|
428
428
|
const inputWitness = convertInput(input);
|
|
429
429
|
const timer = new Timer();
|
|
430
|
-
const outputWitness = await simulator.
|
|
430
|
+
const outputWitness = await simulator.executeProtocolCircuit(inputWitness, artifact);
|
|
431
431
|
const output = convertOutput(outputWitness);
|
|
432
432
|
|
|
433
433
|
const circuitName = mapProtocolArtifactNameToCircuitName(circuitType);
|
|
@@ -680,13 +680,13 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
680
680
|
|
|
681
681
|
public async verifyAvmProof(proof: Proof, verificationKey: VerificationKeyData) {
|
|
682
682
|
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath) =>
|
|
683
|
-
verifyAvmProof(this.config.bbBinaryPath, proofPath, vkPath, logger
|
|
683
|
+
verifyAvmProof(this.config.bbBinaryPath, proofPath, vkPath, logger),
|
|
684
684
|
);
|
|
685
685
|
}
|
|
686
686
|
|
|
687
687
|
public async verifyWithKey(flavor: UltraHonkFlavor, verificationKey: VerificationKeyData, proof: Proof) {
|
|
688
688
|
return await this.verifyWithKeyInternal(proof, verificationKey, (proofPath, vkPath) =>
|
|
689
|
-
verifyProof(this.config.bbBinaryPath, proofPath, vkPath, flavor, logger
|
|
689
|
+
verifyProof(this.config.bbBinaryPath, proofPath, vkPath, flavor, logger),
|
|
690
690
|
);
|
|
691
691
|
}
|
|
692
692
|
|
package/src/test/test_avm.ts
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from '@aztec/circuits.js';
|
|
29
29
|
import { computeVarArgsHash } from '@aztec/circuits.js/hash';
|
|
30
30
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
31
|
-
import { type PublicFunctionCallResult } from '@aztec/simulator';
|
|
31
|
+
import { type PublicFunctionCallResult } from '@aztec/simulator/server';
|
|
32
32
|
|
|
33
33
|
// TODO: pub somewhere more usable - copied from abstract phase manager
|
|
34
34
|
export function getPublicInputs(result: PublicFunctionCallResult): PublicCircuitPublicInputs {
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
convertSimulatedSingleTxBlockRootRollupOutputsFromWitnessMap,
|
|
64
64
|
} from '@aztec/noir-protocol-circuits-types/server';
|
|
65
65
|
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/vks';
|
|
66
|
-
import { type SimulationProvider, WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator';
|
|
66
|
+
import { type SimulationProvider, WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator/server';
|
|
67
67
|
import { type TelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
68
68
|
|
|
69
69
|
import { type WitnessMap } from '@noir-lang/types';
|
|
@@ -324,7 +324,10 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
324
324
|
// the blob operations with an oracle. Appears to be no way to provide nativeACVM with a foreign call hander.
|
|
325
325
|
simulationProvider = this.wasmSimulator;
|
|
326
326
|
}
|
|
327
|
-
const witness = await simulationProvider.
|
|
327
|
+
const witness = await simulationProvider.executeProtocolCircuit(
|
|
328
|
+
witnessMap,
|
|
329
|
+
SimulatedServerCircuitArtifacts[artifactName],
|
|
330
|
+
);
|
|
328
331
|
|
|
329
332
|
const result = convertOutput(witness);
|
|
330
333
|
|
|
@@ -103,16 +103,12 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
103
103
|
await fs.writeFile(proofFileName, proof.buffer);
|
|
104
104
|
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
105
105
|
|
|
106
|
-
const logFunction = (message: string) => {
|
|
107
|
-
this.logger.debug(`${circuit} BB out - ${message}`);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
106
|
const result = await verifyProof(
|
|
111
107
|
this.config.bbBinaryPath,
|
|
112
108
|
proofFileName,
|
|
113
109
|
verificationKeyPath!,
|
|
114
110
|
getUltraHonkFlavorForCircuit(circuit),
|
|
115
|
-
|
|
111
|
+
this.logger,
|
|
116
112
|
);
|
|
117
113
|
|
|
118
114
|
if (result.status === BB_RESULT.FAILURE) {
|
|
@@ -3,6 +3,7 @@ import { ClientIvcProof } from '@aztec/circuits.js';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
5
|
import { type ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
|
|
6
|
+
import { type SimulationProvider } from '@aztec/simulator/client';
|
|
6
7
|
|
|
7
8
|
import { serializeWitness } from '@noir-lang/noirc_abi';
|
|
8
9
|
import { type WitnessMap } from '@noir-lang/types';
|
|
@@ -13,10 +14,11 @@ import { BBPrivateKernelProver } from '../prover/bb_private_kernel_prover.js';
|
|
|
13
14
|
export abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
14
15
|
constructor(
|
|
15
16
|
protected override artifactProvider: ArtifactProvider,
|
|
17
|
+
protected override simulationProvider: SimulationProvider,
|
|
16
18
|
private threads: number = 1,
|
|
17
19
|
protected override log = createLogger('bb-prover:wasm'),
|
|
18
20
|
) {
|
|
19
|
-
super(artifactProvider, log);
|
|
21
|
+
super(artifactProvider, simulationProvider, log);
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
public override async createClientIvcProof(acirs: Buffer[], witnessStack: WitnessMap[]): Promise<ClientIvcProof> {
|
package/src/wasm/bundle.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
3
|
+
import { type SimulationProvider } from '@aztec/simulator/client';
|
|
3
4
|
|
|
4
5
|
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
5
6
|
|
|
6
7
|
export class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
7
|
-
constructor(threads = 1, log = createLogger('bb-prover:wasm:bundle')) {
|
|
8
|
-
super(new BundleArtifactProvider(), threads, log);
|
|
8
|
+
constructor(simulationProvider: SimulationProvider, threads = 1, log = createLogger('bb-prover:wasm:bundle')) {
|
|
9
|
+
super(new BundleArtifactProvider(), simulationProvider, threads, log);
|
|
9
10
|
}
|
|
10
11
|
}
|
package/src/wasm/lazy.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
|
|
3
|
+
import { type SimulationProvider } from '@aztec/simulator/client';
|
|
3
4
|
|
|
4
5
|
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
5
6
|
|
|
6
7
|
export class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
7
|
-
constructor(threads = 1, log = createLogger('bb-prover:wasm:lazy')) {
|
|
8
|
-
super(new LazyArtifactProvider(), threads, log);
|
|
8
|
+
constructor(simulationProvider: SimulationProvider, threads = 1, log = createLogger('bb-prover:wasm:lazy')) {
|
|
9
|
+
super(new LazyArtifactProvider(), simulationProvider, threads, log);
|
|
9
10
|
}
|
|
10
11
|
}
|