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