@aztec/bb.js 0.86.0 → 0.87.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 (117) hide show
  1. package/dest/browser/barretenberg-threads.js +1 -1
  2. package/dest/browser/barretenberg.js +1 -1
  3. package/dest/browser/index.js +179 -345
  4. package/dest/browser/main.worker.js +116 -116
  5. package/dest/browser/thread.worker.js +116 -116
  6. package/dest/node/barretenberg/backend.d.ts +5 -40
  7. package/dest/node/barretenberg/backend.d.ts.map +1 -1
  8. package/dest/node/barretenberg/backend.js +28 -108
  9. package/dest/node/barretenberg/index.d.ts +1 -1
  10. package/dest/node/barretenberg/index.d.ts.map +1 -1
  11. package/dest/node/barretenberg/index.js +6 -6
  12. package/dest/node/barretenberg/verifier.d.ts +0 -2
  13. package/dest/node/barretenberg/verifier.d.ts.map +1 -1
  14. package/dest/node/barretenberg/verifier.js +2 -12
  15. package/dest/node/barretenberg_api/index.d.ts +7 -11
  16. package/dest/node/barretenberg_api/index.d.ts.map +1 -1
  17. package/dest/node/barretenberg_api/index.js +46 -74
  18. package/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
  19. package/dest/node/bigint-array/index.d.ts +1 -0
  20. package/dest/node/bigint-array/index.d.ts.map +1 -1
  21. package/dest/node/bindgen/mappings.js +2 -2
  22. package/dest/node/bindgen/typescript.js +1 -1
  23. package/dest/node/crs/net_crs.d.ts.map +1 -1
  24. package/dest/node/crs/net_crs.js +6 -7
  25. package/dest/node/crs/node/index.js +4 -4
  26. package/dest/node/index.d.ts +1 -1
  27. package/dest/node/index.d.ts.map +1 -1
  28. package/dest/node/index.js +2 -2
  29. package/dest/node/main.d.ts +0 -8
  30. package/dest/node/main.d.ts.map +1 -1
  31. package/dest/node/main.js +38 -244
  32. package/dest/node/proof/index.d.ts +1 -2
  33. package/dest/node/proof/index.d.ts.map +1 -1
  34. package/dest/node/proof/index.js +2 -9
  35. package/dest/node/serialize/buffer_reader.d.ts.map +1 -1
  36. package/dest/node/serialize/buffer_reader.js +1 -1
  37. package/dest/node/types/fields.d.ts +1 -0
  38. package/dest/node/types/fields.d.ts.map +1 -1
  39. package/dest/node/types/fields.js +1 -1
  40. package/dest/node/types/point.d.ts +1 -0
  41. package/dest/node/types/point.d.ts.map +1 -1
  42. package/dest/node/types/point.js +1 -1
  43. package/dest/node-cjs/barretenberg/backend.d.ts +5 -40
  44. package/dest/node-cjs/barretenberg/backend.d.ts.map +1 -1
  45. package/dest/node-cjs/barretenberg/backend.js +28 -109
  46. package/dest/node-cjs/barretenberg/index.d.ts +1 -1
  47. package/dest/node-cjs/barretenberg/index.d.ts.map +1 -1
  48. package/dest/node-cjs/barretenberg/index.js +6 -7
  49. package/dest/node-cjs/barretenberg/verifier.d.ts +0 -2
  50. package/dest/node-cjs/barretenberg/verifier.d.ts.map +1 -1
  51. package/dest/node-cjs/barretenberg/verifier.js +1 -11
  52. package/dest/node-cjs/barretenberg_api/index.d.ts +7 -11
  53. package/dest/node-cjs/barretenberg_api/index.d.ts.map +1 -1
  54. package/dest/node-cjs/barretenberg_api/index.js +45 -73
  55. package/dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
  56. package/dest/node-cjs/bigint-array/index.d.ts +1 -0
  57. package/dest/node-cjs/bigint-array/index.d.ts.map +1 -1
  58. package/dest/node-cjs/bindgen/mappings.js +2 -2
  59. package/dest/node-cjs/bindgen/typescript.js +1 -1
  60. package/dest/node-cjs/crs/net_crs.d.ts.map +1 -1
  61. package/dest/node-cjs/crs/net_crs.js +6 -7
  62. package/dest/node-cjs/crs/node/index.js +4 -4
  63. package/dest/node-cjs/index.d.ts +1 -1
  64. package/dest/node-cjs/index.d.ts.map +1 -1
  65. package/dest/node-cjs/index.js +2 -3
  66. package/dest/node-cjs/main.d.ts +0 -8
  67. package/dest/node-cjs/main.d.ts.map +1 -1
  68. package/dest/node-cjs/main.js +39 -253
  69. package/dest/node-cjs/proof/index.d.ts +1 -2
  70. package/dest/node-cjs/proof/index.d.ts.map +1 -1
  71. package/dest/node-cjs/proof/index.js +3 -11
  72. package/dest/node-cjs/serialize/buffer_reader.d.ts.map +1 -1
  73. package/dest/node-cjs/serialize/buffer_reader.js +1 -1
  74. package/dest/node-cjs/types/fields.d.ts +1 -0
  75. package/dest/node-cjs/types/fields.d.ts.map +1 -1
  76. package/dest/node-cjs/types/fields.js +1 -1
  77. package/dest/node-cjs/types/point.d.ts +1 -0
  78. package/dest/node-cjs/types/point.d.ts.map +1 -1
  79. package/dest/node-cjs/types/point.js +1 -1
  80. package/package.json +7 -8
  81. package/src/barretenberg/backend.ts +41 -159
  82. package/src/barretenberg/index.ts +10 -6
  83. package/src/barretenberg/verifier.ts +1 -13
  84. package/src/barretenberg_api/index.ts +74 -130
  85. package/src/bindgen/mappings.ts +1 -1
  86. package/src/bindgen/typescript.ts +4 -4
  87. package/src/crs/net_crs.ts +5 -6
  88. package/src/crs/node/index.ts +3 -3
  89. package/src/index.html +1 -1
  90. package/src/index.ts +0 -1
  91. package/src/main.ts +44 -279
  92. package/src/proof/index.ts +1 -13
  93. package/src/serialize/buffer_reader.ts +4 -1
  94. package/src/types/fields.ts +2 -2
  95. package/src/types/point.ts +4 -1
  96. package/dest/browser/733.655674bbbb79bdf168c4.js +0 -7
  97. package/dest/node/crs/node/ignition_files_crs.d.ts +0 -38
  98. package/dest/node/crs/node/ignition_files_crs.d.ts.map +0 -1
  99. package/dest/node/crs/node/ignition_files_crs.js +0 -65
  100. package/dest/node/examples/simple.rawtest.d.ts +0 -2
  101. package/dest/node/examples/simple.rawtest.d.ts.map +0 -1
  102. package/dest/node/examples/simple.rawtest.js +0 -30
  103. package/dest/node/examples/simple.test.d.ts +0 -2
  104. package/dest/node/examples/simple.test.d.ts.map +0 -1
  105. package/dest/node/examples/simple.test.js +0 -23
  106. package/dest/node-cjs/crs/node/ignition_files_crs.d.ts +0 -38
  107. package/dest/node-cjs/crs/node/ignition_files_crs.d.ts.map +0 -1
  108. package/dest/node-cjs/crs/node/ignition_files_crs.js +0 -69
  109. package/dest/node-cjs/examples/simple.rawtest.d.ts +0 -2
  110. package/dest/node-cjs/examples/simple.rawtest.d.ts.map +0 -1
  111. package/dest/node-cjs/examples/simple.rawtest.js +0 -33
  112. package/dest/node-cjs/examples/simple.test.d.ts +0 -2
  113. package/dest/node-cjs/examples/simple.test.d.ts.map +0 -1
  114. package/dest/node-cjs/examples/simple.test.js +0 -25
  115. package/src/crs/node/ignition_files_crs.ts +0 -74
  116. package/src/examples/simple.rawtest.ts +0 -38
  117. package/src/examples/simple.test.ts +0 -28
package/src/main.ts CHANGED
@@ -11,13 +11,6 @@ import { UltraHonkBackendOptions } from './barretenberg/backend.js';
11
11
  createDebug.log = console.error.bind(console);
12
12
  const debug = createDebug('bb.js');
13
13
 
14
- // Maximum circuit size for plonk we support in node and the browser is 2^19.
15
- // This is because both node and browser use barretenberg.wasm which has a 4GB memory limit.
16
- //
17
- // This is not a restriction in the bb binary and one should be
18
- // aware of this discrepancy, when creating proofs in bb versus
19
- // creating the same proofs in the node CLI.
20
- const MAX_ULTRAPLONK_CIRCUIT_SIZE_IN_WASM = 2 ** 19;
21
14
  const threads = +process.env.HARDWARE_CONCURRENCY! || undefined;
22
15
 
23
16
  function getBytecode(bytecodePath: string): Uint8Array {
@@ -63,39 +56,6 @@ async function computeCircuitSize(bytecodePath: string, recursive: boolean, honk
63
56
  return { total, subgroup };
64
57
  }
65
58
 
66
- async function initUltraPlonk(
67
- bytecodePath: string,
68
- recursive: boolean,
69
- crsPath: string,
70
- subgroupSizeOverride = -1,
71
- honkRecursion = false,
72
- ) {
73
- const api = await Barretenberg.new({ threads });
74
-
75
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice.
76
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraPlonk function
77
- const circuitSize = await getGatesUltra(bytecodePath, recursive, honkRecursion, api);
78
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin
79
- const subgroupSize = Math.max(subgroupSizeOverride, Math.pow(2, Math.ceil(Math.log2(circuitSize))));
80
-
81
- if (subgroupSize > MAX_ULTRAPLONK_CIRCUIT_SIZE_IN_WASM) {
82
- throw new Error(`Circuit size of ${subgroupSize} exceeds max supported of ${MAX_ULTRAPLONK_CIRCUIT_SIZE_IN_WASM}`);
83
- }
84
- debug(`Loading CRS for UltraPlonk with circuit-size=${circuitSize} subgroup-size=${subgroupSize}`);
85
- // Plus 1 needed! (Move +1 into Crs?)
86
- const crs = await Crs.new(subgroupSize + 1, crsPath);
87
-
88
- // // Important to init slab allocator as first thing, to ensure maximum memory efficiency for Plonk.
89
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/1129): Do slab allocator initialization?
90
- // await api.commonInitSlabAllocator(subgroupSize);
91
-
92
- // Load CRS into wasm global CRS state.
93
- // TODO: Make RawBuffer be default behavior, and have a specific Vector type for when wanting length prefixed.
94
- await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));
95
- const acirComposer = await api.acirNewAcirComposer(subgroupSize);
96
- return { api, acirComposer, circuitSize, subgroupSize };
97
- }
98
-
99
59
  async function initUltraHonk(bytecodePath: string, crsPath: string) {
100
60
  const api = await Barretenberg.new({ threads });
101
61
 
@@ -138,45 +98,10 @@ async function initLite(crsPath: string) {
138
98
  // Load CRS into wasm global CRS state.
139
99
  await api.srsInitSrs(new RawBuffer(crs.getG1Data()), crs.numPoints, new RawBuffer(crs.getG2Data()));
140
100
 
141
- const acirComposer = await api.acirNewAcirComposer(0);
142
- return { api, acirComposer };
143
- }
144
-
145
- export async function proveAndVerify(bytecodePath: string, recursive: boolean, witnessPath: string, crsPath: string) {
146
- /* eslint-disable camelcase */
147
- const acir_test = path.basename(process.cwd());
148
-
149
- const { api, acirComposer, circuitSize, subgroupSize } = await initUltraPlonk(bytecodePath, recursive, crsPath);
150
- try {
151
- debug(`Creating proof bytecode=${bytecodePath} witness=${witnessPath} recursive=${recursive}`);
152
- const bytecode = getBytecode(bytecodePath);
153
- const witness = getWitness(witnessPath);
154
-
155
- const pkTimer = new Timer();
156
- await api.acirInitProvingKey(acirComposer, bytecode, recursive);
157
- writeBenchmark('pk_construction_time', pkTimer.ms(), { acir_test, threads });
158
- writeBenchmark('gate_count', circuitSize, { acir_test, threads });
159
- writeBenchmark('subgroup_size', subgroupSize, { acir_test, threads });
160
-
161
- const proofTimer = new Timer();
162
- const proof = await api.acirCreateProof(acirComposer, bytecode, recursive, witness);
163
- writeBenchmark('proof_construction_time', proofTimer.ms(), { acir_test, threads });
164
-
165
- debug(`Proof complete. Verifying.`);
166
- const verified = await api.acirVerifyProof(acirComposer, proof);
167
- debug(`Verification ${verified ? 'successful' : 'failed'}`);
168
- return verified;
169
- } finally {
170
- await api.destroy();
171
- }
172
- /* eslint-enable camelcase */
101
+ return { api };
173
102
  }
174
103
 
175
- export async function proveAndVerifyUltraHonk(
176
- bytecodePath: string,
177
- witnessPath: string,
178
- crsPath: string,
179
- ) {
104
+ export async function proveAndVerifyUltraHonk(bytecodePath: string, witnessPath: string, crsPath: string) {
180
105
  /* eslint-disable camelcase */
181
106
  const { api } = await initUltraHonk(bytecodePath, crsPath);
182
107
  try {
@@ -191,13 +116,9 @@ export async function proveAndVerifyUltraHonk(
191
116
  /* eslint-enable camelcase */
192
117
  }
193
118
 
194
- export async function proveAndVerifyMegaHonk(
195
- bytecodePath: string,
196
- witnessPath: string,
197
- crsPath: string,
198
- ) {
119
+ export async function proveAndVerifyMegaHonk(bytecodePath: string, witnessPath: string, crsPath: string) {
199
120
  /* eslint-disable camelcase */
200
- const { api } = await initUltraPlonk(bytecodePath, false, crsPath);
121
+ const { api } = await initUltraHonk(bytecodePath, crsPath);
201
122
  try {
202
123
  const bytecode = getBytecode(bytecodePath);
203
124
  const witness = getWitness(witnessPath);
@@ -210,32 +131,6 @@ export async function proveAndVerifyMegaHonk(
210
131
  /* eslint-enable camelcase */
211
132
  }
212
133
 
213
- export async function prove(
214
- bytecodePath: string,
215
- recursive: boolean,
216
- witnessPath: string,
217
- crsPath: string,
218
- outputPath: string,
219
- ) {
220
- const { api, acirComposer } = await initUltraPlonk(bytecodePath, recursive, crsPath);
221
- try {
222
- debug(`Creating proof bytecode=${bytecodePath} witness=${witnessPath} recursive=${recursive}`);
223
- const bytecode = getBytecode(bytecodePath);
224
- const witness = getWitness(witnessPath);
225
- const proof = await api.acirCreateProof(acirComposer, bytecode, recursive, witness);
226
-
227
- if (outputPath === '-') {
228
- process.stdout.write(proof);
229
- debug(`Proof written to stdout`);
230
- } else {
231
- writeFileSync(outputPath, proof);
232
- debug(`Proof written to ${outputPath}`);
233
- }
234
- } finally {
235
- await api.destroy();
236
- }
237
- }
238
-
239
134
  export async function gateCountUltra(bytecodePath: string, recursive: boolean, honkRecursion: boolean) {
240
135
  const api = await Barretenberg.new({ threads: 1 });
241
136
  try {
@@ -253,37 +148,6 @@ export async function gateCountUltra(bytecodePath: string, recursive: boolean, h
253
148
  }
254
149
  }
255
150
 
256
- export async function verify(proofPath: string, vkPath: string, crsPath: string) {
257
- const { api, acirComposer } = await initLite(crsPath);
258
- try {
259
- await api.acirLoadVerificationKey(acirComposer, new RawBuffer(readFileSync(vkPath)));
260
- const verified = await api.acirVerifyProof(acirComposer, Uint8Array.from(readFileSync(proofPath)));
261
- debug(`Verification ${verified ? 'successful' : 'failed'}`);
262
- return verified;
263
- } finally {
264
- await api.destroy();
265
- }
266
- }
267
-
268
- export async function contract(outputPath: string, vkPath: string, crsPath: string) {
269
- const { api, acirComposer } = await initLite(crsPath);
270
- try {
271
- debug(`Creating verifier contract vk=${vkPath}`);
272
- await api.acirLoadVerificationKey(acirComposer, new RawBuffer(readFileSync(vkPath)));
273
- const contract = await api.acirGetSolidityVerifier(acirComposer);
274
-
275
- if (outputPath === '-') {
276
- process.stdout.write(contract);
277
- debug(`Solidity verifier contract written to stdout`);
278
- } else {
279
- writeFileSync(outputPath, contract);
280
- debug(`Solidity verifier contract written to ${outputPath}`);
281
- }
282
- } finally {
283
- await api.destroy();
284
- }
285
- }
286
-
287
151
  export async function contractUltraHonk(bytecodePath: string, vkPath: string, crsPath: string, outputPath: string) {
288
152
  const { api } = await initUltraHonk(bytecodePath, crsPath);
289
153
  try {
@@ -304,94 +168,6 @@ export async function contractUltraHonk(bytecodePath: string, vkPath: string, cr
304
168
  }
305
169
  }
306
170
 
307
- export async function writeVk(bytecodePath: string, recursive: boolean, crsPath: string, outputPath: string) {
308
- const { api, acirComposer } = await initUltraPlonk(bytecodePath, recursive, crsPath);
309
- try {
310
- debug(`Initializing proving key bytecode=${bytecodePath} recursive=${recursive}`);
311
- const bytecode = getBytecode(bytecodePath);
312
- await api.acirInitProvingKey(acirComposer, bytecode, recursive);
313
-
314
- debug(`Initializing verification key`);
315
- const vk = await api.acirGetVerificationKey(acirComposer);
316
-
317
- if (outputPath === '-') {
318
- process.stdout.write(vk);
319
- debug(`Verification key written to stdout`);
320
- } else {
321
- writeFileSync(outputPath, vk);
322
- debug(`Verification key written to ${outputPath}`);
323
- }
324
- } finally {
325
- await api.destroy();
326
- }
327
- }
328
-
329
- export async function writePk(bytecodePath: string, recursive: boolean, crsPath: string, outputPath: string) {
330
- const { api, acirComposer } = await initUltraPlonk(bytecodePath, recursive, crsPath);
331
- try {
332
- debug(`Initializing proving key bytecode=${bytecodePath} recursive=${recursive}`);
333
- const bytecode = getBytecode(bytecodePath);
334
- const pk = await api.acirGetProvingKey(acirComposer, bytecode, recursive);
335
-
336
- if (outputPath === '-') {
337
- process.stdout.write(pk);
338
- debug(`Proving key written to stdout`);
339
- } else {
340
- writeFileSync(outputPath, pk);
341
- debug(`Proving key written to ${outputPath}`);
342
- }
343
- } finally {
344
- await api.destroy();
345
- }
346
- }
347
-
348
- export async function proofAsFields(proofPath: string, vkPath: string, outputPath: string, crsPath: string) {
349
- const { api, acirComposer } = await initLite(crsPath);
350
-
351
- try {
352
- debug(`Serializing proof byte array into field elements proof=${proofPath} vk=${vkPath}`);
353
- const numPublicInputs = readFileSync(vkPath).readUint32BE(8);
354
- const proofAsFields = await api.acirSerializeProofIntoFields(
355
- acirComposer,
356
- Uint8Array.from(readFileSync(proofPath)),
357
- numPublicInputs,
358
- );
359
- const jsonProofAsFields = JSON.stringify(proofAsFields.map(f => f.toString()));
360
-
361
- if (outputPath === '-') {
362
- process.stdout.write(jsonProofAsFields);
363
- debug(`Proof as fields written to stdout`);
364
- } else {
365
- writeFileSync(outputPath, jsonProofAsFields);
366
- debug(`Proof as fields written to ${outputPath}`);
367
- }
368
- } finally {
369
- await api.destroy();
370
- }
371
- }
372
-
373
- export async function vkAsFields(vkPath: string, vkeyOutputPath: string, crsPath: string) {
374
- const { api, acirComposer } = await initLite(crsPath);
375
-
376
- try {
377
- debug(`Serializing vk byte array into field elements vk=${vkPath}`);
378
- await api.acirLoadVerificationKey(acirComposer, new RawBuffer(readFileSync(vkPath)));
379
- const [vkAsFields, vkHash] = await api.acirSerializeVerificationKeyIntoFields(acirComposer);
380
- const output = [vkHash, ...vkAsFields].map(f => f.toString());
381
- const jsonVKAsFields = JSON.stringify(output);
382
-
383
- if (vkeyOutputPath === '-') {
384
- process.stdout.write(jsonVKAsFields);
385
- debug(`Verification key as fields written to stdout`);
386
- } else {
387
- writeFileSync(vkeyOutputPath, jsonVKAsFields);
388
- debug(`Verification key as fields written to ${vkeyOutputPath}`);
389
- }
390
- } finally {
391
- await api.destroy();
392
- }
393
- }
394
-
395
171
  export async function proveUltraHonk(
396
172
  bytecodePath: string,
397
173
  witnessPath: string,
@@ -407,9 +183,11 @@ export async function proveUltraHonk(
407
183
 
408
184
  const acirProveUltraHonk = options?.keccak
409
185
  ? api.acirProveUltraKeccakHonk.bind(api)
410
- : options?.starknet
411
- ? api.acirProveUltraStarknetHonk.bind(api)
412
- : api.acirProveUltraHonk.bind(api);
186
+ : options?.keccakZK
187
+ ? api.acirProveUltraKeccakZKHonk.bind(api)
188
+ : options?.starknet
189
+ ? api.acirProveUltraStarknetHonk.bind(api)
190
+ : api.acirProveUltraHonk.bind(api);
413
191
  const proof = await acirProveUltraHonk(bytecode, witness);
414
192
 
415
193
  if (outputPath === '-') {
@@ -437,9 +215,11 @@ export async function writeVkUltraHonk(
437
215
 
438
216
  const acirWriteVkUltraHonk = options?.keccak
439
217
  ? api.acirWriteVkUltraKeccakHonk.bind(api)
440
- : options?.starknet
441
- ? api.acirWriteVkUltraStarknetHonk.bind(api)
442
- : api.acirWriteVkUltraHonk.bind(api);
218
+ : options?.keccakZK
219
+ ? api.acirWriteVkUltraKeccakZKHonk.bind(api)
220
+ : options?.starknet
221
+ ? api.acirWriteVkUltraStarknetHonk.bind(api)
222
+ : api.acirWriteVkUltraHonk.bind(api);
443
223
  const vk = await acirWriteVkUltraHonk(bytecode);
444
224
 
445
225
  if (outputPath === '-') {
@@ -464,9 +244,11 @@ export async function verifyUltraHonk(
464
244
  try {
465
245
  const acirVerifyUltraHonk = options?.keccak
466
246
  ? api.acirVerifyUltraKeccakHonk.bind(api)
467
- : options?.starknet
468
- ? api.acirVerifyUltraStarknetHonk.bind(api)
469
- : api.acirVerifyUltraHonk.bind(api);
247
+ : options?.keccakZK
248
+ ? api.acirVerifyUltraKeccakZKHonk.bind(api)
249
+ : options?.starknet
250
+ ? api.acirVerifyUltraStarknetHonk.bind(api)
251
+ : api.acirVerifyUltraHonk.bind(api);
470
252
  const verified = await acirVerifyUltraHonk(
471
253
  Uint8Array.from(readFileSync(proofPath)),
472
254
  new RawBuffer(readFileSync(vkPath)),
@@ -530,17 +312,20 @@ function handleGlobalOptions() {
530
312
  return { crsPath: program.opts().crsPath };
531
313
  }
532
314
 
315
+ const deprecatedCommandError = () => async () => {
316
+ console.error(
317
+ `Error: UltraPlonk is now deprecated (see https://github.com/AztecProtocol/barretenberg/issues/1377). Use UltraHonk!`,
318
+ );
319
+ process.exit(1);
320
+ };
321
+
533
322
  program
534
323
  .command('prove_and_verify')
535
- .description('Generate a proof and verify it. Process exits with success or failure code.')
324
+ .description('Generate a proof and verify it. Process exits with success or failure code. [DEPRECATED]')
536
325
  .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
537
326
  .option('-r, --recursive', 'Whether to use a SNARK friendly proof', false)
538
327
  .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
539
- .action(async ({ bytecodePath, recursive, witnessPath }) => {
540
- const { crsPath } = handleGlobalOptions();
541
- const result = await proveAndVerify(bytecodePath, recursive, witnessPath, crsPath);
542
- process.exit(result ? 0 : 1);
543
- });
328
+ .action(deprecatedCommandError());
544
329
 
545
330
  program
546
331
  .command('prove_and_verify_ultra_honk')
@@ -566,15 +351,12 @@ program
566
351
 
567
352
  program
568
353
  .command('prove')
569
- .description('Generate a proof and write it to a file.')
354
+ .description('Generate a proof and write it to a file. [DEPRECATED]')
570
355
  .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
571
356
  .option('-r, --recursive', 'Create a SNARK friendly proof', false)
572
357
  .option('-w, --witness-path <path>', 'Specify the witness path', './target/witness.gz')
573
358
  .option('-o, --output-path <path>', 'Specify the proof output path', './proofs/proof')
574
- .action(async ({ bytecodePath, recursive, witnessPath, outputPath }) => {
575
- const { crsPath } = handleGlobalOptions();
576
- await prove(bytecodePath, recursive, witnessPath, crsPath, outputPath);
577
- });
359
+ .action(deprecatedCommandError());
578
360
 
579
361
  program
580
362
  .command('gates')
@@ -589,25 +371,18 @@ program
589
371
 
590
372
  program
591
373
  .command('verify')
592
- .description('Verify a proof. Process exists with success or failure code.')
374
+ .description('Verify a proof. Process exists with success or failure code. [DEPRECATED]')
593
375
  .requiredOption('-p, --proof-path <path>', 'Specify the path to the proof')
594
376
  .requiredOption('-k, --vk <path>', 'path to a verification key. avoids recomputation.')
595
- .action(async ({ proofPath, vk }) => {
596
- const { crsPath } = handleGlobalOptions();
597
- const result = await verify(proofPath, vk, crsPath);
598
- process.exit(result ? 0 : 1);
599
- });
377
+ .action(deprecatedCommandError());
600
378
 
601
379
  program
602
380
  .command('contract')
603
- .description('Output solidity verification key contract.')
381
+ .description('Output solidity verification key contract. [DEPRECATED]')
604
382
  .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
605
383
  .option('-o, --output-path <path>', 'Specify the path to write the contract', './target/contract.sol')
606
384
  .requiredOption('-k, --vk-path <path>', 'Path to a verification key. avoids recomputation.')
607
- .action(async ({ outputPath, vkPath }) => {
608
- const { crsPath } = handleGlobalOptions();
609
- await contract(outputPath, vkPath, crsPath);
610
- });
385
+ .action(deprecatedCommandError());
611
386
 
612
387
  program
613
388
  .command('contract_ultra_honk')
@@ -622,46 +397,36 @@ program
622
397
 
623
398
  program
624
399
  .command('write_vk')
625
- .description('Output verification key.')
400
+ .description('Output verification key. [DEPRECATED]')
626
401
  .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
627
402
  .option('-r, --recursive', 'Create a SNARK friendly proof', false)
628
403
  .option('-o, --output-path <path>', 'Specify the path to write the key')
629
- .action(async ({ bytecodePath, recursive, outputPath }) => {
630
- const { crsPath } = handleGlobalOptions();
631
- await writeVk(bytecodePath, recursive, crsPath, outputPath);
632
- });
404
+ .action(deprecatedCommandError());
633
405
 
634
406
  program
635
407
  .command('write_pk')
636
- .description('Output proving key.')
408
+ .description('Output proving key. [DEPRECATED]')
637
409
  .option('-b, --bytecode-path <path>', 'Specify the bytecode path', './target/program.json')
638
410
  .option('-r, --recursive', 'Create a SNARK friendly proof', false)
639
411
  .requiredOption('-o, --output-path <path>', 'Specify the path to write the key')
640
- .action(async ({ bytecodePath, recursive, outputPath }) => {
641
- const { crsPath } = handleGlobalOptions();
642
- await writePk(bytecodePath, recursive, crsPath, outputPath);
643
- });
412
+ .action(deprecatedCommandError());
644
413
 
645
414
  program
646
415
  .command('proof_as_fields')
647
- .description('Return the proof as fields elements')
416
+ .description('Return the proof as fields elements. [DEPRECATED]')
648
417
  .requiredOption('-p, --proof-path <path>', 'Specify the proof path')
649
418
  .requiredOption('-k, --vk-path <path>', 'Path to verification key.')
650
419
  .requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the proof fields')
651
- .action(async ({ proofPath, vkPath, outputPath }) => {
652
- const { crsPath } = handleGlobalOptions();
653
- await proofAsFields(proofPath, vkPath, outputPath, crsPath);
654
- });
420
+ .action(deprecatedCommandError());
655
421
 
656
422
  program
657
423
  .command('vk_as_fields')
658
- .description('Return the verification key represented as fields elements. Also return the verification key hash.')
424
+ .description(
425
+ 'Return the verification key represented as fields elements. Also return the verification key hash. [DEPRECATED]',
426
+ )
659
427
  .requiredOption('-k, --vk-path <path>', 'Path to verification key.')
660
428
  .requiredOption('-o, --output-path <path>', 'Specify the JSON path to write the verification key fields and key hash')
661
- .action(async ({ vkPath, outputPath }) => {
662
- const { crsPath } = handleGlobalOptions();
663
- await vkAsFields(vkPath, outputPath, crsPath);
664
- });
429
+ .action(deprecatedCommandError());
665
430
 
666
431
  program
667
432
  .command('prove_ultra_honk')
@@ -1,5 +1,3 @@
1
- import { numToUInt32BE } from '../serialize/serialize.js';
2
-
3
1
  /**
4
2
  * @description
5
3
  * The representation of a proof
@@ -11,7 +9,7 @@ export type ProofData = {
11
9
  proof: Uint8Array;
12
10
  };
13
11
 
14
- export const AGGREGATION_OBJECT_LENGTH = 16;
12
+ export const PAIRING_POINTS_SIZE = 16;
15
13
 
16
14
  // Fields are 32 bytes
17
15
  const fieldByteSize = 32;
@@ -34,16 +32,6 @@ export function reconstructHonkProof(publicInputs: Uint8Array, proof: Uint8Array
34
32
  return proofWithPublicInputs;
35
33
  }
36
34
 
37
- export function reconstructUltraPlonkProof(proofData: ProofData): Uint8Array {
38
- // Flatten publicInputs
39
- const publicInputsConcatenated = flattenFieldsAsArray(proofData.publicInputs);
40
-
41
- // Concatenate publicInputs and proof
42
- const proofWithPublicInputs = Uint8Array.from([...publicInputsConcatenated, ...proofData.proof]);
43
-
44
- return proofWithPublicInputs;
45
- }
46
-
47
35
  export function deflattenFields(flattenedFields: Uint8Array): string[] {
48
36
  const publicInputSize = 32;
49
37
  const chunkedFlattenedPublicInputs: Uint8Array[] = [];
@@ -1,6 +1,9 @@
1
1
  export class BufferReader {
2
2
  private index: number;
3
- constructor(private buffer: Uint8Array, offset = 0) {
3
+ constructor(
4
+ private buffer: Uint8Array,
5
+ offset = 0,
6
+ ) {
4
7
  this.index = offset;
5
8
  }
6
9
 
@@ -26,8 +26,8 @@ export class Fr {
26
26
  typeof value === 'bigint'
27
27
  ? value
28
28
  : value instanceof Buffer
29
- ? buffer32BytesToBigIntBE(value)
30
- : uint8ArrayToBigIntBE(value);
29
+ ? buffer32BytesToBigIntBE(value)
30
+ : uint8ArrayToBigIntBE(value);
31
31
 
32
32
  if (valueBigInt > Fr.MAX_VALUE) {
33
33
  throw new Error(`Value 0x${valueBigInt.toString(16)} is greater or equal to field modulus.`);
@@ -5,7 +5,10 @@ export class Point {
5
5
  static SIZE_IN_BYTES = 64;
6
6
  static EMPTY = new Point(Fr.ZERO, Fr.ZERO);
7
7
 
8
- constructor(public readonly x: Fr, public readonly y: Fr) {}
8
+ constructor(
9
+ public readonly x: Fr,
10
+ public readonly y: Fr,
11
+ ) {}
9
12
 
10
13
  static random() {
11
14
  // TODO: This is not a point on the curve!
@@ -1,7 +0,0 @@
1
- export const __webpack_id__ = 733;
2
-
3
- export const __webpack_ids__ = [ 733 ];
4
-
5
- export const __webpack_modules__ = {
6
- 733: () => {}
7
- };
@@ -1,38 +0,0 @@
1
- /**
2
- * The path to our SRS object, assuming that we are in e.g. barretenberg/ts/dest/node/crs/node folder.
3
- */
4
- export declare const SRS_DEV_PATH: string;
5
- export declare const GRUMPKIN_SRS_DEV_PATH: string;
6
- /**
7
- * Downloader for CRS from a local file (for Node).
8
- */
9
- export declare class IgnitionFilesCrs {
10
- /**
11
- * The number of circuit gates.
12
- */
13
- readonly numPoints: number;
14
- private path;
15
- private data;
16
- private g2Data;
17
- constructor(
18
- /**
19
- * The number of circuit gates.
20
- */
21
- numPoints: number, path?: string);
22
- pathExists(): boolean;
23
- /**
24
- * Read the data file.
25
- */
26
- init(): Promise<void>;
27
- /**
28
- * G1 points data for prover key.
29
- * @returns The points data.
30
- */
31
- getG1Data(): Uint8Array;
32
- /**
33
- * G2 points data for verification key.
34
- * @returns The points data.
35
- */
36
- getG2Data(): Uint8Array;
37
- }
38
- //# sourceMappingURL=ignition_files_crs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ignition_files_crs.d.ts","sourceRoot":"","sources":["../../../../src/crs/node/ignition_files_crs.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,eAAO,MAAM,YAAY,QAAmE,CAAC;AAC7F,eAAO,MAAM,qBAAqB,QAAmE,CAAC;AAEtG;;GAEG;AACH,qBAAa,gBAAgB;IAKzB;;OAEG;aACa,SAAS,EAAE,MAAM;IACjC,OAAO,CAAC,IAAI;IARd,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,MAAM,CAAc;;IAG1B;;OAEG;IACa,SAAS,EAAE,MAAM,EACzB,IAAI,SAAe;IAG7B,UAAU;IAIV;;OAEG;IACG,IAAI;IAeV;;;OAGG;IACH,SAAS,IAAI,UAAU;IAIvB;;;OAGG;IACH,SAAS,IAAI,UAAU;CAGxB"}
@@ -1,65 +0,0 @@
1
- import { existsSync } from 'fs';
2
- import { readFile } from 'fs/promises';
3
- import { dirname } from 'path';
4
- import { fileURLToPath } from 'url';
5
- function getCurrentDir() {
6
- if (typeof __dirname !== 'undefined') {
7
- return __dirname;
8
- }
9
- else {
10
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
11
- // @ts-ignore
12
- return dirname(fileURLToPath(import.meta.url));
13
- }
14
- }
15
- /**
16
- * The path to our SRS object, assuming that we are in e.g. barretenberg/ts/dest/node/crs/node folder.
17
- */
18
- export const SRS_DEV_PATH = getCurrentDir() + '/../../../../../cpp/srs_db/ignition/monomial';
19
- export const GRUMPKIN_SRS_DEV_PATH = getCurrentDir() + '/../../../../../cpp/srs_db/grumpkin/monomial';
20
- /**
21
- * Downloader for CRS from a local file (for Node).
22
- */
23
- export class IgnitionFilesCrs {
24
- constructor(
25
- /**
26
- * The number of circuit gates.
27
- */
28
- numPoints, path = SRS_DEV_PATH) {
29
- this.numPoints = numPoints;
30
- this.path = path;
31
- }
32
- pathExists() {
33
- return existsSync(this.path);
34
- }
35
- /**
36
- * Read the data file.
37
- */
38
- async init() {
39
- // We need this.numPoints number of g1 points.
40
- // numPoints should be circuitSize + 1.
41
- const g1Start = 28;
42
- const g1End = g1Start + this.numPoints * 64;
43
- const data = await readFile(this.path + '/transcript00.dat');
44
- this.data = data.subarray(g1Start, g1End);
45
- // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): proper abstraction from Grumpkin which does not have g2
46
- if (existsSync(this.path + '/g2.dat')) {
47
- this.g2Data = await readFile(this.path + '/g2.dat');
48
- }
49
- }
50
- /**
51
- * G1 points data for prover key.
52
- * @returns The points data.
53
- */
54
- getG1Data() {
55
- return this.data;
56
- }
57
- /**
58
- * G2 points data for verification key.
59
- * @returns The points data.
60
- */
61
- getG2Data() {
62
- return this.g2Data;
63
- }
64
- }
65
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaWduaXRpb25fZmlsZXNfY3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2Nycy9ub2RlL2lnbml0aW9uX2ZpbGVzX2Nycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sSUFBSSxDQUFDO0FBQ2hDLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFDdkMsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUMvQixPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBRXBDLFNBQVMsYUFBYTtJQUNwQixJQUFJLE9BQU8sU0FBUyxLQUFLLFdBQVcsRUFBRSxDQUFDO1FBQ3JDLE9BQU8sU0FBUyxDQUFDO0lBQ25CLENBQUM7U0FBTSxDQUFDO1FBQ04sNkRBQTZEO1FBQzdELGFBQWE7UUFDYixPQUFPLE9BQU8sQ0FBQyxhQUFhLENBQUMsTUFBTSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO0lBQ2pELENBQUM7QUFDSCxDQUFDO0FBRUQ7O0dBRUc7QUFDSCxNQUFNLENBQUMsTUFBTSxZQUFZLEdBQUcsYUFBYSxFQUFFLEdBQUcsOENBQThDLENBQUM7QUFDN0YsTUFBTSxDQUFDLE1BQU0scUJBQXFCLEdBQUcsYUFBYSxFQUFFLEdBQUcsOENBQThDLENBQUM7QUFFdEc7O0dBRUc7QUFDSCxNQUFNLE9BQU8sZ0JBQWdCO0lBSTNCO0lBQ0U7O09BRUc7SUFDYSxTQUFpQixFQUN6QixPQUFPLFlBQVk7UUFEWCxjQUFTLEdBQVQsU0FBUyxDQUFRO1FBQ3pCLFNBQUksR0FBSixJQUFJLENBQWU7SUFDMUIsQ0FBQztJQUVKLFVBQVU7UUFDUixPQUFPLFVBQVUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDL0IsQ0FBQztJQUVEOztPQUVHO0lBQ0gsS0FBSyxDQUFDLElBQUk7UUFDUiw4Q0FBOEM7UUFDOUMsdUNBQXVDO1FBQ3ZDLE1BQU0sT0FBTyxHQUFHLEVBQUUsQ0FBQztRQUNuQixNQUFNLEtBQUssR0FBRyxPQUFPLEdBQUcsSUFBSSxDQUFDLFNBQVMsR0FBRyxFQUFFLENBQUM7UUFFNUMsTUFBTSxJQUFJLEdBQUcsTUFBTSxRQUFRLENBQUMsSUFBSSxDQUFDLElBQUksR0FBRyxtQkFBbUIsQ0FBQyxDQUFDO1FBQzdELElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDLFFBQVEsQ0FBQyxPQUFPLEVBQUUsS0FBSyxDQUFDLENBQUM7UUFFMUMsMEhBQTBIO1FBQzFILElBQUksVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLEdBQUcsU0FBUyxDQUFDLEVBQUUsQ0FBQztZQUN0QyxJQUFJLENBQUMsTUFBTSxHQUFHLE1BQU0sUUFBUSxDQUFDLElBQUksQ0FBQyxJQUFJLEdBQUcsU0FBUyxDQUFDLENBQUM7UUFDdEQsQ0FBQztJQUNILENBQUM7SUFFRDs7O09BR0c7SUFDSCxTQUFTO1FBQ1AsT0FBTyxJQUFJLENBQUMsSUFBSSxDQUFDO0lBQ25CLENBQUM7SUFFRDs7O09BR0c7SUFDSCxTQUFTO1FBQ1AsT0FBTyxJQUFJLENBQUMsTUFBTSxDQUFDO0lBQ3JCLENBQUM7Q0FDRiJ9
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=simple.rawtest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"simple.rawtest.d.ts","sourceRoot":"","sources":["../../../src/examples/simple.rawtest.ts"],"names":[],"mappings":""}