@aztec/bb.js 0.0.1-alpha.5 → 0.0.1-alpha.7
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.
- package/README.md +3 -4
- package/dest/barretenberg-threads.wasm +0 -0
- package/dest/barretenberg.wasm +0 -0
- package/dest/barretenberg_api/index.d.ts +6 -4
- package/dest/barretenberg_api/index.d.ts.map +1 -1
- package/dest/barretenberg_api/index.js +36 -28
- package/dest/barretenberg_wasm/barretenberg_wasm.js +5 -5
- package/dest/barretenberg_wasm/barretenberg_wasm.test.js +2 -2
- package/dest/barretenberg_wasm/index.d.ts +1 -1
- package/dest/barretenberg_wasm/index.js +1 -1
- package/dest/barretenberg_wasm.js +1 -1
- package/dest/crs/browser/cached_net_crs.d.ts.map +1 -1
- package/dest/crs/browser/cached_net_crs.js +1 -1
- package/dest/crs/node/{file_crs.d.ts → ignition_files_crs.d.ts} +2 -2
- package/dest/crs/node/ignition_files_crs.d.ts.map +1 -0
- package/dest/crs/node/ignition_files_crs.js +51 -0
- package/dest/crs/node/index.d.ts +2 -12
- package/dest/crs/node/index.d.ts.map +1 -1
- package/dest/crs/node/index.js +28 -15
- package/dest/examples/simple.test.js +1 -1
- package/dest/main.d.ts +4 -4
- package/dest/main.d.ts.map +1 -1
- package/dest/main.js +48 -63
- package/dest/simple_test.js +1 -1
- package/package.json +9 -4
- package/src/barretenberg_api/index.ts +252 -64
- package/src/barretenberg_wasm/barretenberg_wasm.test.ts +1 -1
- package/src/barretenberg_wasm/barretenberg_wasm.ts +4 -4
- package/src/barretenberg_wasm/index.ts +1 -1
- package/src/crs/browser/cached_net_crs.ts +0 -1
- package/src/crs/node/{file_crs.ts → ignition_files_crs.ts} +2 -2
- package/src/crs/node/index.ts +27 -19
- package/src/examples/simple.test.ts +1 -1
- package/src/main.ts +49 -77
- package/dest/crs/node/file_crs.d.ts.map +0 -1
- package/dest/crs/node/file_crs.js +0 -51
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// WARNING: FILE CODE GENERATED BY BINDGEN UTILITY. DO NOT EDIT!
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3
3
|
import { BarretenbergBinder, BarretenbergBinderSync } from '../barretenberg_binder/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
BufferDeserializer,
|
|
6
|
+
NumberDeserializer,
|
|
7
|
+
VectorDeserializer,
|
|
8
|
+
BoolDeserializer,
|
|
9
|
+
StringDeserializer,
|
|
10
|
+
} from '../serialize/index.js';
|
|
5
11
|
import { Fr, Fq, Point, Buffer32, Buffer128, Ptr } from '../types/index.js';
|
|
6
12
|
|
|
7
13
|
export class BarretenbergApi {
|
|
@@ -12,47 +18,60 @@ export class BarretenbergApi {
|
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
async pedersenInit(): Promise<void> {
|
|
15
|
-
const result = await this.binder.callWasmExport('
|
|
21
|
+
const result = await this.binder.callWasmExport('pedersen___init', [], []);
|
|
16
22
|
return;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
async pedersenCompressFields(left: Fr, right: Fr): Promise<Fr> {
|
|
20
|
-
const result = await this.binder.callWasmExport('
|
|
26
|
+
const result = await this.binder.callWasmExport('pedersen___compress_fields', [left, right], [Fr]);
|
|
21
27
|
return result[0];
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
async pedersenPlookupCompressFields(left: Fr, right: Fr): Promise<Fr> {
|
|
25
|
-
const result = await this.binder.callWasmExport('
|
|
31
|
+
const result = await this.binder.callWasmExport('pedersen___plookup_compress_fields', [left, right], [Fr]);
|
|
26
32
|
return result[0];
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
async pedersenCompress(inputsBuffer: Fr[]): Promise<Fr> {
|
|
30
|
-
const result = await this.binder.callWasmExport('
|
|
36
|
+
const result = await this.binder.callWasmExport('pedersen___compress', [inputsBuffer], [Fr]);
|
|
31
37
|
return result[0];
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
async pedersenPlookupCompress(inputsBuffer: Fr[]): Promise<Fr> {
|
|
35
|
-
const result = await this.binder.callWasmExport('
|
|
41
|
+
const result = await this.binder.callWasmExport('pedersen___plookup_compress', [inputsBuffer], [Fr]);
|
|
36
42
|
return result[0];
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
async pedersenCompressWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Promise<Fr> {
|
|
40
|
-
const result = await this.binder.callWasmExport(
|
|
46
|
+
const result = await this.binder.callWasmExport(
|
|
47
|
+
'pedersen___compress_with_hash_index',
|
|
48
|
+
[inputsBuffer, hashIndex],
|
|
49
|
+
[Fr],
|
|
50
|
+
);
|
|
41
51
|
return result[0];
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
async pedersenCommit(inputsBuffer: Fr[]): Promise<Fr> {
|
|
45
|
-
const result = await this.binder.callWasmExport('
|
|
55
|
+
const result = await this.binder.callWasmExport('pedersen___commit', [inputsBuffer], [Fr]);
|
|
46
56
|
return result[0];
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
async pedersenPlookupCommit(inputsBuffer: Fr[]): Promise<Fr> {
|
|
50
|
-
const result = await this.binder.callWasmExport('
|
|
60
|
+
const result = await this.binder.callWasmExport('pedersen___plookup_commit', [inputsBuffer], [Fr]);
|
|
61
|
+
return result[0];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async pedersenPlookupCommitWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Promise<Fr> {
|
|
65
|
+
const result = await this.binder.callWasmExport(
|
|
66
|
+
'pedersen___plookup_commit_with_hash_index',
|
|
67
|
+
[inputsBuffer, hashIndex],
|
|
68
|
+
[Fr],
|
|
69
|
+
);
|
|
51
70
|
return result[0];
|
|
52
71
|
}
|
|
53
72
|
|
|
54
73
|
async pedersenBufferToField(data: Uint8Array): Promise<Fr> {
|
|
55
|
-
const result = await this.binder.callWasmExport('
|
|
74
|
+
const result = await this.binder.callWasmExport('pedersen___buffer_to_field', [data], [Fr]);
|
|
56
75
|
return result[0];
|
|
57
76
|
}
|
|
58
77
|
|
|
@@ -72,7 +91,11 @@ export class BarretenbergApi {
|
|
|
72
91
|
}
|
|
73
92
|
|
|
74
93
|
async pedersenHashMultipleWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Promise<Fr> {
|
|
75
|
-
const result = await this.binder.callWasmExport(
|
|
94
|
+
const result = await this.binder.callWasmExport(
|
|
95
|
+
'pedersen_hash_multiple_with_hash_index',
|
|
96
|
+
[inputsBuffer, hashIndex],
|
|
97
|
+
[Fr],
|
|
98
|
+
);
|
|
76
99
|
return result[0];
|
|
77
100
|
}
|
|
78
101
|
|
|
@@ -102,37 +125,76 @@ export class BarretenbergApi {
|
|
|
102
125
|
}
|
|
103
126
|
|
|
104
127
|
async schnorrConstructSignature(message: Uint8Array, privateKey: Fr): Promise<[Buffer32, Buffer32]> {
|
|
105
|
-
const result = await this.binder.callWasmExport(
|
|
128
|
+
const result = await this.binder.callWasmExport(
|
|
129
|
+
'schnorr_construct_signature',
|
|
130
|
+
[message, privateKey],
|
|
131
|
+
[Buffer32, Buffer32],
|
|
132
|
+
);
|
|
106
133
|
return result as any;
|
|
107
134
|
}
|
|
108
135
|
|
|
109
136
|
async schnorrVerifySignature(message: Uint8Array, pubKey: Point, sigS: Buffer32, sigE: Buffer32): Promise<boolean> {
|
|
110
|
-
const result = await this.binder.callWasmExport(
|
|
137
|
+
const result = await this.binder.callWasmExport(
|
|
138
|
+
'schnorr_verify_signature',
|
|
139
|
+
[message, pubKey, sigS, sigE],
|
|
140
|
+
[BoolDeserializer()],
|
|
141
|
+
);
|
|
111
142
|
return result[0];
|
|
112
143
|
}
|
|
113
144
|
|
|
114
145
|
async schnorrMultisigCreateMultisigPublicKey(privateKey: Fq): Promise<Buffer128> {
|
|
115
|
-
const result = await this.binder.callWasmExport(
|
|
146
|
+
const result = await this.binder.callWasmExport(
|
|
147
|
+
'schnorr_multisig_create_multisig_public_key',
|
|
148
|
+
[privateKey],
|
|
149
|
+
[Buffer128],
|
|
150
|
+
);
|
|
116
151
|
return result[0];
|
|
117
152
|
}
|
|
118
153
|
|
|
119
154
|
async schnorrMultisigValidateAndCombineSignerPubkeys(signerPubkeyBuf: Buffer128[]): Promise<[Point, boolean]> {
|
|
120
|
-
const result = await this.binder.callWasmExport(
|
|
155
|
+
const result = await this.binder.callWasmExport(
|
|
156
|
+
'schnorr_multisig_validate_and_combine_signer_pubkeys',
|
|
157
|
+
[signerPubkeyBuf],
|
|
158
|
+
[Point, BoolDeserializer()],
|
|
159
|
+
);
|
|
121
160
|
return result as any;
|
|
122
161
|
}
|
|
123
162
|
|
|
124
163
|
async schnorrMultisigConstructSignatureRound1(): Promise<[Buffer128, Buffer128]> {
|
|
125
|
-
const result = await this.binder.callWasmExport(
|
|
164
|
+
const result = await this.binder.callWasmExport(
|
|
165
|
+
'schnorr_multisig_construct_signature_round_1',
|
|
166
|
+
[],
|
|
167
|
+
[Buffer128, Buffer128],
|
|
168
|
+
);
|
|
126
169
|
return result as any;
|
|
127
170
|
}
|
|
128
171
|
|
|
129
|
-
async schnorrMultisigConstructSignatureRound2(
|
|
130
|
-
|
|
172
|
+
async schnorrMultisigConstructSignatureRound2(
|
|
173
|
+
message: Uint8Array,
|
|
174
|
+
privateKey: Fq,
|
|
175
|
+
signerRoundOnePrivateBuf: Buffer128,
|
|
176
|
+
signerPubkeysBuf: Buffer128[],
|
|
177
|
+
roundOnePublicBuf: Buffer128[],
|
|
178
|
+
): Promise<[Fq, boolean]> {
|
|
179
|
+
const result = await this.binder.callWasmExport(
|
|
180
|
+
'schnorr_multisig_construct_signature_round_2',
|
|
181
|
+
[message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf],
|
|
182
|
+
[Fq, BoolDeserializer()],
|
|
183
|
+
);
|
|
131
184
|
return result as any;
|
|
132
185
|
}
|
|
133
186
|
|
|
134
|
-
async schnorrMultisigCombineSignatures(
|
|
135
|
-
|
|
187
|
+
async schnorrMultisigCombineSignatures(
|
|
188
|
+
message: Uint8Array,
|
|
189
|
+
signerPubkeysBuf: Buffer128[],
|
|
190
|
+
roundOneBuf: Buffer128[],
|
|
191
|
+
roundTwoBuf: Fr[],
|
|
192
|
+
): Promise<[Buffer32, Buffer32, boolean]> {
|
|
193
|
+
const result = await this.binder.callWasmExport(
|
|
194
|
+
'schnorr_multisig_combine_signatures',
|
|
195
|
+
[message, signerPubkeysBuf, roundOneBuf, roundTwoBuf],
|
|
196
|
+
[Buffer32, Buffer32, BoolDeserializer()],
|
|
197
|
+
);
|
|
136
198
|
return result as any;
|
|
137
199
|
}
|
|
138
200
|
|
|
@@ -142,7 +204,11 @@ export class BarretenbergApi {
|
|
|
142
204
|
}
|
|
143
205
|
|
|
144
206
|
async examplesSimpleCreateAndVerifyProof(): Promise<boolean> {
|
|
145
|
-
const result = await this.binder.callWasmExport(
|
|
207
|
+
const result = await this.binder.callWasmExport(
|
|
208
|
+
'examples_simple_create_and_verify_proof',
|
|
209
|
+
[],
|
|
210
|
+
[BoolDeserializer()],
|
|
211
|
+
);
|
|
146
212
|
return result[0];
|
|
147
213
|
}
|
|
148
214
|
|
|
@@ -167,12 +233,16 @@ export class BarretenbergApi {
|
|
|
167
233
|
}
|
|
168
234
|
|
|
169
235
|
async acirGetCircuitSizes(constraintSystemBuf: Uint8Array): Promise<[number, number, number]> {
|
|
170
|
-
const result = await this.binder.callWasmExport(
|
|
236
|
+
const result = await this.binder.callWasmExport(
|
|
237
|
+
'acir_get_circuit_sizes',
|
|
238
|
+
[constraintSystemBuf],
|
|
239
|
+
[NumberDeserializer(), NumberDeserializer(), NumberDeserializer()],
|
|
240
|
+
);
|
|
171
241
|
return result as any;
|
|
172
242
|
}
|
|
173
243
|
|
|
174
|
-
async acirNewAcirComposer(): Promise<Ptr> {
|
|
175
|
-
const result = await this.binder.callWasmExport('acir_new_acir_composer', [], [Ptr]);
|
|
244
|
+
async acirNewAcirComposer(sizeHint: number): Promise<Ptr> {
|
|
245
|
+
const result = await this.binder.callWasmExport('acir_new_acir_composer', [sizeHint], [Ptr]);
|
|
176
246
|
return result[0];
|
|
177
247
|
}
|
|
178
248
|
|
|
@@ -182,17 +252,34 @@ export class BarretenbergApi {
|
|
|
182
252
|
}
|
|
183
253
|
|
|
184
254
|
async acirCreateCircuit(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, sizeHint: number): Promise<void> {
|
|
185
|
-
const result = await this.binder.callWasmExport(
|
|
255
|
+
const result = await this.binder.callWasmExport(
|
|
256
|
+
'acir_create_circuit',
|
|
257
|
+
[acirComposerPtr, constraintSystemBuf, sizeHint],
|
|
258
|
+
[],
|
|
259
|
+
);
|
|
186
260
|
return;
|
|
187
261
|
}
|
|
188
262
|
|
|
189
|
-
async acirInitProvingKey(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array
|
|
190
|
-
const result = await this.binder.callWasmExport(
|
|
263
|
+
async acirInitProvingKey(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array): Promise<void> {
|
|
264
|
+
const result = await this.binder.callWasmExport(
|
|
265
|
+
'acir_init_proving_key',
|
|
266
|
+
[acirComposerPtr, constraintSystemBuf],
|
|
267
|
+
[],
|
|
268
|
+
);
|
|
191
269
|
return;
|
|
192
270
|
}
|
|
193
271
|
|
|
194
|
-
async acirCreateProof(
|
|
195
|
-
|
|
272
|
+
async acirCreateProof(
|
|
273
|
+
acirComposerPtr: Ptr,
|
|
274
|
+
constraintSystemBuf: Uint8Array,
|
|
275
|
+
witnessBuf: Uint8Array,
|
|
276
|
+
isRecursive: boolean,
|
|
277
|
+
): Promise<Uint8Array> {
|
|
278
|
+
const result = await this.binder.callWasmExport(
|
|
279
|
+
'acir_create_proof',
|
|
280
|
+
[acirComposerPtr, constraintSystemBuf, witnessBuf, isRecursive],
|
|
281
|
+
[BufferDeserializer()],
|
|
282
|
+
);
|
|
196
283
|
return result[0];
|
|
197
284
|
}
|
|
198
285
|
|
|
@@ -207,27 +294,51 @@ export class BarretenbergApi {
|
|
|
207
294
|
}
|
|
208
295
|
|
|
209
296
|
async acirGetVerificationKey(acirComposerPtr: Ptr): Promise<Uint8Array> {
|
|
210
|
-
const result = await this.binder.callWasmExport(
|
|
297
|
+
const result = await this.binder.callWasmExport(
|
|
298
|
+
'acir_get_verification_key',
|
|
299
|
+
[acirComposerPtr],
|
|
300
|
+
[BufferDeserializer()],
|
|
301
|
+
);
|
|
211
302
|
return result[0];
|
|
212
303
|
}
|
|
213
304
|
|
|
214
305
|
async acirVerifyProof(acirComposerPtr: Ptr, proofBuf: Uint8Array, isRecursive: boolean): Promise<boolean> {
|
|
215
|
-
const result = await this.binder.callWasmExport(
|
|
306
|
+
const result = await this.binder.callWasmExport(
|
|
307
|
+
'acir_verify_proof',
|
|
308
|
+
[acirComposerPtr, proofBuf, isRecursive],
|
|
309
|
+
[BoolDeserializer()],
|
|
310
|
+
);
|
|
216
311
|
return result[0];
|
|
217
312
|
}
|
|
218
313
|
|
|
219
314
|
async acirGetSolidityVerifier(acirComposerPtr: Ptr): Promise<string> {
|
|
220
|
-
const result = await this.binder.callWasmExport(
|
|
315
|
+
const result = await this.binder.callWasmExport(
|
|
316
|
+
'acir_get_solidity_verifier',
|
|
317
|
+
[acirComposerPtr],
|
|
318
|
+
[StringDeserializer()],
|
|
319
|
+
);
|
|
221
320
|
return result[0];
|
|
222
321
|
}
|
|
223
322
|
|
|
224
|
-
async acirSerializeProofIntoFields(
|
|
225
|
-
|
|
323
|
+
async acirSerializeProofIntoFields(
|
|
324
|
+
acirComposerPtr: Ptr,
|
|
325
|
+
proofBuf: Uint8Array,
|
|
326
|
+
numInnerPublicInputs: number,
|
|
327
|
+
): Promise<Fr[]> {
|
|
328
|
+
const result = await this.binder.callWasmExport(
|
|
329
|
+
'acir_serialize_proof_into_fields',
|
|
330
|
+
[acirComposerPtr, proofBuf, numInnerPublicInputs],
|
|
331
|
+
[VectorDeserializer(Fr)],
|
|
332
|
+
);
|
|
226
333
|
return result[0];
|
|
227
334
|
}
|
|
228
335
|
|
|
229
336
|
async acirSerializeVerificationKeyIntoFields(acirComposerPtr: Ptr): Promise<[Fr[], Fr]> {
|
|
230
|
-
const result = await this.binder.callWasmExport(
|
|
337
|
+
const result = await this.binder.callWasmExport(
|
|
338
|
+
'acir_serialize_verification_key_into_fields',
|
|
339
|
+
[acirComposerPtr],
|
|
340
|
+
[VectorDeserializer(Fr), Fr],
|
|
341
|
+
);
|
|
231
342
|
return result as any;
|
|
232
343
|
}
|
|
233
344
|
}
|
|
@@ -240,47 +351,56 @@ export class BarretenbergApiSync {
|
|
|
240
351
|
}
|
|
241
352
|
|
|
242
353
|
pedersenInit(): void {
|
|
243
|
-
const result = this.binder.callWasmExport('
|
|
354
|
+
const result = this.binder.callWasmExport('pedersen___init', [], []);
|
|
244
355
|
return;
|
|
245
356
|
}
|
|
246
357
|
|
|
247
358
|
pedersenCompressFields(left: Fr, right: Fr): Fr {
|
|
248
|
-
const result = this.binder.callWasmExport('
|
|
359
|
+
const result = this.binder.callWasmExport('pedersen___compress_fields', [left, right], [Fr]);
|
|
249
360
|
return result[0];
|
|
250
361
|
}
|
|
251
362
|
|
|
252
363
|
pedersenPlookupCompressFields(left: Fr, right: Fr): Fr {
|
|
253
|
-
const result = this.binder.callWasmExport('
|
|
364
|
+
const result = this.binder.callWasmExport('pedersen___plookup_compress_fields', [left, right], [Fr]);
|
|
254
365
|
return result[0];
|
|
255
366
|
}
|
|
256
367
|
|
|
257
368
|
pedersenCompress(inputsBuffer: Fr[]): Fr {
|
|
258
|
-
const result = this.binder.callWasmExport('
|
|
369
|
+
const result = this.binder.callWasmExport('pedersen___compress', [inputsBuffer], [Fr]);
|
|
259
370
|
return result[0];
|
|
260
371
|
}
|
|
261
372
|
|
|
262
373
|
pedersenPlookupCompress(inputsBuffer: Fr[]): Fr {
|
|
263
|
-
const result = this.binder.callWasmExport('
|
|
374
|
+
const result = this.binder.callWasmExport('pedersen___plookup_compress', [inputsBuffer], [Fr]);
|
|
264
375
|
return result[0];
|
|
265
376
|
}
|
|
266
377
|
|
|
267
378
|
pedersenCompressWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Fr {
|
|
268
|
-
const result = this.binder.callWasmExport('
|
|
379
|
+
const result = this.binder.callWasmExport('pedersen___compress_with_hash_index', [inputsBuffer, hashIndex], [Fr]);
|
|
269
380
|
return result[0];
|
|
270
381
|
}
|
|
271
382
|
|
|
272
383
|
pedersenCommit(inputsBuffer: Fr[]): Fr {
|
|
273
|
-
const result = this.binder.callWasmExport('
|
|
384
|
+
const result = this.binder.callWasmExport('pedersen___commit', [inputsBuffer], [Fr]);
|
|
274
385
|
return result[0];
|
|
275
386
|
}
|
|
276
387
|
|
|
277
388
|
pedersenPlookupCommit(inputsBuffer: Fr[]): Fr {
|
|
278
|
-
const result = this.binder.callWasmExport('
|
|
389
|
+
const result = this.binder.callWasmExport('pedersen___plookup_commit', [inputsBuffer], [Fr]);
|
|
390
|
+
return result[0];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
pedersenPlookupCommitWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Fr {
|
|
394
|
+
const result = this.binder.callWasmExport(
|
|
395
|
+
'pedersen___plookup_commit_with_hash_index',
|
|
396
|
+
[inputsBuffer, hashIndex],
|
|
397
|
+
[Fr],
|
|
398
|
+
);
|
|
279
399
|
return result[0];
|
|
280
400
|
}
|
|
281
401
|
|
|
282
402
|
pedersenBufferToField(data: Uint8Array): Fr {
|
|
283
|
-
const result = this.binder.callWasmExport('
|
|
403
|
+
const result = this.binder.callWasmExport('pedersen___buffer_to_field', [data], [Fr]);
|
|
284
404
|
return result[0];
|
|
285
405
|
}
|
|
286
406
|
|
|
@@ -300,7 +420,11 @@ export class BarretenbergApiSync {
|
|
|
300
420
|
}
|
|
301
421
|
|
|
302
422
|
pedersenHashMultipleWithHashIndex(inputsBuffer: Fr[], hashIndex: number): Fr {
|
|
303
|
-
const result = this.binder.callWasmExport(
|
|
423
|
+
const result = this.binder.callWasmExport(
|
|
424
|
+
'pedersen_hash_multiple_with_hash_index',
|
|
425
|
+
[inputsBuffer, hashIndex],
|
|
426
|
+
[Fr],
|
|
427
|
+
);
|
|
304
428
|
return result[0];
|
|
305
429
|
}
|
|
306
430
|
|
|
@@ -330,12 +454,20 @@ export class BarretenbergApiSync {
|
|
|
330
454
|
}
|
|
331
455
|
|
|
332
456
|
schnorrConstructSignature(message: Uint8Array, privateKey: Fr): [Buffer32, Buffer32] {
|
|
333
|
-
const result = this.binder.callWasmExport(
|
|
457
|
+
const result = this.binder.callWasmExport(
|
|
458
|
+
'schnorr_construct_signature',
|
|
459
|
+
[message, privateKey],
|
|
460
|
+
[Buffer32, Buffer32],
|
|
461
|
+
);
|
|
334
462
|
return result as any;
|
|
335
463
|
}
|
|
336
464
|
|
|
337
465
|
schnorrVerifySignature(message: Uint8Array, pubKey: Point, sigS: Buffer32, sigE: Buffer32): boolean {
|
|
338
|
-
const result = this.binder.callWasmExport(
|
|
466
|
+
const result = this.binder.callWasmExport(
|
|
467
|
+
'schnorr_verify_signature',
|
|
468
|
+
[message, pubKey, sigS, sigE],
|
|
469
|
+
[BoolDeserializer()],
|
|
470
|
+
);
|
|
339
471
|
return result[0];
|
|
340
472
|
}
|
|
341
473
|
|
|
@@ -345,22 +477,49 @@ export class BarretenbergApiSync {
|
|
|
345
477
|
}
|
|
346
478
|
|
|
347
479
|
schnorrMultisigValidateAndCombineSignerPubkeys(signerPubkeyBuf: Buffer128[]): [Point, boolean] {
|
|
348
|
-
const result = this.binder.callWasmExport(
|
|
480
|
+
const result = this.binder.callWasmExport(
|
|
481
|
+
'schnorr_multisig_validate_and_combine_signer_pubkeys',
|
|
482
|
+
[signerPubkeyBuf],
|
|
483
|
+
[Point, BoolDeserializer()],
|
|
484
|
+
);
|
|
349
485
|
return result as any;
|
|
350
486
|
}
|
|
351
487
|
|
|
352
488
|
schnorrMultisigConstructSignatureRound1(): [Buffer128, Buffer128] {
|
|
353
|
-
const result = this.binder.callWasmExport(
|
|
489
|
+
const result = this.binder.callWasmExport(
|
|
490
|
+
'schnorr_multisig_construct_signature_round_1',
|
|
491
|
+
[],
|
|
492
|
+
[Buffer128, Buffer128],
|
|
493
|
+
);
|
|
354
494
|
return result as any;
|
|
355
495
|
}
|
|
356
496
|
|
|
357
|
-
schnorrMultisigConstructSignatureRound2(
|
|
358
|
-
|
|
497
|
+
schnorrMultisigConstructSignatureRound2(
|
|
498
|
+
message: Uint8Array,
|
|
499
|
+
privateKey: Fq,
|
|
500
|
+
signerRoundOnePrivateBuf: Buffer128,
|
|
501
|
+
signerPubkeysBuf: Buffer128[],
|
|
502
|
+
roundOnePublicBuf: Buffer128[],
|
|
503
|
+
): [Fq, boolean] {
|
|
504
|
+
const result = this.binder.callWasmExport(
|
|
505
|
+
'schnorr_multisig_construct_signature_round_2',
|
|
506
|
+
[message, privateKey, signerRoundOnePrivateBuf, signerPubkeysBuf, roundOnePublicBuf],
|
|
507
|
+
[Fq, BoolDeserializer()],
|
|
508
|
+
);
|
|
359
509
|
return result as any;
|
|
360
510
|
}
|
|
361
511
|
|
|
362
|
-
schnorrMultisigCombineSignatures(
|
|
363
|
-
|
|
512
|
+
schnorrMultisigCombineSignatures(
|
|
513
|
+
message: Uint8Array,
|
|
514
|
+
signerPubkeysBuf: Buffer128[],
|
|
515
|
+
roundOneBuf: Buffer128[],
|
|
516
|
+
roundTwoBuf: Fr[],
|
|
517
|
+
): [Buffer32, Buffer32, boolean] {
|
|
518
|
+
const result = this.binder.callWasmExport(
|
|
519
|
+
'schnorr_multisig_combine_signatures',
|
|
520
|
+
[message, signerPubkeysBuf, roundOneBuf, roundTwoBuf],
|
|
521
|
+
[Buffer32, Buffer32, BoolDeserializer()],
|
|
522
|
+
);
|
|
364
523
|
return result as any;
|
|
365
524
|
}
|
|
366
525
|
|
|
@@ -395,12 +554,16 @@ export class BarretenbergApiSync {
|
|
|
395
554
|
}
|
|
396
555
|
|
|
397
556
|
acirGetCircuitSizes(constraintSystemBuf: Uint8Array): [number, number, number] {
|
|
398
|
-
const result = this.binder.callWasmExport(
|
|
557
|
+
const result = this.binder.callWasmExport(
|
|
558
|
+
'acir_get_circuit_sizes',
|
|
559
|
+
[constraintSystemBuf],
|
|
560
|
+
[NumberDeserializer(), NumberDeserializer(), NumberDeserializer()],
|
|
561
|
+
);
|
|
399
562
|
return result as any;
|
|
400
563
|
}
|
|
401
564
|
|
|
402
|
-
acirNewAcirComposer(): Ptr {
|
|
403
|
-
const result = this.binder.callWasmExport('acir_new_acir_composer', [], [Ptr]);
|
|
565
|
+
acirNewAcirComposer(sizeHint: number): Ptr {
|
|
566
|
+
const result = this.binder.callWasmExport('acir_new_acir_composer', [sizeHint], [Ptr]);
|
|
404
567
|
return result[0];
|
|
405
568
|
}
|
|
406
569
|
|
|
@@ -410,17 +573,30 @@ export class BarretenbergApiSync {
|
|
|
410
573
|
}
|
|
411
574
|
|
|
412
575
|
acirCreateCircuit(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array, sizeHint: number): void {
|
|
413
|
-
const result = this.binder.callWasmExport(
|
|
576
|
+
const result = this.binder.callWasmExport(
|
|
577
|
+
'acir_create_circuit',
|
|
578
|
+
[acirComposerPtr, constraintSystemBuf, sizeHint],
|
|
579
|
+
[],
|
|
580
|
+
);
|
|
414
581
|
return;
|
|
415
582
|
}
|
|
416
583
|
|
|
417
|
-
acirInitProvingKey(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array
|
|
418
|
-
const result = this.binder.callWasmExport('acir_init_proving_key', [acirComposerPtr, constraintSystemBuf
|
|
584
|
+
acirInitProvingKey(acirComposerPtr: Ptr, constraintSystemBuf: Uint8Array): void {
|
|
585
|
+
const result = this.binder.callWasmExport('acir_init_proving_key', [acirComposerPtr, constraintSystemBuf], []);
|
|
419
586
|
return;
|
|
420
587
|
}
|
|
421
588
|
|
|
422
|
-
acirCreateProof(
|
|
423
|
-
|
|
589
|
+
acirCreateProof(
|
|
590
|
+
acirComposerPtr: Ptr,
|
|
591
|
+
constraintSystemBuf: Uint8Array,
|
|
592
|
+
witnessBuf: Uint8Array,
|
|
593
|
+
isRecursive: boolean,
|
|
594
|
+
): Uint8Array {
|
|
595
|
+
const result = this.binder.callWasmExport(
|
|
596
|
+
'acir_create_proof',
|
|
597
|
+
[acirComposerPtr, constraintSystemBuf, witnessBuf, isRecursive],
|
|
598
|
+
[BufferDeserializer()],
|
|
599
|
+
);
|
|
424
600
|
return result[0];
|
|
425
601
|
}
|
|
426
602
|
|
|
@@ -440,7 +616,11 @@ export class BarretenbergApiSync {
|
|
|
440
616
|
}
|
|
441
617
|
|
|
442
618
|
acirVerifyProof(acirComposerPtr: Ptr, proofBuf: Uint8Array, isRecursive: boolean): boolean {
|
|
443
|
-
const result = this.binder.callWasmExport(
|
|
619
|
+
const result = this.binder.callWasmExport(
|
|
620
|
+
'acir_verify_proof',
|
|
621
|
+
[acirComposerPtr, proofBuf, isRecursive],
|
|
622
|
+
[BoolDeserializer()],
|
|
623
|
+
);
|
|
444
624
|
return result[0];
|
|
445
625
|
}
|
|
446
626
|
|
|
@@ -450,12 +630,20 @@ export class BarretenbergApiSync {
|
|
|
450
630
|
}
|
|
451
631
|
|
|
452
632
|
acirSerializeProofIntoFields(acirComposerPtr: Ptr, proofBuf: Uint8Array, numInnerPublicInputs: number): Fr[] {
|
|
453
|
-
const result = this.binder.callWasmExport(
|
|
633
|
+
const result = this.binder.callWasmExport(
|
|
634
|
+
'acir_serialize_proof_into_fields',
|
|
635
|
+
[acirComposerPtr, proofBuf, numInnerPublicInputs],
|
|
636
|
+
[VectorDeserializer(Fr)],
|
|
637
|
+
);
|
|
454
638
|
return result[0];
|
|
455
639
|
}
|
|
456
640
|
|
|
457
641
|
acirSerializeVerificationKeyIntoFields(acirComposerPtr: Ptr): [Fr[], Fr] {
|
|
458
|
-
const result = this.binder.callWasmExport(
|
|
642
|
+
const result = this.binder.callWasmExport(
|
|
643
|
+
'acir_serialize_verification_key_into_fields',
|
|
644
|
+
[acirComposerPtr],
|
|
645
|
+
[VectorDeserializer(Fr), Fr],
|
|
646
|
+
);
|
|
459
647
|
return result as any;
|
|
460
648
|
}
|
|
461
649
|
}
|
|
@@ -13,7 +13,7 @@ const debug = createDebug('bb.js:wasm');
|
|
|
13
13
|
EventEmitter.defaultMaxListeners = 30;
|
|
14
14
|
|
|
15
15
|
export class BarretenbergWasm {
|
|
16
|
-
static MAX_THREADS =
|
|
16
|
+
static MAX_THREADS = 32;
|
|
17
17
|
private memStore: { [key: string]: Uint8Array } = {};
|
|
18
18
|
private memory!: WebAssembly.Memory;
|
|
19
19
|
private instance!: WebAssembly.Instance;
|
|
@@ -156,9 +156,9 @@ export class BarretenbergWasm {
|
|
|
156
156
|
const m = this.getMemory();
|
|
157
157
|
const str2 = `${str} (mem: ${(m.length / (1024 * 1024)).toFixed(2)}MiB)`;
|
|
158
158
|
this.logger(str2);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
if (str2.startsWith('WARNING:')) {
|
|
160
|
+
this.logger(new Error().stack!);
|
|
161
|
+
}
|
|
162
162
|
},
|
|
163
163
|
|
|
164
164
|
get_data: (keyAddr: number, outBufAddr: number) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './barretenberg_wasm.js';
|
|
@@ -11,7 +11,7 @@ export const SRS_DEV_PATH = dirname(fileURLToPath(import.meta.url)) + '/../../..
|
|
|
11
11
|
/**
|
|
12
12
|
* Downloader for CRS from a local file (for Node).
|
|
13
13
|
*/
|
|
14
|
-
export class
|
|
14
|
+
export class IgnitionFilesCrs {
|
|
15
15
|
private data!: Uint8Array;
|
|
16
16
|
private g2Data!: Uint8Array;
|
|
17
17
|
|
|
@@ -20,7 +20,7 @@ export class FileCrs {
|
|
|
20
20
|
* The number of circuit gates.
|
|
21
21
|
*/
|
|
22
22
|
public readonly numPoints: number,
|
|
23
|
-
private path = SRS_DEV_PATH
|
|
23
|
+
private path = SRS_DEV_PATH,
|
|
24
24
|
) {}
|
|
25
25
|
|
|
26
26
|
static defaultExists() {
|