-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy pathc.zig
More file actions
507 lines (507 loc) · 33.1 KB
/
c.zig
File metadata and controls
507 lines (507 loc) · 33.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
// automatically generated with 'zig translate-c'
const BLST_SUCCESS: c_int = 0;
const BLST_BAD_ENCODING: c_int = 1;
const BLST_POINT_NOT_ON_CURVE: c_int = 2;
const BLST_POINT_NOT_IN_GROUP: c_int = 3;
const BLST_AGGR_TYPE_MISMATCH: c_int = 4;
const BLST_VERIFY_FAIL: c_int = 5;
const BLST_PK_IS_INFINITY: c_int = 6;
const BLST_BAD_SCALAR: c_int = 7;
const BLST_ERROR = c_uint;
pub const byte = u8;
pub const limb_t = u64;
const blst_scalar = extern struct {
b: [32]byte = @import("std").mem.zeroes([32]byte),
};
const blst_fr = extern struct {
l: [4]limb_t = @import("std").mem.zeroes([4]limb_t),
};
const blst_fp = extern struct {
l: [6]limb_t = @import("std").mem.zeroes([6]limb_t),
};
const blst_fp2 = extern struct {
fp: [2]blst_fp = @import("std").mem.zeroes([2]blst_fp),
};
const blst_fp6 = extern struct {
fp2: [3]blst_fp2 = @import("std").mem.zeroes([3]blst_fp2),
};
const blst_fp12 = extern struct {
fp6: [2]blst_fp6 = @import("std").mem.zeroes([2]blst_fp6),
};
extern fn blst_scalar_from_uint32(out: [*c]blst_scalar, a: [*c]const u32) void;
extern fn blst_uint32_from_scalar(out: [*c]u32, a: [*c]const blst_scalar) void;
extern fn blst_scalar_from_uint64(out: [*c]blst_scalar, a: [*c]const u64) void;
extern fn blst_uint64_from_scalar(out: [*c]u64, a: [*c]const blst_scalar) void;
extern fn blst_scalar_from_bendian(out: [*c]blst_scalar, a: [*c]const byte) void;
extern fn blst_bendian_from_scalar(out: [*c]byte, a: [*c]const blst_scalar) void;
extern fn blst_scalar_from_lendian(out: [*c]blst_scalar, a: [*c]const byte) void;
extern fn blst_lendian_from_scalar(out: [*c]byte, a: [*c]const blst_scalar) void;
extern fn blst_scalar_fr_check(a: [*c]const blst_scalar) bool;
extern fn blst_sk_check(a: [*c]const blst_scalar) bool;
extern fn blst_sk_add_n_check(out: [*c]blst_scalar, a: [*c]const blst_scalar, b: [*c]const blst_scalar) bool;
extern fn blst_sk_sub_n_check(out: [*c]blst_scalar, a: [*c]const blst_scalar, b: [*c]const blst_scalar) bool;
extern fn blst_sk_mul_n_check(out: [*c]blst_scalar, a: [*c]const blst_scalar, b: [*c]const blst_scalar) bool;
extern fn blst_sk_inverse(out: [*c]blst_scalar, a: [*c]const blst_scalar) void;
extern fn blst_scalar_from_le_bytes(out: [*c]blst_scalar, in: [*c]const byte, len: usize) bool;
extern fn blst_scalar_from_be_bytes(out: [*c]blst_scalar, in: [*c]const byte, len: usize) bool;
extern fn blst_fr_add(ret: [*c]blst_fr, a: [*c]const blst_fr, b: [*c]const blst_fr) void;
extern fn blst_fr_sub(ret: [*c]blst_fr, a: [*c]const blst_fr, b: [*c]const blst_fr) void;
extern fn blst_fr_mul_by_3(ret: [*c]blst_fr, a: [*c]const blst_fr) void;
extern fn blst_fr_lshift(ret: [*c]blst_fr, a: [*c]const blst_fr, count: usize) void;
extern fn blst_fr_rshift(ret: [*c]blst_fr, a: [*c]const blst_fr, count: usize) void;
extern fn blst_fr_mul(ret: [*c]blst_fr, a: [*c]const blst_fr, b: [*c]const blst_fr) void;
extern fn blst_fr_sqr(ret: [*c]blst_fr, a: [*c]const blst_fr) void;
extern fn blst_fr_cneg(ret: [*c]blst_fr, a: [*c]const blst_fr, flag: bool) void;
extern fn blst_fr_eucl_inverse(ret: [*c]blst_fr, a: [*c]const blst_fr) void;
extern fn blst_fr_inverse(ret: [*c]blst_fr, a: [*c]const blst_fr) void;
extern fn blst_fr_from_uint64(ret: [*c]blst_fr, a: [*c]const u64) void;
extern fn blst_uint64_from_fr(ret: [*c]u64, a: [*c]const blst_fr) void;
extern fn blst_fr_from_scalar(ret: [*c]blst_fr, a: [*c]const blst_scalar) void;
extern fn blst_scalar_from_fr(ret: [*c]blst_scalar, a: [*c]const blst_fr) void;
extern fn blst_fp_add(ret: [*c]blst_fp, a: [*c]const blst_fp, b: [*c]const blst_fp) void;
extern fn blst_fp_sub(ret: [*c]blst_fp, a: [*c]const blst_fp, b: [*c]const blst_fp) void;
extern fn blst_fp_mul_by_3(ret: [*c]blst_fp, a: [*c]const blst_fp) void;
extern fn blst_fp_mul_by_8(ret: [*c]blst_fp, a: [*c]const blst_fp) void;
extern fn blst_fp_lshift(ret: [*c]blst_fp, a: [*c]const blst_fp, count: usize) void;
extern fn blst_fp_mul(ret: [*c]blst_fp, a: [*c]const blst_fp, b: [*c]const blst_fp) void;
extern fn blst_fp_sqr(ret: [*c]blst_fp, a: [*c]const blst_fp) void;
extern fn blst_fp_cneg(ret: [*c]blst_fp, a: [*c]const blst_fp, flag: bool) void;
extern fn blst_fp_eucl_inverse(ret: [*c]blst_fp, a: [*c]const blst_fp) void;
extern fn blst_fp_inverse(ret: [*c]blst_fp, a: [*c]const blst_fp) void;
extern fn blst_fp_sqrt(ret: [*c]blst_fp, a: [*c]const blst_fp) bool;
extern fn blst_fp_from_uint32(ret: [*c]blst_fp, a: [*c]const u32) void;
extern fn blst_uint32_from_fp(ret: [*c]u32, a: [*c]const blst_fp) void;
extern fn blst_fp_from_uint64(ret: [*c]blst_fp, a: [*c]const u64) void;
extern fn blst_uint64_from_fp(ret: [*c]u64, a: [*c]const blst_fp) void;
extern fn blst_fp_from_bendian(ret: [*c]blst_fp, a: [*c]const byte) void;
extern fn blst_bendian_from_fp(ret: [*c]byte, a: [*c]const blst_fp) void;
extern fn blst_fp_from_lendian(ret: [*c]blst_fp, a: [*c]const byte) void;
extern fn blst_lendian_from_fp(ret: [*c]byte, a: [*c]const blst_fp) void;
extern fn blst_fp2_add(ret: [*c]blst_fp2, a: [*c]const blst_fp2, b: [*c]const blst_fp2) void;
extern fn blst_fp2_sub(ret: [*c]blst_fp2, a: [*c]const blst_fp2, b: [*c]const blst_fp2) void;
extern fn blst_fp2_mul_by_3(ret: [*c]blst_fp2, a: [*c]const blst_fp2) void;
extern fn blst_fp2_mul_by_8(ret: [*c]blst_fp2, a: [*c]const blst_fp2) void;
extern fn blst_fp2_lshift(ret: [*c]blst_fp2, a: [*c]const blst_fp2, count: usize) void;
extern fn blst_fp2_mul(ret: [*c]blst_fp2, a: [*c]const blst_fp2, b: [*c]const blst_fp2) void;
extern fn blst_fp2_sqr(ret: [*c]blst_fp2, a: [*c]const blst_fp2) void;
extern fn blst_fp2_cneg(ret: [*c]blst_fp2, a: [*c]const blst_fp2, flag: bool) void;
extern fn blst_fp2_eucl_inverse(ret: [*c]blst_fp2, a: [*c]const blst_fp2) void;
extern fn blst_fp2_inverse(ret: [*c]blst_fp2, a: [*c]const blst_fp2) void;
extern fn blst_fp2_sqrt(ret: [*c]blst_fp2, a: [*c]const blst_fp2) bool;
extern fn blst_fp12_sqr(ret: [*c]blst_fp12, a: [*c]const blst_fp12) void;
extern fn blst_fp12_cyclotomic_sqr(ret: [*c]blst_fp12, a: [*c]const blst_fp12) void;
extern fn blst_fp12_mul(ret: [*c]blst_fp12, a: [*c]const blst_fp12, b: [*c]const blst_fp12) void;
extern fn blst_fp12_mul_by_xy00z0(ret: [*c]blst_fp12, a: [*c]const blst_fp12, xy00z0: [*c]const blst_fp6) void;
extern fn blst_fp12_conjugate(a: [*c]blst_fp12) void;
extern fn blst_fp12_inverse(ret: [*c]blst_fp12, a: [*c]const blst_fp12) void;
extern fn blst_fp12_frobenius_map(ret: [*c]blst_fp12, a: [*c]const blst_fp12, n: usize) void;
extern fn blst_fp12_is_equal(a: [*c]const blst_fp12, b: [*c]const blst_fp12) bool;
extern fn blst_fp12_is_one(a: [*c]const blst_fp12) bool;
extern fn blst_fp12_in_group(a: [*c]const blst_fp12) bool;
extern fn blst_fp12_one() [*c]const blst_fp12;
const blst_p1 = extern struct {
x: blst_fp = @import("std").mem.zeroes(blst_fp),
y: blst_fp = @import("std").mem.zeroes(blst_fp),
z: blst_fp = @import("std").mem.zeroes(blst_fp),
};
const blst_p1_affine = extern struct {
x: blst_fp = @import("std").mem.zeroes(blst_fp),
y: blst_fp = @import("std").mem.zeroes(blst_fp),
};
extern fn blst_p1_add(out: [*c]blst_p1, a: [*c]const blst_p1, b: [*c]const blst_p1) void;
extern fn blst_p1_add_or_double(out: [*c]blst_p1, a: [*c]const blst_p1, b: [*c]const blst_p1) void;
extern fn blst_p1_add_affine(out: [*c]blst_p1, a: [*c]const blst_p1, b: [*c]const blst_p1_affine) void;
extern fn blst_p1_add_or_double_affine(out: [*c]blst_p1, a: [*c]const blst_p1, b: [*c]const blst_p1_affine) void;
extern fn blst_p1_double(out: [*c]blst_p1, a: [*c]const blst_p1) void;
extern fn blst_p1_mult(out: [*c]blst_p1, p: [*c]const blst_p1, scalar: [*c]const byte, nbits: usize) void;
extern fn blst_p1_cneg(p: [*c]blst_p1, cbit: bool) void;
extern fn blst_p1_to_affine(out: [*c]blst_p1_affine, in: [*c]const blst_p1) void;
extern fn blst_p1_from_affine(out: [*c]blst_p1, in: [*c]const blst_p1_affine) void;
extern fn blst_p1_on_curve(p: [*c]const blst_p1) bool;
extern fn blst_p1_in_g1(p: [*c]const blst_p1) bool;
extern fn blst_p1_is_equal(a: [*c]const blst_p1, b: [*c]const blst_p1) bool;
extern fn blst_p1_is_inf(a: [*c]const blst_p1) bool;
extern fn blst_p1_generator() [*c]const blst_p1;
extern fn blst_p1_affine_on_curve(p: [*c]const blst_p1_affine) bool;
extern fn blst_p1_affine_in_g1(p: [*c]const blst_p1_affine) bool;
extern fn blst_p1_affine_is_equal(a: [*c]const blst_p1_affine, b: [*c]const blst_p1_affine) bool;
extern fn blst_p1_affine_is_inf(a: [*c]const blst_p1_affine) bool;
extern fn blst_p1_affine_generator() [*c]const blst_p1_affine;
const blst_p2 = extern struct {
x: blst_fp2 = @import("std").mem.zeroes(blst_fp2),
y: blst_fp2 = @import("std").mem.zeroes(blst_fp2),
z: blst_fp2 = @import("std").mem.zeroes(blst_fp2),
};
const blst_p2_affine = extern struct {
x: blst_fp2 = @import("std").mem.zeroes(blst_fp2),
y: blst_fp2 = @import("std").mem.zeroes(blst_fp2),
};
extern fn blst_p2_add(out: [*c]blst_p2, a: [*c]const blst_p2, b: [*c]const blst_p2) void;
extern fn blst_p2_add_or_double(out: [*c]blst_p2, a: [*c]const blst_p2, b: [*c]const blst_p2) void;
extern fn blst_p2_add_affine(out: [*c]blst_p2, a: [*c]const blst_p2, b: [*c]const blst_p2_affine) void;
extern fn blst_p2_add_or_double_affine(out: [*c]blst_p2, a: [*c]const blst_p2, b: [*c]const blst_p2_affine) void;
extern fn blst_p2_double(out: [*c]blst_p2, a: [*c]const blst_p2) void;
extern fn blst_p2_mult(out: [*c]blst_p2, p: [*c]const blst_p2, scalar: [*c]const byte, nbits: usize) void;
extern fn blst_p2_cneg(p: [*c]blst_p2, cbit: bool) void;
extern fn blst_p2_to_affine(out: [*c]blst_p2_affine, in: [*c]const blst_p2) void;
extern fn blst_p2_from_affine(out: [*c]blst_p2, in: [*c]const blst_p2_affine) void;
extern fn blst_p2_on_curve(p: [*c]const blst_p2) bool;
extern fn blst_p2_in_g2(p: [*c]const blst_p2) bool;
extern fn blst_p2_is_equal(a: [*c]const blst_p2, b: [*c]const blst_p2) bool;
extern fn blst_p2_is_inf(a: [*c]const blst_p2) bool;
extern fn blst_p2_generator() [*c]const blst_p2;
extern fn blst_p2_affine_on_curve(p: [*c]const blst_p2_affine) bool;
extern fn blst_p2_affine_in_g2(p: [*c]const blst_p2_affine) bool;
extern fn blst_p2_affine_is_equal(a: [*c]const blst_p2_affine, b: [*c]const blst_p2_affine) bool;
extern fn blst_p2_affine_is_inf(a: [*c]const blst_p2_affine) bool;
extern fn blst_p2_affine_generator() [*c]const blst_p2_affine;
extern fn blst_p1s_to_affine(dst: [*c]blst_p1_affine, points: [*c]const [*c]const blst_p1, npoints: usize) void;
extern fn blst_p1s_add(ret: [*c]blst_p1, points: [*c]const [*c]const blst_p1_affine, npoints: usize) void;
extern fn blst_p1s_mult_wbits_precompute_sizeof(wbits: usize, npoints: usize) usize;
extern fn blst_p1s_mult_wbits_precompute(table: [*c]blst_p1_affine, wbits: usize, points: [*c]const [*c]const blst_p1_affine, npoints: usize) void;
extern fn blst_p1s_mult_wbits_scratch_sizeof(npoints: usize) usize;
extern fn blst_p1s_mult_wbits(ret: [*c]blst_p1, table: [*c]const blst_p1_affine, wbits: usize, npoints: usize, scalars: [*c]const [*c]const byte, nbits: usize, scratch: [*c]limb_t) void;
extern fn blst_p1s_mult_pippenger_scratch_sizeof(npoints: usize) usize;
extern fn blst_p1s_mult_pippenger(ret: [*c]blst_p1, points: [*c]const [*c]const blst_p1_affine, npoints: usize, scalars: [*c]const [*c]const byte, nbits: usize, scratch: [*c]limb_t) void;
extern fn blst_p1s_tile_pippenger(ret: [*c]blst_p1, points: [*c]const [*c]const blst_p1_affine, npoints: usize, scalars: [*c]const [*c]const byte, nbits: usize, scratch: [*c]limb_t, bit0: usize, window: usize) void;
extern fn blst_p2s_to_affine(dst: [*c]blst_p2_affine, points: [*c]const [*c]const blst_p2, npoints: usize) void;
extern fn blst_p2s_add(ret: [*c]blst_p2, points: [*c]const [*c]const blst_p2_affine, npoints: usize) void;
extern fn blst_p2s_mult_wbits_precompute_sizeof(wbits: usize, npoints: usize) usize;
extern fn blst_p2s_mult_wbits_precompute(table: [*c]blst_p2_affine, wbits: usize, points: [*c]const [*c]const blst_p2_affine, npoints: usize) void;
extern fn blst_p2s_mult_wbits_scratch_sizeof(npoints: usize) usize;
extern fn blst_p2s_mult_wbits(ret: [*c]blst_p2, table: [*c]const blst_p2_affine, wbits: usize, npoints: usize, scalars: [*c]const [*c]const byte, nbits: usize, scratch: [*c]limb_t) void;
extern fn blst_p2s_mult_pippenger_scratch_sizeof(npoints: usize) usize;
extern fn blst_p2s_mult_pippenger(ret: [*c]blst_p2, points: [*c]const [*c]const blst_p2_affine, npoints: usize, scalars: [*c]const [*c]const byte, nbits: usize, scratch: [*c]limb_t) void;
extern fn blst_p2s_tile_pippenger(ret: [*c]blst_p2, points: [*c]const [*c]const blst_p2_affine, npoints: usize, scalars: [*c]const [*c]const byte, nbits: usize, scratch: [*c]limb_t, bit0: usize, window: usize) void;
extern fn blst_map_to_g1(out: [*c]blst_p1, u: [*c]const blst_fp, v: [*c]const blst_fp) void;
extern fn blst_map_to_g2(out: [*c]blst_p2, u: [*c]const blst_fp2, v: [*c]const blst_fp2) void;
extern fn blst_encode_to_g1(out: [*c]blst_p1, msg: [*c]const byte, msg_len: usize, DST: [*c]const byte, DST_len: usize, aug: [*c]const byte, aug_len: usize) void;
extern fn blst_hash_to_g1(out: [*c]blst_p1, msg: [*c]const byte, msg_len: usize, DST: [*c]const byte, DST_len: usize, aug: [*c]const byte, aug_len: usize) void;
extern fn blst_encode_to_g2(out: [*c]blst_p2, msg: [*c]const byte, msg_len: usize, DST: [*c]const byte, DST_len: usize, aug: [*c]const byte, aug_len: usize) void;
extern fn blst_hash_to_g2(out: [*c]blst_p2, msg: [*c]const byte, msg_len: usize, DST: [*c]const byte, DST_len: usize, aug: [*c]const byte, aug_len: usize) void;
extern fn blst_p1_serialize(out: [*c]byte, in: [*c]const blst_p1) void;
extern fn blst_p1_compress(out: [*c]byte, in: [*c]const blst_p1) void;
extern fn blst_p1_affine_serialize(out: [*c]byte, in: [*c]const blst_p1_affine) void;
extern fn blst_p1_affine_compress(out: [*c]byte, in: [*c]const blst_p1_affine) void;
extern fn blst_p1_uncompress(out: [*c]blst_p1_affine, in: [*c]const byte) BLST_ERROR;
extern fn blst_p1_deserialize(out: [*c]blst_p1_affine, in: [*c]const byte) BLST_ERROR;
extern fn blst_p2_serialize(out: [*c]byte, in: [*c]const blst_p2) void;
extern fn blst_p2_compress(out: [*c]byte, in: [*c]const blst_p2) void;
extern fn blst_p2_affine_serialize(out: [*c]byte, in: [*c]const blst_p2_affine) void;
extern fn blst_p2_affine_compress(out: [*c]byte, in: [*c]const blst_p2_affine) void;
extern fn blst_p2_uncompress(out: [*c]blst_p2_affine, in: [*c]const byte) BLST_ERROR;
extern fn blst_p2_deserialize(out: [*c]blst_p2_affine, in: [*c]const byte) BLST_ERROR;
extern fn blst_keygen(out_SK: [*c]blst_scalar, IKM: [*c]const byte, IKM_len: usize, info: [*c]const byte, info_len: usize) void;
extern fn blst_sk_to_pk_in_g1(out_pk: [*c]blst_p1, SK: [*c]const blst_scalar) void;
extern fn blst_sign_pk_in_g1(out_sig: [*c]blst_p2, hash: [*c]const blst_p2, SK: [*c]const blst_scalar) void;
extern fn blst_sk_to_pk_in_g2(out_pk: [*c]blst_p2, SK: [*c]const blst_scalar) void;
extern fn blst_sign_pk_in_g2(out_sig: [*c]blst_p1, hash: [*c]const blst_p1, SK: [*c]const blst_scalar) void;
extern fn blst_miller_loop(ret: [*c]blst_fp12, Q: [*c]const blst_p2_affine, P: [*c]const blst_p1_affine) void;
extern fn blst_miller_loop_n(ret: [*c]blst_fp12, Qs: [*c]const [*c]const blst_p2_affine, Ps: [*c]const [*c]const blst_p1_affine, n: usize) void;
extern fn blst_final_exp(ret: [*c]blst_fp12, f: [*c]const blst_fp12) void;
extern fn blst_precompute_lines(Qlines: [*c]blst_fp6, Q: [*c]const blst_p2_affine) void;
extern fn blst_miller_loop_lines(ret: [*c]blst_fp12, Qlines: [*c]const blst_fp6, P: [*c]const blst_p1_affine) void;
extern fn blst_fp12_finalverify(gt1: [*c]const blst_fp12, gt2: [*c]const blst_fp12) bool;
pub const struct_blst_opaque = opaque {};
const blst_pairing = struct_blst_opaque;
extern fn blst_pairing_sizeof() usize;
extern fn blst_pairing_init(new_ctx: ?*blst_pairing, hash_or_encode: bool, DST: [*c]const byte, DST_len: usize) void;
extern fn blst_pairing_get_dst(ctx: ?*const blst_pairing) [*c]const byte;
extern fn blst_pairing_commit(ctx: ?*blst_pairing) void;
extern fn blst_pairing_aggregate_pk_in_g2(ctx: ?*blst_pairing, PK: [*c]const blst_p2_affine, signature: [*c]const blst_p1_affine, msg: [*c]const byte, msg_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_pairing_chk_n_aggr_pk_in_g2(ctx: ?*blst_pairing, PK: [*c]const blst_p2_affine, pk_grpchk: bool, signature: [*c]const blst_p1_affine, sig_grpchk: bool, msg: [*c]const byte, msg_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_pairing_mul_n_aggregate_pk_in_g2(ctx: ?*blst_pairing, PK: [*c]const blst_p2_affine, sig: [*c]const blst_p1_affine, scalar: [*c]const byte, nbits: usize, msg: [*c]const byte, msg_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_pairing_chk_n_mul_n_aggr_pk_in_g2(ctx: ?*blst_pairing, PK: [*c]const blst_p2_affine, pk_grpchk: bool, sig: [*c]const blst_p1_affine, sig_grpchk: bool, scalar: [*c]const byte, nbits: usize, msg: [*c]const byte, msg_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_pairing_aggregate_pk_in_g1(ctx: ?*blst_pairing, PK: [*c]const blst_p1_affine, signature: [*c]const blst_p2_affine, msg: [*c]const byte, msg_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_pairing_chk_n_aggr_pk_in_g1(ctx: ?*blst_pairing, PK: [*c]const blst_p1_affine, pk_grpchk: bool, signature: [*c]const blst_p2_affine, sig_grpchk: bool, msg: [*c]const byte, msg_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_pairing_mul_n_aggregate_pk_in_g1(ctx: ?*blst_pairing, PK: [*c]const blst_p1_affine, sig: [*c]const blst_p2_affine, scalar: [*c]const byte, nbits: usize, msg: [*c]const byte, msg_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_pairing_chk_n_mul_n_aggr_pk_in_g1(ctx: ?*blst_pairing, PK: [*c]const blst_p1_affine, pk_grpchk: bool, sig: [*c]const blst_p2_affine, sig_grpchk: bool, scalar: [*c]const byte, nbits: usize, msg: [*c]const byte, msg_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_pairing_merge(ctx: ?*blst_pairing, ctx1: ?*const blst_pairing) BLST_ERROR;
extern fn blst_pairing_finalverify(ctx: ?*const blst_pairing, gtsig: [*c]const blst_fp12) bool;
extern fn blst_aggregate_in_g1(out: [*c]blst_p1, in: [*c]const blst_p1, zwire: [*c]const byte) BLST_ERROR;
extern fn blst_aggregate_in_g2(out: [*c]blst_p2, in: [*c]const blst_p2, zwire: [*c]const byte) BLST_ERROR;
extern fn blst_aggregated_in_g1(out: [*c]blst_fp12, signature: [*c]const blst_p1_affine) void;
extern fn blst_aggregated_in_g2(out: [*c]blst_fp12, signature: [*c]const blst_p2_affine) void;
extern fn blst_core_verify_pk_in_g1(pk: [*c]const blst_p1_affine, signature: [*c]const blst_p2_affine, hash_or_encode: bool, msg: [*c]const byte, msg_len: usize, DST: [*c]const byte, DST_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
extern fn blst_core_verify_pk_in_g2(pk: [*c]const blst_p2_affine, signature: [*c]const blst_p1_affine, hash_or_encode: bool, msg: [*c]const byte, msg_len: usize, DST: [*c]const byte, DST_len: usize, aug: [*c]const byte, aug_len: usize) BLST_ERROR;
pub extern const BLS12_381_G1: blst_p1_affine;
pub extern const BLS12_381_NEG_G1: blst_p1_affine;
pub extern const BLS12_381_G2: blst_p2_affine;
pub extern const BLS12_381_NEG_G2: blst_p2_affine;
extern fn blst_fr_ct_bfly(x0: [*c]blst_fr, x1: [*c]blst_fr, twiddle: [*c]const blst_fr) void;
extern fn blst_fr_gs_bfly(x0: [*c]blst_fr, x1: [*c]blst_fr, twiddle: [*c]const blst_fr) void;
extern fn blst_fr_to(ret: [*c]blst_fr, a: [*c]const blst_fr) void;
extern fn blst_fr_from(ret: [*c]blst_fr, a: [*c]const blst_fr) void;
extern fn blst_fp_to(ret: [*c]blst_fp, a: [*c]const blst_fp) void;
extern fn blst_fp_from(ret: [*c]blst_fp, a: [*c]const blst_fp) void;
extern fn blst_fp_is_square(a: [*c]const blst_fp) bool;
extern fn blst_fp2_is_square(a: [*c]const blst_fp2) bool;
extern fn blst_p1_from_jacobian(out: [*c]blst_p1, in: [*c]const blst_p1) void;
extern fn blst_p2_from_jacobian(out: [*c]blst_p2, in: [*c]const blst_p2) void;
extern fn blst_sk_to_pk2_in_g1(out: [*c]byte, out_pk: [*c]blst_p1_affine, SK: [*c]const blst_scalar) void;
extern fn blst_sign_pk2_in_g1(out: [*c]byte, out_sig: [*c]blst_p2_affine, hash: [*c]const blst_p2, SK: [*c]const blst_scalar) void;
extern fn blst_sk_to_pk2_in_g2(out: [*c]byte, out_pk: [*c]blst_p2_affine, SK: [*c]const blst_scalar) void;
extern fn blst_sign_pk2_in_g2(out: [*c]byte, out_sig: [*c]blst_p1_affine, hash: [*c]const blst_p1, SK: [*c]const blst_scalar) void;
const blst_uniq = struct_blst_opaque;
extern fn blst_uniq_sizeof(n_nodes: usize) usize;
extern fn blst_uniq_init(tree: ?*blst_uniq) void;
extern fn blst_uniq_test(tree: ?*blst_uniq, msg: [*c]const byte, len: usize) bool;
extern fn blst_expand_message_xmd(out: [*c]byte, out_len: usize, msg: [*c]const byte, msg_len: usize, DST: [*c]const byte, DST_len: usize) void;
extern fn blst_p1_unchecked_mult(out: [*c]blst_p1, p: [*c]const blst_p1, scalar: [*c]const byte, nbits: usize) void;
extern fn blst_p2_unchecked_mult(out: [*c]blst_p2, p: [*c]const blst_p2, scalar: [*c]const byte, nbits: usize) void;
extern fn blst_pairing_raw_aggregate(ctx: ?*blst_pairing, q: [*c]const blst_p2_affine, p: [*c]const blst_p1_affine) void;
extern fn blst_pairing_as_fp12(ctx: ?*blst_pairing) [*c]blst_fp12;
extern fn blst_bendian_from_fp12(out: [*c]byte, a: [*c]const blst_fp12) void;
extern fn blst_keygen_v3(out_SK: [*c]blst_scalar, IKM: [*c]const byte, IKM_len: usize, info: [*c]const byte, info_len: usize) void;
extern fn blst_keygen_v4_5(out_SK: [*c]blst_scalar, IKM: [*c]const byte, IKM_len: usize, salt: [*c]const byte, salt_len: usize, info: [*c]const byte, info_len: usize) void;
extern fn blst_keygen_v5(out_SK: [*c]blst_scalar, IKM: [*c]const byte, IKM_len: usize, salt: [*c]const byte, salt_len: usize, info: [*c]const byte, info_len: usize) void;
extern fn blst_derive_master_eip2333(out_SK: [*c]blst_scalar, IKM: [*c]const byte, IKM_len: usize) void;
extern fn blst_derive_child_eip2333(out_SK: [*c]blst_scalar, SK: [*c]const blst_scalar, child_index: u32) void;
extern fn blst_scalar_from_hexascii(out: [*c]blst_scalar, hex: [*c]const byte) void;
extern fn blst_fr_from_hexascii(ret: [*c]blst_fr, hex: [*c]const byte) void;
extern fn blst_fp_from_hexascii(ret: [*c]blst_fp, hex: [*c]const byte) void;
extern fn blst_p1_sizeof() usize;
extern fn blst_p1_affine_sizeof() usize;
extern fn blst_p2_sizeof() usize;
extern fn blst_p2_affine_sizeof() usize;
extern fn blst_fp12_sizeof() usize;
extern fn blst_fp_from_le_bytes(ret: [*c]blst_fp, in: [*c]const byte, len: usize) void;
extern fn blst_fp_from_be_bytes(ret: [*c]blst_fp, in: [*c]const byte, len: usize) void;
extern fn blst_sha256(out: [*c]byte, msg: [*c]const byte, msg_len: usize) void;
// reexport symbols without blst_ prefix
pub const SUCCESS = BLST_SUCCESS;
pub const BAD_ENCODING = BLST_BAD_ENCODING;
pub const POINT_NOT_ON_CURVE = BLST_POINT_NOT_ON_CURVE;
pub const POINT_NOT_IN_GROUP = BLST_POINT_NOT_IN_GROUP;
pub const AGGR_TYPE_MISMATCH = BLST_AGGR_TYPE_MISMATCH;
pub const VERIFY_FAIL = BLST_VERIFY_FAIL;
pub const PK_IS_INFINITY = BLST_PK_IS_INFINITY;
pub const BAD_SCALAR = BLST_BAD_SCALAR;
pub const ERROR = BLST_ERROR;
pub const scalar = blst_scalar;
pub const fr = blst_fr;
pub const fp = blst_fp;
pub const fp2 = blst_fp2;
pub const fp6 = blst_fp6;
pub const fp12 = blst_fp12;
pub const scalar_from_uint32 = blst_scalar_from_uint32;
pub const uint32_from_scalar = blst_uint32_from_scalar;
pub const scalar_from_uint64 = blst_scalar_from_uint64;
pub const uint64_from_scalar = blst_uint64_from_scalar;
pub const scalar_from_bendian = blst_scalar_from_bendian;
pub const bendian_from_scalar = blst_bendian_from_scalar;
pub const scalar_from_lendian = blst_scalar_from_lendian;
pub const lendian_from_scalar = blst_lendian_from_scalar;
pub const scalar_fr_check = blst_scalar_fr_check;
pub const sk_check = blst_sk_check;
pub const sk_add_n_check = blst_sk_add_n_check;
pub const sk_sub_n_check = blst_sk_sub_n_check;
pub const sk_mul_n_check = blst_sk_mul_n_check;
pub const sk_inverse = blst_sk_inverse;
pub const scalar_from_le_bytes = blst_scalar_from_le_bytes;
pub const scalar_from_be_bytes = blst_scalar_from_be_bytes;
pub const fr_add = blst_fr_add;
pub const fr_sub = blst_fr_sub;
pub const fr_mul_by_3 = blst_fr_mul_by_3;
pub const fr_lshift = blst_fr_lshift;
pub const fr_rshift = blst_fr_rshift;
pub const fr_mul = blst_fr_mul;
pub const fr_sqr = blst_fr_sqr;
pub const fr_cneg = blst_fr_cneg;
pub const fr_eucl_inverse = blst_fr_eucl_inverse;
pub const fr_inverse = blst_fr_inverse;
pub const fr_from_uint64 = blst_fr_from_uint64;
pub const uint64_from_fr = blst_uint64_from_fr;
pub const fr_from_scalar = blst_fr_from_scalar;
pub const scalar_from_fr = blst_scalar_from_fr;
pub const fp_add = blst_fp_add;
pub const fp_sub = blst_fp_sub;
pub const fp_mul_by_3 = blst_fp_mul_by_3;
pub const fp_mul_by_8 = blst_fp_mul_by_8;
pub const fp_lshift = blst_fp_lshift;
pub const fp_mul = blst_fp_mul;
pub const fp_sqr = blst_fp_sqr;
pub const fp_cneg = blst_fp_cneg;
pub const fp_eucl_inverse = blst_fp_eucl_inverse;
pub const fp_inverse = blst_fp_inverse;
pub const fp_sqrt = blst_fp_sqrt;
pub const fp_from_uint32 = blst_fp_from_uint32;
pub const uint32_from_fp = blst_uint32_from_fp;
pub const fp_from_uint64 = blst_fp_from_uint64;
pub const uint64_from_fp = blst_uint64_from_fp;
pub const fp_from_bendian = blst_fp_from_bendian;
pub const bendian_from_fp = blst_bendian_from_fp;
pub const fp_from_lendian = blst_fp_from_lendian;
pub const lendian_from_fp = blst_lendian_from_fp;
pub const fp2_add = blst_fp2_add;
pub const fp2_sub = blst_fp2_sub;
pub const fp2_mul_by_3 = blst_fp2_mul_by_3;
pub const fp2_mul_by_8 = blst_fp2_mul_by_8;
pub const fp2_lshift = blst_fp2_lshift;
pub const fp2_mul = blst_fp2_mul;
pub const fp2_sqr = blst_fp2_sqr;
pub const fp2_cneg = blst_fp2_cneg;
pub const fp2_eucl_inverse = blst_fp2_eucl_inverse;
pub const fp2_inverse = blst_fp2_inverse;
pub const fp2_sqrt = blst_fp2_sqrt;
pub const fp12_sqr = blst_fp12_sqr;
pub const fp12_cyclotomic_sqr = blst_fp12_cyclotomic_sqr;
pub const fp12_mul = blst_fp12_mul;
pub const fp12_mul_by_xy00z0 = blst_fp12_mul_by_xy00z0;
pub const fp12_conjugate = blst_fp12_conjugate;
pub const fp12_inverse = blst_fp12_inverse;
pub const fp12_frobenius_map = blst_fp12_frobenius_map;
pub const fp12_is_equal = blst_fp12_is_equal;
pub const fp12_is_one = blst_fp12_is_one;
pub const fp12_in_group = blst_fp12_in_group;
pub const fp12_one = blst_fp12_one;
pub const p1 = blst_p1;
pub const p1_affine = blst_p1_affine;
pub const p1_add = blst_p1_add;
pub const p1_add_or_double = blst_p1_add_or_double;
pub const p1_add_affine = blst_p1_add_affine;
pub const p1_add_or_double_affine = blst_p1_add_or_double_affine;
pub const p1_double = blst_p1_double;
pub const p1_mult = blst_p1_mult;
pub const p1_cneg = blst_p1_cneg;
pub const p1_to_affine = blst_p1_to_affine;
pub const p1_from_affine = blst_p1_from_affine;
pub const p1_on_curve = blst_p1_on_curve;
pub const p1_in_g1 = blst_p1_in_g1;
pub const p1_is_equal = blst_p1_is_equal;
pub const p1_is_inf = blst_p1_is_inf;
pub const p1_generator = blst_p1_generator;
pub const p1_affine_on_curve = blst_p1_affine_on_curve;
pub const p1_affine_in_g1 = blst_p1_affine_in_g1;
pub const p1_affine_is_equal = blst_p1_affine_is_equal;
pub const p1_affine_is_inf = blst_p1_affine_is_inf;
pub const p1_affine_generator = blst_p1_affine_generator;
pub const p2 = blst_p2;
pub const p2_affine = blst_p2_affine;
pub const p2_add = blst_p2_add;
pub const p2_add_or_double = blst_p2_add_or_double;
pub const p2_add_affine = blst_p2_add_affine;
pub const p2_add_or_double_affine = blst_p2_add_or_double_affine;
pub const p2_double = blst_p2_double;
pub const p2_mult = blst_p2_mult;
pub const p2_cneg = blst_p2_cneg;
pub const p2_to_affine = blst_p2_to_affine;
pub const p2_from_affine = blst_p2_from_affine;
pub const p2_on_curve = blst_p2_on_curve;
pub const p2_in_g2 = blst_p2_in_g2;
pub const p2_is_equal = blst_p2_is_equal;
pub const p2_is_inf = blst_p2_is_inf;
pub const p2_generator = blst_p2_generator;
pub const p2_affine_on_curve = blst_p2_affine_on_curve;
pub const p2_affine_in_g2 = blst_p2_affine_in_g2;
pub const p2_affine_is_equal = blst_p2_affine_is_equal;
pub const p2_affine_is_inf = blst_p2_affine_is_inf;
pub const p2_affine_generator = blst_p2_affine_generator;
pub const p1s_to_affine = blst_p1s_to_affine;
pub const p1s_add = blst_p1s_add;
pub const p1s_mult_wbits_precompute_sizeof = blst_p1s_mult_wbits_precompute_sizeof;
pub const p1s_mult_wbits_precompute = blst_p1s_mult_wbits_precompute;
pub const p1s_mult_wbits_scratch_sizeof = blst_p1s_mult_wbits_scratch_sizeof;
pub const p1s_mult_wbits = blst_p1s_mult_wbits;
pub const p1s_mult_pippenger_scratch_sizeof = blst_p1s_mult_pippenger_scratch_sizeof;
pub const p1s_mult_pippenger = blst_p1s_mult_pippenger;
pub const p1s_tile_pippenger = blst_p1s_tile_pippenger;
pub const p2s_to_affine = blst_p2s_to_affine;
pub const p2s_add = blst_p2s_add;
pub const p2s_mult_wbits_precompute_sizeof = blst_p2s_mult_wbits_precompute_sizeof;
pub const p2s_mult_wbits_precompute = blst_p2s_mult_wbits_precompute;
pub const p2s_mult_wbits_scratch_sizeof = blst_p2s_mult_wbits_scratch_sizeof;
pub const p2s_mult_wbits = blst_p2s_mult_wbits;
pub const p2s_mult_pippenger_scratch_sizeof = blst_p2s_mult_pippenger_scratch_sizeof;
pub const p2s_mult_pippenger = blst_p2s_mult_pippenger;
pub const p2s_tile_pippenger = blst_p2s_tile_pippenger;
pub const map_to_g1 = blst_map_to_g1;
pub const map_to_g2 = blst_map_to_g2;
pub const encode_to_g1 = blst_encode_to_g1;
pub const hash_to_g1 = blst_hash_to_g1;
pub const encode_to_g2 = blst_encode_to_g2;
pub const hash_to_g2 = blst_hash_to_g2;
pub const p1_serialize = blst_p1_serialize;
pub const p1_compress = blst_p1_compress;
pub const p1_affine_serialize = blst_p1_affine_serialize;
pub const p1_affine_compress = blst_p1_affine_compress;
pub const p1_uncompress = blst_p1_uncompress;
pub const p1_deserialize = blst_p1_deserialize;
pub const p2_serialize = blst_p2_serialize;
pub const p2_compress = blst_p2_compress;
pub const p2_affine_serialize = blst_p2_affine_serialize;
pub const p2_affine_compress = blst_p2_affine_compress;
pub const p2_uncompress = blst_p2_uncompress;
pub const p2_deserialize = blst_p2_deserialize;
pub const keygen = blst_keygen;
pub const sk_to_pk_in_g1 = blst_sk_to_pk_in_g1;
pub const sign_pk_in_g1 = blst_sign_pk_in_g1;
pub const sk_to_pk_in_g2 = blst_sk_to_pk_in_g2;
pub const sign_pk_in_g2 = blst_sign_pk_in_g2;
pub const miller_loop = blst_miller_loop;
pub const miller_loop_n = blst_miller_loop_n;
pub const final_exp = blst_final_exp;
pub const precompute_lines = blst_precompute_lines;
pub const miller_loop_lines = blst_miller_loop_lines;
pub const fp12_finalverify = blst_fp12_finalverify;
pub const pairing = blst_pairing;
pub const pairing_sizeof = blst_pairing_sizeof;
pub const pairing_init = blst_pairing_init;
pub const pairing_get_dst = blst_pairing_get_dst;
pub const pairing_commit = blst_pairing_commit;
pub const pairing_aggregate_pk_in_g2 = blst_pairing_aggregate_pk_in_g2;
pub const pairing_chk_n_aggr_pk_in_g2 = blst_pairing_chk_n_aggr_pk_in_g2;
pub const pairing_mul_n_aggregate_pk_in_g2 = blst_pairing_mul_n_aggregate_pk_in_g2;
pub const pairing_chk_n_mul_n_aggr_pk_in_g2 = blst_pairing_chk_n_mul_n_aggr_pk_in_g2;
pub const pairing_aggregate_pk_in_g1 = blst_pairing_aggregate_pk_in_g1;
pub const pairing_chk_n_aggr_pk_in_g1 = blst_pairing_chk_n_aggr_pk_in_g1;
pub const pairing_mul_n_aggregate_pk_in_g1 = blst_pairing_mul_n_aggregate_pk_in_g1;
pub const pairing_chk_n_mul_n_aggr_pk_in_g1 = blst_pairing_chk_n_mul_n_aggr_pk_in_g1;
pub const pairing_merge = blst_pairing_merge;
pub const pairing_finalverify = blst_pairing_finalverify;
pub const aggregate_in_g1 = blst_aggregate_in_g1;
pub const aggregate_in_g2 = blst_aggregate_in_g2;
pub const aggregated_in_g1 = blst_aggregated_in_g1;
pub const aggregated_in_g2 = blst_aggregated_in_g2;
pub const core_verify_pk_in_g1 = blst_core_verify_pk_in_g1;
pub const core_verify_pk_in_g2 = blst_core_verify_pk_in_g2;
pub const fr_ct_bfly = blst_fr_ct_bfly;
pub const fr_gs_bfly = blst_fr_gs_bfly;
pub const fr_to = blst_fr_to;
pub const fr_from = blst_fr_from;
pub const fp_to = blst_fp_to;
pub const fp_from = blst_fp_from;
pub const fp_is_square = blst_fp_is_square;
pub const fp2_is_square = blst_fp2_is_square;
pub const p1_from_jacobian = blst_p1_from_jacobian;
pub const p2_from_jacobian = blst_p2_from_jacobian;
pub const sk_to_pk2_in_g1 = blst_sk_to_pk2_in_g1;
pub const sign_pk2_in_g1 = blst_sign_pk2_in_g1;
pub const sk_to_pk2_in_g2 = blst_sk_to_pk2_in_g2;
pub const sign_pk2_in_g2 = blst_sign_pk2_in_g2;
pub const uniq = blst_uniq;
pub const uniq_sizeof = blst_uniq_sizeof;
pub const uniq_init = blst_uniq_init;
pub const uniq_test = blst_uniq_test;
pub const expand_message_xmd = blst_expand_message_xmd;
pub const p1_unchecked_mult = blst_p1_unchecked_mult;
pub const p2_unchecked_mult = blst_p2_unchecked_mult;
pub const pairing_raw_aggregate = blst_pairing_raw_aggregate;
pub const pairing_as_fp12 = blst_pairing_as_fp12;
pub const bendian_from_fp12 = blst_bendian_from_fp12;
pub const keygen_v3 = blst_keygen_v3;
pub const keygen_v4_5 = blst_keygen_v4_5;
pub const keygen_v5 = blst_keygen_v5;
pub const derive_master_eip2333 = blst_derive_master_eip2333;
pub const derive_child_eip2333 = blst_derive_child_eip2333;
pub const scalar_from_hexascii = blst_scalar_from_hexascii;
pub const fr_from_hexascii = blst_fr_from_hexascii;
pub const fp_from_hexascii = blst_fp_from_hexascii;
pub const p1_sizeof = blst_p1_sizeof;
pub const p1_affine_sizeof = blst_p1_affine_sizeof;
pub const p2_sizeof = blst_p2_sizeof;
pub const p2_affine_sizeof = blst_p2_affine_sizeof;
pub const fp12_sizeof = blst_fp12_sizeof;
pub const fp_from_le_bytes = blst_fp_from_le_bytes;
pub const fp_from_be_bytes = blst_fp_from_be_bytes;
pub const sha256 = blst_sha256;