Line data Source code
1 : #ifndef HEADER_fd_src_ballet_bn254_fd_bn254_h
2 : #define HEADER_fd_src_ballet_bn254_fd_bn254_h
3 :
4 : /* fd_bn254 implements utility functions for the bn254 (alt_bn128) curve. */
5 :
6 : #include "../fd_ballet_base.h"
7 : #include "../bigint/fd_uint256.h"
8 : #include "./fd_bn254_scalar.h"
9 :
10 1752 : #define FD_BN254_PAIRING_BATCH_MAX 16UL
11 400761 : #define FD_BIG_ENDIAN_LIKELY FD_LIKELY
12 :
13 : FD_PROTOTYPES_BEGIN
14 :
15 : int
16 : fd_bn254_g1_add_syscall( uchar out[64],
17 : uchar const in[],
18 : ulong in_sz,
19 : int big_endian );
20 :
21 : int
22 : fd_bn254_g1_scalar_mul_syscall( uchar out[64],
23 : uchar const in[],
24 : ulong in_sz,
25 : int big_endian );
26 :
27 : int
28 : fd_bn254_pairing_is_one_syscall( uchar out[32],
29 : uchar const in[],
30 : ulong in_sz,
31 : int big_endian,
32 : int check_len );
33 :
34 : /* fd_bn254_g1_compress compresses a point in G1.
35 : Input in is a 64-byte big endian buffer representing the point (x, y),
36 : with additional flags.
37 : Output out will contain x, serialized as 32-byte big endian buffer,
38 : with proper flags set.
39 : Returns out on success, NULL on failure.
40 : Note: this function does NOT check that (x, y) is in G1. */
41 : uchar *
42 : fd_bn254_g1_compress( uchar out[32],
43 : uchar const in [64],
44 : int big_endian );
45 :
46 : /* fd_bn254_g1_decompress decompresses a point in G1.
47 : Input in is a 32-byte big endian buffer representing the x coord of a point,
48 : with additional flags.
49 : Output out will contain (x, y), serialized as 64-byte big endian buffer,
50 : with no flags set.
51 : Returns out on success, NULL on failure.
52 : (Success implies that (x, y) is in G1.) */
53 : uchar *
54 : fd_bn254_g1_decompress( uchar out[64],
55 : uchar const in [32],
56 : int big_endian );
57 :
58 : /* fd_bn254_g2_compress compresses a point in G2.
59 : Same as fd_bn254_g1_compress, but x, y are in Fp2, so twice as long.
60 : Input in is a 128-byte big endian buffer representing the point (x, y),
61 : with additional flags.
62 : Output out will contain x, serialized as 64-byte big endian buffer,
63 : with proper flags set.
64 : Returns out on success, NULL on failure.
65 : Note: this function does NOT check that (x, y) is in G2. */
66 : uchar *
67 : fd_bn254_g2_compress( uchar out[64],
68 : uchar const in[128],
69 : int big_endian );
70 :
71 : /* fd_bn254_g2_decompress decompresses a point in G2.
72 : Same as fd_bn254_g1_decompress, but x, y are in Fp2, so twice as long.
73 : Input in is a 64-byte big endian buffer representing the x coord of a point,
74 : with additional flags.
75 : Output out will contain (x, y), serialized as 128-byte big endian buffer,
76 : with no flags set.
77 : Returns out on success, NULL on failure.
78 : Note: this function does NOT check that (x, y) is in G2 (success does NOT
79 : imply that). */
80 : uchar *
81 : fd_bn254_g2_decompress( uchar out[128],
82 : uchar const in [64],
83 : int big_endian );
84 :
85 : FD_PROTOTYPES_END
86 :
87 : #endif /* HEADER_fd_src_ballet_bn254_fd_bn254_h */
|