CiFEr
data_ser.h
1 /*
2  * Copyright (c) 2018 XLAB d.o.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CIFER_DATA_SER_H
18 #define CIFER_DATA_SER_H
19 
20 #include <cifer/data/mat.h>
21 #include <cifer/data/vec_curve.h>
22 #include <cifer/abe/policy.h>
23 #include "data.pb-c.h"
24 
25 typedef struct cfe_ser {
26  uint8_t *ser;
27  size_t len;
28 } cfe_ser;
29 
30 void cfe_ser_free(cfe_ser *s);
31 
32 void cfe_mpz_ser_init(MpzSer *o);
33 
34 void cfe_mpz_pack(mpz_t a, MpzSer *msg);
35 
36 void cfe_mpz_ser(mpz_t aa, cfe_ser *buf);
37 
38 void cfe_mpz_unpack(mpz_t a, MpzSer *msg);
39 
40 cfe_error cfe_mpz_read(mpz_t a, cfe_ser *buf);
41 
42 void cfe_mat_pack(cfe_mat *a, MatSer *msg, MpzSer *val);
43 
44 void cfe_mat_ser(cfe_mat *a, cfe_ser *buf);
45 
46 void cfe_mat_unpack(cfe_mat *a, MatSer *msg);
47 
48 cfe_error cfe_mat_read(cfe_mat *a, cfe_ser *buf);
49 
50 void cfe_octet_ser_init(OctetSer *o);
51 
52 void cfe_ECP_BN254_pack(ECP_BN254 *a, OctetSer *msg);
53 
54 void cfe_ECP_BN254_ser(ECP_BN254 *a, cfe_ser *buf);
55 
56 void cfe_ECP_BN254_unpack(ECP_BN254 *a, OctetSer *msg);
57 
58 cfe_error cfe_ECP_BN254_read(ECP_BN254 *a, cfe_ser *buf);
59 
60 void cfe_ECP2_BN254_pack(ECP2_BN254 *a, OctetSer *msg);
61 
62 void cfe_ECP2_BN254_ser(ECP2_BN254 *a, cfe_ser *buf);
63 
64 void cfe_ECP2_BN254_unpack(ECP2_BN254 *a, OctetSer *msg);
65 
66 cfe_error cfe_ECP2_BN254_read(ECP2_BN254 *a, cfe_ser *buf);
67 
68 void cfe_FP12_BN254_pack(FP12_BN254 *a, OctetSer *msg);
69 
70 void cfe_FP12_BN254_ser(FP12_BN254 *a, cfe_ser *buf);
71 
72 void cfe_FP12_BN254_unpack(FP12_BN254 *a, OctetSer *msg);
73 
74 cfe_error cfe_FP12_BN254_read(FP12_BN254 *a, cfe_ser *buf);
75 
76 void cfe_msp_pack(cfe_msp *a, MspSer *msg, MpzSer *val);
77 
78 void cfe_msp_ser(cfe_msp *a, cfe_ser *buf);
79 
80 void cfe_msp_unpack(cfe_msp *a, MspSer *msg);
81 
82 cfe_error cfe_msp_read(cfe_msp *a, cfe_ser *buf);
83 
84 void cfe_vec_octet_pack(cfe_vec_octet *a, VecOctetSer *msg, OctetSer *val);
85 
86 void cfe_vec_octet_ser(cfe_vec_octet *a, cfe_ser *buf);
87 
88 void cfe_vec_octet_unpack(cfe_vec_octet *a, VecOctetSer *msg);
89 
90 cfe_error cfe_vec_octet_read(cfe_vec_octet *a, cfe_ser *buf);
91 
92 void cfe_vec_ECP2_BN254_ser(cfe_vec_G2 *a, cfe_ser *buf);
93 
94 cfe_error cfe_vec_ECP2_BN254_read(cfe_vec_G2 *a, cfe_ser *buf);
95 
96 #endif
cfe_vec_octet
Definition: vec_curve.h:58
policy.h
Functions for policy conversion needed for ABE schemes.
cfe_ser
Definition: data_ser.h:25
mat.h
Matrix struct and operations.
vec_curve.h
Vectors of elements of an elliptic curve struct and operations on it.
cfe_msp
Definition: policy.h:43
_MspSer
Definition: data.pb-c.h:68
cfe_vec_G2
Definition: vec_curve.h:42
_OctetSer
Definition: data.pb-c.h:55
_VecOctetSer
Definition: data.pb-c.h:80
cfe_mat
Definition: mat.h:44
_MatSer
Definition: data.pb-c.h:42