@aztec/ivc-integration 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107

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 (69) hide show
  1. package/artifacts/app_creator.json +190 -1
  2. package/artifacts/app_reader.json +190 -1
  3. package/artifacts/keys/mock_hiding.ivc.vk +0 -0
  4. package/artifacts/keys/mock_rollup_root_verifier.sol +92 -92
  5. package/artifacts/mock_hiding.json +224 -1
  6. package/artifacts/mock_private_kernel_init.json +287 -1
  7. package/artifacts/mock_private_kernel_inner.json +337 -1
  8. package/artifacts/mock_private_kernel_reset.json +273 -1
  9. package/artifacts/mock_private_kernel_tail.json +242 -1
  10. package/artifacts/mock_rollup_root.json +241 -1
  11. package/artifacts/mock_rollup_tx_base_private.json +232 -0
  12. package/artifacts/mock_rollup_tx_base_public.json +1394 -0
  13. package/artifacts/mock_rollup_tx_merge.json +297 -0
  14. package/dest/bb_working_directory.d.ts +1 -1
  15. package/dest/index.d.ts +1 -1
  16. package/dest/prove_native.d.ts +7 -7
  17. package/dest/prove_native.d.ts.map +1 -1
  18. package/dest/prove_native.js +24 -44
  19. package/dest/scripts/generate_declaration_files.d.ts +1 -1
  20. package/dest/scripts/generate_declaration_files.js +0 -6
  21. package/dest/scripts/generate_ts_from_abi.d.ts +1 -1
  22. package/dest/scripts/generate_ts_from_abi.js +3 -3
  23. package/dest/serve.d.ts +1 -1
  24. package/dest/serve.js +34 -17
  25. package/dest/types/index.d.ts +27 -28
  26. package/dest/types/index.d.ts.map +1 -1
  27. package/dest/types/index.js +8 -9
  28. package/dest/witgen.d.ts +52 -22
  29. package/dest/witgen.d.ts.map +1 -1
  30. package/dest/witgen.js +48 -47
  31. package/package.json +23 -25
  32. package/src/prove_native.ts +27 -65
  33. package/src/scripts/generate_declaration_files.ts +0 -8
  34. package/src/scripts/generate_ts_from_abi.ts +3 -3
  35. package/src/serve.ts +43 -16
  36. package/src/types/index.ts +32 -33
  37. package/src/witgen.ts +60 -34
  38. package/artifacts/keys/app_creator.vk.data.d.json.ts +0 -2
  39. package/artifacts/keys/app_creator.vk.data.json +0 -132
  40. package/artifacts/keys/app_reader.vk.data.d.json.ts +0 -2
  41. package/artifacts/keys/app_reader.vk.data.json +0 -132
  42. package/artifacts/keys/mock_hiding.vk.data.d.json.ts +0 -2
  43. package/artifacts/keys/mock_hiding.vk.data.json +0 -132
  44. package/artifacts/keys/mock_private_kernel_init.vk.data.d.json.ts +0 -2
  45. package/artifacts/keys/mock_private_kernel_init.vk.data.json +0 -132
  46. package/artifacts/keys/mock_private_kernel_inner.vk.data.d.json.ts +0 -2
  47. package/artifacts/keys/mock_private_kernel_inner.vk.data.json +0 -132
  48. package/artifacts/keys/mock_private_kernel_reset.vk.data.d.json.ts +0 -2
  49. package/artifacts/keys/mock_private_kernel_reset.vk.data.json +0 -132
  50. package/artifacts/keys/mock_private_kernel_tail.vk.data.d.json.ts +0 -2
  51. package/artifacts/keys/mock_private_kernel_tail.vk.data.json +0 -132
  52. package/artifacts/keys/mock_rollup_base_private.vk.data.d.json.ts +0 -2
  53. package/artifacts/keys/mock_rollup_base_private.vk.data.json +0 -120
  54. package/artifacts/keys/mock_rollup_base_public.vk.data.d.json.ts +0 -2
  55. package/artifacts/keys/mock_rollup_base_public.vk.data.json +0 -120
  56. package/artifacts/keys/mock_rollup_merge.vk.data.d.json.ts +0 -2
  57. package/artifacts/keys/mock_rollup_merge.vk.data.json +0 -120
  58. package/artifacts/keys/mock_rollup_root.vk.data.d.json.ts +0 -2
  59. package/artifacts/keys/mock_rollup_root.vk.data.json +0 -64
  60. package/artifacts/mock_rollup_base_private.json +0 -1
  61. package/artifacts/mock_rollup_base_public.json +0 -1
  62. package/artifacts/mock_rollup_merge.json +0 -1
  63. package/dest/prove_wasm.d.ts +0 -4
  64. package/dest/prove_wasm.d.ts.map +0 -1
  65. package/dest/prove_wasm.js +0 -36
  66. package/src/prove_wasm.ts +0 -57
  67. /package/artifacts/{mock_rollup_base_private.d.json.ts → mock_rollup_tx_base_private.d.json.ts} +0 -0
  68. /package/artifacts/{mock_rollup_base_public.d.json.ts → mock_rollup_tx_base_public.d.json.ts} +0 -0
  69. /package/artifacts/{mock_rollup_merge.d.json.ts → mock_rollup_tx_merge.d.json.ts} +0 -0
@@ -4,70 +4,50 @@ import {
4
4
  PUBLIC_INPUTS_FILENAME,
5
5
  type UltraHonkFlavor,
6
6
  VK_FILENAME,
7
- executeBbClientIvcProof,
8
- extractVkData,
9
7
  generateAvmProof,
10
8
  generateProof,
11
- generateTubeProof,
12
- readClientIVCProofFromOutputDirectory,
13
- readProofAsFields,
9
+ readProofsFromOutputDirectory,
14
10
  verifyAvmProof,
15
11
  verifyProof,
16
12
  } from '@aztec/bb-prover';
17
13
  import {
18
14
  AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
19
15
  AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED,
16
+ CHONK_PROOF_LENGTH,
17
+ HIDING_KERNEL_IO_PUBLIC_INPUTS_SIZE,
20
18
  NESTED_RECURSIVE_PROOF_LENGTH,
21
19
  RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
22
- TUBE_PROOF_LENGTH,
23
20
  } from '@aztec/constants';
24
- import { Fr } from '@aztec/foundation/fields';
21
+ import { Fr } from '@aztec/foundation/curves/bn254';
25
22
  import type { Logger } from '@aztec/foundation/log';
26
23
  import { BufferReader } from '@aztec/foundation/serialize';
27
24
  import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
28
25
  import { makeProofAndVerificationKey } from '@aztec/stdlib/interfaces/server';
29
26
  import type { NoirCompiledCircuit } from '@aztec/stdlib/noir';
30
- import type { ClientIvcProof, Proof } from '@aztec/stdlib/proofs';
31
- import { enhanceProofWithPiValidationFlag } from '@aztec/stdlib/rollup';
32
- import { VerificationKeyAsFields, type VerificationKeyData } from '@aztec/stdlib/vks';
27
+ import { Proof, RecursiveProof } from '@aztec/stdlib/proofs';
28
+ import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
33
29
 
34
30
  import * as fs from 'fs/promises';
35
- import { Encoder } from 'msgpackr';
36
31
  import * as path from 'path';
37
32
 
38
- export async function proveClientIVC(
39
- bbBinaryPath: string,
40
- bbWorkingDirectory: string,
41
- witnessStack: Uint8Array[],
42
- bytecodes: string[],
43
- vks: string[],
44
- logger: Logger,
45
- ): Promise<ClientIvcProof> {
46
- const stepToStruct = (bytecode: string, index: number) => {
47
- return {
48
- bytecode: Buffer.from(bytecode, 'base64'),
49
- witness: witnessStack[index],
50
- vk: Buffer.from(vks[index], 'hex'),
51
- functionName: `unknown_${index}`,
52
- };
53
- };
54
- const encoded = new Encoder({ useRecords: false }).pack(bytecodes.map(stepToStruct));
55
- const ivcInputsPath = path.join(bbWorkingDirectory, 'ivc-inputs.msgpack');
56
- await fs.writeFile(ivcInputsPath, encoded);
33
+ export async function proofBytesToRecursiveProof(
34
+ proofAsFields: Uint8Array[],
35
+ vkBytes: Uint8Array,
36
+ ): Promise<RecursiveProof<typeof CHONK_PROOF_LENGTH>> {
37
+ const vk = await VerificationKeyAsFields.fromFrBuffer(Buffer.from(vkBytes));
38
+ const numCustomPublicInputs = vk.numPublicInputs - HIDING_KERNEL_IO_PUBLIC_INPUTS_SIZE;
39
+ // Convert Uint8Array fields to Fr instances
40
+ const fields = proofAsFields.map(f => Fr.fromBuffer(Buffer.from(f)));
57
41
 
58
- const provingResult = await executeBbClientIvcProof(
59
- bbBinaryPath,
60
- bbWorkingDirectory,
61
- ivcInputsPath,
62
- logger.info,
63
- true,
64
- );
42
+ // Slice off custom public inputs from the beginning.
43
+ const fieldsWithoutPublicInputs = fields.slice(numCustomPublicInputs);
65
44
 
66
- if (provingResult.status === BB_RESULT.FAILURE) {
67
- throw new Error(provingResult.reason);
68
- }
45
+ // Convert fields to binary buffer
46
+ const proofBuffer = Buffer.concat(proofAsFields.slice(numCustomPublicInputs));
69
47
 
70
- return readClientIVCProofFromOutputDirectory(bbWorkingDirectory);
48
+ // Create Proof directly (not using fromBuffer which expects different format)
49
+ const proof = new Proof(proofBuffer, numCustomPublicInputs);
50
+ return new RecursiveProof(fieldsWithoutPublicInputs, proof, true, CHONK_PROOF_LENGTH);
71
51
  }
72
52
 
73
53
  async function verifyProofWithKey(
@@ -93,22 +73,6 @@ async function verifyProofWithKey(
93
73
  logger.info(`Successfully verified proof from key in ${result.durationMs} ms`);
94
74
  }
95
75
 
96
- export async function proveTube(pathToBB: string, workingDirectory: string, logger: Logger) {
97
- const tubeResult = await generateTubeProof(pathToBB, workingDirectory, workingDirectory.concat('/vk'), logger.info);
98
-
99
- if (tubeResult.status != BB_RESULT.SUCCESS) {
100
- throw new Error('Failed to prove tube');
101
- }
102
-
103
- const tubeVK = await extractVkData(tubeResult.vkDirectoryPath!);
104
- const tubeProof = await readProofAsFields(tubeResult.proofPath!, tubeVK, TUBE_PROOF_LENGTH, logger);
105
-
106
- // Sanity check the tube proof
107
- await verifyProofWithKey(pathToBB, workingDirectory, tubeVK, tubeProof.binaryProof, 'ultra_rollup_honk', logger);
108
-
109
- return makeProofAndVerificationKey(tubeProof, tubeVK);
110
- }
111
-
112
76
  async function proveRollupCircuit<T extends UltraHonkFlavor, ProofLength extends number>(
113
77
  name: string,
114
78
  pathToBB: string,
@@ -120,11 +84,13 @@ async function proveRollupCircuit<T extends UltraHonkFlavor, ProofLength extends
120
84
  proofLength: ProofLength,
121
85
  ) {
122
86
  await fs.writeFile(path.join(workingDirectory, 'witness.gz'), witness);
87
+ const vkBuffer = Buffer.from(circuit.verificationKey.bytes, 'hex');
123
88
  const proofResult = await generateProof(
124
89
  pathToBB,
125
90
  workingDirectory,
126
91
  name,
127
92
  Buffer.from(circuit.bytecode, 'base64'),
93
+ vkBuffer,
128
94
  path.join(workingDirectory, 'witness.gz'),
129
95
  flavor,
130
96
  logger,
@@ -134,8 +100,8 @@ async function proveRollupCircuit<T extends UltraHonkFlavor, ProofLength extends
134
100
  throw new Error(`Failed to generate proof for ${name} with flavor ${flavor}`);
135
101
  }
136
102
 
137
- const vk = await extractVkData(proofResult.vkDirectoryPath!);
138
- const proof = await readProofAsFields(proofResult.proofPath!, vk, proofLength, logger);
103
+ const vk = await VerificationKeyData.fromFrBuffer(vkBuffer);
104
+ const proof = await readProofsFromOutputDirectory(proofResult.proofPath!, vk, proofLength, logger);
139
105
 
140
106
  await verifyProofWithKey(pathToBB, workingDirectory, vk, proof.binaryProof, flavor, logger);
141
107
 
@@ -186,14 +152,13 @@ export async function proveAvm(
186
152
  avmCircuitInputs: AvmCircuitInputs,
187
153
  workingDirectory: string,
188
154
  logger: Logger,
189
- skipPublicInputsValidation: boolean = false,
190
155
  ): Promise<{
191
156
  vk: VerificationKeyAsFields;
192
157
  proof: Fr[];
193
158
  publicInputs: AvmCircuitPublicInputs;
194
159
  }> {
195
160
  // The paths for the barretenberg binary and the write path are hardcoded for now.
196
- const bbPath = path.resolve('../../barretenberg/cpp/build/bin/bb');
161
+ const bbPath = path.resolve('../../barretenberg/cpp/build/bin/bb-avm');
197
162
 
198
163
  // Then we prove.
199
164
  const proofRes = await generateAvmProof(bbPath, workingDirectory, avmCircuitInputs, logger);
@@ -253,11 +218,8 @@ export async function proveAvm(
253
218
  throw new Error(`AVM V2 proof verification failed: ${verificationResult.reason}`);
254
219
  }
255
220
 
256
- // TODO(#14234)[Unconditional PIs validation]: Remove next lines and return proof instead of proofWithPublicInputsValidationFlag
257
- const proofWithPublicInputsValidationFlag = enhanceProofWithPiValidationFlag(proof, skipPublicInputsValidation);
258
-
259
221
  return {
260
- proof: proofWithPublicInputsValidationFlag,
222
+ proof,
261
223
  vk: await VerificationKeyAsFields.fromKey(vk),
262
224
  publicInputs: avmCircuitInputs.publicInputs,
263
225
  };
@@ -9,11 +9,6 @@ const circuit: NoirCompiledCircuit;
9
9
  export = circuit;
10
10
  `;
11
11
 
12
- const vk = `\
13
- const vk: { keyAsBytes: string; keyAsFields: string[] };
14
- export = vk;
15
- `;
16
-
17
12
  async function generateDeclarationFor(target: string, content: string) {
18
13
  const files = await readdir(target);
19
14
  for (const file of files) {
@@ -28,6 +23,3 @@ async function generateDeclarationFor(target: string, content: string) {
28
23
 
29
24
  // Generate declaration files for contracts
30
25
  await generateDeclarationFor(fileURLToPath(new URL('../../artifacts', import.meta.url).href), contract);
31
-
32
- // Generate declaration files for vks
33
- await generateDeclarationFor(fileURLToPath(new URL('../../artifacts/keys', import.meta.url).href), vk);
@@ -15,9 +15,9 @@ const circuits = [
15
15
  'mock_private_kernel_inner',
16
16
  'mock_private_kernel_reset',
17
17
  'mock_private_kernel_tail',
18
- 'mock_rollup_base_public',
19
- 'mock_rollup_base_private',
20
- 'mock_rollup_merge',
18
+ 'mock_rollup_tx_base_public',
19
+ 'mock_rollup_tx_base_private',
20
+ 'mock_rollup_tx_merge',
21
21
  'mock_rollup_root',
22
22
  ];
23
23
 
package/src/serve.ts CHANGED
@@ -1,12 +1,27 @@
1
+ import { AztecClientBackend, Barretenberg } from '@aztec/bb.js';
1
2
  import { createLogger } from '@aztec/foundation/log';
2
3
 
3
- import { proveThenVerifyAztecClient } from './prove_wasm.js';
4
- import { generateTestingIVCStack } from './witgen.js';
4
+ import {
5
+ MockAppCreatorCircuit,
6
+ MockHidingCircuit,
7
+ MockPrivateKernelInitCircuit,
8
+ MockPrivateKernelTailCircuit,
9
+ generateTestingIVCStack,
10
+ } from './witgen.js';
5
11
 
6
12
  const logger = createLogger('aztec:ivc-test');
7
13
 
8
14
  /* eslint-disable no-console */
9
15
 
16
+ // Expose APIs on window for browser testing
17
+ (window as any).Barretenberg = Barretenberg;
18
+ (window as any).AztecClientBackend = AztecClientBackend;
19
+ (window as any).generateTestingIVCStack = generateTestingIVCStack;
20
+ (window as any).MockAppCreatorCircuit = MockAppCreatorCircuit;
21
+ (window as any).MockPrivateKernelInitCircuit = MockPrivateKernelInitCircuit;
22
+ (window as any).MockPrivateKernelTailCircuit = MockPrivateKernelTailCircuit;
23
+ (window as any).MockHidingCircuit = MockHidingCircuit;
24
+
10
25
  // Function to set up the output element and redirect all console output
11
26
  function setupConsoleOutput() {
12
27
  const container = document.createElement('div');
@@ -78,20 +93,32 @@ function setupConsoleOutput() {
78
93
  };
79
94
  }
80
95
 
81
- (window as any).proveThenVerifyAztecClient = proveThenVerifyAztecClient;
96
+ // Only set up the interactive UI if this is not being used for automated testing
97
+ if (!document.getElementById('status')) {
98
+ document.addEventListener('DOMContentLoaded', function () {
99
+ setupConsoleOutput(); // Initialize console output capture
100
+
101
+ const button = document.createElement('button');
102
+ button.innerText = 'Run Test';
103
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
104
+ button.addEventListener('click', async () => {
105
+ logger.info(`generating circuit and witness...`);
106
+ const [bytecodes, witnessStack, _publicInputs, precomputedVks] = await generateTestingIVCStack(1, 0);
107
+ logger.info(`done. proving and verifying...`);
108
+
109
+ const barretenberg = await Barretenberg.initSingleton({
110
+ threads: 16,
111
+ logger: (m: string) => logger.info(m),
112
+ });
113
+
114
+ const backend = new AztecClientBackend(bytecodes, barretenberg);
115
+ const [, proof, vk] = await backend.prove(witnessStack, precomputedVks);
116
+ const verified = await backend.verify(proof, vk);
82
117
 
83
- document.addEventListener('DOMContentLoaded', function () {
84
- setupConsoleOutput(); // Initialize console output capture
118
+ logger.info(`verified? ${verified}`);
85
119
 
86
- const button = document.createElement('button');
87
- button.innerText = 'Run Test';
88
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
89
- button.addEventListener('click', async () => {
90
- logger.info(`generating circuit and witness...`);
91
- const [bytecodes, witnessStack, _publicInputs, precomputedVks] = await generateTestingIVCStack(1, 0);
92
- logger.info(`done. proving and verifying...`);
93
- const verified = await proveThenVerifyAztecClient(bytecodes, witnessStack, precomputedVks);
94
- logger.info(`verified? ${verified}`);
120
+ await Barretenberg.destroySingleton();
121
+ });
122
+ document.body.appendChild(button);
95
123
  });
96
- document.body.appendChild(button);
97
- });
124
+ }
@@ -37,19 +37,21 @@ export type PrivateKernelPublicInputs = {
37
37
  read_requests: FixedLengthArray<Field, 4>;
38
38
  }
39
39
 
40
- export type TubeData = {
40
+ export type ChonkProofData = {
41
41
  public_inputs: KernelPublicInputs;
42
- proof: FixedLengthArray<Field, 535>;
43
- vk_data: VerificationKey<115>;
42
+ proof: FixedLengthArray<Field, 1963>;
43
+ vk_data: VerificationKey<127>;
44
44
  }
45
45
 
46
46
  export type AvmCircuitPublicInputs = {
47
47
  global_variables: GlobalVariables;
48
+ protocol_contracts: ProtocolContracts;
48
49
  start_tree_snapshots: TreeSnapshots;
49
50
  start_gas_used: Gas;
50
51
  gas_settings: GasSettings;
51
52
  effective_gas_fees: GasFees;
52
53
  fee_payer: AztecAddress;
54
+ prover_id: Field;
53
55
  public_call_request_array_lengths: PublicCallRequestArrayLengths;
54
56
  public_setup_call_requests: FixedLengthArray<PublicCallRequest, 32>;
55
57
  public_app_logic_call_requests: FixedLengthArray<PublicCallRequest, 32>;
@@ -77,6 +79,10 @@ export type GlobalVariables = {
77
79
  gas_fees: GasFees;
78
80
  }
79
81
 
82
+ export type ProtocolContracts = {
83
+ derived_addresses: FixedLengthArray<AztecAddress, 11>;
84
+ }
85
+
80
86
  export type TreeSnapshots = {
81
87
  l1_to_l2_message_tree: AppendOnlyTreeSnapshot;
82
88
  note_hash_tree: AppendOnlyTreeSnapshot;
@@ -134,7 +140,6 @@ export type AvmAccumulatedDataArrayLengths = {
134
140
  note_hashes: u32;
135
141
  nullifiers: u32;
136
142
  l2_to_l1_msgs: u32;
137
- public_logs: u32;
138
143
  public_data_writes: u32;
139
144
  }
140
145
 
@@ -142,7 +147,7 @@ export type AvmAccumulatedData = {
142
147
  note_hashes: FixedLengthArray<Field, 64>;
143
148
  nullifiers: FixedLengthArray<Field, 64>;
144
149
  l2_to_l1_msgs: FixedLengthArray<Scoped, 8>;
145
- public_logs: FixedLengthArray<PublicLog, 8>;
150
+ public_logs: PublicLogs;
146
151
  public_data_writes: FixedLengthArray<PublicDataWrite, 64>;
147
152
  }
148
153
 
@@ -152,7 +157,7 @@ export type EthAddress = {
152
157
 
153
158
  export type AppendOnlyTreeSnapshot = {
154
159
  root: Field;
155
- next_available_leaf_index: u32;
160
+ next_available_leaf_index: Field;
156
161
  }
157
162
 
158
163
  export type Scoped = {
@@ -160,9 +165,9 @@ export type Scoped = {
160
165
  contract_address: AztecAddress;
161
166
  }
162
167
 
163
- export type PublicLog = {
164
- log: Log;
165
- contract_address: AztecAddress;
168
+ export type PublicLogs = {
169
+ length: u32;
170
+ payload: FixedLengthArray<Field, 4096>;
166
171
  }
167
172
 
168
173
  export type PublicDataWrite = {
@@ -175,18 +180,13 @@ export type L2ToL1Message = {
175
180
  content: Field;
176
181
  }
177
182
 
178
- export type Log = {
179
- fields: FixedLengthArray<Field, 13>;
180
- length: u32;
181
- }
182
-
183
183
  export type RollupPublicInputs = {
184
184
  accumulated: u32;
185
185
  }
186
186
 
187
187
  export type PreviousRollupData = {
188
188
  base_or_merge_public_inputs: RollupPublicInputs;
189
- proof: FixedLengthArray<Field, 535>;
189
+ proof: FixedLengthArray<Field, 531>;
190
190
  vk: VerificationKey<115>;
191
191
  }
192
192
 
@@ -291,45 +291,44 @@ export async function MockPrivateKernelTail(prev_kernel_public_inputs: PrivateKe
291
291
  const { returnValue } = await program.execute(args, foreignCallHandler);
292
292
  return returnValue as KernelPublicInputs;
293
293
  }
294
- export type MockRollupBasePublicInputType = {
295
- tube_data: TubeData;
296
- verification_key: VerificationKey<1000>;
297
- proof: FixedLengthArray<Field, 20000>;
294
+ export type MockRollupTxBasePublicInputType = {
295
+ chonk_proof_data: ChonkProofData;
296
+ proof: FixedLengthArray<Field, 16200>;
298
297
  public_inputs: AvmCircuitPublicInputs;
299
298
  }
300
299
 
301
- export type MockRollupBasePublicReturnType = RollupPublicInputs;
300
+ export type MockRollupTxBasePublicReturnType = RollupPublicInputs;
302
301
 
303
302
 
304
- export async function MockRollupBasePublic(tube_data: TubeData, verification_key: VerificationKey<1000>, proof: FixedLengthArray<Field, 20000>, public_inputs: AvmCircuitPublicInputs, MockRollupBasePublic_circuit: CompiledCircuit, foreignCallHandler?: ForeignCallHandler): Promise<RollupPublicInputs> {
305
- const program = new Noir(MockRollupBasePublic_circuit);
306
- const args: InputMap = { tube_data, verification_key, proof, public_inputs };
303
+ export async function MockRollupTxBasePublic(chonk_proof_data: ChonkProofData, proof: FixedLengthArray<Field, 16200>, public_inputs: AvmCircuitPublicInputs, MockRollupTxBasePublic_circuit: CompiledCircuit, foreignCallHandler?: ForeignCallHandler): Promise<RollupPublicInputs> {
304
+ const program = new Noir(MockRollupTxBasePublic_circuit);
305
+ const args: InputMap = { chonk_proof_data, proof, public_inputs };
307
306
  const { returnValue } = await program.execute(args, foreignCallHandler);
308
307
  return returnValue as RollupPublicInputs;
309
308
  }
310
- export type MockRollupBasePrivateInputType = {
311
- tube_data: TubeData;
309
+ export type MockRollupTxBasePrivateInputType = {
310
+ chonk_proof_data: ChonkProofData;
312
311
  }
313
312
 
314
- export type MockRollupBasePrivateReturnType = RollupPublicInputs;
313
+ export type MockRollupTxBasePrivateReturnType = RollupPublicInputs;
315
314
 
316
315
 
317
- export async function MockRollupBasePrivate(tube_data: TubeData, MockRollupBasePrivate_circuit: CompiledCircuit, foreignCallHandler?: ForeignCallHandler): Promise<RollupPublicInputs> {
318
- const program = new Noir(MockRollupBasePrivate_circuit);
319
- const args: InputMap = { tube_data };
316
+ export async function MockRollupTxBasePrivate(chonk_proof_data: ChonkProofData, MockRollupTxBasePrivate_circuit: CompiledCircuit, foreignCallHandler?: ForeignCallHandler): Promise<RollupPublicInputs> {
317
+ const program = new Noir(MockRollupTxBasePrivate_circuit);
318
+ const args: InputMap = { chonk_proof_data };
320
319
  const { returnValue } = await program.execute(args, foreignCallHandler);
321
320
  return returnValue as RollupPublicInputs;
322
321
  }
323
- export type MockRollupMergeInputType = {
322
+ export type MockRollupTxMergeInputType = {
324
323
  a: PreviousRollupData;
325
324
  b: PreviousRollupData;
326
325
  }
327
326
 
328
- export type MockRollupMergeReturnType = RollupPublicInputs;
327
+ export type MockRollupTxMergeReturnType = RollupPublicInputs;
329
328
 
330
329
 
331
- export async function MockRollupMerge(a: PreviousRollupData, b: PreviousRollupData, MockRollupMerge_circuit: CompiledCircuit, foreignCallHandler?: ForeignCallHandler): Promise<RollupPublicInputs> {
332
- const program = new Noir(MockRollupMerge_circuit);
330
+ export async function MockRollupTxMerge(a: PreviousRollupData, b: PreviousRollupData, MockRollupTxMerge_circuit: CompiledCircuit, foreignCallHandler?: ForeignCallHandler): Promise<RollupPublicInputs> {
331
+ const program = new Noir(MockRollupTxMerge_circuit);
333
332
  const args: InputMap = { a, b };
334
333
  const { returnValue } = await program.execute(args, foreignCallHandler);
335
334
  return returnValue as RollupPublicInputs;
package/src/witgen.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  MEGA_VK_LENGTH_IN_FIELDS,
5
5
  } from '@aztec/constants';
6
6
  import { padArrayEnd } from '@aztec/foundation/collection';
7
- import { Fr } from '@aztec/foundation/fields';
7
+ import { Fr } from '@aztec/foundation/curves/bn254';
8
8
  import { applyStringFormatting, createLogger } from '@aztec/foundation/log';
9
9
  import { type ForeignCallInput, type ForeignCallOutput, Noir } from '@aztec/noir-noir_js';
10
10
  import type { AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
@@ -12,29 +12,19 @@ import type { RecursiveProof } from '@aztec/stdlib/proofs';
12
12
  import { VerificationKeyAsFields } from '@aztec/stdlib/vks';
13
13
 
14
14
  import { strict as assert } from 'assert';
15
+ import { ungzip } from 'pako';
15
16
 
16
17
  import MockAppCreatorCircuit from '../artifacts/app_creator.json' with { type: 'json' };
17
18
  import MockAppReaderCircuit from '../artifacts/app_reader.json' with { type: 'json' };
18
- import MockAppCreatorVk from '../artifacts/keys/app_creator.vk.data.json' with { type: 'json' };
19
- import MockAppReaderVk from '../artifacts/keys/app_reader.vk.data.json' with { type: 'json' };
20
- import MockHidingVk from '../artifacts/keys/mock_hiding.vk.data.json' with { type: 'json' };
21
- import MockPrivateKernelInitVk from '../artifacts/keys/mock_private_kernel_init.vk.data.json' with { type: 'json' };
22
- import MockPrivateKernelInnerVk from '../artifacts/keys/mock_private_kernel_inner.vk.data.json' with { type: 'json' };
23
- import MockPrivateKernelResetVk from '../artifacts/keys/mock_private_kernel_reset.vk.data.json' with { type: 'json' };
24
- import MockPrivateKernelTailVk from '../artifacts/keys/mock_private_kernel_tail.vk.data.json' with { type: 'json' };
25
- import MockRollupBasePrivateVk from '../artifacts/keys/mock_rollup_base_private.vk.data.json' with { type: 'json' };
26
- import MockRollupBasePublicVk from '../artifacts/keys/mock_rollup_base_public.vk.data.json' with { type: 'json' };
27
- import MockRollupMergeVk from '../artifacts/keys/mock_rollup_merge.vk.data.json' with { type: 'json' };
28
- import MockRollupRootVk from '../artifacts/keys/mock_rollup_root.vk.data.json' with { type: 'json' };
29
19
  import MockHidingCircuit from '../artifacts/mock_hiding.json' with { type: 'json' };
30
20
  import MockPrivateKernelInitCircuit from '../artifacts/mock_private_kernel_init.json' with { type: 'json' };
31
21
  import MockPrivateKernelInnerCircuit from '../artifacts/mock_private_kernel_inner.json' with { type: 'json' };
32
22
  import MockPrivateKernelResetCircuit from '../artifacts/mock_private_kernel_reset.json' with { type: 'json' };
33
23
  import MockPrivateKernelTailCircuit from '../artifacts/mock_private_kernel_tail.json' with { type: 'json' };
34
- import MockRollupBasePrivateCircuit from '../artifacts/mock_rollup_base_private.json' with { type: 'json' };
35
- import MockRollupBasePublicCircuit from '../artifacts/mock_rollup_base_public.json' with { type: 'json' };
36
- import MockRollupMergeCircuit from '../artifacts/mock_rollup_merge.json' with { type: 'json' };
37
24
  import MockRollupRootCircuit from '../artifacts/mock_rollup_root.json' with { type: 'json' };
25
+ import MockRollupTxBasePrivateCircuit from '../artifacts/mock_rollup_tx_base_private.json' with { type: 'json' };
26
+ import MockRollupTxBasePublicCircuit from '../artifacts/mock_rollup_tx_base_public.json' with { type: 'json' };
27
+ import MockRollupTxMergeCircuit from '../artifacts/mock_rollup_tx_merge.json' with { type: 'json' };
38
28
  import type {
39
29
  AppCreatorInputType,
40
30
  AppPublicInputs,
@@ -46,15 +36,36 @@ import type {
46
36
  MockPrivateKernelInnerInputType,
47
37
  MockPrivateKernelResetInputType,
48
38
  MockPrivateKernelTailInputType,
49
- MockRollupBasePrivateInputType,
50
- MockRollupBasePublicInputType,
51
- MockRollupMergeInputType,
52
39
  MockRollupRootInputType,
40
+ MockRollupTxBasePrivateInputType,
41
+ MockRollupTxBasePublicInputType,
42
+ MockRollupTxMergeInputType,
53
43
  PrivateKernelPublicInputs,
54
44
  RollupPublicInputs,
55
45
  VerificationKey,
56
46
  } from './types/index.js';
57
47
 
48
+ // Helper to extract VK from circuit artifact
49
+ function extractVkFromCircuit(circuit: any) {
50
+ return {
51
+ keyAsBytes: circuit.verificationKey.bytes,
52
+ keyAsFields: circuit.verificationKey.fields,
53
+ };
54
+ }
55
+
56
+ // Extract VKs from circuit artifacts
57
+ const MockAppCreatorVk = extractVkFromCircuit(MockAppCreatorCircuit);
58
+ const MockAppReaderVk = extractVkFromCircuit(MockAppReaderCircuit);
59
+ const MockPrivateKernelInitVk = extractVkFromCircuit(MockPrivateKernelInitCircuit);
60
+ const MockPrivateKernelInnerVk = extractVkFromCircuit(MockPrivateKernelInnerCircuit);
61
+ const MockPrivateKernelResetVk = extractVkFromCircuit(MockPrivateKernelResetCircuit);
62
+ const MockPrivateKernelTailVk = extractVkFromCircuit(MockPrivateKernelTailCircuit);
63
+ const MockHidingVk = extractVkFromCircuit(MockHidingCircuit);
64
+ const MockRollupTxBasePrivateVk = extractVkFromCircuit(MockRollupTxBasePrivateCircuit);
65
+ const MockRollupTxBasePublicVk = extractVkFromCircuit(MockRollupTxBasePublicCircuit);
66
+ const MockRollupTxMergeVk = extractVkFromCircuit(MockRollupTxMergeCircuit);
67
+ const MockRollupRootVk = extractVkFromCircuit(MockRollupRootCircuit);
68
+
58
69
  // Re export the circuit jsons
59
70
  export {
60
71
  MockAppCreatorCircuit,
@@ -70,12 +81,12 @@ export {
70
81
  MockPrivateKernelTailCircuit,
71
82
  MockHidingCircuit,
72
83
  MockPrivateKernelTailVk,
73
- MockRollupBasePrivateCircuit,
74
- MockRollupBasePrivateVk,
75
- MockRollupBasePublicCircuit,
76
- MockRollupBasePublicVk,
77
- MockRollupMergeCircuit,
78
- MockRollupMergeVk,
84
+ MockRollupTxBasePrivateCircuit,
85
+ MockRollupTxBasePrivateVk,
86
+ MockRollupTxBasePublicCircuit,
87
+ MockRollupTxBasePublicVk,
88
+ MockRollupTxMergeCircuit,
89
+ MockRollupTxMergeVk,
79
90
  MockRollupRootCircuit,
80
91
  MockRollupRootVk,
81
92
  };
@@ -192,9 +203,9 @@ export async function witnessGenMockHidingCircuit(
192
203
  }
193
204
 
194
205
  export async function witnessGenMockPublicBaseCircuit(
195
- args: MockRollupBasePublicInputType,
206
+ args: MockRollupTxBasePublicInputType,
196
207
  ): Promise<WitnessGenResult<RollupPublicInputs>> {
197
- const program = new Noir(MockRollupBasePublicCircuit);
208
+ const program = new Noir(MockRollupTxBasePublicCircuit);
198
209
  const { witness, returnValue } = await program.execute(args, foreignCallHandler);
199
210
  return {
200
211
  witness,
@@ -202,10 +213,10 @@ export async function witnessGenMockPublicBaseCircuit(
202
213
  };
203
214
  }
204
215
 
205
- export async function witnessGenMockRollupBasePrivateCircuit(
206
- args: MockRollupBasePrivateInputType,
216
+ export async function witnessGenMockRollupTxBasePrivateCircuit(
217
+ args: MockRollupTxBasePrivateInputType,
207
218
  ): Promise<WitnessGenResult<RollupPublicInputs>> {
208
- const program = new Noir(MockRollupBasePrivateCircuit);
219
+ const program = new Noir(MockRollupTxBasePrivateCircuit);
209
220
  const { witness, returnValue } = await program.execute(args, foreignCallHandler);
210
221
  return {
211
222
  witness,
@@ -213,10 +224,10 @@ export async function witnessGenMockRollupBasePrivateCircuit(
213
224
  };
214
225
  }
215
226
 
216
- export async function witnessGenMockRollupMergeCircuit(
217
- args: MockRollupMergeInputType,
227
+ export async function witnessGenMockRollupTxMergeCircuit(
228
+ args: MockRollupTxMergeInputType,
218
229
  ): Promise<WitnessGenResult<RollupPublicInputs>> {
219
- const program = new Noir(MockRollupMergeCircuit);
230
+ const program = new Noir(MockRollupTxMergeCircuit);
220
231
  const { witness, returnValue } = await program.execute(args, foreignCallHandler);
221
232
  return {
222
233
  witness,
@@ -241,7 +252,7 @@ export async function generateTestingIVCStack(
241
252
  // A call to the reader app creates 1 read request. A reset kernel will be run if there are 2 read requests in the
242
253
  // public inputs. All read requests must be cleared before running the tail kernel.
243
254
  numReaderAppCalls: number,
244
- ): Promise<[string[], Uint8Array[], KernelPublicInputs, string[]]> {
255
+ ): Promise<[Uint8Array[], Uint8Array[], KernelPublicInputs, Uint8Array[]]> {
245
256
  if (numCreatorAppCalls > 2) {
246
257
  throw new Error('The creator app can only be called at most twice.');
247
258
  }
@@ -358,7 +369,22 @@ export async function generateTestingIVCStack(
358
369
  bytecodes.push(MockHidingCircuit.bytecode);
359
370
  vks.push(MockHidingVk.keyAsBytes);
360
371
 
361
- return [bytecodes, witnessStack, hidingWitnessGenResult.publicInputs, vks];
372
+ function base64ToUint8Array(base64: string): Uint8Array {
373
+ return Uint8Array.from(atob(base64), c => c.charCodeAt(0));
374
+ }
375
+ function hexToUint8Array(hex: string): Uint8Array {
376
+ const cleaned = hex.replace(/^0x/i, '');
377
+ const bytes = new Uint8Array(cleaned.length / 2);
378
+ for (let i = 0; i < bytes.length; i++) {
379
+ bytes[i] = parseInt(cleaned.slice(i * 2, i * 2 + 2), 16);
380
+ }
381
+ return bytes;
382
+ }
383
+ const rawBytecodes = bytecodes.map(base64ToUint8Array).map((arr: Uint8Array) => ungzip(arr));
384
+ const rawWitnessStack = witnessStack.map((arr: Uint8Array) => ungzip(arr));
385
+ const rawVks = vks.map(hexToUint8Array);
386
+
387
+ return [rawBytecodes, rawWitnessStack, hidingWitnessGenResult.publicInputs, rawVks];
362
388
  }
363
389
 
364
390
  export function mapRecursiveProofToNoir<N extends number>(proof: RecursiveProof<N>): FixedLengthArray<string, N> {
@@ -1,2 +0,0 @@
1
- const vk: { keyAsBytes: string; keyAsFields: string[] };
2
- export = vk;