CiFEr
ddh.h
Go to the documentation of this file.
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_DDH_H
18 #define CIFER_DDH_H
19 
20 #include "cifer/data/vec.h"
21 #include "cifer/internal/errors.h"
22 
32 typedef struct cfe_ddh {
33  size_t l;
34  mpz_t bound;
35  mpz_t g;
36  mpz_t p;
37  mpz_t q;
38 } cfe_ddh;
39 
51 cfe_error cfe_ddh_init(cfe_ddh *s, size_t l, size_t modulus_len, mpz_t bound);
52 
65 cfe_error cfe_ddh_precomp_init(cfe_ddh *s, size_t l, size_t modulus_len, mpz_t bound);
66 
73 void cfe_ddh_free(cfe_ddh *s);
74 
82 void cfe_ddh_copy(cfe_ddh *res, cfe_ddh *s);
83 
92 void cfe_ddh_master_keys_init(cfe_vec *msk, cfe_vec *mpk, cfe_ddh *s);
93 
100 void cfe_ddh_ciphertext_init(cfe_vec *ciphertext, cfe_ddh *s);
101 
111 
122 cfe_error cfe_ddh_derive_fe_key(mpz_t res, cfe_ddh *s, cfe_vec *msk, cfe_vec *y);
123 
135 cfe_error cfe_ddh_encrypt(cfe_vec *ciphertext, cfe_ddh *s, cfe_vec *x, cfe_vec *mpk);
136 
149 cfe_error cfe_ddh_decrypt(mpz_t res, cfe_ddh *s, cfe_vec *ciphertext, mpz_t key, cfe_vec *y);
150 
151 #endif
cfe_ddh_precomp_init
cfe_error cfe_ddh_precomp_init(cfe_ddh *s, size_t l, size_t modulus_len, mpz_t bound)
cfe_vec
Definition: vec.h:41
cfe_ddh_init
cfe_error cfe_ddh_init(cfe_ddh *s, size_t l, size_t modulus_len, mpz_t bound)
cfe_ddh_master_keys_init
void cfe_ddh_master_keys_init(cfe_vec *msk, cfe_vec *mpk, cfe_ddh *s)
errors.h
Error definitions.
cfe_ddh_copy
void cfe_ddh_copy(cfe_ddh *res, cfe_ddh *s)
cfe_ddh
struct cfe_ddh cfe_ddh
cfe_ddh_free
void cfe_ddh_free(cfe_ddh *s)
cfe_ddh_generate_master_keys
void cfe_ddh_generate_master_keys(cfe_vec *msk, cfe_vec *mpk, cfe_ddh *s)
cfe_ddh_encrypt
cfe_error cfe_ddh_encrypt(cfe_vec *ciphertext, cfe_ddh *s, cfe_vec *x, cfe_vec *mpk)
vec.h
Vector struct and operations.
cfe_ddh
Definition: ddh.h:32
cfe_ddh_decrypt
cfe_error cfe_ddh_decrypt(mpz_t res, cfe_ddh *s, cfe_vec *ciphertext, mpz_t key, cfe_vec *y)
cfe_ddh_derive_fe_key
cfe_error cfe_ddh_derive_fe_key(mpz_t res, cfe_ddh *s, cfe_vec *msk, cfe_vec *y)
cfe_ddh_ciphertext_init
void cfe_ddh_ciphertext_init(cfe_vec *ciphertext, cfe_ddh *s)