@aztec/bb-prover 0.0.0-test.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dest/avm_proving_tests/avm_proving_tester.d.ts +25 -0
  2. package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -0
  3. package/dest/avm_proving_tests/avm_proving_tester.js +105 -0
  4. package/dest/bb/cli.d.ts +12 -0
  5. package/dest/bb/cli.d.ts.map +1 -0
  6. package/dest/bb/cli.js +19 -0
  7. package/dest/bb/execute.d.ts +140 -0
  8. package/dest/bb/execute.d.ts.map +1 -0
  9. package/dest/bb/execute.js +780 -0
  10. package/dest/bb/index.d.ts +3 -0
  11. package/dest/bb/index.d.ts.map +1 -0
  12. package/dest/bb/index.js +16 -0
  13. package/dest/config.d.ts +13 -0
  14. package/dest/config.d.ts.map +1 -0
  15. package/dest/config.js +1 -0
  16. package/dest/honk.d.ts +13 -0
  17. package/dest/honk.d.ts.map +1 -0
  18. package/dest/honk.js +18 -0
  19. package/dest/index.d.ts +8 -0
  20. package/dest/index.d.ts.map +1 -0
  21. package/dest/index.js +6 -0
  22. package/dest/instrumentation.d.ts +47 -0
  23. package/dest/instrumentation.d.ts.map +1 -0
  24. package/dest/instrumentation.js +100 -0
  25. package/dest/prover/bb_native_private_kernel_prover.d.ts +25 -0
  26. package/dest/prover/bb_native_private_kernel_prover.d.ts.map +1 -0
  27. package/dest/prover/bb_native_private_kernel_prover.js +69 -0
  28. package/dest/prover/bb_private_kernel_prover.d.ts +32 -0
  29. package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -0
  30. package/dest/prover/bb_private_kernel_prover.js +109 -0
  31. package/dest/prover/bb_prover.d.ts +120 -0
  32. package/dest/prover/bb_prover.d.ts.map +1 -0
  33. package/dest/prover/bb_prover.js +423 -0
  34. package/dest/prover/client_ivc_proof_utils.d.ts +25 -0
  35. package/dest/prover/client_ivc_proof_utils.d.ts.map +1 -0
  36. package/dest/prover/client_ivc_proof_utils.js +43 -0
  37. package/dest/prover/index.d.ts +4 -0
  38. package/dest/prover/index.d.ts.map +1 -0
  39. package/dest/prover/index.js +3 -0
  40. package/dest/stats.d.ts +5 -0
  41. package/dest/stats.d.ts.map +1 -0
  42. package/dest/stats.js +62 -0
  43. package/dest/test/delay_values.d.ts +4 -0
  44. package/dest/test/delay_values.d.ts.map +1 -0
  45. package/dest/test/delay_values.js +29 -0
  46. package/dest/test/index.d.ts +3 -0
  47. package/dest/test/index.d.ts.map +1 -0
  48. package/dest/test/index.js +2 -0
  49. package/dest/test/test_circuit_prover.d.ts +81 -0
  50. package/dest/test/test_circuit_prover.d.ts.map +1 -0
  51. package/dest/test/test_circuit_prover.js +175 -0
  52. package/dest/test/test_verifier.d.ts +6 -0
  53. package/dest/test/test_verifier.d.ts.map +1 -0
  54. package/dest/test/test_verifier.js +5 -0
  55. package/dest/verification_key/verification_key_data.d.ts +9 -0
  56. package/dest/verification_key/verification_key_data.d.ts.map +1 -0
  57. package/dest/verification_key/verification_key_data.js +44 -0
  58. package/dest/verifier/bb_verifier.d.ts +17 -0
  59. package/dest/verifier/bb_verifier.d.ts.map +1 -0
  60. package/dest/verifier/bb_verifier.js +86 -0
  61. package/dest/verifier/index.d.ts +2 -0
  62. package/dest/verifier/index.d.ts.map +1 -0
  63. package/dest/verifier/index.js +1 -0
  64. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +17 -0
  65. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -0
  66. package/dest/wasm/bb_wasm_private_kernel_prover.js +46 -0
  67. package/dest/wasm/bundle.d.ts +6 -0
  68. package/dest/wasm/bundle.d.ts.map +1 -0
  69. package/dest/wasm/bundle.js +8 -0
  70. package/dest/wasm/lazy.d.ts +6 -0
  71. package/dest/wasm/lazy.d.ts.map +1 -0
  72. package/dest/wasm/lazy.js +8 -0
  73. package/package.json +111 -0
  74. package/src/avm_proving_tests/avm_proving_tester.ts +170 -0
  75. package/src/bb/cli.ts +32 -0
  76. package/src/bb/execute.ts +853 -0
  77. package/src/bb/index.ts +23 -0
  78. package/src/config.ts +13 -0
  79. package/src/honk.ts +30 -0
  80. package/src/index.ts +8 -0
  81. package/src/instrumentation.ts +144 -0
  82. package/src/prover/bb_native_private_kernel_prover.ts +119 -0
  83. package/src/prover/bb_private_kernel_prover.ts +249 -0
  84. package/src/prover/bb_prover.ts +781 -0
  85. package/src/prover/client_ivc_proof_utils.ts +42 -0
  86. package/src/prover/index.ts +3 -0
  87. package/src/stats.ts +64 -0
  88. package/src/test/delay_values.ts +31 -0
  89. package/src/test/index.ts +2 -0
  90. package/src/test/test_circuit_prover.ts +368 -0
  91. package/src/test/test_verifier.ts +8 -0
  92. package/src/verification_key/verification_key_data.ts +45 -0
  93. package/src/verifier/bb_verifier.ts +114 -0
  94. package/src/verifier/index.ts +1 -0
  95. package/src/wasm/bb_wasm_private_kernel_prover.ts +55 -0
  96. package/src/wasm/bundle.ts +11 -0
  97. package/src/wasm/lazy.ts +11 -0
@@ -0,0 +1,81 @@
1
+ import { AVM_PROOF_LENGTH_IN_FIELDS, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
2
+ import { type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/server';
3
+ import { type SimulationProvider } from '@aztec/simulator/server';
4
+ import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
5
+ import { type ProofAndVerificationKey, type PublicInputsAndRecursiveProof, type ServerCircuitProver } from '@aztec/stdlib/interfaces/server';
6
+ import type { BaseParityInputs, ParityPublicInputs, RootParityInputs } from '@aztec/stdlib/parity';
7
+ import { type Proof } from '@aztec/stdlib/proofs';
8
+ import type { BaseOrMergeRollupPublicInputs, BlockMergeRollupInputs, BlockRootOrBlockMergePublicInputs, BlockRootRollupInputs, EmptyBlockRootRollupInputs, MergeRollupInputs, PrivateBaseRollupInputs, PublicBaseRollupInputs, RootRollupInputs, RootRollupPublicInputs, SingleTxBlockRootRollupInputs, TubeInputs } from '@aztec/stdlib/rollup';
9
+ import { type TelemetryClient } from '@aztec/telemetry-client';
10
+ type TestDelay = {
11
+ proverTestDelayType: 'fixed';
12
+ proverTestDelayMs?: number;
13
+ } | {
14
+ proverTestDelayType: 'realistic';
15
+ proverTestDelayFactor?: number;
16
+ };
17
+ /**
18
+ * A class for use in testing situations (e2e, unit test, etc) and temporarily for assembling a block in the sequencer.
19
+ * Simulates circuits using the most efficient method and performs no proving.
20
+ */
21
+ export declare class TestCircuitProver implements ServerCircuitProver {
22
+ private simulationProvider?;
23
+ private opts;
24
+ private wasmSimulator;
25
+ private instrumentation;
26
+ private logger;
27
+ constructor(simulationProvider?: SimulationProvider | undefined, opts?: TestDelay, telemetry?: TelemetryClient);
28
+ get tracer(): import("@aztec/telemetry-client").Tracer;
29
+ /**
30
+ * Simulates the base parity circuit from its inputs.
31
+ * @param inputs - Inputs to the circuit.
32
+ * @returns The public inputs of the parity circuit.
33
+ */
34
+ getBaseParityProof(inputs: BaseParityInputs): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>>;
35
+ /**
36
+ * Simulates the root parity circuit from its inputs.
37
+ * @param inputs - Inputs to the circuit.
38
+ * @returns The public inputs of the parity circuit.
39
+ */
40
+ getRootParityProof(inputs: RootParityInputs): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>>;
41
+ getTubeProof(_tubeInput: TubeInputs): Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>>;
42
+ getPrivateBaseRollupProof(inputs: PrivateBaseRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
43
+ getPublicBaseRollupProof(inputs: PublicBaseRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
44
+ /**
45
+ * Simulates the merge rollup circuit from its inputs.
46
+ * @param input - Inputs to the circuit.
47
+ * @returns The public inputs as outputs of the simulation.
48
+ */
49
+ getMergeRollupProof(input: MergeRollupInputs): Promise<PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
50
+ /**
51
+ * Simulates the block root rollup circuit from its inputs.
52
+ * @param input - Inputs to the circuit.
53
+ * @returns The public inputs as outputs of the simulation.
54
+ */
55
+ getBlockRootRollupProof(input: BlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
56
+ getSingleTxBlockRootRollupProof(input: SingleTxBlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
57
+ /**
58
+ * Simulates the empty block root rollup circuit from its inputs.
59
+ * @param input - Inputs to the circuit.
60
+ * @returns The public inputs as outputs of the simulation.
61
+ */
62
+ getEmptyBlockRootRollupProof(input: EmptyBlockRootRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
63
+ /**
64
+ * Simulates the block merge rollup circuit from its inputs.
65
+ * @param input - Inputs to the circuit.
66
+ * @returns The public inputs as outputs of the simulation.
67
+ */
68
+ getBlockMergeRollupProof(input: BlockMergeRollupInputs): Promise<PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>>;
69
+ /**
70
+ * Simulates the root rollup circuit from its inputs.
71
+ * @param input - Inputs to the circuit.
72
+ * @returns The public inputs as outputs of the simulation.
73
+ */
74
+ getRootRollupProof(input: RootRollupInputs): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs>>;
75
+ getAvmProof(_inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>>;
76
+ private applyDelay;
77
+ verifyProof(_1: ServerProtocolArtifact, _2: Proof): Promise<void>;
78
+ private simulate;
79
+ }
80
+ export {};
81
+ //# sourceMappingURL=test_circuit_prover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_circuit_prover.d.ts","sourceRoot":"","sources":["../../src/test/test_circuit_prover.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,175 @@
1
+ function _ts_decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ import { AVM_PROOF_LENGTH_IN_FIELDS, AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, RECURSIVE_PROOF_LENGTH, TUBE_PROOF_LENGTH } from '@aztec/constants';
8
+ import { createLogger } from '@aztec/foundation/log';
9
+ import { sleep } from '@aztec/foundation/sleep';
10
+ import { Timer } from '@aztec/foundation/timer';
11
+ import { SimulatedServerCircuitArtifacts, convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap, convertBlockMergeRollupInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap, convertEmptyBlockRootRollupInputsToWitnessMap, convertEmptyBlockRootRollupOutputsFromWitnessMap, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap, convertSimulatedBlockRootRollupInputsToWitnessMap, convertSimulatedBlockRootRollupOutputsFromWitnessMap, convertSimulatedPrivateBaseRollupInputsToWitnessMap, convertSimulatedPrivateBaseRollupOutputsFromWitnessMap, convertSimulatedPublicBaseRollupInputsToWitnessMap, convertSimulatedPublicBaseRollupOutputsFromWitnessMap, convertSimulatedSingleTxBlockRootRollupInputsToWitnessMap, convertSimulatedSingleTxBlockRootRollupOutputsFromWitnessMap } from '@aztec/noir-protocol-circuits-types/server';
12
+ import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
13
+ import { WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator/server';
14
+ import { makeProofAndVerificationKey, makePublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
15
+ import { ProvingRequestType, makeEmptyRecursiveProof, makeRecursiveProof } from '@aztec/stdlib/proofs';
16
+ import { VerificationKeyData } from '@aztec/stdlib/vks';
17
+ import { getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
18
+ import { ProverInstrumentation } from '../instrumentation.js';
19
+ import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
20
+ import { PROOF_DELAY_MS, WITGEN_DELAY_MS } from './delay_values.js';
21
+ /**
22
+ * A class for use in testing situations (e2e, unit test, etc) and temporarily for assembling a block in the sequencer.
23
+ * Simulates circuits using the most efficient method and performs no proving.
24
+ */ export class TestCircuitProver {
25
+ simulationProvider;
26
+ opts;
27
+ wasmSimulator;
28
+ instrumentation;
29
+ logger;
30
+ constructor(simulationProvider, opts = {
31
+ proverTestDelayType: 'fixed',
32
+ proverTestDelayMs: 0
33
+ }, telemetry = getTelemetryClient()){
34
+ this.simulationProvider = simulationProvider;
35
+ this.opts = opts;
36
+ this.wasmSimulator = new WASMSimulatorWithBlobs();
37
+ this.logger = createLogger('bb-prover:test-prover');
38
+ this.instrumentation = new ProverInstrumentation(telemetry, 'TestCircuitProver');
39
+ }
40
+ get tracer() {
41
+ return this.instrumentation.tracer;
42
+ }
43
+ /**
44
+ * Simulates the base parity circuit from its inputs.
45
+ * @param inputs - Inputs to the circuit.
46
+ * @returns The public inputs of the parity circuit.
47
+ */ getBaseParityProof(inputs) {
48
+ return this.applyDelay(ProvingRequestType.BASE_PARITY, ()=>this.simulate(inputs, 'BaseParityArtifact', RECURSIVE_PROOF_LENGTH, convertBaseParityInputsToWitnessMap, convertBaseParityOutputsFromWitnessMap));
49
+ }
50
+ /**
51
+ * Simulates the root parity circuit from its inputs.
52
+ * @param inputs - Inputs to the circuit.
53
+ * @returns The public inputs of the parity circuit.
54
+ */ getRootParityProof(inputs) {
55
+ return this.applyDelay(ProvingRequestType.ROOT_PARITY, ()=>this.simulate(inputs, 'RootParityArtifact', NESTED_RECURSIVE_PROOF_LENGTH, convertRootParityInputsToWitnessMap, convertRootParityOutputsFromWitnessMap));
56
+ }
57
+ getTubeProof(_tubeInput) {
58
+ return this.applyDelay(ProvingRequestType.TUBE_PROOF, ()=>makeProofAndVerificationKey(makeEmptyRecursiveProof(TUBE_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()));
59
+ }
60
+ getPrivateBaseRollupProof(inputs) {
61
+ return this.applyDelay(ProvingRequestType.PRIVATE_BASE_ROLLUP, ()=>this.simulate(inputs, 'PrivateBaseRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertSimulatedPrivateBaseRollupInputsToWitnessMap, convertSimulatedPrivateBaseRollupOutputsFromWitnessMap));
62
+ }
63
+ getPublicBaseRollupProof(inputs) {
64
+ return this.applyDelay(ProvingRequestType.PUBLIC_BASE_ROLLUP, ()=>this.simulate(inputs, 'PublicBaseRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertSimulatedPublicBaseRollupInputsToWitnessMap, convertSimulatedPublicBaseRollupOutputsFromWitnessMap));
65
+ }
66
+ /**
67
+ * Simulates the merge rollup circuit from its inputs.
68
+ * @param input - Inputs to the circuit.
69
+ * @returns The public inputs as outputs of the simulation.
70
+ */ getMergeRollupProof(input) {
71
+ return this.applyDelay(ProvingRequestType.MERGE_ROLLUP, ()=>this.simulate(input, 'MergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertMergeRollupInputsToWitnessMap, convertMergeRollupOutputsFromWitnessMap));
72
+ }
73
+ /**
74
+ * Simulates the block root rollup circuit from its inputs.
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));
79
+ }
80
+ async getSingleTxBlockRootRollupProof(input) {
81
+ return await this.applyDelay(ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP, ()=>this.simulate(input, 'SingleTxBlockRootRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertSimulatedSingleTxBlockRootRollupInputsToWitnessMap, convertSimulatedSingleTxBlockRootRollupOutputsFromWitnessMap));
82
+ }
83
+ /**
84
+ * Simulates the empty block root rollup circuit from its inputs.
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));
89
+ }
90
+ /**
91
+ * Simulates the block merge rollup circuit from its inputs.
92
+ * @param input - Inputs to the circuit.
93
+ * @returns The public inputs as outputs of the simulation.
94
+ */ getBlockMergeRollupProof(input) {
95
+ return this.applyDelay(ProvingRequestType.BLOCK_MERGE_ROLLUP, ()=>this.simulate(input, 'BlockMergeRollupArtifact', NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, convertBlockMergeRollupInputsToWitnessMap, convertBlockMergeRollupOutputsFromWitnessMap));
96
+ }
97
+ /**
98
+ * Simulates the root rollup circuit from its inputs.
99
+ * @param input - Inputs to the circuit.
100
+ * @returns The public inputs as outputs of the simulation.
101
+ */ getRootRollupProof(input) {
102
+ return this.applyDelay(ProvingRequestType.ROOT_ROLLUP, ()=>this.simulate(input, 'RootRollupArtifact', NESTED_RECURSIVE_PROOF_LENGTH, convertRootRollupInputsToWitnessMap, convertRootRollupOutputsFromWitnessMap));
103
+ }
104
+ getAvmProof(_inputs) {
105
+ // We can't simulate the AVM because we don't have enough context to do so (e.g., DBs).
106
+ // We just return an empty proof and VK data.
107
+ this.logger.debug('Skipping AVM simulation in TestCircuitProver.');
108
+ return this.applyDelay(ProvingRequestType.PUBLIC_VM, ()=>makeProofAndVerificationKey(makeEmptyRecursiveProof(AVM_PROOF_LENGTH_IN_FIELDS), VerificationKeyData.makeFake(AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS)));
109
+ }
110
+ async applyDelay(type, fn) {
111
+ const timer = new Timer();
112
+ const res = await fn();
113
+ const duration = timer.ms();
114
+ if (this.opts.proverTestDelayType === 'fixed') {
115
+ await sleep(Math.max(0, (this.opts.proverTestDelayMs ?? 0) - duration));
116
+ } else if (this.opts.proverTestDelayType === 'realistic') {
117
+ const delay = WITGEN_DELAY_MS[type] + PROOF_DELAY_MS[type];
118
+ await sleep(Math.max(0, delay * (this.opts.proverTestDelayFactor ?? 1) - duration));
119
+ }
120
+ return res;
121
+ }
122
+ // Not implemented for test circuits
123
+ verifyProof(_1, _2) {
124
+ return Promise.reject(new Error('Method not implemented.'));
125
+ }
126
+ async simulate(input, artifactName, proofLength, convertInput, convertOutput) {
127
+ const timer = new Timer();
128
+ const witnessMap = convertInput(input);
129
+ const circuitName = mapProtocolArtifactNameToCircuitName(artifactName);
130
+ let simulationProvider = this.simulationProvider ?? this.wasmSimulator;
131
+ if ([
132
+ 'BlockRootRollupArtifact',
133
+ 'SingleTxBlockRootRollupArtifact'
134
+ ].includes(artifactName)) {
135
+ // TODO(#10323): temporarily force block root to use wasm while we simulate
136
+ // the blob operations with an oracle. Appears to be no way to provide nativeACVM with a foreign call hander.
137
+ simulationProvider = this.wasmSimulator;
138
+ }
139
+ const witness = await simulationProvider.executeProtocolCircuit(witnessMap, SimulatedServerCircuitArtifacts[artifactName]);
140
+ const result = convertOutput(witness);
141
+ this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
142
+ emitCircuitSimulationStats(circuitName, timer.ms(), input.toBuffer().length, result.toBuffer().length, this.logger);
143
+ return makePublicInputsAndRecursiveProof(result, makeRecursiveProof(proofLength), ProtocolCircuitVks[artifactName]);
144
+ }
145
+ }
146
+ _ts_decorate([
147
+ trackSpan('TestCircuitProver.getBaseParityProof')
148
+ ], TestCircuitProver.prototype, "getBaseParityProof", null);
149
+ _ts_decorate([
150
+ trackSpan('TestCircuitProver.getRootParityProof')
151
+ ], TestCircuitProver.prototype, "getRootParityProof", null);
152
+ _ts_decorate([
153
+ trackSpan('TestCircuitProver.getPrivateBaseRollupProof')
154
+ ], TestCircuitProver.prototype, "getPrivateBaseRollupProof", null);
155
+ _ts_decorate([
156
+ trackSpan('TestCircuitProver.getPublicBaseRollupProof')
157
+ ], TestCircuitProver.prototype, "getPublicBaseRollupProof", null);
158
+ _ts_decorate([
159
+ trackSpan('TestCircuitProver.getMergeRollupProof')
160
+ ], TestCircuitProver.prototype, "getMergeRollupProof", null);
161
+ _ts_decorate([
162
+ trackSpan('TestCircuitProver.getBlockRootRollupProof')
163
+ ], TestCircuitProver.prototype, "getBlockRootRollupProof", null);
164
+ _ts_decorate([
165
+ trackSpan('TestCircuitProver.getSingleTxBlockRootRollupProof')
166
+ ], TestCircuitProver.prototype, "getSingleTxBlockRootRollupProof", null);
167
+ _ts_decorate([
168
+ trackSpan('TestCircuitProver.getEmptyBlockRootRollupProof')
169
+ ], TestCircuitProver.prototype, "getEmptyBlockRootRollupProof", null);
170
+ _ts_decorate([
171
+ trackSpan('TestCircuitProver.getBlockMergeRollupProof')
172
+ ], TestCircuitProver.prototype, "getBlockMergeRollupProof", null);
173
+ _ts_decorate([
174
+ trackSpan('TestCircuitProver.getRootRollupProof')
175
+ ], TestCircuitProver.prototype, "getRootRollupProof", null);
@@ -0,0 +1,6 @@
1
+ import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
2
+ import type { Tx } from '@aztec/stdlib/tx';
3
+ export declare class TestCircuitVerifier implements ClientProtocolCircuitVerifier {
4
+ verifyProof(_tx: Tx): Promise<boolean>;
5
+ }
6
+ //# sourceMappingURL=test_verifier.d.ts.map
@@ -0,0 +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;AACrF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,qBAAa,mBAAoB,YAAW,6BAA6B;IACvE,WAAW,CAAC,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAGvC"}
@@ -0,0 +1,5 @@
1
+ export class TestCircuitVerifier {
2
+ verifyProof(_tx) {
3
+ return Promise.resolve(true);
4
+ }
5
+ }
@@ -0,0 +1,9 @@
1
+ import { VerificationKeyData } from '@aztec/stdlib/vks';
2
+ /**
3
+ * Reads the verification key data stored at the specified location and parses into a VerificationKeyData
4
+ * @param vkDirectoryPath - The directory containing the verification key data files
5
+ * @returns The verification key data
6
+ */
7
+ export declare function extractVkData(vkDirectoryPath: string): Promise<VerificationKeyData>;
8
+ export declare function extractAvmVkData(vkDirectoryPath: string): Promise<VerificationKeyData>;
9
+ //# sourceMappingURL=verification_key_data.d.ts.map
@@ -0,0 +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,CAWzF;AAGD,wBAAsB,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAc5F"}
@@ -0,0 +1,44 @@
1
+ import { AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS } from '@aztec/constants';
2
+ import { Fr } from '@aztec/foundation/fields';
3
+ import { hashVK } from '@aztec/stdlib/hash';
4
+ import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
5
+ import { strict as assert } from 'assert';
6
+ import { promises as fs } from 'fs';
7
+ import * as path from 'path';
8
+ import { VK_FIELDS_FILENAME, VK_FILENAME } from '../bb/execute.js';
9
+ /**
10
+ * Reads the verification key data stored at the specified location and parses into a VerificationKeyData
11
+ * @param vkDirectoryPath - The directory containing the verification key data files
12
+ * @returns The verification key data
13
+ */ export async function extractVkData(vkDirectoryPath) {
14
+ const [rawFields, rawBinary] = await Promise.all([
15
+ fs.readFile(path.join(vkDirectoryPath, VK_FIELDS_FILENAME), {
16
+ encoding: 'utf-8'
17
+ }),
18
+ fs.readFile(path.join(vkDirectoryPath, VK_FILENAME))
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);
25
+ return new VerificationKeyData(vkAsFields, rawBinary);
26
+ }
27
+ // TODO: This was adapted from the above function. A refactor might be needed.
28
+ export async function extractAvmVkData(vkDirectoryPath) {
29
+ const [rawFields, rawBinary] = await Promise.all([
30
+ fs.readFile(path.join(vkDirectoryPath, VK_FIELDS_FILENAME), {
31
+ encoding: 'utf-8'
32
+ }),
33
+ fs.readFile(path.join(vkDirectoryPath, VK_FILENAME))
34
+ ]);
35
+ const fieldsJson = JSON.parse(rawFields);
36
+ const fields = fieldsJson.map(Fr.fromHexString);
37
+ // The first item is the hash, this is not part of the actual VK
38
+ // TODO: is the above actually the case?
39
+ const vkHash = fields[0];
40
+ assert(fields.length === AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS, 'Invalid AVM verification key length');
41
+ const vkAsFields = new VerificationKeyAsFields(fields, vkHash);
42
+ const vk = new VerificationKeyData(vkAsFields, rawBinary);
43
+ return vk;
44
+ }
@@ -0,0 +1,17 @@
1
+ import { type Logger } from '@aztec/foundation/log';
2
+ import type { ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
3
+ import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
4
+ import type { Proof } from '@aztec/stdlib/proofs';
5
+ import { Tx } from '@aztec/stdlib/tx';
6
+ import type { VerificationKeyData } from '@aztec/stdlib/vks';
7
+ import type { BBConfig } from '../config.js';
8
+ export declare class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
9
+ private config;
10
+ private logger;
11
+ private constructor();
12
+ static new(config: BBConfig, logger?: Logger): Promise<BBCircuitVerifier>;
13
+ getVerificationKeyData(circuitType: ServerProtocolArtifact): VerificationKeyData;
14
+ verifyProofForCircuit(circuit: ServerProtocolArtifact, proof: Proof): Promise<void>;
15
+ verifyProof(tx: Tx): Promise<boolean>;
16
+ }
17
+ //# sourceMappingURL=bb_verifier.d.ts.map
@@ -0,0 +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;AAElE,OAAO,KAAK,EAA0B,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAChH,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrF,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;AAM7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAK7C,qBAAa,iBAAkB,YAAW,6BAA6B;IACjD,OAAO,CAAC,MAAM;IAAY,OAAO,CAAC,MAAM;IAA5D,OAAO;WAEa,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAqC;IAK9E,sBAAsB,CAAC,WAAW,EAAE,sBAAsB,GAAG,mBAAmB;IAQ1E,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK;IAkCnE,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CA4CnD"}
@@ -0,0 +1,86 @@
1
+ import { runInDirectory } from '@aztec/foundation/fs';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
4
+ import { Tx } from '@aztec/stdlib/tx';
5
+ import { promises as fs } from 'fs';
6
+ import * as path from 'path';
7
+ import { BB_RESULT, PROOF_FILENAME, VK_FILENAME, verifyClientIvcProof, verifyProof } from '../bb/execute.js';
8
+ import { getUltraHonkFlavorForCircuit } from '../honk.js';
9
+ import { writeToOutputDirectory } from '../prover/client_ivc_proof_utils.js';
10
+ import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
11
+ export class BBCircuitVerifier {
12
+ config;
13
+ logger;
14
+ constructor(config, logger){
15
+ this.config = config;
16
+ this.logger = logger;
17
+ }
18
+ static async new(config, logger = createLogger('bb-prover:verifier')) {
19
+ await fs.mkdir(config.bbWorkingDirectory, {
20
+ recursive: true
21
+ });
22
+ return new BBCircuitVerifier(config, logger);
23
+ }
24
+ getVerificationKeyData(circuitType) {
25
+ const vk = ServerCircuitVks[circuitType];
26
+ if (vk === undefined) {
27
+ throw new Error('Could not find VK for server artifact ' + circuitType);
28
+ }
29
+ return vk;
30
+ }
31
+ async verifyProofForCircuit(circuit, proof) {
32
+ const operation = async (bbWorkingDirectory)=>{
33
+ const proofFileName = path.join(bbWorkingDirectory, PROOF_FILENAME);
34
+ const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
35
+ const verificationKey = this.getVerificationKeyData(circuit);
36
+ this.logger.debug(`${circuit} Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
37
+ await fs.writeFile(proofFileName, proof.buffer);
38
+ await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
39
+ const result = await verifyProof(this.config.bbBinaryPath, proofFileName, verificationKeyPath, getUltraHonkFlavorForCircuit(circuit), this.logger);
40
+ if (result.status === BB_RESULT.FAILURE) {
41
+ const errorMessage = `Failed to verify ${circuit} proof!`;
42
+ throw new Error(errorMessage);
43
+ }
44
+ this.logger.debug(`${circuit} verification successful`, {
45
+ circuitName: mapProtocolArtifactNameToCircuitName(circuit),
46
+ duration: result.durationMs,
47
+ eventName: 'circuit-verification',
48
+ proofType: 'ultra-honk'
49
+ });
50
+ };
51
+ await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
52
+ }
53
+ async verifyProof(tx) {
54
+ try {
55
+ // TODO(#7370) The verification keys should be supplied separately and based on the expectedCircuit
56
+ // rather than read from the tx object itself. We also need the vks for the translator and ecc, which
57
+ // are not being saved along the other vks yet. Reuse the 'verifyProofForCircuit' method above once
58
+ // we have all the verification keys available.
59
+ const expectedCircuit = tx.data.forPublic ? 'PrivateKernelTailToPublicArtifact' : 'PrivateKernelTailArtifact';
60
+ const circuit = 'ClientIVC';
61
+ // Block below is almost copy-pasted from verifyProofForCircuit
62
+ const operation = async (bbWorkingDirectory)=>{
63
+ const logFunction = (message)=>{
64
+ this.logger.debug(`${circuit} BB out - ${message}`);
65
+ };
66
+ await writeToOutputDirectory(tx.clientIvcProof, bbWorkingDirectory);
67
+ const result = await verifyClientIvcProof(this.config.bbBinaryPath, bbWorkingDirectory.concat('/proof'), bbWorkingDirectory.concat('/vk'), logFunction);
68
+ if (result.status === BB_RESULT.FAILURE) {
69
+ const errorMessage = `Failed to verify ${circuit} proof!`;
70
+ throw new Error(errorMessage);
71
+ }
72
+ this.logger.debug(`${circuit} verification successful`, {
73
+ circuitName: mapProtocolArtifactNameToCircuitName(expectedCircuit),
74
+ duration: result.durationMs,
75
+ eventName: 'circuit-verification',
76
+ proofType: 'client-ivc'
77
+ });
78
+ };
79
+ await runInDirectory(this.config.bbWorkingDirectory, operation, this.config.bbSkipCleanup, this.logger);
80
+ return true;
81
+ } catch (err) {
82
+ this.logger.warn(`Failed to verify ClientIVC proof for tx ${Tx.getHash(tx)}: ${String(err)}`);
83
+ return false;
84
+ }
85
+ }
86
+ }
@@ -0,0 +1,2 @@
1
+ export * from './bb_verifier.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './bb_verifier.js';
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ import type { ArtifactProvider } from '@aztec/noir-protocol-circuits-types/types';
4
+ import type { SimulationProvider } from '@aztec/simulator/client';
5
+ import { ClientIvcProof } from '@aztec/stdlib/proofs';
6
+ import type { WitnessMap } from '@noir-lang/types';
7
+ import { BBPrivateKernelProver } from '../prover/bb_private_kernel_prover.js';
8
+ export declare abstract class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
9
+ protected artifactProvider: ArtifactProvider;
10
+ protected simulationProvider: SimulationProvider;
11
+ private threads;
12
+ protected log: import("@aztec/foundation/log").Logger;
13
+ constructor(artifactProvider: ArtifactProvider, simulationProvider: SimulationProvider, threads?: number, log?: import("@aztec/foundation/log").Logger);
14
+ createClientIvcProof(acirs: Buffer[], witnessStack: WitnessMap[]): Promise<ClientIvcProof>;
15
+ computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number>;
16
+ }
17
+ //# 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/wasm/bb_wasm_private_kernel_prover.ts"],"names":[],"mappings":";;AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,8BAAsB,yBAA0B,SAAQ,qBAAqB;cAEtD,gBAAgB,EAAE,gBAAgB;cAClC,kBAAkB,EAAE,kBAAkB;IACzD,OAAO,CAAC,OAAO;cACI,GAAG;gBAHH,gBAAgB,EAAE,gBAAgB,EAClC,kBAAkB,EAAE,kBAAkB,EACjD,OAAO,GAAE,MAAU,EACR,GAAG,yCAAiC;IAKnC,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAmB1F,0BAA0B,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAY3G"}
@@ -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 { ClientIvcProof } from '@aztec/stdlib/proofs';
5
+ import { serializeWitness } from '@noir-lang/noirc_abi';
6
+ import { ungzip } from 'pako';
7
+ import { BBPrivateKernelProver } from '../prover/bb_private_kernel_prover.js';
8
+ export class BBWASMPrivateKernelProver extends BBPrivateKernelProver {
9
+ artifactProvider;
10
+ simulationProvider;
11
+ threads;
12
+ log;
13
+ constructor(artifactProvider, simulationProvider, threads = 1, log = createLogger('bb-prover:wasm')){
14
+ super(artifactProvider, simulationProvider, log), this.artifactProvider = artifactProvider, this.simulationProvider = simulationProvider, this.threads = threads, this.log = log;
15
+ }
16
+ async createClientIvcProof(acirs, witnessStack) {
17
+ const timer = new Timer();
18
+ this.log.info(`Generating ClientIVC proof...`);
19
+ const backend = new AztecClientBackend(acirs.map((acir)=>ungzip(acir)), {
20
+ threads: this.threads,
21
+ logger: this.log.verbose,
22
+ wasmPath: process.env.BB_WASM_PATH
23
+ });
24
+ const [proof, vk] = await backend.prove(witnessStack.map((witnessMap)=>ungzip(serializeWitness(witnessMap))));
25
+ await backend.destroy();
26
+ this.log.info(`Generated ClientIVC proof`, {
27
+ eventName: 'client-ivc-proof-generation',
28
+ duration: timer.ms(),
29
+ proofSize: proof.length,
30
+ vkSize: vk.length
31
+ });
32
+ return new ClientIvcProof(Buffer.from(proof), Buffer.from(vk));
33
+ }
34
+ async computeGateCountForCircuit(_bytecode, _circuitName) {
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 { SimulationProvider } from '@aztec/simulator/client';
2
+ import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
3
+ export declare class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
4
+ constructor(simulationProvider: SimulationProvider, 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/wasm/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,+BAAgC,SAAQ,yBAAyB;gBAChE,kBAAkB,EAAE,kBAAkB,EAAE,OAAO,SAAI,EAAE,GAAG,yCAAwC;CAG7G"}
@@ -0,0 +1,8 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { BundleArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/bundle';
3
+ import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
4
+ export class BBWASMBundlePrivateKernelProver extends BBWASMPrivateKernelProver {
5
+ constructor(simulationProvider, threads = 1, log = createLogger('bb-prover:wasm:bundle')){
6
+ super(new BundleArtifactProvider(), simulationProvider, threads, log);
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import type { SimulationProvider } from '@aztec/simulator/client';
2
+ import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
3
+ export declare class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
4
+ constructor(simulationProvider: SimulationProvider, 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/wasm/lazy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E,qBAAa,6BAA8B,SAAQ,yBAAyB;gBAC9D,kBAAkB,EAAE,kBAAkB,EAAE,OAAO,SAAI,EAAE,GAAG,yCAAsC;CAG3G"}
@@ -0,0 +1,8 @@
1
+ import { createLogger } from '@aztec/foundation/log';
2
+ import { LazyArtifactProvider } from '@aztec/noir-protocol-circuits-types/client/lazy';
3
+ import { BBWASMPrivateKernelProver } from './bb_wasm_private_kernel_prover.js';
4
+ export class BBWASMLazyPrivateKernelProver extends BBWASMPrivateKernelProver {
5
+ constructor(simulationProvider, threads = 1, log = createLogger('bb-prover:wasm:lazy')){
6
+ super(new LazyArtifactProvider(), simulationProvider, threads, log);
7
+ }
8
+ }