@aztec/bb.js 0.85.0-nightly.20250417 → 0.85.0-nightly.20250418

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 (48) hide show
  1. package/dest/browser/barretenberg/backend.d.ts +5 -6
  2. package/dest/browser/barretenberg/backend.d.ts.map +1 -1
  3. package/dest/browser/barretenberg-threads.js +1 -1
  4. package/dest/browser/barretenberg.js +1 -1
  5. package/dest/browser/barretenberg_api/index.d.ts +15 -27
  6. package/dest/browser/barretenberg_api/index.d.ts.map +1 -1
  7. package/dest/browser/index.js +2149 -198
  8. package/dest/node/barretenberg/backend.d.ts +5 -6
  9. package/dest/node/barretenberg/backend.d.ts.map +1 -1
  10. package/dest/node/barretenberg/backend.js +49 -10
  11. package/dest/node/barretenberg_api/index.d.ts +15 -27
  12. package/dest/node/barretenberg_api/index.d.ts.map +1 -1
  13. package/dest/node/barretenberg_api/index.js +93 -194
  14. package/dest/node/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
  15. package/dest/node/bindgen/mappings.d.ts.map +1 -1
  16. package/dest/node/bindgen/mappings.js +2 -1
  17. package/dest/node/bindgen/typescript.d.ts.map +1 -1
  18. package/dest/node/bindgen/typescript.js +3 -2
  19. package/dest/node/main.d.ts +0 -1
  20. package/dest/node/main.d.ts.map +1 -1
  21. package/dest/node/main.js +1 -35
  22. package/dest/node-cjs/barretenberg/backend.d.ts +5 -6
  23. package/dest/node-cjs/barretenberg/backend.d.ts.map +1 -1
  24. package/dest/node-cjs/barretenberg/backend.js +49 -10
  25. package/dest/node-cjs/barretenberg_api/index.d.ts +15 -27
  26. package/dest/node-cjs/barretenberg_api/index.d.ts.map +1 -1
  27. package/dest/node-cjs/barretenberg_api/index.js +92 -193
  28. package/dest/node-cjs/barretenberg_wasm/barretenberg-threads.wasm.gz +0 -0
  29. package/dest/node-cjs/bindgen/mappings.d.ts.map +1 -1
  30. package/dest/node-cjs/bindgen/mappings.js +2 -1
  31. package/dest/node-cjs/bindgen/typescript.d.ts.map +1 -1
  32. package/dest/node-cjs/bindgen/typescript.js +3 -2
  33. package/dest/node-cjs/main.d.ts +0 -1
  34. package/dest/node-cjs/main.d.ts.map +1 -1
  35. package/dest/node-cjs/main.js +2 -37
  36. package/package.json +2 -2
  37. package/src/barretenberg/backend.ts +64 -11
  38. package/src/barretenberg_api/index.ts +152 -355
  39. package/src/bindgen/mappings.ts +1 -0
  40. package/src/bindgen/typescript.ts +2 -1
  41. package/src/main.ts +0 -39
  42. package/dest/node/barretenberg/schnorr.test.d.ts +0 -2
  43. package/dest/node/barretenberg/schnorr.test.d.ts.map +0 -1
  44. package/dest/node/barretenberg/schnorr.test.js +0 -113
  45. package/dest/node-cjs/barretenberg/schnorr.test.d.ts +0 -2
  46. package/dest/node-cjs/barretenberg/schnorr.test.d.ts.map +0 -1
  47. package/dest/node-cjs/barretenberg/schnorr.test.js +0 -115
  48. package/src/barretenberg/schnorr.test.ts +0 -182
@@ -12,26 +12,6 @@ import {
12
12
  OutputType,
13
13
  } from '../serialize/index.js';
14
14
  import { Fr, Fq, Point, Buffer32, Buffer128, Ptr } from '../types/index.js';
15
- function parseBigEndianU32Array(buffer: Uint8Array, hasSizePrefix = false): number[] {
16
- const dv = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
17
-
18
- let offset = 0;
19
- let count = buffer.byteLength >>> 2; // default is entire buffer length / 4
20
-
21
- if (hasSizePrefix) {
22
- // Read the first 4 bytes as the size (big-endian).
23
- count = dv.getUint32(0, /* littleEndian= */ false);
24
- offset = 4;
25
- }
26
-
27
- const out: number[] = new Array(count);
28
- for (let i = 0; i < count; i++) {
29
- out[i] = dv.getUint32(offset, false);
30
- offset += 4;
31
- }
32
-
33
- return out;
34
- }
35
15
 
36
16
  export class BarretenbergApi {
37
17
  constructor(protected wasm: BarretenbergWasmWorker | BarretenbergWasmMain) {}
@@ -96,11 +76,11 @@ export class BarretenbergApi {
96
76
  return out[0];
97
77
  }
98
78
 
99
- async poseidon2HashAccumulate(inputsBuffer: Fr[]): Promise<Fr> {
79
+ async poseidon2Hashes(inputsBuffer: Fr[]): Promise<Fr> {
100
80
  const inArgs = [inputsBuffer].map(serializeBufferable);
101
81
  const outTypes: OutputType[] = [Fr];
102
82
  const result = await this.wasm.callWasmExport(
103
- 'poseidon2_hash_accumulate',
83
+ 'poseidon2_hashes',
104
84
  inArgs,
105
85
  outTypes.map(t => t.SIZE_IN_BYTES),
106
86
  );
@@ -108,11 +88,11 @@ export class BarretenbergApi {
108
88
  return out[0];
109
89
  }
110
90
 
111
- async poseidon2Hashes(inputsBuffer: Fr[]): Promise<Fr> {
91
+ async poseidon2Permutation(inputsBuffer: Fr[]): Promise<Fr[]> {
112
92
  const inArgs = [inputsBuffer].map(serializeBufferable);
113
- const outTypes: OutputType[] = [Fr];
93
+ const outTypes: OutputType[] = [VectorDeserializer(Fr)];
114
94
  const result = await this.wasm.callWasmExport(
115
- 'poseidon2_hashes',
95
+ 'poseidon2_permutation',
116
96
  inArgs,
117
97
  outTypes.map(t => t.SIZE_IN_BYTES),
118
98
  );
@@ -120,11 +100,11 @@ export class BarretenbergApi {
120
100
  return out[0];
121
101
  }
122
102
 
123
- async poseidon2Permutation(inputsBuffer: Fr[]): Promise<Fr[]> {
103
+ async poseidon2HashAccumulate(inputsBuffer: Fr[]): Promise<Fr> {
124
104
  const inArgs = [inputsBuffer].map(serializeBufferable);
125
- const outTypes: OutputType[] = [VectorDeserializer(Fr)];
105
+ const outTypes: OutputType[] = [Fr];
126
106
  const result = await this.wasm.callWasmExport(
127
- 'poseidon2_permutation',
107
+ 'poseidon2_hash_accumulate',
128
108
  inArgs,
129
109
  outTypes.map(t => t.SIZE_IN_BYTES),
130
110
  );
@@ -156,127 +136,6 @@ export class BarretenbergApi {
156
136
  return out[0];
157
137
  }
158
138
 
159
- async schnorrComputePublicKey(privateKey: Fr): Promise<Point> {
160
- const inArgs = [privateKey].map(serializeBufferable);
161
- const outTypes: OutputType[] = [Point];
162
- const result = await this.wasm.callWasmExport(
163
- 'schnorr_compute_public_key',
164
- inArgs,
165
- outTypes.map(t => t.SIZE_IN_BYTES),
166
- );
167
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
168
- return out[0];
169
- }
170
-
171
- async schnorrNegatePublicKey(publicKeyBuffer: Point): Promise<Point> {
172
- const inArgs = [publicKeyBuffer].map(serializeBufferable);
173
- const outTypes: OutputType[] = [Point];
174
- const result = await this.wasm.callWasmExport(
175
- 'schnorr_negate_public_key',
176
- inArgs,
177
- outTypes.map(t => t.SIZE_IN_BYTES),
178
- );
179
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
180
- return out[0];
181
- }
182
-
183
- async schnorrConstructSignature(message: Uint8Array, privateKey: Fr): Promise<[Buffer32, Buffer32]> {
184
- const inArgs = [message, privateKey].map(serializeBufferable);
185
- const outTypes: OutputType[] = [Buffer32, Buffer32];
186
- const result = await this.wasm.callWasmExport(
187
- 'schnorr_construct_signature',
188
- inArgs,
189
- outTypes.map(t => t.SIZE_IN_BYTES),
190
- );
191
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
192
- return out as any;
193
- }
194
-
195
- async schnorrVerifySignature(message: Uint8Array, pubKey: Point, sigS: Buffer32, sigE: Buffer32): Promise<boolean> {
196
- const inArgs = [message, pubKey, sigS, sigE].map(serializeBufferable);
197
- const outTypes: OutputType[] = [BoolDeserializer()];
198
- const result = await this.wasm.callWasmExport(
199
- 'schnorr_verify_signature',
200
- inArgs,
201
- outTypes.map(t => t.SIZE_IN_BYTES),
202
- );
203
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
204
- return out[0];
205
- }
206
-
207
- async schnorrMultisigCreateMultisigPublicKey(privateKey: Fq): Promise<Buffer128> {
208
- const inArgs = [privateKey].map(serializeBufferable);
209
- const outTypes: OutputType[] = [Buffer128];
210
- const result = await this.wasm.callWasmExport(
211
- 'schnorr_multisig_create_multisig_public_key',
212
- inArgs,
213
- outTypes.map(t => t.SIZE_IN_BYTES),
214
- );
215
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
216
- return out[0];
217
- }
218
-
219
- async schnorrMultisigValidateAndCombineSignerPubkeys(signerPubkeyBuf: Buffer128[]): Promise<[Point, boolean]> {
220
- const inArgs = [signerPubkeyBuf].map(serializeBufferable);
221
- const outTypes: OutputType[] = [Point, BoolDeserializer()];
222
- const result = await this.wasm.callWasmExport(
223
- 'schnorr_multisig_validate_and_combine_signer_pubkeys',
224
- inArgs,
225
- outTypes.map(t => t.SIZE_IN_BYTES),
226
- );
227
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
228
- return out as any;
229
- }
230
-
231
- async schnorrMultisigConstructSignatureRound1(): Promise<[Buffer128, Buffer128]> {
232
- const inArgs = [].map(serializeBufferable);
233
- const outTypes: OutputType[] = [Buffer128, Buffer128];
234
- const result = await this.wasm.callWasmExport(
235
- 'schnorr_multisig_construct_signature_round_1',
236
- inArgs,
237
- outTypes.map(t => t.SIZE_IN_BYTES),
238
- );
239
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
240
- return out as any;
241
- }
242
-
243
- async schnorrMultisigConstructSignatureRound2(
244
- message: Uint8Array,
245
- privateKey: Fq,
246
- signerRoundOnePrivateBuf: Buffer128,
247
- signerPubkeysBuf: Buffer128[],
248
- roundOnePublicBuf: Buffer128[],
249
- ): Promise<[Fq, boolean]> {
250
- const inArgs = [message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf].map(
251
- serializeBufferable,
252
- );
253
- const outTypes: OutputType[] = [Fq, BoolDeserializer()];
254
- const result = await this.wasm.callWasmExport(
255
- 'schnorr_multisig_construct_signature_round_2',
256
- inArgs,
257
- outTypes.map(t => t.SIZE_IN_BYTES),
258
- );
259
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
260
- return out as any;
261
- }
262
-
263
- async schnorrMultisigCombineSignatures(
264
- message: Uint8Array,
265
- signerPubkeysBuf: Buffer128[],
266
- roundOneBuf: Buffer128[],
267
- roundTwoBuf: Fq[],
268
- ): Promise<[Buffer32, Buffer32, boolean]> {
269
- const inArgs = [message, signerPubkeysBuf, roundOneBuf, roundTwoBuf].map(serializeBufferable);
270
- const outTypes: OutputType[] = [Buffer32, Buffer32, BoolDeserializer()];
271
- const result = await this.wasm.callWasmExport(
272
- 'schnorr_multisig_combine_signatures',
273
- inArgs,
274
- outTypes.map(t => t.SIZE_IN_BYTES),
275
- );
276
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
277
- return out as any;
278
- }
279
-
280
139
  async aesEncryptBufferCbc(input: Uint8Array, iv: Uint8Array, key: Uint8Array, length: number): Promise<Uint8Array> {
281
140
  const inArgs = [input, iv, key, length].map(serializeBufferable);
282
141
  const outTypes: OutputType[] = [BufferDeserializer()];
@@ -374,22 +233,7 @@ export class BarretenbergApi {
374
233
  outTypes.map(t => t.SIZE_IN_BYTES),
375
234
  );
376
235
  const out = result.map((r, i) => outTypes[i].fromBuffer(r));
377
- return out as [number, number];
378
- }
379
-
380
- async acirGatesAztecClient(
381
- // cf acirProveAztecClient
382
- acirVec: Uint8Array[],
383
- ): Promise<number[]> {
384
- const inArgs = [acirVec].map(serializeBufferable);
385
- const outTypes: OutputType[] = [BufferDeserializer()];
386
- const resultBuffer = await this.wasm.callWasmExport(
387
- 'acir_gates_aztec_client',
388
- inArgs,
389
- outTypes.map(t => t.SIZE_IN_BYTES),
390
- );
391
-
392
- return parseBigEndianU32Array(resultBuffer[0], /*hasSizePrefix=*/ true);
236
+ return out as any;
393
237
  }
394
238
 
395
239
  async acirNewAcirComposer(sizeHint: number): Promise<Ptr> {
@@ -445,10 +289,7 @@ export class BarretenbergApi {
445
289
  return out[0];
446
290
  }
447
291
 
448
- async acirProveAndVerifyUltraHonk(
449
- constraintSystemBuf: Uint8Array,
450
- witnessBuf: Uint8Array,
451
- ): Promise<boolean> {
292
+ async acirProveAndVerifyUltraHonk(constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Promise<boolean> {
452
293
  const inArgs = [constraintSystemBuf, witnessBuf].map(serializeBufferable);
453
294
  const outTypes: OutputType[] = [BoolDeserializer()];
454
295
  const result = await this.wasm.callWasmExport(
@@ -460,10 +301,7 @@ export class BarretenbergApi {
460
301
  return out[0];
461
302
  }
462
303
 
463
- async acirProveAndVerifyMegaHonk(
464
- constraintSystemBuf: Uint8Array,
465
- witnessBuf: Uint8Array,
466
- ): Promise<boolean> {
304
+ async acirProveAndVerifyMegaHonk(constraintSystemBuf: Uint8Array, witnessBuf: Uint8Array): Promise<boolean> {
467
305
  const inArgs = [constraintSystemBuf, witnessBuf].map(serializeBufferable);
468
306
  const outTypes: OutputType[] = [BoolDeserializer()];
469
307
  const result = await this.wasm.callWasmExport(
@@ -475,6 +313,30 @@ export class BarretenbergApi {
475
313
  return out[0];
476
314
  }
477
315
 
316
+ async acirProveAztecClient(ivcInputsBuf: Uint8Array): Promise<[Uint8Array, Uint8Array]> {
317
+ const inArgs = [ivcInputsBuf].map(serializeBufferable);
318
+ const outTypes: OutputType[] = [BufferDeserializer(), BufferDeserializer()];
319
+ const result = await this.wasm.callWasmExport(
320
+ 'acir_prove_aztec_client',
321
+ inArgs,
322
+ outTypes.map(t => t.SIZE_IN_BYTES),
323
+ );
324
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
325
+ return out as any;
326
+ }
327
+
328
+ async acirVerifyAztecClient(proofBuf: Uint8Array, vkBuf: Uint8Array): Promise<boolean> {
329
+ const inArgs = [proofBuf, vkBuf].map(serializeBufferable);
330
+ const outTypes: OutputType[] = [BoolDeserializer()];
331
+ const result = await this.wasm.callWasmExport(
332
+ 'acir_verify_aztec_client',
333
+ inArgs,
334
+ outTypes.map(t => t.SIZE_IN_BYTES),
335
+ );
336
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
337
+ return out[0];
338
+ }
339
+
478
340
  async acirLoadVerificationKey(acirComposerPtr: Ptr, vkBuf: Uint8Array): Promise<void> {
479
341
  const inArgs = [acirComposerPtr, vkBuf].map(serializeBufferable);
480
342
  const outTypes: OutputType[] = [];
@@ -547,6 +409,18 @@ export class BarretenbergApi {
547
409
  return out[0];
548
410
  }
549
411
 
412
+ async acirHonkSolidityVerifier(proofBuf: Uint8Array, vkBuf: Uint8Array): Promise<string> {
413
+ const inArgs = [proofBuf, vkBuf].map(serializeBufferable);
414
+ const outTypes: OutputType[] = [StringDeserializer()];
415
+ const result = await this.wasm.callWasmExport(
416
+ 'acir_honk_solidity_verifier',
417
+ inArgs,
418
+ outTypes.map(t => t.SIZE_IN_BYTES),
419
+ );
420
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
421
+ return out[0];
422
+ }
423
+
550
424
  async acirSerializeProofIntoFields(
551
425
  acirComposerPtr: Ptr,
552
426
  proofBuf: Uint8Array,
@@ -575,42 +449,6 @@ export class BarretenbergApi {
575
449
  return out as any;
576
450
  }
577
451
 
578
- async acirProveAndVerifyAztecClient(acirVec: Uint8Array[], witnessVec: Uint8Array[]): Promise<boolean> {
579
- const inArgs = [acirVec, witnessVec].map(serializeBufferable);
580
- const outTypes: OutputType[] = [BoolDeserializer()];
581
- const result = await this.wasm.callWasmExport(
582
- 'acir_prove_and_verify_aztec_client',
583
- inArgs,
584
- outTypes.map(t => t.SIZE_IN_BYTES),
585
- );
586
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
587
- return out[0];
588
- }
589
-
590
- async acirProveAztecClient(acirVec: Uint8Array[], witnessVec: Uint8Array[]): Promise<[Uint8Array, Uint8Array]> {
591
- const inArgs = [acirVec, witnessVec].map(serializeBufferable);
592
- const outTypes: OutputType[] = [BufferDeserializer(), BufferDeserializer()];
593
- const result = await this.wasm.callWasmExport(
594
- 'acir_prove_aztec_client',
595
- inArgs,
596
- outTypes.map(t => t.SIZE_IN_BYTES),
597
- );
598
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
599
- return [out[0], out[1]];
600
- }
601
-
602
- async acirVerifyAztecClient(proofBuf: Uint8Array, vkBuf: Uint8Array): Promise<boolean> {
603
- const inArgs = [proofBuf, vkBuf].map(serializeBufferable);
604
- const outTypes: OutputType[] = [BoolDeserializer()];
605
- const result = await this.wasm.callWasmExport(
606
- 'acir_verify_aztec_client',
607
- inArgs,
608
- outTypes.map(t => t.SIZE_IN_BYTES),
609
- );
610
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
611
- return out[0];
612
- }
613
-
614
452
  async acirProveUltraHonk(acirVec: Uint8Array, witnessVec: Uint8Array): Promise<Uint8Array> {
615
453
  const inArgs = [acirVec, witnessVec].map(serializeBufferable);
616
454
  const outTypes: OutputType[] = [BufferDeserializer()];
@@ -683,18 +521,6 @@ export class BarretenbergApi {
683
521
  return out[0];
684
522
  }
685
523
 
686
- async acirHonkSolidityVerifier(acirVec: Uint8Array, vkBuf: Uint8Array): Promise<string> {
687
- const inArgs = [acirVec, vkBuf].map(serializeBufferable);
688
- const outTypes: OutputType[] = [BufferDeserializer()];
689
- const result = await this.wasm.callWasmExport(
690
- 'acir_honk_solidity_verifier',
691
- inArgs,
692
- outTypes.map(t => t.SIZE_IN_BYTES),
693
- );
694
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
695
- return out[0];
696
- }
697
-
698
524
  async acirProofAsFieldsUltraHonk(proofBuf: Uint8Array): Promise<Fr[]> {
699
525
  const inArgs = [proofBuf].map(serializeBufferable);
700
526
  const outTypes: OutputType[] = [VectorDeserializer(Fr)];
@@ -730,6 +556,18 @@ export class BarretenbergApi {
730
556
  const out = result.map((r, i) => outTypes[i].fromBuffer(r));
731
557
  return out[0];
732
558
  }
559
+
560
+ async acirGatesAztecClient(ivcInputsBuf: Uint8Array): Promise<Uint8Array> {
561
+ const inArgs = [ivcInputsBuf].map(serializeBufferable);
562
+ const outTypes: OutputType[] = [BufferDeserializer()];
563
+ const result = await this.wasm.callWasmExport(
564
+ 'acir_gates_aztec_client',
565
+ inArgs,
566
+ outTypes.map(t => t.SIZE_IN_BYTES),
567
+ );
568
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
569
+ return out[0];
570
+ }
733
571
  }
734
572
  export class BarretenbergApiSync {
735
573
  constructor(protected wasm: BarretenbergWasm) {}
@@ -794,11 +632,11 @@ export class BarretenbergApiSync {
794
632
  return out[0];
795
633
  }
796
634
 
797
- poseidon2HashAccumulate(inputsBuffer: Fr[]): Fr {
635
+ poseidon2Hashes(inputsBuffer: Fr[]): Fr {
798
636
  const inArgs = [inputsBuffer].map(serializeBufferable);
799
637
  const outTypes: OutputType[] = [Fr];
800
638
  const result = this.wasm.callWasmExport(
801
- 'poseidon2_hash_accumulate',
639
+ 'poseidon2_hashes',
802
640
  inArgs,
803
641
  outTypes.map(t => t.SIZE_IN_BYTES),
804
642
  );
@@ -806,11 +644,11 @@ export class BarretenbergApiSync {
806
644
  return out[0];
807
645
  }
808
646
 
809
- poseidon2Hashes(inputsBuffer: Fr[]): Fr {
647
+ poseidon2Permutation(inputsBuffer: Fr[]): Fr[] {
810
648
  const inArgs = [inputsBuffer].map(serializeBufferable);
811
- const outTypes: OutputType[] = [Fr];
649
+ const outTypes: OutputType[] = [VectorDeserializer(Fr)];
812
650
  const result = this.wasm.callWasmExport(
813
- 'poseidon2_hashes',
651
+ 'poseidon2_permutation',
814
652
  inArgs,
815
653
  outTypes.map(t => t.SIZE_IN_BYTES),
816
654
  );
@@ -818,11 +656,11 @@ export class BarretenbergApiSync {
818
656
  return out[0];
819
657
  }
820
658
 
821
- poseidon2Permutation(inputsBuffer: Fr[]): Fr[] {
659
+ poseidon2HashAccumulate(inputsBuffer: Fr[]): Fr {
822
660
  const inArgs = [inputsBuffer].map(serializeBufferable);
823
- const outTypes: OutputType[] = [VectorDeserializer(Fr)];
661
+ const outTypes: OutputType[] = [Fr];
824
662
  const result = this.wasm.callWasmExport(
825
- 'poseidon2_permutation',
663
+ 'poseidon2_hash_accumulate',
826
664
  inArgs,
827
665
  outTypes.map(t => t.SIZE_IN_BYTES),
828
666
  );
@@ -854,127 +692,6 @@ export class BarretenbergApiSync {
854
692
  return out[0];
855
693
  }
856
694
 
857
- schnorrComputePublicKey(privateKey: Fr): Point {
858
- const inArgs = [privateKey].map(serializeBufferable);
859
- const outTypes: OutputType[] = [Point];
860
- const result = this.wasm.callWasmExport(
861
- 'schnorr_compute_public_key',
862
- inArgs,
863
- outTypes.map(t => t.SIZE_IN_BYTES),
864
- );
865
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
866
- return out[0];
867
- }
868
-
869
- schnorrNegatePublicKey(publicKeyBuffer: Point): Point {
870
- const inArgs = [publicKeyBuffer].map(serializeBufferable);
871
- const outTypes: OutputType[] = [Point];
872
- const result = this.wasm.callWasmExport(
873
- 'schnorr_negate_public_key',
874
- inArgs,
875
- outTypes.map(t => t.SIZE_IN_BYTES),
876
- );
877
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
878
- return out[0];
879
- }
880
-
881
- schnorrConstructSignature(message: Uint8Array, privateKey: Fr): [Buffer32, Buffer32] {
882
- const inArgs = [message, privateKey].map(serializeBufferable);
883
- const outTypes: OutputType[] = [Buffer32, Buffer32];
884
- const result = this.wasm.callWasmExport(
885
- 'schnorr_construct_signature',
886
- inArgs,
887
- outTypes.map(t => t.SIZE_IN_BYTES),
888
- );
889
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
890
- return out as any;
891
- }
892
-
893
- schnorrVerifySignature(message: Uint8Array, pubKey: Point, sigS: Buffer32, sigE: Buffer32): boolean {
894
- const inArgs = [message, pubKey, sigS, sigE].map(serializeBufferable);
895
- const outTypes: OutputType[] = [BoolDeserializer()];
896
- const result = this.wasm.callWasmExport(
897
- 'schnorr_verify_signature',
898
- inArgs,
899
- outTypes.map(t => t.SIZE_IN_BYTES),
900
- );
901
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
902
- return out[0];
903
- }
904
-
905
- schnorrMultisigCreateMultisigPublicKey(privateKey: Fq): Buffer128 {
906
- const inArgs = [privateKey].map(serializeBufferable);
907
- const outTypes: OutputType[] = [Buffer128];
908
- const result = this.wasm.callWasmExport(
909
- 'schnorr_multisig_create_multisig_public_key',
910
- inArgs,
911
- outTypes.map(t => t.SIZE_IN_BYTES),
912
- );
913
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
914
- return out[0];
915
- }
916
-
917
- schnorrMultisigValidateAndCombineSignerPubkeys(signerPubkeyBuf: Buffer128[]): [Point, boolean] {
918
- const inArgs = [signerPubkeyBuf].map(serializeBufferable);
919
- const outTypes: OutputType[] = [Point, BoolDeserializer()];
920
- const result = this.wasm.callWasmExport(
921
- 'schnorr_multisig_validate_and_combine_signer_pubkeys',
922
- inArgs,
923
- outTypes.map(t => t.SIZE_IN_BYTES),
924
- );
925
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
926
- return out as any;
927
- }
928
-
929
- schnorrMultisigConstructSignatureRound1(): [Buffer128, Buffer128] {
930
- const inArgs = [].map(serializeBufferable);
931
- const outTypes: OutputType[] = [Buffer128, Buffer128];
932
- const result = this.wasm.callWasmExport(
933
- 'schnorr_multisig_construct_signature_round_1',
934
- inArgs,
935
- outTypes.map(t => t.SIZE_IN_BYTES),
936
- );
937
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
938
- return out as any;
939
- }
940
-
941
- schnorrMultisigConstructSignatureRound2(
942
- message: Uint8Array,
943
- privateKey: Fq,
944
- signerRoundOnePrivateBuf: Buffer128,
945
- signerPubkeysBuf: Buffer128[],
946
- roundOnePublicBuf: Buffer128[],
947
- ): [Fq, boolean] {
948
- const inArgs = [message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf].map(
949
- serializeBufferable,
950
- );
951
- const outTypes: OutputType[] = [Fq, BoolDeserializer()];
952
- const result = this.wasm.callWasmExport(
953
- 'schnorr_multisig_construct_signature_round_2',
954
- inArgs,
955
- outTypes.map(t => t.SIZE_IN_BYTES),
956
- );
957
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
958
- return out as any;
959
- }
960
-
961
- schnorrMultisigCombineSignatures(
962
- message: Uint8Array,
963
- signerPubkeysBuf: Buffer128[],
964
- roundOneBuf: Buffer128[],
965
- roundTwoBuf: Fq[],
966
- ): [Buffer32, Buffer32, boolean] {
967
- const inArgs = [message, signerPubkeysBuf, roundOneBuf, roundTwoBuf].map(serializeBufferable);
968
- const outTypes: OutputType[] = [Buffer32, Buffer32, BoolDeserializer()];
969
- const result = this.wasm.callWasmExport(
970
- 'schnorr_multisig_combine_signatures',
971
- inArgs,
972
- outTypes.map(t => t.SIZE_IN_BYTES),
973
- );
974
- const out = result.map((r, i) => outTypes[i].fromBuffer(r));
975
- return out as any;
976
- }
977
-
978
695
  aesEncryptBufferCbc(input: Uint8Array, iv: Uint8Array, key: Uint8Array, length: number): Uint8Array {
979
696
  const inArgs = [input, iv, key, length].map(serializeBufferable);
980
697
  const outTypes: OutputType[] = [BufferDeserializer()];
@@ -1059,11 +776,7 @@ export class BarretenbergApiSync {
1059
776
  return;
1060
777
  }
1061
778
 
1062
- acirGetCircuitSizes(
1063
- constraintSystemBuf: Uint8Array,
1064
- recursive: boolean,
1065
- honkRecursion: boolean,
1066
- ): [number, number, number] {
779
+ acirGetCircuitSizes(constraintSystemBuf: Uint8Array, recursive: boolean, honkRecursion: boolean): [number, number] {
1067
780
  const inArgs = [constraintSystemBuf, recursive, honkRecursion].map(serializeBufferable);
1068
781
  const outTypes: OutputType[] = [NumberDeserializer(), NumberDeserializer()];
1069
782
  const result = this.wasm.callWasmExport(
@@ -1152,6 +865,30 @@ export class BarretenbergApiSync {
1152
865
  return out[0];
1153
866
  }
1154
867
 
868
+ acirProveAztecClient(ivcInputsBuf: Uint8Array): [Uint8Array, Uint8Array] {
869
+ const inArgs = [ivcInputsBuf].map(serializeBufferable);
870
+ const outTypes: OutputType[] = [BufferDeserializer(), BufferDeserializer()];
871
+ const result = this.wasm.callWasmExport(
872
+ 'acir_prove_aztec_client',
873
+ inArgs,
874
+ outTypes.map(t => t.SIZE_IN_BYTES),
875
+ );
876
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
877
+ return out as any;
878
+ }
879
+
880
+ acirVerifyAztecClient(proofBuf: Uint8Array, vkBuf: Uint8Array): boolean {
881
+ const inArgs = [proofBuf, vkBuf].map(serializeBufferable);
882
+ const outTypes: OutputType[] = [BoolDeserializer()];
883
+ const result = this.wasm.callWasmExport(
884
+ 'acir_verify_aztec_client',
885
+ inArgs,
886
+ outTypes.map(t => t.SIZE_IN_BYTES),
887
+ );
888
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
889
+ return out[0];
890
+ }
891
+
1155
892
  acirLoadVerificationKey(acirComposerPtr: Ptr, vkBuf: Uint8Array): void {
1156
893
  const inArgs = [acirComposerPtr, vkBuf].map(serializeBufferable);
1157
894
  const outTypes: OutputType[] = [];
@@ -1224,6 +961,18 @@ export class BarretenbergApiSync {
1224
961
  return out[0];
1225
962
  }
1226
963
 
964
+ acirHonkSolidityVerifier(proofBuf: Uint8Array, vkBuf: Uint8Array): string {
965
+ const inArgs = [proofBuf, vkBuf].map(serializeBufferable);
966
+ const outTypes: OutputType[] = [StringDeserializer()];
967
+ const result = this.wasm.callWasmExport(
968
+ 'acir_honk_solidity_verifier',
969
+ inArgs,
970
+ outTypes.map(t => t.SIZE_IN_BYTES),
971
+ );
972
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
973
+ return out[0];
974
+ }
975
+
1227
976
  acirSerializeProofIntoFields(acirComposerPtr: Ptr, proofBuf: Uint8Array, numInnerPublicInputs: number): Fr[] {
1228
977
  const inArgs = [acirComposerPtr, proofBuf, numInnerPublicInputs].map(serializeBufferable);
1229
978
  const outTypes: OutputType[] = [VectorDeserializer(Fr)];
@@ -1260,6 +1009,18 @@ export class BarretenbergApiSync {
1260
1009
  return out[0];
1261
1010
  }
1262
1011
 
1012
+ acirProveUltraKeccakHonk(acirVec: Uint8Array, witnessVec: Uint8Array): Uint8Array {
1013
+ const inArgs = [acirVec, witnessVec].map(serializeBufferable);
1014
+ const outTypes: OutputType[] = [BufferDeserializer()];
1015
+ const result = this.wasm.callWasmExport(
1016
+ 'acir_prove_ultra_keccak_honk',
1017
+ inArgs,
1018
+ outTypes.map(t => t.SIZE_IN_BYTES),
1019
+ );
1020
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
1021
+ return out[0];
1022
+ }
1023
+
1263
1024
  acirVerifyUltraHonk(proofBuf: Uint8Array, vkBuf: Uint8Array): boolean {
1264
1025
  const inArgs = [proofBuf, vkBuf].map(serializeBufferable);
1265
1026
  const outTypes: OutputType[] = [BoolDeserializer()];
@@ -1272,6 +1033,18 @@ export class BarretenbergApiSync {
1272
1033
  return out[0];
1273
1034
  }
1274
1035
 
1036
+ acirVerifyUltraKeccakHonk(proofBuf: Uint8Array, vkBuf: Uint8Array): boolean {
1037
+ const inArgs = [proofBuf, vkBuf].map(serializeBufferable);
1038
+ const outTypes: OutputType[] = [BoolDeserializer()];
1039
+ const result = this.wasm.callWasmExport(
1040
+ 'acir_verify_ultra_keccak_honk',
1041
+ inArgs,
1042
+ outTypes.map(t => t.SIZE_IN_BYTES),
1043
+ );
1044
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
1045
+ return out[0];
1046
+ }
1047
+
1275
1048
  acirWriteVkUltraHonk(acirVec: Uint8Array): Uint8Array {
1276
1049
  const inArgs = [acirVec].map(serializeBufferable);
1277
1050
  const outTypes: OutputType[] = [BufferDeserializer()];
@@ -1284,6 +1057,18 @@ export class BarretenbergApiSync {
1284
1057
  return out[0];
1285
1058
  }
1286
1059
 
1060
+ acirWriteVkUltraKeccakHonk(acirVec: Uint8Array): Uint8Array {
1061
+ const inArgs = [acirVec].map(serializeBufferable);
1062
+ const outTypes: OutputType[] = [BufferDeserializer()];
1063
+ const result = this.wasm.callWasmExport(
1064
+ 'acir_write_vk_ultra_keccak_honk',
1065
+ inArgs,
1066
+ outTypes.map(t => t.SIZE_IN_BYTES),
1067
+ );
1068
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
1069
+ return out[0];
1070
+ }
1071
+
1287
1072
  acirProofAsFieldsUltraHonk(proofBuf: Uint8Array): Fr[] {
1288
1073
  const inArgs = [proofBuf].map(serializeBufferable);
1289
1074
  const outTypes: OutputType[] = [VectorDeserializer(Fr)];
@@ -1319,4 +1104,16 @@ export class BarretenbergApiSync {
1319
1104
  const out = result.map((r, i) => outTypes[i].fromBuffer(r));
1320
1105
  return out[0];
1321
1106
  }
1107
+
1108
+ acirGatesAztecClient(ivcInputsBuf: Uint8Array): Uint8Array {
1109
+ const inArgs = [ivcInputsBuf].map(serializeBufferable);
1110
+ const outTypes: OutputType[] = [BufferDeserializer()];
1111
+ const result = this.wasm.callWasmExport(
1112
+ 'acir_gates_aztec_client',
1113
+ inArgs,
1114
+ outTypes.map(t => t.SIZE_IN_BYTES),
1115
+ );
1116
+ const out = result.map((r, i) => outTypes[i].fromBuffer(r));
1117
+ return out[0];
1118
+ }
1322
1119
  }
@@ -13,6 +13,7 @@ const typeMap: { [key: string]: string } = {
13
13
  'fq::vec_in_buf': 'Fq[]',
14
14
  'fq::vec_out_buf': 'Fq[]',
15
15
  'const uint8_t *': 'Uint8Array',
16
+ 'uint8_vec_vec_in_buf': 'Uint8Array[]',
16
17
  'uint8_t **': 'Uint8Array',
17
18
  in_str_buf: 'string',
18
19
  out_str_buf: 'string',
@@ -9,6 +9,7 @@ export function generateTypeScriptCode(filename: string) {
9
9
 
10
10
  let output = `// WARNING: FILE CODE GENERATED BY BINDGEN UTILITY. DO NOT EDIT!
11
11
  /* eslint-disable @typescript-eslint/no-unused-vars */
12
+ import { BarretenbergWasmMain } from '../barretenberg_wasm/barretenberg_wasm_main/index.js';
12
13
  import { BarretenbergWasmWorker, BarretenbergWasm } from '../barretenberg_wasm/index.js';
13
14
  import { BufferDeserializer, NumberDeserializer, VectorDeserializer, BoolDeserializer, StringDeserializer, serializeBufferable, OutputType } from '../serialize/index.js';
14
15
  import { Fr, Fq, Point, Buffer32, Buffer128, Ptr } from '../types/index.js';
@@ -24,7 +25,7 @@ import { Fr, Fq, Point, Buffer32, Buffer128, Ptr } from '../types/index.js';
24
25
  function generateClass(functionDeclarations: FunctionDeclaration[]) {
25
26
  let output = `
26
27
  export class BarretenbergApi {
27
- constructor(protected wasm: BarretenbergWasmWorker) {}
28
+ constructor(protected wasm: BarretenbergWasmWorker | BarretenbergWasmMain) {}
28
29
 
29
30
  `;
30
31