Improved ID-based Proxy Signature Scheme with Message Recovery
Improved version provided by Caixue Zhou of the Singh and Verma’s proxy signature scheme with message recovery.
Loading...
Searching...
No Matches
data.h
Go to the documentation of this file.
1
7#ifndef DATA_H
8#define DATA_H
9
10#include <string.h>
11#include <pbc/pbc.h>
12#include "define.h"
13
14#define IDENTITY_SIZE 32
15#define WARRANT_SIZE 64
16#define MAX_DIGEST_SIZE 64
17#define MAX_PARAM_LINE_SIZE 4096
18#define generic_dlog_secure_size_by_security_level(level) ((level)*2)
19#define STR_IDENTITY_SIZE(string) strlen(string) > IDENTITY_SIZE ? IDENTITY_SIZE : strlen(string)
20
21typedef enum
22{
23 sha_1,
24 sha_256,
25 sha_512
26} hash_type_t;
27
28typedef uint8_t sv_identity_t[IDENTITY_SIZE];
29typedef uint8_t serialized_warrant_t[WARRANT_SIZE];
30
32{
33 pairing_t pairing; // The pairing used by the scheme.
34 element_t pk; // The public key.
35 element_t P; // The generator of G1.
36 int l1; // Half of number bits of an element in G1.
37 int l2; // Half of number bits of an element in G1.
38 int q; // Order of the group.
39 hash_type_t hash_type; // Hash algorithm used by the scheme.
40 short precompute; // Flag to indicate if the precomputation has been done.
41 pairing_pp_t eP_pp; // Precomputed value of P to speed up pairings e(P,.).
42 pairing_pp_t epk_pp; // Precomputed value of pk to speed up pairings e(pk,.).
43 element_pp_t PP_pp; // Precomputed value of e(P,P) to speed up powers e(P, P)^..
44 element_pp_t P_pp; // Precomputed value of P to speed up multiplications .P.
45 element_pp_t pk_pp; // Precomputed value of pk to speed up multiplications .pk.
46};
48typedef struct sv_public_params_struct sv_public_params_t[1];
49
51{
52 sv_public_params_ptr public_params; // Public parameters of the scheme.
53 element_t msk; // The master secret key.
54};
56typedef struct sv_secret_params_struct sv_secret_params_t[1];
57
59{
60 sv_identity_t id; // Identity of the user.
61 element_t sk; // The secret key of the user.
62 element_t pk; // The public key of the user.
63 element_pp_t sk_pp; // Precomputed value of sk to speed up multiplications .sk.
64};
65typedef struct sv_user_struct *sv_user_ptr;
66typedef struct sv_user_struct sv_user_t[1];
67
69{
70 sv_identity_t from; // Identity of the user that is delegating the signature.
71 sv_identity_t to; // Identity of the user that is invested with the signature.
72};
73typedef struct warrant_struct *warrant_ptr;
74typedef struct warrant_struct warrant_t[1];
75
77{
78 warrant_t m; // Warrant of the delegation.
79 element_t r; // r value used to verify the delegation (in GT).
80 element_t S; // S value used to verify the delegation (in G1).
81};
82typedef struct delegation_struct *delegation_ptr;
83typedef struct delegation_struct delegation_t[1];
84
86{
87 warrant_t m; // Warrant of the delegation.
88 element_t r; // r value used to verify the signature (in GT).
89 element_t V; // V value used to verify the signature (in Zr).
90 element_t U; // U value used to verify the signature (in G1).
91};
93typedef struct proxy_signature_struct proxy_signature_t[1];
94
95long read_binary_file(uint8_t **data, const char file_path[]);
96
106void user_init(sv_user_t user, const sv_identity_t identity, sv_public_params_t public_p);
107
117void user_init_str(sv_user_t user, const char identity[], sv_public_params_t public_p);
118
126void delegation_init(delegation_t w, sv_public_params_t public_p);
127
135void proxy_signature_init(proxy_signature_t p_sig, sv_public_params_t public_p);
136
145uint16_t serialize_warrant(uint8_t buffer[WARRANT_SIZE], const warrant_t m);
146
154uint16_t deserialize_warrant(warrant_t m, const uint8_t buffer[WARRANT_SIZE]);
155
164int serialize_delegation(uint8_t **data, delegation_t w);
165
172void deserialize_delegation(delegation_t w, uint8_t data[]);
173
180void deserialize_delegation_from_file(delegation_t w, const char file_path[]);
181
187void delegation_printf(delegation_t w);
188
195void delegation_fprintf(FILE *stream, delegation_t w);
196
205int serialize_proxy_signature(uint8_t **data, proxy_signature_t p_sign);
206
213void deserialize_proxy_signature(proxy_signature_t p_sign, uint8_t data[]);
214
221void deserialize_proxy_signature_from_file(proxy_signature_t p_sig, const char file_path[]);
222
228void proxy_signature_printf(proxy_signature_t p_sign);
229
236void proxy_signature_fprintf(FILE *stream, proxy_signature_t p_sign);
237
244void public_param_clear(sv_public_params_t public_p);
245
252void secret_param_clear(sv_secret_params_t secret_p);
253
260void user_clear(sv_user_t user);
261
268void delegation_clear(delegation_t w);
269
276void proxy_signature_clear(proxy_signature_t p_sig);
277
278#endif // DATA_H
void delegation_init(delegation_t w, sv_public_params_t public_p)
Initialize the warrant struct. Make sure all elements are initialized.
Definition: data.c:43
void public_param_clear(sv_public_params_t public_p)
Clear the public param struct. Makes sure all elements are cleared.
Definition: data.c:174
void delegation_printf(delegation_t w)
Print the delegation structure to stdout in binary format.
Definition: data.c:104
int serialize_delegation(uint8_t **data, delegation_t w)
Serialize the delegation structure converting it into a byte array. The buffer is allocated inside th...
Definition: data.c:70
void proxy_signature_printf(proxy_signature_t p_sign)
Print the proxy signature structure to stdout in binary format.
Definition: data.c:160
void user_clear(sv_user_t user)
Clear the user struct. Make sure all elements are cleared.
Definition: data.c:194
void user_init(sv_user_t user, const sv_identity_t identity, sv_public_params_t public_p)
Initialize the user struct. Make sure all elements are initialized. Both the secret and public keys a...
Definition: data.c:24
void deserialize_delegation(delegation_t w, uint8_t data[])
Read a serialized delegation from a buffer and deserialize it, obtaining a delegation structure.
Definition: data.c:84
void deserialize_delegation_from_file(delegation_t w, const char file_path[])
Read a serialized delegation from a file and deserialize it, obtaining a delegation structure.
Definition: data.c:94
void user_init_str(sv_user_t user, const char identity[], sv_public_params_t public_p)
Initialize the user struct using a string as identity. Make sure all elements are initialized....
Definition: data.c:35
void deserialize_proxy_signature(proxy_signature_t p_sign, uint8_t data[])
Read a serialized proxy signature from a buffer and deserialize it, obtaining a proxy signature struc...
Definition: data.c:135
void proxy_signature_init(proxy_signature_t p_sig, sv_public_params_t public_p)
Initialize the proxy signature struct. Make sure all elements are initialized.
Definition: data.c:49
uint16_t deserialize_warrant(warrant_t m, const uint8_t buffer[WARRANT_SIZE])
Deserialize a warrant structure converting it from a byte array to a warrant structure.
Definition: data.c:63
void delegation_clear(delegation_t w)
Clear the warrant struct. Make sure all elements are cleared.
Definition: data.c:202
void deserialize_proxy_signature_from_file(proxy_signature_t p_sig, const char file_path[])
Read a serialized proxy signature from a file and deserialize it, obtaining a proxy signature structu...
Definition: data.c:150
uint16_t serialize_warrant(uint8_t buffer[WARRANT_SIZE], const warrant_t m)
Serialize a warrant structure converting it into a byte array. This allows for easy hashing and stora...
Definition: data.c:56
int serialize_proxy_signature(uint8_t **data, proxy_signature_t p_sign)
Serialize the proxy signature structure converting it into a byte array. The buffer is allocated insi...
Definition: data.c:118
void proxy_signature_clear(proxy_signature_t p_sig)
Clear the proxy signature struct. Make sure all elements are cleared.
Definition: data.c:208
void delegation_fprintf(FILE *stream, delegation_t w)
Print the delegation structure to the provided stream in binary format.
Definition: data.c:109
void secret_param_clear(sv_secret_params_t secret_p)
Clear the secret param struct. Make sure all elements are cleared.
Definition: data.c:189
void proxy_signature_fprintf(FILE *stream, proxy_signature_t p_sign)
Print the proxy signature structure to the provided stream in binary format.
Definition: data.c:165
Header file containing some utility macros and constants.
Definition: data.h:77
Definition: data.h:86
Definition: data.h:32
Definition: data.h:51
Definition: data.h:59
Definition: data.h:69
void p_sign(proxy_signature_t p_sig, element_t k_sign, delegation_t w, const uint8_t msg[], size_t msg_size, sv_public_params_t public_p)
The proxy signer signs a message m. After choosing a random k in Zq*, the proxy signer computes the f...
Definition: sv-scheme.c:3