@aztec/bb-prover 0.0.0-test.0 → 0.0.1-commit.24de95ac
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/avm_proving_tests/avm_proving_tester.d.ts +14 -17
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +128 -78
- package/dest/bb/execute.d.ts +13 -46
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +120 -228
- package/dest/config.d.ts +2 -0
- package/dest/config.d.ts.map +1 -1
- package/dest/honk.d.ts +2 -2
- package/dest/honk.d.ts.map +1 -1
- package/dest/honk.js +3 -2
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/instrumentation.d.ts +2 -2
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +2 -4
- package/dest/prover/{bb_private_kernel_prover.d.ts → client/bb_private_kernel_prover.d.ts} +10 -10
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/{bb_private_kernel_prover.js → client/bb_private_kernel_prover.js} +21 -18
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts +23 -0
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/{bb_native_private_kernel_prover.js → client/native/bb_native_private_kernel_prover.js} +19 -22
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts +15 -0
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.js +46 -0
- package/dest/prover/client/wasm/bundle.d.ts +6 -0
- package/dest/prover/client/wasm/bundle.d.ts.map +1 -0
- package/dest/{wasm → prover/client/wasm}/bundle.js +2 -2
- package/dest/prover/client/wasm/lazy.d.ts +6 -0
- package/dest/prover/client/wasm/lazy.d.ts.map +1 -0
- package/dest/{wasm → prover/client/wasm}/lazy.js +2 -2
- package/dest/prover/index.d.ts +2 -3
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/prover/index.js +2 -3
- package/dest/prover/proof_utils.d.ts +19 -0
- package/dest/prover/proof_utils.d.ts.map +1 -0
- package/dest/prover/proof_utils.js +72 -0
- package/dest/prover/server/bb_prover.d.ts +109 -0
- package/dest/prover/server/bb_prover.d.ts.map +1 -0
- package/dest/prover/server/bb_prover.js +339 -0
- package/dest/test/delay_values.d.ts.map +1 -1
- package/dest/test/delay_values.js +30 -18
- package/dest/test/test_circuit_prover.d.ts +24 -33
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +85 -59
- package/dest/test/test_verifier.d.ts +3 -2
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +8 -1
- package/dest/verification_key/verification_key_data.d.ts +6 -0
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +23 -29
- package/dest/verifier/bb_verifier.d.ts +5 -4
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +43 -25
- package/dest/verifier/index.d.ts +1 -0
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -0
- package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/queued_chonk_verifier.js +132 -0
- package/package.json +32 -31
- package/src/avm_proving_tests/avm_proving_tester.ts +209 -103
- package/src/bb/execute.ts +98 -242
- package/src/config.ts +2 -0
- package/src/honk.ts +3 -2
- package/src/index.ts +1 -0
- package/src/instrumentation.ts +2 -4
- package/src/prover/{bb_private_kernel_prover.ts → client/bb_private_kernel_prover.ts} +53 -29
- package/src/prover/{bb_native_private_kernel_prover.ts → client/native/bb_native_private_kernel_prover.ts} +23 -37
- package/src/{wasm → prover/client/wasm}/bb_wasm_private_kernel_prover.ts +18 -15
- package/src/{wasm → prover/client/wasm}/bundle.ts +3 -3
- package/src/{wasm → prover/client/wasm}/lazy.ts +3 -3
- package/src/prover/index.ts +2 -3
- package/src/prover/proof_utils.ts +115 -0
- package/src/prover/server/bb_prover.ts +733 -0
- package/src/test/delay_values.ts +30 -18
- package/src/test/test_circuit_prover.ts +260 -147
- package/src/test/test_verifier.ts +7 -3
- package/src/verification_key/verification_key_data.ts +29 -24
- package/src/verifier/bb_verifier.ts +60 -32
- package/src/verifier/index.ts +1 -0
- package/src/verifier/queued_chonk_verifier.ts +140 -0
- package/dest/prover/bb_native_private_kernel_prover.d.ts +0 -25
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.d.ts +0 -120
- package/dest/prover/bb_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.js +0 -423
- package/dest/prover/client_ivc_proof_utils.d.ts +0 -25
- package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
- package/dest/prover/client_ivc_proof_utils.js +0 -43
- package/dest/stats.d.ts +0 -5
- package/dest/stats.d.ts.map +0 -1
- package/dest/stats.js +0 -62
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +0 -17
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.js +0 -46
- package/dest/wasm/bundle.d.ts +0 -6
- package/dest/wasm/bundle.d.ts.map +0 -1
- package/dest/wasm/lazy.d.ts +0 -6
- package/dest/wasm/lazy.d.ts.map +0 -1
- package/src/prover/bb_prover.ts +0 -781
- package/src/prover/client_ivc_proof_utils.ts +0 -42
- package/src/stats.ts +0 -64
package/dest/instrumentation.js
CHANGED
|
@@ -61,8 +61,7 @@ import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
|
61
61
|
*/ recordDuration(metric, circuitName, timerOrMS) {
|
|
62
62
|
const s = typeof timerOrMS === 'number' ? timerOrMS / 1000 : timerOrMS.s();
|
|
63
63
|
this[metric].record(s, {
|
|
64
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName
|
|
65
|
-
[Attributes.PROTOCOL_CIRCUIT_TYPE]: 'server'
|
|
64
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName
|
|
66
65
|
});
|
|
67
66
|
}
|
|
68
67
|
/**
|
|
@@ -83,8 +82,7 @@ import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
|
|
|
83
82
|
* @param size - The size
|
|
84
83
|
*/ recordSize(metric, circuitName, size) {
|
|
85
84
|
this[metric].record(Math.ceil(size), {
|
|
86
|
-
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName
|
|
87
|
-
[Attributes.PROTOCOL_CIRCUIT_TYPE]: 'server'
|
|
85
|
+
[Attributes.PROTOCOL_CIRCUIT_NAME]: circuitName
|
|
88
86
|
});
|
|
89
87
|
}
|
|
90
88
|
/**
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
import type { SimulationProvider } from '@aztec/simulator/client';
|
|
1
|
+
import { type ArtifactProvider, type ClientProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
2
|
+
import type { Abi, WitnessMap } from '@aztec/noir-types';
|
|
3
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
5
4
|
import type { PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
|
|
6
|
-
import type { PrivateKernelCircuitPublicInputs, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelResetCircuitPrivateInputs, PrivateKernelSimulateOutput, PrivateKernelTailCircuitPrivateInputs, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
7
|
-
import type {
|
|
8
|
-
import type { Abi, WitnessMap } from '@noir-lang/types';
|
|
5
|
+
import type { HidingKernelToPublicPrivateInputs, HidingKernelToRollupPrivateInputs, PrivateExecutionStep, PrivateKernelCircuitPublicInputs, PrivateKernelInitCircuitPrivateInputs, PrivateKernelInnerCircuitPrivateInputs, PrivateKernelResetCircuitPrivateInputs, PrivateKernelSimulateOutput, PrivateKernelTailCircuitPrivateInputs, PrivateKernelTailCircuitPublicInputs } from '@aztec/stdlib/kernel';
|
|
6
|
+
import type { ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
9
7
|
export declare abstract class BBPrivateKernelProver implements PrivateKernelProver {
|
|
10
8
|
protected artifactProvider: ArtifactProvider;
|
|
11
|
-
protected
|
|
9
|
+
protected simulator: CircuitSimulator;
|
|
12
10
|
protected log: import("@aztec/foundation/log").Logger;
|
|
13
|
-
constructor(artifactProvider: ArtifactProvider,
|
|
11
|
+
constructor(artifactProvider: ArtifactProvider, simulator: CircuitSimulator, log?: import("@aztec/foundation/log").Logger);
|
|
14
12
|
generateInitOutput(inputs: PrivateKernelInitCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
15
13
|
simulateInit(inputs: PrivateKernelInitCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
16
14
|
generateInnerOutput(inputs: PrivateKernelInnerCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
@@ -19,6 +17,8 @@ export declare abstract class BBPrivateKernelProver implements PrivateKernelProv
|
|
|
19
17
|
simulateReset(inputs: PrivateKernelResetCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>>;
|
|
20
18
|
generateTailOutput(inputs: PrivateKernelTailCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
21
19
|
simulateTail(inputs: PrivateKernelTailCircuitPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
20
|
+
generateHidingToRollupOutput(inputs: HidingKernelToRollupPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
21
|
+
generateHidingToPublicOutput(inputs: HidingKernelToPublicPrivateInputs): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>>;
|
|
22
22
|
simulateCircuitOutput<I extends {
|
|
23
23
|
toBuffer: () => Buffer;
|
|
24
24
|
}, O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs>(inputs: I, circuitType: ClientProtocolArtifact, convertInputs: (inputs: I, abi: Abi) => WitnessMap, convertOutputs: (outputs: WitnessMap, abi: Abi) => O): Promise<PrivateKernelSimulateOutput<O>>;
|
|
@@ -26,7 +26,7 @@ export declare abstract class BBPrivateKernelProver implements PrivateKernelProv
|
|
|
26
26
|
toBuffer: () => Buffer;
|
|
27
27
|
}, O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs>(inputs: I, circuitType: ClientProtocolArtifact, convertInputs: (inputs: I, abi: Abi) => WitnessMap, convertOutputs: (outputs: WitnessMap, abi: Abi) => O): Promise<PrivateKernelSimulateOutput<O>>;
|
|
28
28
|
makeEmptyKernelSimulateOutput<PublicInputsType extends PrivateKernelTailCircuitPublicInputs | PrivateKernelCircuitPublicInputs>(publicInputs: PublicInputsType, circuitType: ClientProtocolArtifact): Promise<PrivateKernelSimulateOutput<PublicInputsType>>;
|
|
29
|
-
|
|
29
|
+
createChonkProof(_executionSteps: PrivateExecutionStep[]): Promise<ChonkProofWithPublicInputs>;
|
|
30
30
|
computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=bb_private_kernel_prover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bb_private_kernel_prover.d.ts","sourceRoot":"","sources":["../../../src/prover/client/bb_private_kernel_prover.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
2
|
+
import { convertHidingKernelPublicInputsToWitnessMapWithAbi, convertHidingKernelToRollupInputsToWitnessMapWithAbi, convertPrivateKernelInitInputsToWitnessMapWithAbi, convertPrivateKernelInitOutputsFromWitnessMapWithAbi, convertPrivateKernelInnerInputsToWitnessMapWithAbi, convertPrivateKernelInnerOutputsFromWitnessMapWithAbi, convertPrivateKernelResetInputsToWitnessMapWithAbi, convertPrivateKernelResetOutputsFromWitnessMapWithAbi, convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi, convertPrivateKernelTailInputsToWitnessMapWithAbi, convertPrivateKernelTailOutputsFromWitnessMapWithAbi, convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi, foreignCallHandler, getPrivateKernelResetArtifactName, updateResetCircuitSampleInputs } from '@aztec/noir-protocol-circuits-types/client';
|
|
3
|
+
import { mapProtocolArtifactNameToCircuitName } from '@aztec/noir-protocol-circuits-types/types';
|
|
5
4
|
export class BBPrivateKernelProver {
|
|
6
5
|
artifactProvider;
|
|
7
|
-
|
|
6
|
+
simulator;
|
|
8
7
|
log;
|
|
9
|
-
constructor(artifactProvider,
|
|
8
|
+
constructor(artifactProvider, simulator, log = createLogger('bb-prover')){
|
|
10
9
|
this.artifactProvider = artifactProvider;
|
|
11
|
-
this.
|
|
10
|
+
this.simulator = simulator;
|
|
12
11
|
this.log = log;
|
|
13
12
|
}
|
|
14
13
|
async generateInitOutput(inputs) {
|
|
@@ -46,22 +45,27 @@ export class BBPrivateKernelProver {
|
|
|
46
45
|
}
|
|
47
46
|
return await this.simulateCircuitOutput(inputs, 'PrivateKernelTailToPublicArtifact', convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi, convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi);
|
|
48
47
|
}
|
|
48
|
+
async generateHidingToRollupOutput(inputs) {
|
|
49
|
+
return await this.generateCircuitOutput(inputs, 'HidingKernelToRollup', convertHidingKernelToRollupInputsToWitnessMapWithAbi, convertPrivateKernelTailOutputsFromWitnessMapWithAbi);
|
|
50
|
+
}
|
|
51
|
+
async generateHidingToPublicOutput(inputs) {
|
|
52
|
+
return await this.generateCircuitOutput(inputs, 'HidingKernelToPublic', convertHidingKernelPublicInputsToWitnessMapWithAbi, convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi);
|
|
53
|
+
}
|
|
49
54
|
async simulateCircuitOutput(inputs, circuitType, convertInputs, convertOutputs) {
|
|
50
55
|
const compiledCircuit = await this.artifactProvider.getSimulatedClientCircuitArtifactByName(circuitType);
|
|
51
56
|
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
52
|
-
const
|
|
53
|
-
const outputWitness = await this.simulationProvider.executeProtocolCircuit(witnessMap, compiledCircuit).catch((err)=>{
|
|
57
|
+
const outputWitness = await this.simulator.executeProtocolCircuit(witnessMap, compiledCircuit, foreignCallHandler).catch((err)=>{
|
|
54
58
|
this.log.debug(`Failed to simulate ${circuitType}`, {
|
|
55
59
|
circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
|
|
56
60
|
error: err
|
|
57
61
|
});
|
|
58
62
|
throw err;
|
|
59
63
|
});
|
|
60
|
-
const output = convertOutputs(outputWitness, compiledCircuit.abi);
|
|
64
|
+
const output = convertOutputs(outputWitness.witness, compiledCircuit.abi);
|
|
61
65
|
this.log.debug(`Simulated ${circuitType}`, {
|
|
62
66
|
eventName: 'circuit-simulation',
|
|
63
67
|
circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
|
|
64
|
-
duration:
|
|
68
|
+
duration: outputWitness.duration,
|
|
65
69
|
inputSize: inputs.toBuffer().length,
|
|
66
70
|
outputSize: output.toBuffer().length
|
|
67
71
|
});
|
|
@@ -71,22 +75,21 @@ export class BBPrivateKernelProver {
|
|
|
71
75
|
this.log.debug(`Generating witness for ${circuitType}`);
|
|
72
76
|
const compiledCircuit = await this.artifactProvider.getClientCircuitArtifactByName(circuitType);
|
|
73
77
|
const witnessMap = convertInputs(inputs, compiledCircuit.abi);
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const output = convertOutputs(outputWitness, compiledCircuit.abi);
|
|
78
|
+
const outputWitness = await this.simulator.executeProtocolCircuit(witnessMap, compiledCircuit, foreignCallHandler);
|
|
79
|
+
const output = convertOutputs(outputWitness.witness, compiledCircuit.abi);
|
|
77
80
|
this.log.debug(`Generated witness for ${circuitType}`, {
|
|
78
81
|
eventName: 'circuit-witness-generation',
|
|
79
82
|
circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
|
|
80
|
-
duration:
|
|
83
|
+
duration: outputWitness.duration,
|
|
81
84
|
inputSize: inputs.toBuffer().length,
|
|
82
85
|
outputSize: output.toBuffer().length
|
|
83
86
|
});
|
|
84
|
-
const verificationKey =
|
|
87
|
+
const verificationKey = await this.artifactProvider.getCircuitVkByName(circuitType);
|
|
85
88
|
const bytecode = Buffer.from(compiledCircuit.bytecode, 'base64');
|
|
86
89
|
const kernelOutput = {
|
|
87
90
|
publicInputs: output,
|
|
88
91
|
verificationKey,
|
|
89
|
-
outputWitness,
|
|
92
|
+
outputWitness: outputWitness.witness,
|
|
90
93
|
bytecode
|
|
91
94
|
};
|
|
92
95
|
return kernelOutput;
|
|
@@ -94,13 +97,13 @@ export class BBPrivateKernelProver {
|
|
|
94
97
|
async makeEmptyKernelSimulateOutput(publicInputs, circuitType) {
|
|
95
98
|
const kernelProofOutput = {
|
|
96
99
|
publicInputs,
|
|
97
|
-
verificationKey:
|
|
100
|
+
verificationKey: await this.artifactProvider.getCircuitVkByName(circuitType),
|
|
98
101
|
outputWitness: new Map(),
|
|
99
102
|
bytecode: Buffer.from([])
|
|
100
103
|
};
|
|
101
104
|
return kernelProofOutput;
|
|
102
105
|
}
|
|
103
|
-
|
|
106
|
+
createChonkProof(_executionSteps) {
|
|
104
107
|
throw new Error('Not implemented');
|
|
105
108
|
}
|
|
106
109
|
computeGateCountForCircuit(_bytecode, _circuitName) {
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,51 +1,48 @@
|
|
|
1
1
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
4
|
-
import {
|
|
5
|
-
import { serializeWitness } from '@noir-lang/noirc_abi';
|
|
4
|
+
import { serializePrivateExecutionSteps } from '@aztec/stdlib/kernel';
|
|
6
5
|
import { promises as fs } from 'fs';
|
|
7
6
|
import path from 'path';
|
|
8
|
-
import { BB_RESULT, computeGateCountForCircuit,
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
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';
|
|
11
10
|
/**
|
|
12
11
|
* This proof creator implementation uses the native bb binary.
|
|
13
12
|
*/ export class BBNativePrivateKernelProver extends BBPrivateKernelProver {
|
|
14
13
|
bbBinaryPath;
|
|
15
14
|
bbWorkingDirectory;
|
|
16
15
|
skipCleanup;
|
|
17
|
-
|
|
16
|
+
simulator;
|
|
18
17
|
log;
|
|
19
|
-
constructor(bbBinaryPath, bbWorkingDirectory, skipCleanup,
|
|
20
|
-
super(new BundleArtifactProvider(),
|
|
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;
|
|
21
20
|
}
|
|
22
|
-
static async new(config,
|
|
21
|
+
static async new(config, simulator, log) {
|
|
23
22
|
await fs.mkdir(config.bbWorkingDirectory, {
|
|
24
23
|
recursive: true
|
|
25
24
|
});
|
|
26
|
-
return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup,
|
|
25
|
+
return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, simulator, log);
|
|
27
26
|
}
|
|
28
|
-
async
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
await
|
|
32
|
-
await fs.writeFile(path.join(directory, 'witnesses.msgpack'), encode(witnessStack.map((map)=>serializeWitness(map))));
|
|
33
|
-
const provingResult = await executeBbClientIvcProof(this.bbBinaryPath, directory, path.join(directory, 'acir.msgpack'), path.join(directory, 'witnesses.msgpack'), this.log.info);
|
|
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);
|
|
34
31
|
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
35
|
-
this.log.error(`Failed to generate
|
|
32
|
+
this.log.error(`Failed to generate chonk proof`);
|
|
36
33
|
throw new Error(provingResult.reason);
|
|
37
34
|
}
|
|
38
|
-
const proof = await
|
|
39
|
-
this.log.info(`Generated
|
|
35
|
+
const proof = await readChonkProofFromOutputDirectory(directory);
|
|
36
|
+
this.log.info(`Generated Chonk proof`, {
|
|
40
37
|
duration: provingResult.durationMs,
|
|
41
38
|
eventName: 'circuit-proving'
|
|
42
39
|
});
|
|
43
40
|
return proof;
|
|
44
41
|
}
|
|
45
|
-
async
|
|
46
|
-
this.log.info(`Generating
|
|
42
|
+
async createChonkProof(executionSteps) {
|
|
43
|
+
this.log.info(`Generating Chonk proof`);
|
|
47
44
|
const operation = async (directory)=>{
|
|
48
|
-
return await this.
|
|
45
|
+
return await this._createChonkProof(directory, executionSteps);
|
|
49
46
|
};
|
|
50
47
|
return await this.runInDirectory(operation);
|
|
51
48
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AztecClientBackend } from '@aztec/bb.js';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import { serializeWitness } from '@aztec/noir-noirc_abi';
|
|
5
|
+
import { ChonkProofWithPublicInputs } from '@aztec/stdlib/proofs';
|
|
6
|
+
import { ungzip } from 'pako';
|
|
7
|
+
import { BBPrivateKernelProver } from '../bb_private_kernel_prover.js';
|
|
8
|
+
export class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
|
|
9
|
+
artifactProvider;
|
|
10
|
+
simulator;
|
|
11
|
+
threads;
|
|
12
|
+
log;
|
|
13
|
+
constructor(artifactProvider, simulator, threads = 1, log = createLogger('bb-prover:wasm')){
|
|
14
|
+
super(artifactProvider, simulator, log), this.artifactProvider = artifactProvider, this.simulator = simulator, this.threads = threads, this.log = log;
|
|
15
|
+
}
|
|
16
|
+
async createChonkProof(executionSteps) {
|
|
17
|
+
const timer = new Timer();
|
|
18
|
+
this.log.info(`Generating Chonk proof...`);
|
|
19
|
+
const backend = new AztecClientBackend(executionSteps.map((step)=>ungzip(step.bytecode)), {
|
|
20
|
+
threads: this.threads,
|
|
21
|
+
logger: this.log.verbose,
|
|
22
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
23
|
+
});
|
|
24
|
+
const [proof] = await backend.prove(executionSteps.map((step)=>ungzip(serializeWitness(step.witness))), executionSteps.map((step)=>step.vk));
|
|
25
|
+
await backend.destroy();
|
|
26
|
+
this.log.info(`Generated Chonk proof`, {
|
|
27
|
+
eventName: 'chonk-proof-generation',
|
|
28
|
+
duration: timer.ms(),
|
|
29
|
+
proofSize: proof.length
|
|
30
|
+
});
|
|
31
|
+
return ChonkProofWithPublicInputs.fromBufferArray(proof);
|
|
32
|
+
}
|
|
33
|
+
async computeGateCountForCircuit(_bytecode, _circuitName) {
|
|
34
|
+
// Note we do not pass the vk to the backend. This is unneeded for gate counts.
|
|
35
|
+
const backend = new AztecClientBackend([
|
|
36
|
+
ungzip(_bytecode)
|
|
37
|
+
], {
|
|
38
|
+
threads: this.threads,
|
|
39
|
+
logger: this.log.verbose,
|
|
40
|
+
wasmPath: process.env.BB_WASM_PATH
|
|
41
|
+
});
|
|
42
|
+
const gateCount = await backend.gates();
|
|
43
|
+
await backend.destroy();
|
|
44
|
+
return gateCount[0];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
2
|
+
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
3
|
+
export declare class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
4
|
+
constructor(simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,+BAAgC,SAAQ,yBAAyB;gBAChE,SAAS,EAAE,gBAAgB,EAAE,OAAO,SAAK,EAAE,GAAG,yCAAwC;CAGnG"}
|
|
@@ -2,7 +2,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
|
|
3
3
|
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
4
4
|
export class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
5
|
-
constructor(
|
|
6
|
-
super(new BundleArtifactProvider(),
|
|
5
|
+
constructor(simulator, threads = 16, log = createLogger('bb-prover:wasm:bundle')){
|
|
6
|
+
super(new BundleArtifactProvider(), simulator, threads, log);
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CircuitSimulator } from '@aztec/simulator/client';
|
|
2
|
+
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
3
|
+
export declare class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
4
|
+
constructor(simulator: CircuitSimulator, threads?: number, log?: import("@aztec/foundation/log").Logger);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../../src/prover/client/wasm/lazy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,6BAA8B,SAAQ,yBAAyB;gBAC9D,SAAS,EAAE,gBAAgB,EAAE,OAAO,SAAK,EAAE,GAAG,yCAAsC;CAGjG"}
|
|
@@ -2,7 +2,7 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
2
2
|
import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
|
|
3
3
|
import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
|
|
4
4
|
export class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
|
|
5
|
-
constructor(
|
|
6
|
-
super(new LazyArtifactProvider(),
|
|
5
|
+
constructor(simulator, threads = 16, log = createLogger('bb-prover:wasm:lazy')){
|
|
6
|
+
super(new LazyArtifactProvider(), simulator, threads, log);
|
|
7
7
|
}
|
|
8
8
|
}
|
package/dest/prover/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prover/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prover/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC"}
|
package/dest/prover/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export * from './bb_prover.js';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './client_ivc_proof_utils.js';
|
|
1
|
+
export * from './server/bb_prover.js';
|
|
2
|
+
export * from './proof_utils.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { ChonkProofWithPublicInputs, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
3
|
+
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
4
|
+
/**
|
|
5
|
+
* Create a ChonkProof proof file.
|
|
6
|
+
*
|
|
7
|
+
* @param directory the directory to read the proof from.
|
|
8
|
+
* @returns the encapsulated chonk proof
|
|
9
|
+
*/
|
|
10
|
+
export declare function readChonkProofFromOutputDirectory(directory: string): Promise<ChonkProofWithPublicInputs>;
|
|
11
|
+
/**
|
|
12
|
+
* Serialize a ChonkProof to a proof file.
|
|
13
|
+
*
|
|
14
|
+
* @param proof the ChonkProof from object
|
|
15
|
+
* @param directory the directory to write in
|
|
16
|
+
*/
|
|
17
|
+
export declare function writeChonkProofToPath(chonkProof: ChonkProofWithPublicInputs, outputPath: string): Promise<void>;
|
|
18
|
+
export declare function readProofsFromOutputDirectory<PROOF_LENGTH extends number>(directory: string, vkData: VerificationKeyData, proofLength: PROOF_LENGTH, logger: Logger): Promise<RecursiveProof<PROOF_LENGTH>>;
|
|
19
|
+
//# sourceMappingURL=proof_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proof_utils.d.ts","sourceRoot":"","sources":["../../src/prover/proof_utils.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAS,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQ7D;;;;;GAKG;AACH,wBAAsB,iCAAiC,CAAC,SAAS,EAAE,MAAM,uCAKxE;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,iBAIrG;AAuBD,wBAAsB,6BAA6B,CAAC,YAAY,SAAS,MAAM,EAC7E,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,YAAY,EACzB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CA2CvC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CHONK_PROOF_LENGTH, HIDING_KERNEL_IO_PUBLIC_INPUTS_SIZE, IPA_CLAIM_SIZE, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, PAIRING_POINTS_SIZE, ULTRA_KECCAK_PROOF_LENGTH } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { ChonkProofWithPublicInputs, Proof, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
4
|
+
import assert from 'assert';
|
|
5
|
+
import { promises as fs } from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { PROOF_FILENAME, PUBLIC_INPUTS_FILENAME } from '../bb/execute.js';
|
|
8
|
+
/**
|
|
9
|
+
* Create a ChonkProof proof file.
|
|
10
|
+
*
|
|
11
|
+
* @param directory the directory to read the proof from.
|
|
12
|
+
* @returns the encapsulated chonk proof
|
|
13
|
+
*/ export async function readChonkProofFromOutputDirectory(directory) {
|
|
14
|
+
const proofFilename = path.join(directory, PROOF_FILENAME);
|
|
15
|
+
const binaryProof = await fs.readFile(proofFilename);
|
|
16
|
+
const proofFields = splitBufferIntoFields(binaryProof);
|
|
17
|
+
return new ChonkProofWithPublicInputs(proofFields);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Serialize a ChonkProof to a proof file.
|
|
21
|
+
*
|
|
22
|
+
* @param proof the ChonkProof from object
|
|
23
|
+
* @param directory the directory to write in
|
|
24
|
+
*/ export async function writeChonkProofToPath(chonkProof, outputPath) {
|
|
25
|
+
// NB: Don't use chonkProof.toBuffer here because it will include the proof length.
|
|
26
|
+
const fieldsBuf = Buffer.concat(chonkProof.fieldsWithPublicInputs.map((field)=>field.toBuffer()));
|
|
27
|
+
await fs.writeFile(outputPath, fieldsBuf);
|
|
28
|
+
}
|
|
29
|
+
function getNumCustomPublicInputs(proofLength, vkData) {
|
|
30
|
+
let numPublicInputs = vkData.numPublicInputs;
|
|
31
|
+
if (proofLength == CHONK_PROOF_LENGTH) {
|
|
32
|
+
numPublicInputs -= HIDING_KERNEL_IO_PUBLIC_INPUTS_SIZE;
|
|
33
|
+
} else {
|
|
34
|
+
numPublicInputs -= PAIRING_POINTS_SIZE;
|
|
35
|
+
if (proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH) {
|
|
36
|
+
numPublicInputs -= IPA_CLAIM_SIZE;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return numPublicInputs;
|
|
40
|
+
}
|
|
41
|
+
function splitBufferIntoFields(buffer) {
|
|
42
|
+
const fields = [];
|
|
43
|
+
for(let i = 0; i < buffer.length / Fr.SIZE_IN_BYTES; i++){
|
|
44
|
+
fields.push(Fr.fromBuffer(buffer.subarray(i * Fr.SIZE_IN_BYTES, (i + 1) * Fr.SIZE_IN_BYTES)));
|
|
45
|
+
}
|
|
46
|
+
return fields;
|
|
47
|
+
}
|
|
48
|
+
export async function readProofsFromOutputDirectory(directory, vkData, proofLength, logger) {
|
|
49
|
+
assert(proofLength == CHONK_PROOF_LENGTH || proofLength == NESTED_RECURSIVE_PROOF_LENGTH || proofLength == NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH || proofLength == ULTRA_KECCAK_PROOF_LENGTH, `Proof length must be one of the expected proof lengths, received ${proofLength}`);
|
|
50
|
+
const publicInputsFilename = path.join(directory, PUBLIC_INPUTS_FILENAME);
|
|
51
|
+
const proofFilename = path.join(directory, PROOF_FILENAME);
|
|
52
|
+
// Handle CHONK separately because bb outputs the proof fields with public inputs for CHONK.
|
|
53
|
+
const isChonk = proofLength == CHONK_PROOF_LENGTH;
|
|
54
|
+
const [binaryPublicInputs, binaryProof] = await Promise.all([
|
|
55
|
+
isChonk ? Buffer.alloc(0) : fs.readFile(publicInputsFilename),
|
|
56
|
+
fs.readFile(proofFilename)
|
|
57
|
+
]);
|
|
58
|
+
const numPublicInputs = getNumCustomPublicInputs(proofLength, vkData);
|
|
59
|
+
let fieldsWithoutPublicInputs = splitBufferIntoFields(binaryProof);
|
|
60
|
+
if (isChonk) {
|
|
61
|
+
fieldsWithoutPublicInputs = fieldsWithoutPublicInputs.slice(numPublicInputs);
|
|
62
|
+
}
|
|
63
|
+
assert(fieldsWithoutPublicInputs.length == proofLength, `Proof fields length mismatch: ${fieldsWithoutPublicInputs.length} != ${proofLength}`);
|
|
64
|
+
// Concat binary public inputs and binary proof
|
|
65
|
+
// This buffer will have the form: [binary public inputs, binary proof]
|
|
66
|
+
const binaryProofWithPublicInputs = Buffer.concat([
|
|
67
|
+
binaryPublicInputs,
|
|
68
|
+
binaryProof
|
|
69
|
+
]);
|
|
70
|
+
logger.debug(`Circuit path: ${directory}, proof fields length: ${fieldsWithoutPublicInputs.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}`);
|
|
71
|
+
return new RecursiveProof(fieldsWithoutPublicInputs, new Proof(binaryProofWithPublicInputs, numPublicInputs), true, proofLength);
|
|
72
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH } from '@aztec/constants';
|
|
2
|
+
import { type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
3
|
+
import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
4
|
+
import { type ProofAndVerificationKey, type PublicInputsAndRecursiveProof, type ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
|
|
5
|
+
import type { ParityBasePrivateInputs, ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
6
|
+
import { Proof } from '@aztec/stdlib/proofs';
|
|
7
|
+
import { BlockMergeRollupPrivateInputs, BlockRollupPublicInputs, BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, CheckpointMergeRollupPrivateInputs, CheckpointPaddingRollupPrivateInputs, CheckpointRollupPublicInputs, CheckpointRootRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs, type PrivateTxBaseRollupPrivateInputs, PublicChonkVerifierPrivateInputs, PublicChonkVerifierPublicInputs, PublicTxBaseRollupPrivateInputs, type RootRollupPrivateInputs, type RootRollupPublicInputs, type TxMergeRollupPrivateInputs, type TxRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
8
|
+
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
9
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
10
|
+
import type { ACVMConfig, BBConfig } from '../../config.js';
|
|
11
|
+
import { type UltraHonkFlavor } from '../../honk.js';
|
|
12
|
+
export interface BBProverConfig extends BBConfig, ACVMConfig {
|
|
13
|
+
circuitFilter?: ServerProtocolArtifact[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Prover implementation that uses barretenberg native proving
|
|
17
|
+
*/
|
|
18
|
+
export declare class BBNativeRollupProver implements ServerCircuitProver {
|
|
19
|
+
private config;
|
|
20
|
+
private instrumentation;
|
|
21
|
+
constructor(config: BBProverConfig, telemetry: TelemetryClient);
|
|
22
|
+
get tracer(): import("@aztec/telemetry-client").Tracer;
|
|
23
|
+
static new(config: BBProverConfig, telemetry?: TelemetryClient): Promise<BBNativeRollupProver>;
|
|
24
|
+
/**
|
|
25
|
+
* Simulates the base parity circuit from its inputs.
|
|
26
|
+
* @param inputs - Inputs to the circuit.
|
|
27
|
+
* @returns The public inputs of the parity circuit.
|
|
28
|
+
*/
|
|
29
|
+
getBaseParityProof(inputs: ParityBasePrivateInputs): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>>;
|
|
30
|
+
/**
|
|
31
|
+
* Simulates the root parity circuit from its inputs.
|
|
32
|
+
* @param inputs - Inputs to the circuit.
|
|
33
|
+
* @returns The public inputs of the parity circuit.
|
|
34
|
+
*/
|
|
35
|
+
getRootParityProof(inputs: ParityRootPrivateInputs): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates an AVM proof and verifies it.
|
|
38
|
+
* @param inputs - The inputs to the AVM circuit.
|
|
39
|
+
* @returns The proof.
|
|
40
|
+
*/
|
|
41
|
+
getAvmProof(inputs: AvmCircuitInputs, skipPublicInputsValidation?: boolean): Promise<ProofAndVerificationKey<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>>;
|
|
42
|
+
getPublicChonkVerifierProof(inputs: PublicChonkVerifierPrivateInputs): Promise<PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
43
|
+
/**
|
|
44
|
+
* Simulates the base rollup circuit from its inputs.
|
|
45
|
+
* @param inputs - Inputs to the circuit.
|
|
46
|
+
* @returns The public inputs as outputs of the simulation.
|
|
47
|
+
*/
|
|
48
|
+
getPrivateTxBaseRollupProof(inputs: PrivateTxBaseRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
49
|
+
/**
|
|
50
|
+
* Requests that the public kernel tail circuit be executed and the proof generated
|
|
51
|
+
* @param kernelRequest - The object encapsulating the request for a proof
|
|
52
|
+
* @returns The requested circuit's public inputs and proof
|
|
53
|
+
*/
|
|
54
|
+
getPublicTxBaseRollupProof(inputs: PublicTxBaseRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
55
|
+
/**
|
|
56
|
+
* Simulates the merge rollup circuit from its inputs.
|
|
57
|
+
* @param input - Inputs to the circuit.
|
|
58
|
+
* @returns The public inputs as outputs of the simulation.
|
|
59
|
+
*/
|
|
60
|
+
getTxMergeRollupProof(input: TxMergeRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
61
|
+
getBlockRootFirstRollupProof(input: BlockRootFirstRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
62
|
+
getBlockRootSingleTxFirstRollupProof(input: BlockRootSingleTxFirstRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
63
|
+
getBlockRootEmptyTxFirstRollupProof(input: BlockRootEmptyTxFirstRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
64
|
+
getBlockRootRollupProof(input: BlockRootRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
65
|
+
getBlockRootSingleTxRollupProof(input: BlockRootSingleTxRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
66
|
+
getBlockMergeRollupProof(input: BlockMergeRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
67
|
+
getCheckpointRootRollupProof(input: CheckpointRootRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
68
|
+
getCheckpointRootSingleBlockRollupProof(input: CheckpointRootSingleBlockRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
69
|
+
getCheckpointPaddingRollupProof(input: CheckpointPaddingRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
70
|
+
getCheckpointMergeRollupProof(input: CheckpointMergeRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
|
|
71
|
+
/**
|
|
72
|
+
* Simulates the root rollup circuit from its inputs.
|
|
73
|
+
* @param input - Inputs to the circuit.
|
|
74
|
+
* @returns The public inputs as outputs of the simulation.
|
|
75
|
+
*/
|
|
76
|
+
getRootRollupProof(input: RootRollupPrivateInputs): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>>;
|
|
77
|
+
private createRecursiveProofAndVerify;
|
|
78
|
+
private generateProofWithBB;
|
|
79
|
+
private generateAvmProofWithBB;
|
|
80
|
+
private createAvmProof;
|
|
81
|
+
/**
|
|
82
|
+
* Executes a circuit and returns its outputs and corresponding proof with embedded aggregation object
|
|
83
|
+
* @param witnessMap - The input witness
|
|
84
|
+
* @param circuitType - The type of circuit to be executed
|
|
85
|
+
* @param proofLength - The length of the proof to be generated. This is a dummy parameter to aid in type checking
|
|
86
|
+
* @param convertInput - Function for mapping the input object to a witness map.
|
|
87
|
+
* @param convertOutput - Function for parsing the output witness to it's corresponding object
|
|
88
|
+
* @returns The circuits output object and it's proof
|
|
89
|
+
*/
|
|
90
|
+
private createRecursiveProof;
|
|
91
|
+
/**
|
|
92
|
+
* Verifies a proof, will generate the verification key if one is not cached internally
|
|
93
|
+
* @param circuitType - The type of circuit whose proof is to be verified
|
|
94
|
+
* @param proof - The proof to be verified
|
|
95
|
+
*/
|
|
96
|
+
verifyProof(circuitType: ServerProtocolArtifact, proof: Proof): Promise<void>;
|
|
97
|
+
verifyAvmProof(proof: Proof, verificationKey: VerificationKeyData, publicInputs: AvmCircuitPublicInputs): Promise<void>;
|
|
98
|
+
verifyWithKey(flavor: UltraHonkFlavor, verificationKey: VerificationKeyData, proof: Proof): Promise<void>;
|
|
99
|
+
private verifyWithKeyInternal;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the verification key data for a circuit.
|
|
102
|
+
* @param circuitType - The type of circuit for which the verification key is required
|
|
103
|
+
* @returns The verification key data
|
|
104
|
+
*/
|
|
105
|
+
private getVerificationKeyDataForCircuit;
|
|
106
|
+
private readAvmProofAsFields;
|
|
107
|
+
private runInDirectory;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=bb_prover.d.ts.map
|