@aztec/bb-prover 0.69.0-devnet → 0.69.1-devnet

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 (53) hide show
  1. package/dest/bb/cli.d.ts +3 -0
  2. package/dest/bb/cli.d.ts.map +1 -1
  3. package/dest/bb/cli.js +7 -2
  4. package/dest/honk.d.ts +8 -8
  5. package/dest/honk.d.ts.map +1 -1
  6. package/dest/honk.js +2 -7
  7. package/dest/prover/bb_native_private_kernel_prover.d.ts +23 -0
  8. package/dest/prover/bb_native_private_kernel_prover.d.ts.map +1 -0
  9. package/dest/prover/bb_native_private_kernel_prover.js +68 -0
  10. package/dest/prover/bb_private_kernel_prover.d.ts +26 -41
  11. package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
  12. package/dest/prover/bb_private_kernel_prover.js +62 -117
  13. package/dest/prover/bb_prover.d.ts +4 -6
  14. package/dest/prover/bb_prover.d.ts.map +1 -1
  15. package/dest/prover/bb_prover.js +9 -30
  16. package/dest/prover/index.d.ts +1 -1
  17. package/dest/prover/index.d.ts.map +1 -1
  18. package/dest/prover/index.js +2 -2
  19. package/dest/stats.d.ts +3 -3
  20. package/dest/stats.d.ts.map +1 -1
  21. package/dest/stats.js +4 -7
  22. package/dest/test/test_circuit_prover.d.ts +4 -4
  23. package/dest/test/test_circuit_prover.d.ts.map +1 -1
  24. package/dest/test/test_circuit_prover.js +11 -9
  25. package/dest/verifier/bb_verifier.d.ts +6 -6
  26. package/dest/verifier/bb_verifier.d.ts.map +1 -1
  27. package/dest/verifier/bb_verifier.js +4 -4
  28. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +14 -0
  29. package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -0
  30. package/dest/wasm/bb_wasm_private_kernel_prover.js +30 -0
  31. package/dest/wasm/bundle.d.ts +5 -0
  32. package/dest/wasm/bundle.d.ts.map +1 -0
  33. package/dest/wasm/bundle.js +9 -0
  34. package/dest/wasm/lazy.d.ts +5 -0
  35. package/dest/wasm/lazy.d.ts.map +1 -0
  36. package/dest/wasm/lazy.js +9 -0
  37. package/package.json +11 -10
  38. package/src/bb/cli.ts +9 -1
  39. package/src/honk.ts +16 -21
  40. package/src/prover/bb_native_private_kernel_prover.ts +110 -0
  41. package/src/prover/bb_private_kernel_prover.ts +138 -201
  42. package/src/prover/bb_prover.ts +25 -67
  43. package/src/prover/index.ts +1 -1
  44. package/src/stats.ts +6 -11
  45. package/src/test/test_circuit_prover.ts +21 -36
  46. package/src/verifier/bb_verifier.ts +11 -10
  47. package/src/wasm/bb_wasm_private_kernel_prover.ts +40 -0
  48. package/src/wasm/bundle.ts +10 -0
  49. package/src/wasm/lazy.ts +10 -0
  50. package/dest/wasm/index.d.ts +0 -19
  51. package/dest/wasm/index.d.ts.map +0 -1
  52. package/dest/wasm/index.js +0 -74
  53. package/src/wasm/index.ts +0 -155
@@ -1,5 +1,5 @@
1
1
  import { type PrivateKernelProver, type PrivateKernelSimulateOutput } from '@aztec/circuit-types';
2
- import { type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
2
+ import { type CircuitSimulationStats, type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
3
3
  import {
4
4
  type ClientIvcProof,
5
5
  type PrivateKernelCircuitPublicInputs,
@@ -8,264 +8,194 @@ import {
8
8
  type PrivateKernelResetCircuitPrivateInputs,
9
9
  type PrivateKernelTailCircuitPrivateInputs,
10
10
  type PrivateKernelTailCircuitPublicInputs,
11
- type Proof,
12
- type VerificationKeyData,
13
11
  } from '@aztec/circuits.js';
14
- import { runInDirectory } from '@aztec/foundation/fs';
15
- import { type Logger, createLogger } from '@aztec/foundation/log';
12
+ import { createLogger } from '@aztec/foundation/log';
16
13
  import { Timer } from '@aztec/foundation/timer';
17
14
  import {
18
- ClientCircuitArtifacts,
19
- ClientCircuitVks,
20
- type ClientProtocolArtifact,
21
- ProtocolCircuitVks,
22
- convertPrivateKernelInitInputsToWitnessMap,
23
- convertPrivateKernelInitOutputsFromWitnessMap,
24
- convertPrivateKernelInnerInputsToWitnessMap,
25
- convertPrivateKernelInnerOutputsFromWitnessMap,
26
- convertPrivateKernelResetInputsToWitnessMap,
27
- convertPrivateKernelResetOutputsFromWitnessMap,
28
- convertPrivateKernelTailForPublicOutputsFromWitnessMap,
29
- convertPrivateKernelTailInputsToWitnessMap,
30
- convertPrivateKernelTailOutputsFromWitnessMap,
31
- convertPrivateKernelTailToPublicInputsToWitnessMap,
15
+ convertPrivateKernelInitInputsToWitnessMapWithAbi,
16
+ convertPrivateKernelInitOutputsFromWitnessMapWithAbi,
17
+ convertPrivateKernelInnerInputsToWitnessMapWithAbi,
18
+ convertPrivateKernelInnerOutputsFromWitnessMapWithAbi,
19
+ convertPrivateKernelResetInputsToWitnessMapWithAbi,
20
+ convertPrivateKernelResetOutputsFromWitnessMapWithAbi,
21
+ convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
22
+ convertPrivateKernelTailInputsToWitnessMapWithAbi,
23
+ convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
24
+ convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi,
32
25
  getPrivateKernelResetArtifactName,
33
- } from '@aztec/noir-protocol-circuits-types';
34
- import { WASMSimulatorWithBlobs } from '@aztec/simulator';
26
+ updateResetCircuitSampleInputs,
27
+ } from '@aztec/noir-protocol-circuits-types/client';
28
+ import { type ArtifactProvider, type ClientProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
29
+ import { ClientCircuitVks } from '@aztec/noir-protocol-circuits-types/vks';
30
+ import { WASMSimulator } from '@aztec/simulator/client';
35
31
  import { type NoirCompiledCircuit } from '@aztec/types/noir';
36
32
 
37
- import { encode } from '@msgpack/msgpack';
38
- import { serializeWitness } from '@noir-lang/noirc_abi';
39
- import { type WitnessMap } from '@noir-lang/types';
40
- import { promises as fs } from 'fs';
41
- import path from 'path';
33
+ import { type Abi, type WitnessMap } from '@noir-lang/types';
42
34
 
43
- import { BB_RESULT, computeGateCountForCircuit, executeBbClientIvcProof, verifyProof } from '../bb/execute.js';
44
- import { type BBConfig } from '../config.js';
45
- import { type UltraHonkFlavor, getUltraHonkFlavorForCircuit } from '../honk.js';
46
35
  import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
47
- import { extractVkData } from '../verification_key/verification_key_data.js';
48
- import { readFromOutputDirectory } from './client_ivc_proof_utils.js';
49
36
 
50
- /**
51
- * This proof creator implementation uses the native bb binary.
52
- * This is a temporary implementation until we make the WASM version work.
53
- * TODO(#7368): this class grew 'organically' aka it could use a look at its resposibilities
54
- */
55
- export class BBNativePrivateKernelProver implements PrivateKernelProver {
56
- private simulator = new WASMSimulatorWithBlobs();
37
+ export abstract class BBPrivateKernelProver implements PrivateKernelProver {
38
+ protected simulator = new WASMSimulator();
57
39
 
58
- private verificationKeys: Map<ClientProtocolArtifact, Promise<VerificationKeyData>> = new Map<
59
- ClientProtocolArtifact,
60
- Promise<VerificationKeyData>
61
- >();
40
+ constructor(protected artifactProvider: ArtifactProvider, protected log = createLogger('bb-prover')) {}
62
41
 
63
- private constructor(
64
- private bbBinaryPath: string,
65
- private bbWorkingDirectory: string,
66
- private skipCleanup: boolean,
67
- private log = createLogger('bb-prover:native'),
68
- ) {}
69
-
70
- public static async new(config: BBConfig, log?: Logger) {
71
- await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
72
- return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, log);
73
- }
74
-
75
- private async _createClientIvcProof(
76
- directory: string,
77
- acirs: Buffer[],
78
- witnessStack: WitnessMap[],
79
- ): Promise<ClientIvcProof> {
80
- // TODO(#7371): Longer term we won't use this hacked together msgpack format
81
- // and instead properly create the bincode serialization from rust
82
- await fs.writeFile(path.join(directory, 'acir.msgpack'), encode(acirs));
83
- await fs.writeFile(
84
- path.join(directory, 'witnesses.msgpack'),
85
- encode(witnessStack.map(map => serializeWitness(map))),
86
- );
87
- const provingResult = await executeBbClientIvcProof(
88
- this.bbBinaryPath,
89
- directory,
90
- path.join(directory, 'acir.msgpack'),
91
- path.join(directory, 'witnesses.msgpack'),
92
- this.log.info,
42
+ public async generateInitOutput(
43
+ inputs: PrivateKernelInitCircuitPrivateInputs,
44
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
45
+ return await this.generateCircuitOutput(
46
+ inputs,
47
+ 'PrivateKernelInitArtifact',
48
+ convertPrivateKernelInitInputsToWitnessMapWithAbi,
49
+ convertPrivateKernelInitOutputsFromWitnessMapWithAbi,
93
50
  );
94
-
95
- if (provingResult.status === BB_RESULT.FAILURE) {
96
- this.log.error(`Failed to generate client ivc proof`);
97
- throw new Error(provingResult.reason);
98
- }
99
-
100
- const proof = await readFromOutputDirectory(directory);
101
-
102
- this.log.info(`Generated IVC proof`, {
103
- duration: provingResult.durationMs,
104
- eventName: 'circuit-proving',
105
- });
106
-
107
- return proof;
108
51
  }
109
52
 
110
- async createClientIvcProof(acirs: Buffer[], witnessStack: WitnessMap[]): Promise<ClientIvcProof> {
111
- this.log.info(`Generating Client IVC proof`);
112
- const operation = async (directory: string) => {
113
- return await this._createClientIvcProof(directory, acirs, witnessStack);
114
- };
115
- return await this.runInDirectory(operation);
116
- }
117
-
118
- public async simulateProofInit(
53
+ public async simulateInit(
119
54
  inputs: PrivateKernelInitCircuitPrivateInputs,
120
55
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
121
- return await this.simulate(
56
+ return await this.simulateCircuitOutput(
122
57
  inputs,
123
58
  'PrivateKernelInitArtifact',
124
- convertPrivateKernelInitInputsToWitnessMap,
125
- convertPrivateKernelInitOutputsFromWitnessMap,
59
+ convertPrivateKernelInitInputsToWitnessMapWithAbi,
60
+ convertPrivateKernelInitOutputsFromWitnessMapWithAbi,
61
+ );
62
+ }
63
+
64
+ public async generateInnerOutput(
65
+ inputs: PrivateKernelInnerCircuitPrivateInputs,
66
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
67
+ return await this.generateCircuitOutput(
68
+ inputs,
69
+ 'PrivateKernelInnerArtifact',
70
+ convertPrivateKernelInnerInputsToWitnessMapWithAbi,
71
+ convertPrivateKernelInnerOutputsFromWitnessMapWithAbi,
126
72
  );
127
73
  }
128
74
 
129
- public async simulateProofInner(
75
+ public async simulateInner(
130
76
  inputs: PrivateKernelInnerCircuitPrivateInputs,
131
77
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
132
- return await this.simulate(
78
+ return await this.simulateCircuitOutput(
133
79
  inputs,
134
80
  'PrivateKernelInnerArtifact',
135
- convertPrivateKernelInnerInputsToWitnessMap,
136
- convertPrivateKernelInnerOutputsFromWitnessMap,
81
+ convertPrivateKernelInnerInputsToWitnessMapWithAbi,
82
+ convertPrivateKernelInnerOutputsFromWitnessMapWithAbi,
137
83
  );
138
84
  }
139
85
 
140
- public async simulateProofReset(
86
+ public async generateResetOutput(
141
87
  inputs: PrivateKernelResetCircuitPrivateInputs,
142
88
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
143
89
  const variantInputs = inputs.trimToSizes();
144
90
  const artifactName = getPrivateKernelResetArtifactName(inputs.dimensions);
145
- return await this.simulate(
91
+ return await this.generateCircuitOutput(
146
92
  variantInputs,
147
93
  artifactName,
148
- variantInputs => convertPrivateKernelResetInputsToWitnessMap(variantInputs, artifactName),
149
- output => convertPrivateKernelResetOutputsFromWitnessMap(output, artifactName),
94
+ convertPrivateKernelResetInputsToWitnessMapWithAbi,
95
+ convertPrivateKernelResetOutputsFromWitnessMapWithAbi,
150
96
  );
151
97
  }
152
98
 
153
- public async simulateProofTail(
99
+ public async simulateReset(
100
+ inputs: PrivateKernelResetCircuitPrivateInputs,
101
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>> {
102
+ updateResetCircuitSampleInputs(inputs);
103
+ const variantInputs = inputs.trimToSizes();
104
+ const artifactName = getPrivateKernelResetArtifactName(inputs.dimensions);
105
+ return await this.simulateCircuitOutput(
106
+ variantInputs,
107
+ artifactName,
108
+ convertPrivateKernelResetInputsToWitnessMapWithAbi,
109
+ convertPrivateKernelResetOutputsFromWitnessMapWithAbi,
110
+ );
111
+ }
112
+
113
+ public async generateTailOutput(
154
114
  inputs: PrivateKernelTailCircuitPrivateInputs,
155
115
  ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
156
116
  if (!inputs.isForPublic()) {
157
- return await this.simulate(
117
+ return await this.generateCircuitOutput(
158
118
  inputs,
159
119
  'PrivateKernelTailArtifact',
160
- convertPrivateKernelTailInputsToWitnessMap,
161
- convertPrivateKernelTailOutputsFromWitnessMap,
120
+ convertPrivateKernelTailInputsToWitnessMapWithAbi,
121
+ convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
162
122
  );
163
123
  }
164
- return await this.simulate(
124
+ return await this.generateCircuitOutput(
165
125
  inputs,
166
126
  'PrivateKernelTailToPublicArtifact',
167
- convertPrivateKernelTailToPublicInputsToWitnessMap,
168
- convertPrivateKernelTailForPublicOutputsFromWitnessMap,
127
+ convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi,
128
+ convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
169
129
  );
170
130
  }
171
131
 
172
- /**
173
- * Verifies a proof, will generate the verification key if one is not cached internally
174
- * @param circuitType - The type of circuit whose proof is to be verified
175
- * @param proof - The proof to be verified
176
- */
177
- public async verifyProofForProtocolCircuit(circuitType: ClientProtocolArtifact, proof: Proof) {
178
- const verificationKey = ProtocolCircuitVks[circuitType];
179
-
180
- this.log.debug(`Verifying with key: ${verificationKey.keyAsFields.hash.toString()}`);
181
-
182
- const logFunction = (message: string) => {
183
- this.log.debug(`${circuitType} BB out - ${message}`);
184
- };
185
-
186
- const result = await this.verifyProofFromKey(
187
- getUltraHonkFlavorForCircuit(circuitType),
188
- verificationKey.keyAsBytes,
189
- proof,
190
- logFunction,
191
- );
192
-
193
- if (result.status === BB_RESULT.FAILURE) {
194
- const errorMessage = `Failed to verify ${circuitType} proof!`;
195
- throw new Error(errorMessage);
132
+ public async simulateTail(
133
+ inputs: PrivateKernelTailCircuitPrivateInputs,
134
+ ): Promise<PrivateKernelSimulateOutput<PrivateKernelTailCircuitPublicInputs>> {
135
+ if (!inputs.isForPublic()) {
136
+ return await this.simulateCircuitOutput(
137
+ inputs,
138
+ 'PrivateKernelTailArtifact',
139
+ convertPrivateKernelTailInputsToWitnessMapWithAbi,
140
+ convertPrivateKernelTailOutputsFromWitnessMapWithAbi,
141
+ );
196
142
  }
197
-
198
- this.log.info(`Successfully verified ${circuitType} proof in ${Math.ceil(result.durationMs)} ms`);
143
+ return await this.simulateCircuitOutput(
144
+ inputs,
145
+ 'PrivateKernelTailToPublicArtifact',
146
+ convertPrivateKernelTailToPublicInputsToWitnessMapWithAbi,
147
+ convertPrivateKernelTailForPublicOutputsFromWitnessMapWithAbi,
148
+ );
199
149
  }
200
150
 
201
- public async computeGateCountForCircuit(bytecode: Buffer, circuitName: string): Promise<number> {
202
- const logFunction = (message: string) => {
203
- this.log.debug(`$bb gates ${circuitName} - ${message}`);
204
- };
205
-
206
- const result = await computeGateCountForCircuit(
207
- this.bbBinaryPath,
208
- this.bbWorkingDirectory,
209
- circuitName,
210
- bytecode,
211
- 'mega_honk',
212
- logFunction,
151
+ public async simulateCircuitOutput<
152
+ I extends { toBuffer: () => Buffer },
153
+ O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs,
154
+ >(
155
+ inputs: I,
156
+ circuitType: ClientProtocolArtifact,
157
+ convertInputs: (inputs: I, abi: Abi) => WitnessMap,
158
+ convertOutputs: (outputs: WitnessMap, abi: Abi) => O,
159
+ ): Promise<PrivateKernelSimulateOutput<O>> {
160
+ const compiledCircuit: NoirCompiledCircuit = await this.artifactProvider.getSimulatedClientCircuitArtifactByName(
161
+ circuitType,
213
162
  );
214
- if (result.status === BB_RESULT.FAILURE) {
215
- throw new Error(result.reason);
216
- }
217
163
 
218
- return result.circuitSize as number;
219
- }
164
+ const witnessMap = convertInputs(inputs, compiledCircuit.abi);
220
165
 
221
- private async verifyProofFromKey(
222
- flavor: UltraHonkFlavor,
223
- verificationKey: Buffer,
224
- proof: Proof,
225
- logFunction: (message: string) => void = () => {},
226
- ) {
227
- const operation = async (bbWorkingDirectory: string) => {
228
- const proofFileName = `${bbWorkingDirectory}/proof`;
229
- const verificationKeyPath = `${bbWorkingDirectory}/vk`;
166
+ const timer = new Timer();
167
+ const outputWitness = await this.simulator.simulateCircuit(witnessMap, compiledCircuit);
168
+ const output = convertOutputs(outputWitness, compiledCircuit.abi);
230
169
 
231
- await fs.writeFile(proofFileName, proof.buffer);
232
- await fs.writeFile(verificationKeyPath, verificationKey);
233
- return await verifyProof(this.bbBinaryPath, proofFileName, verificationKeyPath!, flavor, logFunction);
234
- };
235
- return await this.runInDirectory(operation);
236
- }
170
+ this.log.debug(`Simulated ${circuitType}`, {
171
+ eventName: 'circuit-simulation',
172
+ circuitName: mapProtocolArtifactNameToCircuitName(circuitType),
173
+ duration: timer.ms(),
174
+ inputSize: inputs.toBuffer().length,
175
+ outputSize: output.toBuffer().length,
176
+ } satisfies CircuitSimulationStats);
237
177
 
238
- /**
239
- * Ensures our verification key cache includes the key data located at the specified directory
240
- * @param filePath - The directory containing the verification key data files
241
- * @param circuitType - The type of circuit to which the verification key corresponds
242
- */
243
- private async updateVerificationKeyAfterSimulation(filePath: string, circuitType: ClientProtocolArtifact) {
244
- let promise = this.verificationKeys.get(circuitType);
245
- if (!promise) {
246
- promise = extractVkData(filePath);
247
- this.log.debug(`Updated verification key for circuit: ${circuitType}`);
248
- this.verificationKeys.set(circuitType, promise);
249
- }
250
- return await promise;
178
+ return this.makeEmptyKernelSimulateOutput<O>(output, circuitType);
251
179
  }
252
180
 
253
- private async simulate<
181
+ public async generateCircuitOutput<
254
182
  I extends { toBuffer: () => Buffer },
255
183
  O extends PrivateKernelCircuitPublicInputs | PrivateKernelTailCircuitPublicInputs,
256
184
  >(
257
185
  inputs: I,
258
186
  circuitType: ClientProtocolArtifact,
259
- convertInputs: (inputs: I) => WitnessMap,
260
- convertOutputs: (outputs: WitnessMap) => O,
187
+ convertInputs: (inputs: I, abi: Abi) => WitnessMap,
188
+ convertOutputs: (outputs: WitnessMap, abi: Abi) => O,
261
189
  ): Promise<PrivateKernelSimulateOutput<O>> {
262
190
  this.log.debug(`Generating witness for ${circuitType}`);
263
- const compiledCircuit: NoirCompiledCircuit = ClientCircuitArtifacts[circuitType];
191
+ const compiledCircuit: NoirCompiledCircuit = await this.artifactProvider.getClientCircuitArtifactByName(
192
+ circuitType,
193
+ );
264
194
 
265
- const witnessMap = convertInputs(inputs);
195
+ const witnessMap = convertInputs(inputs, compiledCircuit.abi);
266
196
  const timer = new Timer();
267
197
  const outputWitness = await this.simulator.simulateCircuit(witnessMap, compiledCircuit);
268
- const output = convertOutputs(outputWitness);
198
+ const output = convertOutputs(outputWitness, compiledCircuit.abi);
269
199
 
270
200
  this.log.debug(`Generated witness for ${circuitType}`, {
271
201
  eventName: 'circuit-witness-generation',
@@ -287,16 +217,23 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
287
217
  return kernelOutput;
288
218
  }
289
219
 
290
- private runInDirectory<T>(fn: (dir: string) => Promise<T>) {
291
- const log = this.log;
292
- return runInDirectory(
293
- this.bbWorkingDirectory,
294
- (dir: string) =>
295
- fn(dir).catch(err => {
296
- log.error(`Error running operation at ${dir}: ${err}`);
297
- throw err;
298
- }),
299
- this.skipCleanup,
300
- );
220
+ public makeEmptyKernelSimulateOutput<
221
+ PublicInputsType extends PrivateKernelTailCircuitPublicInputs | PrivateKernelCircuitPublicInputs,
222
+ >(publicInputs: PublicInputsType, circuitType: ClientProtocolArtifact) {
223
+ const kernelProofOutput: PrivateKernelSimulateOutput<PublicInputsType> = {
224
+ publicInputs,
225
+ verificationKey: ClientCircuitVks[circuitType].keyAsFields,
226
+ outputWitness: new Map(),
227
+ bytecode: Buffer.from([]),
228
+ };
229
+ return kernelProofOutput;
230
+ }
231
+
232
+ public createClientIvcProof(_acirs: Buffer[], _witnessStack: WitnessMap[]): Promise<ClientIvcProof> {
233
+ throw new Error('Not implemented');
234
+ }
235
+
236
+ public computeGateCountForCircuit(_bytecode: Buffer, _circuitName: string): Promise<number> {
237
+ throw new Error('Not implemented');
301
238
  }
302
239
  }
@@ -13,19 +13,13 @@ import {
13
13
  AVM_PROOF_LENGTH_IN_FIELDS,
14
14
  type AvmCircuitInputs,
15
15
  type BaseParityInputs,
16
- EmptyNestedCircuitInputs,
17
- EmptyNestedData,
18
16
  Fr,
19
17
  IPA_CLAIM_LENGTH,
20
- type KernelCircuitPublicInputs,
21
18
  NESTED_RECURSIVE_PROOF_LENGTH,
22
19
  NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
23
20
  type ParityPublicInputs,
24
- type PrivateKernelEmptyInputData,
25
- PrivateKernelEmptyInputs,
26
21
  Proof,
27
22
  RECURSIVE_PROOF_LENGTH,
28
- RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
29
23
  RecursiveProof,
30
24
  type RootParityInputs,
31
25
  TUBE_PROOF_LENGTH,
@@ -44,6 +38,7 @@ import {
44
38
  type PublicBaseRollupInputs,
45
39
  type RootRollupInputs,
46
40
  type RootRollupPublicInputs,
41
+ type SingleTxBlockRootRollupInputs,
47
42
  type TubeInputs,
48
43
  } from '@aztec/circuits.js/rollup';
49
44
  import { runInDirectory } from '@aztec/foundation/fs';
@@ -51,7 +46,6 @@ import { createLogger } from '@aztec/foundation/log';
51
46
  import { BufferReader } from '@aztec/foundation/serialize';
52
47
  import { Timer } from '@aztec/foundation/timer';
53
48
  import {
54
- ProtocolCircuitVks,
55
49
  ServerCircuitArtifacts,
56
50
  type ServerProtocolArtifact,
57
51
  convertBaseParityInputsToWitnessMap,
@@ -66,20 +60,19 @@ import {
66
60
  convertMergeRollupOutputsFromWitnessMap,
67
61
  convertPrivateBaseRollupInputsToWitnessMap,
68
62
  convertPrivateBaseRollupOutputsFromWitnessMap,
69
- convertPrivateKernelEmptyInputsToWitnessMap,
70
- convertPrivateKernelEmptyOutputsFromWitnessMap,
71
63
  convertPublicBaseRollupInputsToWitnessMap,
72
64
  convertPublicBaseRollupOutputsFromWitnessMap,
73
65
  convertRootParityInputsToWitnessMap,
74
66
  convertRootParityOutputsFromWitnessMap,
75
67
  convertRootRollupInputsToWitnessMap,
76
68
  convertRootRollupOutputsFromWitnessMap,
77
- } from '@aztec/noir-protocol-circuits-types';
69
+ convertSingleTxBlockRootRollupInputsToWitnessMap,
70
+ convertSingleTxBlockRootRollupOutputsFromWitnessMap,
71
+ } from '@aztec/noir-protocol-circuits-types/server';
78
72
  import { NativeACVMSimulator } from '@aztec/simulator';
79
73
  import { Attributes, type TelemetryClient, trackSpan } from '@aztec/telemetry-client';
80
74
 
81
- import { abiEncode } from '@noir-lang/noirc_abi';
82
- import { type Abi, type WitnessMap } from '@noir-lang/types';
75
+ import { type WitnessMap } from '@noir-lang/types';
83
76
  import { assert } from 'console';
84
77
  import crypto from 'crypto';
85
78
  import { promises as fs } from 'fs';
@@ -313,6 +306,26 @@ export class BBNativeRollupProver implements ServerCircuitProver {
313
306
  return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
314
307
  }
315
308
 
309
+ public async getSingleTxBlockRootRollupProof(
310
+ input: SingleTxBlockRootRollupInputs,
311
+ ): Promise<
312
+ PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
313
+ > {
314
+ const { circuitOutput, proof } = await this.createRecursiveProof(
315
+ input,
316
+ 'SingleTxBlockRootRollupArtifact',
317
+ NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
318
+ convertSingleTxBlockRootRollupInputsToWitnessMap,
319
+ convertSingleTxBlockRootRollupOutputsFromWitnessMap,
320
+ );
321
+
322
+ const verificationKey = await this.getVerificationKeyDataForCircuit('SingleTxBlockRootRollupArtifact');
323
+
324
+ await this.verifyProof('SingleTxBlockRootRollupArtifact', proof.binaryProof);
325
+
326
+ return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
327
+ }
328
+
316
329
  /**
317
330
  * Simulates the empty block root rollup circuit from its inputs.
318
331
  * @param input - Inputs to the circuit.
@@ -387,61 +400,6 @@ export class BBNativeRollupProver implements ServerCircuitProver {
387
400
  return makePublicInputsAndRecursiveProof(circuitOutput, recursiveProof, verificationKey);
388
401
  }
389
402
 
390
- public async getEmptyPrivateKernelProof(
391
- inputs: PrivateKernelEmptyInputData,
392
- ): Promise<
393
- PublicInputsAndRecursiveProof<KernelCircuitPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
394
- > {
395
- const emptyNested = await this.getEmptyNestedProof();
396
- const emptyPrivateKernelProof = await this.getEmptyPrivateKernelProofFromEmptyNested(
397
- PrivateKernelEmptyInputs.from({
398
- ...inputs,
399
- emptyNested,
400
- }),
401
- );
402
-
403
- return emptyPrivateKernelProof;
404
- }
405
-
406
- private async getEmptyNestedProof(): Promise<EmptyNestedData> {
407
- const inputs = new EmptyNestedCircuitInputs();
408
- const { proof } = await this.createRecursiveProof(
409
- inputs,
410
- 'EmptyNestedArtifact',
411
- RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
412
- (nothing: any) => abiEncode(ServerCircuitArtifacts.EmptyNestedArtifact.abi as Abi, { _inputs: nothing as any }),
413
- () => new EmptyNestedCircuitInputs(),
414
- );
415
-
416
- const verificationKey = await this.getVerificationKeyDataForCircuit('EmptyNestedArtifact');
417
- await this.verifyProof('EmptyNestedArtifact', proof.binaryProof);
418
- // logger.debug(`EmptyNestedData proof size: ${proof.proof.length}`);
419
- // logger.debug(`EmptyNestedData proof: ${proof.proof}`);
420
- // logger.debug(`EmptyNestedData vk size: ${verificationKey.keyAsFields.key.length}`);
421
- // logger.debug(`EmptyNestedData vk: ${verificationKey.keyAsFields.key}`);
422
-
423
- return new EmptyNestedData(proof, verificationKey.keyAsFields);
424
- }
425
-
426
- private async getEmptyPrivateKernelProofFromEmptyNested(
427
- inputs: PrivateKernelEmptyInputs,
428
- ): Promise<
429
- PublicInputsAndRecursiveProof<KernelCircuitPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
430
- > {
431
- const { circuitOutput, proof } = await this.createRecursiveProof(
432
- inputs,
433
- 'PrivateKernelEmptyArtifact',
434
- NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
435
- convertPrivateKernelEmptyInputsToWitnessMap,
436
- convertPrivateKernelEmptyOutputsFromWitnessMap,
437
- );
438
- //info(`proof: ${proof.proof}`);
439
- const verificationKey = ProtocolCircuitVks['PrivateKernelEmptyArtifact'];
440
- await this.verifyProof('PrivateKernelEmptyArtifact', proof.binaryProof);
441
-
442
- return makePublicInputsAndRecursiveProof(circuitOutput, proof, verificationKey);
443
- }
444
-
445
403
  private async generateProofWithBB<
446
404
  Input extends { toBuffer: () => Buffer },
447
405
  Output extends { toBuffer: () => Buffer },
@@ -1,3 +1,3 @@
1
1
  export * from './bb_prover.js';
2
- export * from './bb_private_kernel_prover.js';
2
+ export * from './bb_native_private_kernel_prover.js';
3
3
  export * from './client_ivc_proof_utils.js';
package/src/stats.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { CircuitName } from '@aztec/circuit-types/stats';
2
- import { type ClientProtocolArtifact, type ServerProtocolArtifact } from '@aztec/noir-protocol-circuits-types';
2
+ import { type ProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
3
3
 
4
- export function mapProtocolArtifactNameToCircuitName(
5
- artifact: ServerProtocolArtifact | ClientProtocolArtifact,
6
- ): CircuitName {
4
+ export function mapProtocolArtifactNameToCircuitName(artifact: ProtocolArtifact): CircuitName {
7
5
  switch (artifact) {
8
6
  case 'BaseParityArtifact':
9
7
  return 'base-parity';
@@ -17,6 +15,8 @@ export function mapProtocolArtifactNameToCircuitName(
17
15
  return 'merge-rollup';
18
16
  case 'BlockRootRollupArtifact':
19
17
  return 'block-root-rollup';
18
+ case 'SingleTxBlockRootRollupArtifact':
19
+ return 'single-tx-block-root-rollup';
20
20
  case 'EmptyBlockRootRollupArtifact':
21
21
  return 'empty-block-root-rollup';
22
22
  case 'BlockMergeRollupArtifact':
@@ -31,10 +31,6 @@ export function mapProtocolArtifactNameToCircuitName(
31
31
  return 'private-kernel-tail';
32
32
  case 'PrivateKernelTailToPublicArtifact':
33
33
  return 'private-kernel-tail-to-public';
34
- case 'EmptyNestedArtifact':
35
- return 'empty-nested';
36
- case 'PrivateKernelEmptyArtifact':
37
- return 'private-kernel-empty';
38
34
  default: {
39
35
  if (artifact.startsWith('PrivateKernelReset')) {
40
36
  return 'private-kernel-reset';
@@ -44,16 +40,15 @@ export function mapProtocolArtifactNameToCircuitName(
44
40
  }
45
41
  }
46
42
 
47
- export function isProtocolArtifactRecursive(artifact: ServerProtocolArtifact | ClientProtocolArtifact): boolean {
43
+ export function isProtocolArtifactRecursive(artifact: ProtocolArtifact): boolean {
48
44
  switch (artifact) {
49
- case 'EmptyNestedArtifact':
50
- case 'PrivateKernelEmptyArtifact':
51
45
  case 'BaseParityArtifact':
52
46
  case 'RootParityArtifact':
53
47
  case 'PrivateBaseRollupArtifact':
54
48
  case 'PublicBaseRollupArtifact':
55
49
  case 'MergeRollupArtifact':
56
50
  case 'BlockRootRollupArtifact':
51
+ case 'SingleTxBlockRootRollupArtifact':
57
52
  case 'EmptyBlockRootRollupArtifact':
58
53
  case 'BlockMergeRollupArtifact':
59
54
  case 'RootRollupArtifact':