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 510 : #define FD_BN254_PAIRING_BATCH_MAX 16UL
11 :
12 : FD_PROTOTYPES_BEGIN
13 :
14 : int
15 : fd_bn254_g1_add_syscall( uchar out[64],
16 : uchar const in[],
17 : ulong in_sz );
18 :
19 : int
20 : fd_bn254_g1_scalar_mul_syscall( uchar out[64],
21 : uchar const in[],
22 : ulong in_sz );
23 :
24 : int
25 : fd_bn254_pairing_is_one_syscall( uchar out[32],
26 : uchar const in[],
27 : ulong in_sz );
28 :
29 : /* fd_bn254_g1_compress compresses a point in G1.
30 : Input in is a 64-byte big endian buffer representing the point (x, y),
31 : with additional flags.
32 : Output out will contain x, serialized as 32-byte big endian buffer,
33 : with proper flags set.
34 : Returns out on success, NULL on failure.
35 : Note: this function does NOT check that (x, y) is in G1. */
36 : uchar *
37 : fd_bn254_g1_compress( uchar out[32],
38 : uchar const in [64] );
39 :
40 : /* fd_bn254_g1_decompress decompresses a point in G1.
41 : Input in is a 32-byte big endian buffer representing the x coord of a point,
42 : with additional flags.
43 : Output out will contain (x, y), serialized as 64-byte big endian buffer,
44 : with no flags set.
45 : Returns out on success, NULL on failure.
46 : (Success implies that (x, y) is in G1.) */
47 : uchar *
48 : fd_bn254_g1_decompress( uchar out[64],
49 : uchar const in [32] );
50 :
51 : /* fd_bn254_g2_compress compresses a point in G2.
52 : Same as fd_bn254_g1_compress, but x, y are in Fp2, so twice as long.
53 : Input in is a 128-byte big endian buffer representing the point (x, y),
54 : with additional flags.
55 : Output out will contain x, serialized as 64-byte big endian buffer,
56 : with proper flags set.
57 : Returns out on success, NULL on failure.
58 : Note: this function does NOT check that (x, y) is in G2. */
59 : uchar *
60 : fd_bn254_g2_compress( uchar out[64],
61 : uchar const in[128] );
62 :
63 : /* fd_bn254_g2_decompress decompresses a point in G2.
64 : Same as fd_bn254_g1_decompress, but x, y are in Fp2, so twice as long.
65 : Input in is a 64-byte big endian buffer representing the x coord of a point,
66 : with additional flags.
67 : Output out will contain (x, y), serialized as 128-byte big endian buffer,
68 : with no flags set.
69 : Returns out on success, NULL on failure.
70 : Note: this function does NOT check that (x, y) is in G2 (success does NOT
71 : imply that). */
72 : uchar *
73 : fd_bn254_g2_decompress( uchar out[128],
74 : uchar const in [64] );
75 :
76 : FD_PROTOTYPES_END
77 :
78 : #endif /* HEADER_fd_src_ballet_bn254_fd_bn254_h */
|