@aztec/bb-prover 0.0.0-test.0 → 0.0.1-commit.21caa21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/avm_proving_tests/avm_proving_tester.d.ts +14 -18
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +130 -79
- package/dest/bb/cli.d.ts +1 -1
- package/dest/bb/execute.d.ts +14 -47
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +132 -236
- package/dest/bb/index.d.ts +1 -1
- package/dest/config.d.ts +3 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/honk.d.ts +3 -3
- package/dest/honk.d.ts.map +1 -1
- package/dest/honk.js +3 -2
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/instrumentation.d.ts +3 -3
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +2 -4
- package/dest/prover/client/bb_private_kernel_prover.d.ts +32 -0
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/{bb_private_kernel_prover.js → client/bb_private_kernel_prover.js} +42 -20
- package/dest/prover/client/bundle.d.ts +6 -0
- package/dest/prover/client/bundle.d.ts.map +1 -0
- package/dest/prover/client/bundle.js +8 -0
- package/dest/prover/client/lazy.d.ts +6 -0
- package/dest/prover/client/lazy.d.ts.map +1 -0
- package/dest/prover/client/lazy.js +8 -0
- package/dest/prover/index.d.ts +3 -4
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/prover/index.js +2 -3
- package/dest/prover/proof_utils.d.ts +19 -0
- package/dest/prover/proof_utils.d.ts.map +1 -0
- package/dest/prover/proof_utils.js +72 -0
- package/dest/prover/server/bb_prover.d.ts +100 -0
- package/dest/prover/server/bb_prover.d.ts.map +1 -0
- package/dest/prover/server/bb_prover.js +339 -0
- package/dest/test/delay_values.d.ts +1 -1
- package/dest/test/delay_values.d.ts.map +1 -1
- package/dest/test/delay_values.js +33 -21
- package/dest/test/index.d.ts +1 -1
- package/dest/test/test_circuit_prover.d.ts +25 -34
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +85 -59
- package/dest/test/test_verifier.d.ts +6 -3
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +23 -1
- package/dest/verification_key/verification_key_data.d.ts +7 -1
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +23 -29
- package/dest/verifier/bb_verifier.d.ts +6 -5
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +46 -25
- package/dest/verifier/index.d.ts +2 -1
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -0
- package/dest/verifier/queued_chonk_verifier.d.ts +15 -0
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/queued_chonk_verifier.js +132 -0
- package/package.json +35 -33
- package/src/avm_proving_tests/avm_proving_tester.ts +210 -104
- package/src/bb/execute.ts +103 -250
- package/src/config.ts +2 -0
- package/src/honk.ts +3 -2
- package/src/index.ts +1 -0
- package/src/instrumentation.ts +2 -4
- package/src/prover/{bb_private_kernel_prover.ts → client/bb_private_kernel_prover.ts} +78 -30
- package/src/prover/client/bundle.ts +11 -0
- package/src/prover/client/lazy.ts +11 -0
- package/src/prover/index.ts +2 -3
- package/src/prover/proof_utils.ts +115 -0
- package/src/prover/server/bb_prover.ts +733 -0
- package/src/test/delay_values.ts +33 -21
- package/src/test/test_circuit_prover.ts +260 -147
- package/src/test/test_verifier.ts +15 -3
- package/src/verification_key/verification_key_data.ts +29 -24
- package/src/verifier/bb_verifier.ts +63 -32
- package/src/verifier/index.ts +1 -0
- package/src/verifier/queued_chonk_verifier.ts +140 -0
- package/dest/prover/bb_native_private_kernel_prover.d.ts +0 -25
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_native_private_kernel_prover.js +0 -69
- package/dest/prover/bb_private_kernel_prover.d.ts +0 -32
- package/dest/prover/bb_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.d.ts +0 -120
- package/dest/prover/bb_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.js +0 -423
- package/dest/prover/client_ivc_proof_utils.d.ts +0 -25
- package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
- package/dest/prover/client_ivc_proof_utils.js +0 -43
- package/dest/stats.d.ts +0 -5
- package/dest/stats.d.ts.map +0 -1
- package/dest/stats.js +0 -62
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +0 -17
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.js +0 -46
- package/dest/wasm/bundle.d.ts +0 -6
- package/dest/wasm/bundle.d.ts.map +0 -1
- package/dest/wasm/bundle.js +0 -8
- package/dest/wasm/lazy.d.ts +0 -6
- package/dest/wasm/lazy.d.ts.map +0 -1
- package/dest/wasm/lazy.js +0 -8
- package/src/prover/bb_native_private_kernel_prover.ts +0 -119
- package/src/prover/bb_prover.ts +0 -781
- package/src/prover/client_ivc_proof_utils.ts +0 -42
- package/src/stats.ts +0 -64
- package/src/wasm/bb_wasm_private_kernel_prover.ts +0 -55
- package/src/wasm/bundle.ts +0 -11
- package/src/wasm/lazy.ts +0 -11
|
@@ -4,34 +4,35 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
4
4
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
}
|
|
7
|
-
import {
|
|
7
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH } from '@aztec/constants';
|
|
8
8
|
import { createLogger } from '@aztec/foundation/log';
|
|
9
9
|
import { sleep } from '@aztec/foundation/sleep';
|
|
10
10
|
import { Timer } from '@aztec/foundation/timer';
|
|
11
|
-
import {
|
|
11
|
+
import { convertBlockMergeRollupOutputsFromWitnessMap, convertBlockMergeRollupPrivateInputsToWitnessMap, convertBlockRootEmptyTxFirstRollupOutputsFromWitnessMap, convertBlockRootEmptyTxFirstRollupPrivateInputsToWitnessMap, convertBlockRootFirstRollupOutputsFromWitnessMap, convertBlockRootFirstRollupPrivateInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap, convertBlockRootRollupPrivateInputsToWitnessMap, convertBlockRootSingleTxFirstRollupOutputsFromWitnessMap, convertBlockRootSingleTxFirstRollupPrivateInputsToWitnessMap, convertBlockRootSingleTxRollupOutputsFromWitnessMap, convertBlockRootSingleTxRollupPrivateInputsToWitnessMap, convertCheckpointMergeRollupOutputsFromWitnessMap, convertCheckpointMergeRollupPrivateInputsToWitnessMap, convertCheckpointPaddingRollupOutputsFromWitnessMap, convertCheckpointPaddingRollupPrivateInputsToWitnessMap, convertCheckpointRootRollupOutputsFromWitnessMap, convertCheckpointRootRollupPrivateInputsToWitnessMap, convertCheckpointRootSingleBlockRollupOutputsFromWitnessMap, convertCheckpointRootSingleBlockRollupPrivateInputsToWitnessMap, convertParityBaseOutputsFromWitnessMap, convertParityBasePrivateInputsToWitnessMap, convertParityRootOutputsFromWitnessMap, convertParityRootPrivateInputsToWitnessMap, convertPrivateTxBaseRollupOutputsFromWitnessMap, convertPrivateTxBaseRollupPrivateInputsToWitnessMap, convertPublicTxBaseRollupOutputsFromWitnessMap, convertPublicTxBaseRollupPrivateInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertRootRollupPrivateInputsToWitnessMap, convertTxMergeRollupOutputsFromWitnessMap, convertTxMergeRollupPrivateInputsToWitnessMap, foreignCallHandler, getSimulatedServerCircuitArtifact } from '@aztec/noir-protocol-circuits-types/server';
|
|
12
12
|
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
13
|
+
import { mapProtocolArtifactNameToCircuitName } from '@aztec/noir-protocol-circuits-types/types';
|
|
13
14
|
import { WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator/server';
|
|
14
15
|
import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
15
16
|
import { ProvingRequestType, makeEmptyRecursiveProof, makeRecursiveProof } from '@aztec/stdlib/proofs';
|
|
17
|
+
import { PublicChonkVerifierPublicInputs } from '@aztec/stdlib/rollup';
|
|
16
18
|
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
17
19
|
import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
18
20
|
import { ProverInstrumentation } from '../instrumentation.js';
|
|
19
|
-
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
20
21
|
import { PROOF_DELAY_MS, WITGEN_DELAY_MS } from './delay_values.js';
|
|
21
22
|
/**
|
|
22
23
|
* A class for use in testing situations (e2e, unit test, etc) and temporarily for assembling a block in the sequencer.
|
|
23
24
|
* Simulates circuits using the most efficient method and performs no proving.
|
|
24
25
|
*/ export class TestCircuitProver {
|
|
25
|
-
|
|
26
|
+
simulator;
|
|
26
27
|
opts;
|
|
27
28
|
wasmSimulator;
|
|
28
29
|
instrumentation;
|
|
29
30
|
logger;
|
|
30
|
-
constructor(
|
|
31
|
+
constructor(simulator, opts = {
|
|
31
32
|
proverTestDelayType: 'fixed',
|
|
32
33
|
proverTestDelayMs: 0
|
|
33
34
|
}, telemetry = getTelemetryClient()){
|
|
34
|
-
this.
|
|
35
|
+
this.simulator = simulator;
|
|
35
36
|
this.opts = opts;
|
|
36
37
|
this.wasmSimulator = new WASMSimulatorWithBlobs();
|
|
37
38
|
this.logger = createLogger('bb-prover:test-prover');
|
|
@@ -45,67 +46,73 @@ import { PROOF_DELAY_MS, WITGEN_DELAY_MS } from './delay_values.js';
|
|
|
45
46
|
* @param inputs - Inputs to the circuit.
|
|
46
47
|
* @returns The public inputs of the parity circuit.
|
|
47
48
|
*/ getBaseParityProof(inputs) {
|
|
48
|
-
return this.applyDelay(ProvingRequestType.
|
|
49
|
+
return this.applyDelay(ProvingRequestType.PARITY_BASE, ()=>this.simulate(inputs, 'ParityBaseArtifact', RECURSIVE_PROOF_LENGTH, convertParityBasePrivateInputsToWitnessMap, convertParityBaseOutputsFromWitnessMap));
|
|
49
50
|
}
|
|
50
51
|
/**
|
|
51
52
|
* Simulates the root parity circuit from its inputs.
|
|
52
53
|
* @param inputs - Inputs to the circuit.
|
|
53
54
|
* @returns The public inputs of the parity circuit.
|
|
54
55
|
*/ getRootParityProof(inputs) {
|
|
55
|
-
return this.applyDelay(ProvingRequestType.
|
|
56
|
+
return this.applyDelay(ProvingRequestType.PARITY_ROOT, ()=>this.simulate(inputs, 'ParityRootArtifact', NESTED_RECURSIVE_PROOF_LENGTH, convertParityRootPrivateInputsToWitnessMap, convertParityRootOutputsFromWitnessMap));
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
return this.applyDelay(ProvingRequestType.
|
|
58
|
+
getPublicChonkVerifierProof(inputs) {
|
|
59
|
+
return this.applyDelay(ProvingRequestType.PUBLIC_CHONK_VERIFIER, ()=>makePublicInputsAndRecursiveProof(new PublicChonkVerifierPublicInputs(inputs.hidingKernelProofData.publicInputs, inputs.proverId), makeEmptyRecursiveProof(NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH), ProtocolCircuitVks.PublicChonkVerifier));
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
return this.applyDelay(ProvingRequestType.
|
|
61
|
+
getPrivateTxBaseRollupProof(inputs) {
|
|
62
|
+
return this.applyDelay(ProvingRequestType.PRIVATE_TX_BASE_ROLLUP, ()=>this.simulate(inputs, 'PrivateTxBaseRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertPrivateTxBaseRollupPrivateInputsToWitnessMap, convertPrivateTxBaseRollupOutputsFromWitnessMap));
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
return this.applyDelay(ProvingRequestType.
|
|
64
|
+
getPublicTxBaseRollupProof(inputs) {
|
|
65
|
+
return this.applyDelay(ProvingRequestType.PUBLIC_TX_BASE_ROLLUP, ()=>this.simulate(inputs, 'PublicTxBaseRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertPublicTxBaseRollupPrivateInputsToWitnessMap, convertPublicTxBaseRollupOutputsFromWitnessMap));
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Simulates the merge rollup circuit from its inputs.
|
|
68
69
|
* @param input - Inputs to the circuit.
|
|
69
70
|
* @returns The public inputs as outputs of the simulation.
|
|
70
|
-
*/
|
|
71
|
-
return this.applyDelay(ProvingRequestType.
|
|
71
|
+
*/ getTxMergeRollupProof(input) {
|
|
72
|
+
return this.applyDelay(ProvingRequestType.TX_MERGE_ROLLUP, ()=>this.simulate(input, 'TxMergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertTxMergeRollupPrivateInputsToWitnessMap, convertTxMergeRollupOutputsFromWitnessMap));
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* @param input - Inputs to the circuit.
|
|
76
|
-
* @returns The public inputs as outputs of the simulation.
|
|
77
|
-
*/ getBlockRootRollupProof(input) {
|
|
78
|
-
return this.applyDelay(ProvingRequestType.BLOCK_ROOT_ROLLUP, ()=>this.simulate(input, 'BlockRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertSimulatedBlockRootRollupInputsToWitnessMap, convertSimulatedBlockRootRollupOutputsFromWitnessMap));
|
|
74
|
+
getBlockRootFirstRollupProof(input) {
|
|
75
|
+
return this.applyDelay(ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP, ()=>this.simulate(input, 'BlockRootFirstRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootFirstRollupPrivateInputsToWitnessMap, convertBlockRootFirstRollupOutputsFromWitnessMap));
|
|
79
76
|
}
|
|
80
|
-
async
|
|
81
|
-
return await this.applyDelay(ProvingRequestType.
|
|
77
|
+
async getBlockRootSingleTxFirstRollupProof(input) {
|
|
78
|
+
return await this.applyDelay(ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP, ()=>this.simulate(input, 'BlockRootSingleTxFirstRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootSingleTxFirstRollupPrivateInputsToWitnessMap, convertBlockRootSingleTxFirstRollupOutputsFromWitnessMap));
|
|
82
79
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* @param input - Inputs to the circuit.
|
|
86
|
-
* @returns The public inputs as outputs of the simulation.
|
|
87
|
-
*/ getEmptyBlockRootRollupProof(input) {
|
|
88
|
-
return this.applyDelay(ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP, ()=>this.simulate(input, 'EmptyBlockRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertEmptyBlockRootRollupInputsToWitnessMap, convertEmptyBlockRootRollupOutputsFromWitnessMap));
|
|
80
|
+
getBlockRootEmptyTxFirstRollupProof(input) {
|
|
81
|
+
return this.applyDelay(ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP, ()=>this.simulate(input, 'BlockRootEmptyTxFirstRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootEmptyTxFirstRollupPrivateInputsToWitnessMap, convertBlockRootEmptyTxFirstRollupOutputsFromWitnessMap));
|
|
89
82
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
83
|
+
getBlockRootRollupProof(input) {
|
|
84
|
+
return this.applyDelay(ProvingRequestType.BLOCK_ROOT_ROLLUP, ()=>this.simulate(input, 'BlockRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootRollupPrivateInputsToWitnessMap, convertBlockRootRollupOutputsFromWitnessMap));
|
|
85
|
+
}
|
|
86
|
+
async getBlockRootSingleTxRollupProof(input) {
|
|
87
|
+
return await this.applyDelay(ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP, ()=>this.simulate(input, 'BlockRootSingleTxRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockRootSingleTxRollupPrivateInputsToWitnessMap, convertBlockRootSingleTxRollupOutputsFromWitnessMap));
|
|
88
|
+
}
|
|
89
|
+
getBlockMergeRollupProof(input) {
|
|
90
|
+
return this.applyDelay(ProvingRequestType.BLOCK_MERGE_ROLLUP, ()=>this.simulate(input, 'BlockMergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockMergeRollupPrivateInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap));
|
|
91
|
+
}
|
|
92
|
+
getCheckpointRootRollupProof(input) {
|
|
93
|
+
return this.applyDelay(ProvingRequestType.CHECKPOINT_ROOT_ROLLUP, ()=>this.simulate(input, 'CheckpointRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertCheckpointRootRollupPrivateInputsToWitnessMap, convertCheckpointRootRollupOutputsFromWitnessMap));
|
|
94
|
+
}
|
|
95
|
+
getCheckpointRootSingleBlockRollupProof(input) {
|
|
96
|
+
return this.applyDelay(ProvingRequestType.CHECKPOINT_ROOT_SINGLE_BLOCK_ROLLUP, ()=>this.simulate(input, 'CheckpointRootSingleBlockRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertCheckpointRootSingleBlockRollupPrivateInputsToWitnessMap, convertCheckpointRootSingleBlockRollupOutputsFromWitnessMap));
|
|
97
|
+
}
|
|
98
|
+
getCheckpointPaddingRollupProof(input) {
|
|
99
|
+
return this.applyDelay(ProvingRequestType.CHECKPOINT_PADDING_ROLLUP, ()=>this.simulate(input, 'CheckpointPaddingRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertCheckpointPaddingRollupPrivateInputsToWitnessMap, convertCheckpointPaddingRollupOutputsFromWitnessMap));
|
|
100
|
+
}
|
|
101
|
+
getCheckpointMergeRollupProof(input) {
|
|
102
|
+
return this.applyDelay(ProvingRequestType.CHECKPOINT_MERGE_ROLLUP, ()=>this.simulate(input, 'CheckpointMergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertCheckpointMergeRollupPrivateInputsToWitnessMap, convertCheckpointMergeRollupOutputsFromWitnessMap));
|
|
96
103
|
}
|
|
97
104
|
/**
|
|
98
105
|
* Simulates the root rollup circuit from its inputs.
|
|
99
106
|
* @param input - Inputs to the circuit.
|
|
100
107
|
* @returns The public inputs as outputs of the simulation.
|
|
101
108
|
*/ getRootRollupProof(input) {
|
|
102
|
-
return this.applyDelay(ProvingRequestType.ROOT_ROLLUP, ()=>this.simulate(input, 'RootRollupArtifact', NESTED_RECURSIVE_PROOF_LENGTH,
|
|
109
|
+
return this.applyDelay(ProvingRequestType.ROOT_ROLLUP, ()=>this.simulate(input, 'RootRollupArtifact', NESTED_RECURSIVE_PROOF_LENGTH, convertRootRollupPrivateInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap));
|
|
103
110
|
}
|
|
104
111
|
getAvmProof(_inputs) {
|
|
105
112
|
// We can't simulate the AVM because we don't have enough context to do so (e.g., DBs).
|
|
106
113
|
// We just return an empty proof and VK data.
|
|
107
114
|
this.logger.debug('Skipping AVM simulation in TestCircuitProver.');
|
|
108
|
-
return this.applyDelay(ProvingRequestType.PUBLIC_VM, ()=>makeProofAndVerificationKey(makeEmptyRecursiveProof(
|
|
115
|
+
return this.applyDelay(ProvingRequestType.PUBLIC_VM, ()=>makeProofAndVerificationKey(makeEmptyRecursiveProof(AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED), VerificationKeyData.makeFake(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED)));
|
|
109
116
|
}
|
|
110
117
|
async applyDelay(type, fn) {
|
|
111
118
|
const timer = new Timer();
|
|
@@ -125,19 +132,20 @@ import { PROOF_DELAY_MS, WITGEN_DELAY_MS } from './delay_values.js';
|
|
|
125
132
|
}
|
|
126
133
|
async simulate(input, artifactName, proofLength, convertInput, convertOutput) {
|
|
127
134
|
const timer = new Timer();
|
|
128
|
-
const witnessMap = convertInput(input);
|
|
135
|
+
const witnessMap = convertInput(input, true);
|
|
129
136
|
const circuitName = mapProtocolArtifactNameToCircuitName(artifactName);
|
|
130
|
-
let
|
|
137
|
+
let witness;
|
|
131
138
|
if ([
|
|
132
|
-
'
|
|
133
|
-
'
|
|
134
|
-
].includes(artifactName)) {
|
|
135
|
-
// TODO(#10323):
|
|
136
|
-
//
|
|
137
|
-
|
|
139
|
+
'CheckpointRootRollupArtifact',
|
|
140
|
+
'CheckpointRootSingleBlockRollupArtifact'
|
|
141
|
+
].includes(artifactName) || this.simulator == undefined) {
|
|
142
|
+
// TODO(#10323): Native ACVM simulator does not support foreign call handler so we use the wasm simulator
|
|
143
|
+
// when simulating checkpoint root rollup circuits or when the native ACVM simulator is not provided.
|
|
144
|
+
witness = (await this.wasmSimulator.executeProtocolCircuit(witnessMap, getSimulatedServerCircuitArtifact(artifactName), foreignCallHandler)).witness;
|
|
145
|
+
} else {
|
|
146
|
+
witness = (await this.simulator.executeProtocolCircuit(witnessMap, getSimulatedServerCircuitArtifact(artifactName), undefined)).witness;
|
|
138
147
|
}
|
|
139
|
-
const
|
|
140
|
-
const result = convertOutput(witness);
|
|
148
|
+
const result = convertOutput(witness, true);
|
|
141
149
|
this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
|
|
142
150
|
emitCircuitSimulationStats(circuitName, timer.ms(), input.toBuffer().length, result.toBuffer().length, this.logger);
|
|
143
151
|
return makePublicInputsAndRecursiveProof(result, makeRecursiveProof(proofLength), ProtocolCircuitVks[artifactName]);
|
|
@@ -150,26 +158,44 @@ _ts_decorate([
|
|
|
150
158
|
trackSpan('TestCircuitProver.getRootParityProof')
|
|
151
159
|
], TestCircuitProver.prototype, "getRootParityProof", null);
|
|
152
160
|
_ts_decorate([
|
|
153
|
-
trackSpan('TestCircuitProver.
|
|
154
|
-
], TestCircuitProver.prototype, "
|
|
161
|
+
trackSpan('TestCircuitProver.getPrivateTxBaseRollupProof')
|
|
162
|
+
], TestCircuitProver.prototype, "getPrivateTxBaseRollupProof", null);
|
|
163
|
+
_ts_decorate([
|
|
164
|
+
trackSpan('TestCircuitProver.getPublicTxBaseRollupProof')
|
|
165
|
+
], TestCircuitProver.prototype, "getPublicTxBaseRollupProof", null);
|
|
166
|
+
_ts_decorate([
|
|
167
|
+
trackSpan('TestCircuitProver.getTxMergeRollupProof')
|
|
168
|
+
], TestCircuitProver.prototype, "getTxMergeRollupProof", null);
|
|
169
|
+
_ts_decorate([
|
|
170
|
+
trackSpan('TestCircuitProver.getBlockRootFirstRollupProof')
|
|
171
|
+
], TestCircuitProver.prototype, "getBlockRootFirstRollupProof", null);
|
|
155
172
|
_ts_decorate([
|
|
156
|
-
trackSpan('TestCircuitProver.
|
|
157
|
-
], TestCircuitProver.prototype, "
|
|
173
|
+
trackSpan('TestCircuitProver.getBlockRootSingleTxFirstRollupProof')
|
|
174
|
+
], TestCircuitProver.prototype, "getBlockRootSingleTxFirstRollupProof", null);
|
|
158
175
|
_ts_decorate([
|
|
159
|
-
trackSpan('TestCircuitProver.
|
|
160
|
-
], TestCircuitProver.prototype, "
|
|
176
|
+
trackSpan('TestCircuitProver.getBlockRootEmptyTxFirstRollupProof')
|
|
177
|
+
], TestCircuitProver.prototype, "getBlockRootEmptyTxFirstRollupProof", null);
|
|
161
178
|
_ts_decorate([
|
|
162
179
|
trackSpan('TestCircuitProver.getBlockRootRollupProof')
|
|
163
180
|
], TestCircuitProver.prototype, "getBlockRootRollupProof", null);
|
|
164
181
|
_ts_decorate([
|
|
165
|
-
trackSpan('TestCircuitProver.
|
|
166
|
-
], TestCircuitProver.prototype, "
|
|
167
|
-
_ts_decorate([
|
|
168
|
-
trackSpan('TestCircuitProver.getEmptyBlockRootRollupProof')
|
|
169
|
-
], TestCircuitProver.prototype, "getEmptyBlockRootRollupProof", null);
|
|
182
|
+
trackSpan('TestCircuitProver.getBlockRootSingleTxRollupProof')
|
|
183
|
+
], TestCircuitProver.prototype, "getBlockRootSingleTxRollupProof", null);
|
|
170
184
|
_ts_decorate([
|
|
171
185
|
trackSpan('TestCircuitProver.getBlockMergeRollupProof')
|
|
172
186
|
], TestCircuitProver.prototype, "getBlockMergeRollupProof", null);
|
|
187
|
+
_ts_decorate([
|
|
188
|
+
trackSpan('TestCircuitProver.getCheckpointRootRollupProof')
|
|
189
|
+
], TestCircuitProver.prototype, "getCheckpointRootRollupProof", null);
|
|
190
|
+
_ts_decorate([
|
|
191
|
+
trackSpan('TestCircuitProver.getCheckpointRootSingleBlockRollupProof')
|
|
192
|
+
], TestCircuitProver.prototype, "getCheckpointRootSingleBlockRollupProof", null);
|
|
193
|
+
_ts_decorate([
|
|
194
|
+
trackSpan('TestCircuitProver.getCheckpointPaddingRollupProof')
|
|
195
|
+
], TestCircuitProver.prototype, "getCheckpointPaddingRollupProof", null);
|
|
196
|
+
_ts_decorate([
|
|
197
|
+
trackSpan('TestCircuitProver.getCheckpointMergeRollupProof')
|
|
198
|
+
], TestCircuitProver.prototype, "getCheckpointMergeRollupProof", null);
|
|
173
199
|
_ts_decorate([
|
|
174
200
|
trackSpan('TestCircuitProver.getRootRollupProof')
|
|
175
201
|
], TestCircuitProver.prototype, "getRootRollupProof", null);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
1
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
export declare class TestCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
4
|
-
|
|
4
|
+
private verificationDelayMs?;
|
|
5
|
+
constructor(verificationDelayMs?: number | undefined);
|
|
6
|
+
verifyProof(_tx: Tx): Promise<IVCProofVerificationResult>;
|
|
7
|
+
stop(): Promise<void>;
|
|
5
8
|
}
|
|
6
|
-
//# sourceMappingURL=
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdF92ZXJpZmllci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvdGVzdF92ZXJpZmllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSw2QkFBNkIsRUFBRSwwQkFBMEIsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2pILE9BQU8sS0FBSyxFQUFFLEVBQUUsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRTNDLHFCQUFhLG1CQUFvQixZQUFXLDZCQUE2QjtJQUMzRCxPQUFPLENBQUMsbUJBQW1CLENBQUM7SUFBeEMsWUFBb0IsbUJBQW1CLENBQUMsb0JBQVEsRUFBSTtJQUNwRCxXQUFXLENBQUMsR0FBRyxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsMEJBQTBCLENBQUMsQ0FTeEQ7SUFFTSxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUUzQjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_verifier.d.ts","sourceRoot":"","sources":["../../src/test/test_verifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"test_verifier.d.ts","sourceRoot":"","sources":["../../src/test/test_verifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,mBAAoB,YAAW,6BAA6B;IAC3D,OAAO,CAAC,mBAAmB,CAAC;IAAxC,YAAoB,mBAAmB,CAAC,oBAAQ,EAAI;IACpD,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CASxD;IAEM,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;CACF"}
|
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
export class TestCircuitVerifier {
|
|
2
|
+
verificationDelayMs;
|
|
3
|
+
constructor(verificationDelayMs){
|
|
4
|
+
this.verificationDelayMs = verificationDelayMs;
|
|
5
|
+
}
|
|
2
6
|
verifyProof(_tx) {
|
|
3
|
-
|
|
7
|
+
if (this.verificationDelayMs !== undefined && this.verificationDelayMs > 0) {
|
|
8
|
+
return new Promise((resolve)=>{
|
|
9
|
+
setTimeout(()=>{
|
|
10
|
+
resolve({
|
|
11
|
+
valid: true,
|
|
12
|
+
durationMs: this.verificationDelayMs,
|
|
13
|
+
totalDurationMs: this.verificationDelayMs
|
|
14
|
+
});
|
|
15
|
+
}, this.verificationDelayMs);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return Promise.resolve({
|
|
19
|
+
valid: true,
|
|
20
|
+
durationMs: 0,
|
|
21
|
+
totalDurationMs: 0
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
stop() {
|
|
25
|
+
return Promise.resolve();
|
|
4
26
|
}
|
|
5
27
|
}
|
|
@@ -5,5 +5,11 @@ import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
|
5
5
|
* @returns The verification key data
|
|
6
6
|
*/
|
|
7
7
|
export declare function extractVkData(vkDirectoryPath: string): Promise<VerificationKeyData>;
|
|
8
|
+
/**
|
|
9
|
+
* Reads the verification key data stored in a binary file at the specified directory location and parses into a VerificationKeyData.
|
|
10
|
+
* We do not assume any JSON file available but only the binary version, contrary to the above extractVkData() method.
|
|
11
|
+
* @param vkDirectoryPath - The directory containing the verification key binary data file.
|
|
12
|
+
* @returns The verification key data
|
|
13
|
+
*/
|
|
8
14
|
export declare function extractAvmVkData(vkDirectoryPath: string): Promise<VerificationKeyData>;
|
|
9
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmVyaWZpY2F0aW9uX2tleV9kYXRhLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpY2F0aW9uX2tleS92ZXJpZmljYXRpb25fa2V5X2RhdGEudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBR0EsT0FBTyxFQUEyQixtQkFBbUIsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBUWpGOzs7O0dBSUc7QUFDSCx3QkFBc0IsYUFBYSxDQUFDLGVBQWUsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBVXpGO0FBRUQ7Ozs7O0dBS0c7QUFDSCx3QkFBc0IsZ0JBQWdCLENBQUMsZUFBZSxFQUFFLE1BQU0sR0FBRyxPQUFPLENBQUMsbUJBQW1CLENBQUMsQ0FlNUYifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification_key_data.d.ts","sourceRoot":"","sources":["../../src/verification_key/verification_key_data.ts"],"names":[],"mappings":"AAGA,OAAO,EAA2B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQjF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"verification_key_data.d.ts","sourceRoot":"","sources":["../../src/verification_key/verification_key_data.ts"],"names":[],"mappings":"AAGA,OAAO,EAA2B,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAQjF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAUzF;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAe5F"}
|
|
@@ -1,44 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import {
|
|
3
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
4
4
|
import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
|
|
5
5
|
import { strict as assert } from 'assert';
|
|
6
6
|
import { promises as fs } from 'fs';
|
|
7
7
|
import * as path from 'path';
|
|
8
|
-
import {
|
|
8
|
+
import { VK_FILENAME } from '../bb/execute.js';
|
|
9
9
|
/**
|
|
10
10
|
* Reads the verification key data stored at the specified location and parses into a VerificationKeyData
|
|
11
11
|
* @param vkDirectoryPath - The directory containing the verification key data files
|
|
12
12
|
* @returns The verification key data
|
|
13
13
|
*/ export async function extractVkData(vkDirectoryPath) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const fieldsJson = JSON.parse(rawFields);
|
|
21
|
-
const fields = fieldsJson.map(Fr.fromHexString);
|
|
22
|
-
// The hash is not included in the BB response
|
|
23
|
-
const vkHash = await hashVK(fields);
|
|
24
|
-
const vkAsFields = new VerificationKeyAsFields(fields, vkHash);
|
|
14
|
+
const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
|
|
15
|
+
// Convert binary to field elements (32 bytes per field)
|
|
16
|
+
const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
|
|
17
|
+
const reader = BufferReader.asReader(rawBinary);
|
|
18
|
+
const fields = reader.readArray(numFields, Fr);
|
|
19
|
+
const vkAsFields = await VerificationKeyAsFields.fromKey(fields);
|
|
25
20
|
return new VerificationKeyData(vkAsFields, rawBinary);
|
|
26
21
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
const vkAsFields = new VerificationKeyAsFields(fields, vkHash);
|
|
22
|
+
/**
|
|
23
|
+
* Reads the verification key data stored in a binary file at the specified directory location and parses into a VerificationKeyData.
|
|
24
|
+
* We do not assume any JSON file available but only the binary version, contrary to the above extractVkData() method.
|
|
25
|
+
* @param vkDirectoryPath - The directory containing the verification key binary data file.
|
|
26
|
+
* @returns The verification key data
|
|
27
|
+
*/ export async function extractAvmVkData(vkDirectoryPath) {
|
|
28
|
+
const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
|
|
29
|
+
const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
|
|
30
|
+
assert(numFields <= AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED, 'Invalid AVM verification key length');
|
|
31
|
+
const reader = BufferReader.asReader(rawBinary);
|
|
32
|
+
const fieldsArray = reader.readArray(numFields, Fr);
|
|
33
|
+
const fieldsArrayPadded = fieldsArray.concat(Array(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED - fieldsArray.length).fill(new Fr(0)));
|
|
34
|
+
const vkAsFields = await VerificationKeyAsFields.fromKey(fieldsArrayPadded);
|
|
35
|
+
// 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.
|
|
42
36
|
const vk = new VerificationKeyData(vkAsFields, rawBinary);
|
|
43
37
|
return vk;
|
|
44
38
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import type
|
|
3
|
-
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import { type ProtocolArtifact, type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
3
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
4
4
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
5
5
|
import { Tx } from '@aztec/stdlib/tx';
|
|
6
6
|
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
@@ -9,9 +9,10 @@ export declare class BBCircuitVerifier implements ClientProtocolCircuitVerifier
|
|
|
9
9
|
private config;
|
|
10
10
|
private logger;
|
|
11
11
|
private constructor();
|
|
12
|
+
stop(): Promise<void>;
|
|
12
13
|
static new(config: BBConfig, logger?: Logger): Promise<BBCircuitVerifier>;
|
|
13
|
-
getVerificationKeyData(
|
|
14
|
+
getVerificationKeyData(circuit: ProtocolArtifact): VerificationKeyData;
|
|
14
15
|
verifyProofForCircuit(circuit: ServerProtocolArtifact, proof: Proof): Promise<void>;
|
|
15
|
-
verifyProof(tx: Tx): Promise<
|
|
16
|
+
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
16
17
|
}
|
|
17
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmJfdmVyaWZpZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9iYl92ZXJpZmllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFHbEUsT0FBTyxFQUVMLEtBQUssZ0JBQWdCLEVBQ3JCLEtBQUssc0JBQXNCLEVBRTVCLE1BQU0sMkNBQTJDLENBQUM7QUFDbkQsT0FBTyxLQUFLLEVBQUUsNkJBQTZCLEVBQUUsMEJBQTBCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqSCxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUVsRCxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDdEMsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQWE3RCxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFJN0MscUJBQWEsaUJBQWtCLFlBQVcsNkJBQTZCO0lBRW5FLE9BQU8sQ0FBQyxNQUFNO0lBQ2QsT0FBTyxDQUFDLE1BQU07SUFGaEIsT0FBTyxlQUdIO0lBRUcsSUFBSSxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFM0I7SUFFRCxPQUFvQixHQUFHLENBQUMsTUFBTSxFQUFFLFFBQVEsRUFBRSxNQUFNLFNBQXFDLDhCQU1wRjtJQUVNLHNCQUFzQixDQUFDLE9BQU8sRUFBRSxnQkFBZ0IsR0FBRyxtQkFBbUIsQ0FNNUU7SUFFWSxxQkFBcUIsQ0FBQyxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsS0FBSyxFQUFFLEtBQUssaUJBbUMvRTtJQUVZLFdBQVcsQ0FBQyxFQUFFLEVBQUUsRUFBRSxHQUFHLE9BQU8sQ0FBQywwQkFBMEIsQ0FBQyxDQWlEcEU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/bb_verifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"bb_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/bb_verifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAa7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAI7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAEnE,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IAFhB,OAAO,eAGH;IAEG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED,OAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAqC,8BAMpF;IAEM,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,CAM5E;IAEY,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK,iBAmC/E;IAEY,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAiDpE;CACF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
4
|
+
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
5
|
+
import { mapProtocolArtifactNameToCircuitName } from '@aztec/noir-protocol-circuits-types/types';
|
|
5
6
|
import { promises as fs } from 'fs';
|
|
6
7
|
import * as path from 'path';
|
|
7
|
-
import { BB_RESULT, PROOF_FILENAME, VK_FILENAME,
|
|
8
|
+
import { BB_RESULT, PROOF_FILENAME, PUBLIC_INPUTS_FILENAME, VK_FILENAME, verifyChonkProof, verifyProof } from '../bb/execute.js';
|
|
8
9
|
import { getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
9
|
-
import {
|
|
10
|
-
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
10
|
+
import { writeChonkProofToPath } from '../prover/proof_utils.js';
|
|
11
11
|
export class BBCircuitVerifier {
|
|
12
12
|
config;
|
|
13
13
|
logger;
|
|
@@ -15,26 +15,35 @@ export class BBCircuitVerifier {
|
|
|
15
15
|
this.config = config;
|
|
16
16
|
this.logger = logger;
|
|
17
17
|
}
|
|
18
|
+
stop() {
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
18
21
|
static async new(config, logger = createLogger('bb-prover:verifier')) {
|
|
22
|
+
if (!config.bbWorkingDirectory) {
|
|
23
|
+
throw new Error(`Barretenberg working directory (BB_WORKING_DIRECTORY) is not set`);
|
|
24
|
+
}
|
|
19
25
|
await fs.mkdir(config.bbWorkingDirectory, {
|
|
20
26
|
recursive: true
|
|
21
27
|
});
|
|
22
28
|
return new BBCircuitVerifier(config, logger);
|
|
23
29
|
}
|
|
24
|
-
getVerificationKeyData(
|
|
25
|
-
const vk =
|
|
30
|
+
getVerificationKeyData(circuit) {
|
|
31
|
+
const vk = ProtocolCircuitVks[circuit];
|
|
26
32
|
if (vk === undefined) {
|
|
27
|
-
throw new Error(
|
|
33
|
+
throw new Error(`Could not find VK for artifact ${circuit}`);
|
|
28
34
|
}
|
|
29
35
|
return vk;
|
|
30
36
|
}
|
|
31
37
|
async verifyProofForCircuit(circuit, proof) {
|
|
32
38
|
const operation = async (bbWorkingDirectory)=>{
|
|
39
|
+
const publicInputsFileName = path.join(bbWorkingDirectory, PUBLIC_INPUTS_FILENAME);
|
|
33
40
|
const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
34
41
|
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
35
42
|
const verificationKey = this.getVerificationKeyData(circuit);
|
|
36
43
|
this.logger.debug(`${circuit} Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
|
|
37
|
-
|
|
44
|
+
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/13189): Put this proof parsing logic in the proof class.
|
|
45
|
+
await fs.writeFile(publicInputsFileName, proof.buffer.slice(0, proof.numPublicInputs * 32));
|
|
46
|
+
await fs.writeFile(proofFileName, proof.buffer.slice(proof.numPublicInputs * 32));
|
|
38
47
|
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
39
48
|
const result = await verifyProof(this.config.bbBinaryPath, proofFileName, verificationKeyPath, getUltraHonkFlavorForCircuit(circuit), this.logger);
|
|
40
49
|
if (result.status === BB_RESULT.FAILURE) {
|
|
@@ -51,36 +60,48 @@ export class BBCircuitVerifier {
|
|
|
51
60
|
await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
|
|
52
61
|
}
|
|
53
62
|
async verifyProof(tx) {
|
|
63
|
+
const proofType = 'Chonk';
|
|
54
64
|
try {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// we have all the verification keys available.
|
|
59
|
-
const expectedCircuit = tx.data.forPublic ? 'PrivateKernelTailToPublicArtifact' : 'PrivateKernelTailArtifact';
|
|
60
|
-
const circuit = 'ClientIVC';
|
|
65
|
+
const totalTimer = new Timer();
|
|
66
|
+
let verificationDuration = 0;
|
|
67
|
+
const circuit = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
|
|
61
68
|
// Block below is almost copy-pasted from verifyProofForCircuit
|
|
62
69
|
const operation = async (bbWorkingDirectory)=>{
|
|
63
70
|
const logFunction = (message)=>{
|
|
64
|
-
this.logger.debug(`${
|
|
71
|
+
this.logger.debug(`${proofType} BB out - ${message}`);
|
|
65
72
|
};
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
74
|
+
await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
|
|
75
|
+
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
76
|
+
const verificationKey = this.getVerificationKeyData(circuit);
|
|
77
|
+
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
78
|
+
const timer = new Timer();
|
|
79
|
+
const result = await verifyChonkProof(this.config.bbBinaryPath, proofPath, verificationKeyPath, logFunction, this.config.bbIVCConcurrency);
|
|
80
|
+
verificationDuration = timer.ms();
|
|
68
81
|
if (result.status === BB_RESULT.FAILURE) {
|
|
69
|
-
const errorMessage = `Failed to verify ${
|
|
82
|
+
const errorMessage = `Failed to verify ${proofType} proof for ${circuit}!`;
|
|
70
83
|
throw new Error(errorMessage);
|
|
71
84
|
}
|
|
72
|
-
this.logger.debug(`${
|
|
73
|
-
circuitName: mapProtocolArtifactNameToCircuitName(
|
|
85
|
+
this.logger.debug(`${proofType} verification successful`, {
|
|
86
|
+
circuitName: mapProtocolArtifactNameToCircuitName(circuit),
|
|
74
87
|
duration: result.durationMs,
|
|
75
88
|
eventName: 'circuit-verification',
|
|
76
|
-
proofType: '
|
|
89
|
+
proofType: 'chonk'
|
|
77
90
|
});
|
|
78
91
|
};
|
|
79
92
|
await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
|
|
80
|
-
return
|
|
93
|
+
return {
|
|
94
|
+
valid: true,
|
|
95
|
+
durationMs: verificationDuration,
|
|
96
|
+
totalDurationMs: totalTimer.ms()
|
|
97
|
+
};
|
|
81
98
|
} catch (err) {
|
|
82
|
-
this.logger.warn(`Failed to verify
|
|
83
|
-
return
|
|
99
|
+
this.logger.warn(`Failed to verify ${proofType} proof for tx ${tx.getTxHash().toString()}: ${String(err)}`);
|
|
100
|
+
return {
|
|
101
|
+
valid: false,
|
|
102
|
+
durationMs: 0,
|
|
103
|
+
totalDurationMs: 0
|
|
104
|
+
};
|
|
84
105
|
}
|
|
85
106
|
}
|
|
86
107
|
}
|
package/dest/verifier/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export * from './bb_verifier.js';
|
|
2
|
-
|
|
2
|
+
export * from './queued_chonk_verifier.js';
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLGNBQWMsNEJBQTRCLENBQUMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
|
package/dest/verifier/index.js
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
+
import type { BBConfig } from '../config.js';
|
|
5
|
+
export declare class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
6
|
+
private verifier;
|
|
7
|
+
private telemetry;
|
|
8
|
+
private logger;
|
|
9
|
+
private queue;
|
|
10
|
+
private metrics;
|
|
11
|
+
constructor(config: BBConfig, verifier: ClientProtocolCircuitVerifier, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
|
|
12
|
+
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
13
|
+
stop(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVldWVkX2Nob25rX3ZlcmlmaWVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpZXIvcXVldWVkX2Nob25rX3ZlcmlmaWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLDZCQUE2QixFQUFFLDBCQUEwQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakgsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDM0MsT0FBTyxFQU1MLEtBQUssZUFBZSxFQUlyQixNQUFNLHlCQUF5QixDQUFDO0FBSWpDLE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLGNBQWMsQ0FBQztBQWdHN0MscUJBQWEsaUJBQWtCLFlBQVcsNkJBQTZCO0lBTW5FLE9BQU8sQ0FBQyxRQUFRO0lBQ2hCLE9BQU8sQ0FBQyxTQUFTO0lBQ2pCLE9BQU8sQ0FBQyxNQUFNO0lBUGhCLE9BQU8sQ0FBQyxLQUFLLENBQWM7SUFDM0IsT0FBTyxDQUFDLE9BQU8sQ0FBcUI7SUFFcEMsWUFDRSxNQUFNLEVBQUUsUUFBUSxFQUNSLFFBQVEsRUFBRSw2QkFBNkIsRUFDdkMsU0FBUyxHQUFFLGVBQXNDLEVBQ2pELE1BQU0seUNBQWtELEVBTWpFO0lBRVksV0FBVyxDQUFDLEVBQUUsRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLDBCQUEwQixDQUFDLENBSXBFO0lBRUQsSUFBSSxJQUFJLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFcEI7Q0FDRiJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queued_chonk_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_chonk_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAIjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAgG7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAMnE,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IAPhB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAqB;IAEpC,YACE,MAAM,EAAE,QAAQ,EACR,QAAQ,EAAE,6BAA6B,EACvC,SAAS,GAAE,eAAsC,EACjD,MAAM,yCAAkD,EAMjE;IAEY,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAIpE;IAED,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAEpB;CACF"}
|