CiFEr
damgard.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_DAMGARD_H
18 #define CIFER_DAMGARD_H
19 
20 #include "cifer/data/vec.h"
21 #include "cifer/internal/errors.h"
22 
32 typedef struct cfe_damgard {
33  size_t l;
34  mpz_t bound;
35  mpz_t g;
36  mpz_t h;
37  mpz_t p;
38  mpz_t q;
39 } cfe_damgard;
40 
44 typedef struct cfe_damgard_sec_key {
45  cfe_vec s;
46  cfe_vec t;
48 
52 typedef struct cfe_damgard_fe_key {
53  mpz_t key1;
54  mpz_t key2;
56 
68 cfe_error cfe_damgard_init(cfe_damgard *s, size_t l, size_t modulus_len, mpz_t bound);
69 
82 cfe_error cfe_damgard_precomp_init(cfe_damgard *s, size_t l, size_t modulus_len, mpz_t bound);
83 
92 
102 
110 
118 
127 
136 
147 
154 
168 
176 void cfe_damgard_ciphertext_init(cfe_vec *ciphertext, cfe_damgard *s);
177 
190 cfe_error cfe_damgard_encrypt(cfe_vec *ciphertext, cfe_damgard *s, cfe_vec *x, cfe_vec *mpk);
191 
205 cfe_error cfe_damgard_decrypt(mpz_t res, cfe_damgard *s, cfe_vec *ciphertext, cfe_damgard_fe_key *key, cfe_vec *y);
206 
207 #endif
cfe_vec
Definition: vec.h:41
cfe_damgard_fe_key
struct cfe_damgard_fe_key cfe_damgard_fe_key
cfe_damgard_precomp_init
cfe_error cfe_damgard_precomp_init(cfe_damgard *s, size_t l, size_t modulus_len, mpz_t bound)
cfe_damgard_fe_key_init
void cfe_damgard_fe_key_init(cfe_damgard_fe_key *fe_key)
cfe_damgard_fe_key_free
void cfe_damgard_fe_key_free(cfe_damgard_fe_key *key)
errors.h
Error definitions.
cfe_damgard_derive_fe_key
cfe_error cfe_damgard_derive_fe_key(cfe_damgard_fe_key *fe_key, cfe_damgard *s, cfe_damgard_sec_key *msk, cfe_vec *y)
cfe_damgard_pub_key_init
void cfe_damgard_pub_key_init(cfe_vec *mpk, cfe_damgard *s)
cfe_damgard_generate_master_keys
void cfe_damgard_generate_master_keys(cfe_damgard_sec_key *msk, cfe_vec *mpk, cfe_damgard *s)
cfe_damgard_sec_key_init
void cfe_damgard_sec_key_init(cfe_damgard_sec_key *msk, cfe_damgard *s)
cfe_damgard_sec_key
struct cfe_damgard_sec_key cfe_damgard_sec_key
cfe_damgard_encrypt
cfe_error cfe_damgard_encrypt(cfe_vec *ciphertext, cfe_damgard *s, cfe_vec *x, cfe_vec *mpk)
cfe_damgard_init
cfe_error cfe_damgard_init(cfe_damgard *s, size_t l, size_t modulus_len, mpz_t bound)
cfe_damgard_free
void cfe_damgard_free(cfe_damgard *s)
cfe_damgard_sec_key_free
void cfe_damgard_sec_key_free(cfe_damgard_sec_key *key)
cfe_damgard_sec_key
Definition: damgard.h:44
cfe_damgard_ciphertext_init
void cfe_damgard_ciphertext_init(cfe_vec *ciphertext, cfe_damgard *s)
cfe_damgard
Definition: damgard.h:32
vec.h
Vector struct and operations.
cfe_damgard
struct cfe_damgard cfe_damgard
cfe_damgard_fe_key
Definition: damgard.h:52
cfe_damgard_copy
void cfe_damgard_copy(cfe_damgard *res, cfe_damgard *s)
cfe_damgard_decrypt
cfe_error cfe_damgard_decrypt(mpz_t res, cfe_damgard *s, cfe_vec *ciphertext, cfe_damgard_fe_key *key, cfe_vec *y)