libhcs
egcs.h
Go to the documentation of this file.
1 
16 #ifndef HCS_EGCS_H
17 #define HCS_EGCS_H
18 
19 #include <gmp.h>
20 #include "hcs_random.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
29 typedef struct {
30  mpz_t c1;
31  mpz_t c2;
32 } egcs_cipher;
33 
37 typedef struct {
38  mpz_t g;
39  mpz_t q;
40  mpz_t h;
42 
46 typedef struct {
47  mpz_t x;
48  mpz_t q;
50 
59 
68 
83  hcs_random *hr, const unsigned long bits);
84 
92 
99 void egcs_set(egcs_cipher *rop, egcs_cipher *op);
100 
110  mpz_t plain1);
111 
122  egcs_cipher *ct2);
123 
131 void egcs_decrypt(egcs_private_key *vk, mpz_t rop, egcs_cipher *cipher1);
132 
139 
145 void egcs_free_cipher(egcs_cipher *ct);
146 
154 
162 
169 
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif
void egcs_set(egcs_cipher *rop, egcs_cipher *op)
Copy value of op to rop.
Provides secure random state for use in functions which require random values.
egcs_cipher * egcs_init_cipher(void)
Initialise a egcs_cipher and return a pointer to the newly created structure.
void egcs_clear_cipher(egcs_cipher *ct)
Zero all data related to the given egcs_cipher.
mpz_t c2
Second value of egcs cipher.
Definition: egcs.h:31
mpz_t q
Order of the cyclic group.
Definition: egcs.h:48
mpz_t g
Generator for the cyclic group.
Definition: egcs.h:38
void egcs_decrypt(egcs_private_key *vk, mpz_t rop, egcs_cipher *cipher1)
Decrypt a value cipher1, and set rop to the decrypted result.
egcs_public_key * egcs_init_public_key(void)
Initialise a egcs_public_key and return a pointer to the newly created structure. ...
mpz_t x
Random value in {1, ..., q-1}.
Definition: egcs.h:47
mpz_t h
g^x in G
Definition: egcs.h:40
void egcs_ee_mul(egcs_public_key *pk, egcs_cipher *rop, egcs_cipher *ct1, egcs_cipher *ct2)
Multiply an encrypted value ct1 with an encrypted value ct2, storing the result in rop...
mpz_t q
Order of the cyclic group.
Definition: egcs.h:39
void egcs_generate_key_pair(egcs_public_key *pk, egcs_private_key *vk, hcs_random *hr, const unsigned long bits)
Initialise a key pair with modulus size bits.
egcs_private_key * egcs_init_private_key(void)
Initialise a egcs_private_key and return a pointer to the newly created structure.
void egcs_clear_public_key(egcs_public_key *pk)
Zero all memory associated with a egcs_public_key.
Private key for use in the ElGamal scheme.
Definition: egcs.h:46
void egcs_free_public_key(egcs_public_key *pk)
Frees a egcs_public_key and all associated memory.
void egcs_free_private_key(egcs_private_key *vk)
Frees a egcs_private_key and all associated memory.
mpz_t c1
First value of egcs cipher.
Definition: egcs.h:30
void egcs_encrypt(egcs_public_key *pk, hcs_random *hr, egcs_cipher *rop, mpz_t plain1)
Encrypt a value plain1, and set rop to the encrypted result.
void egcs_free_cipher(egcs_cipher *ct)
Free all associated memory with a given egcs_cipher.
Public key for use in the ElGamal scheme.
Definition: egcs.h:37
Ciphertext type for use in the ElGamal scheme.
Definition: egcs.h:29
void egcs_clear_private_key(egcs_private_key *vk)
Zero all memory associated with a egcs_private_key.
Random state used by a number of cryptographic functions.
Definition: hcs_random.h:39