libBBS
 
Loading...
Searching...
No Matches
bbs.h
Go to the documentation of this file.
1
14#ifndef BBS_H
15#define BBS_H
16
17#include <stdint.h>
18#include <stdarg.h>
19
23#define BBS_SK_LEN 32
24
28#define BBS_PK_LEN 96
29
33#define BBS_SIG_LEN 80
34
38#define BBS_PROOF_BASE_LEN 272
39
43#define BBS_PROOF_UD_ELEM_LEN 32
44
50#define BBS_PROOF_LEN(num_undisclosed) (BBS_PROOF_BASE_LEN + num_undisclosed * BBS_PROOF_UD_ELEM_LEN \
51 )
52
56#define BBS_OK 0
57
61#define BBS_ERROR 1
62
69typedef uint8_t bbs_secret_key[BBS_SK_LEN];
70
77typedef uint8_t bbs_public_key[BBS_PK_LEN];
78
85typedef uint8_t bbs_signature[BBS_SIG_LEN];
86
93typedef struct bbs_cipher_suite bbs_cipher_suite_t;
94
102int
103bbs_init (void);
104
105
112int
113bbs_deinit (void);
114
115// Key Generation
116
128int bbs_keygen_full (
129 bbs_cipher_suite_t *cipher_suite,
132 );
133
134
155int bbs_keygen (
156 bbs_cipher_suite_t *cipher_suite,
158 const uint8_t *key_material,
159 uint16_t key_material_len,
160 const uint8_t *key_info,
161 uint16_t key_info_len,
162 const uint8_t *key_dst,
163 uint8_t key_dst_len
164 );
165
176int bbs_sk_to_pk (
177 bbs_cipher_suite_t *cipher_suite,
178 const bbs_secret_key sk,
180 );
181
201int bbs_sign (
202 bbs_cipher_suite_t *cipher_suite,
203 const bbs_secret_key sk,
204 const bbs_public_key pk,
205 bbs_signature signature,
206 const uint8_t *header,
207 uint64_t header_len,
208 uint64_t num_messages,
209 ...
210 );
211
230int bbs_verify (
231 bbs_cipher_suite_t *cipher_suite,
232 const bbs_public_key pk,
233 const bbs_signature signature,
234 const uint8_t *header,
235 uint64_t header_len,
236 uint64_t num_messages,
237 ...
238 );
239
271int bbs_proof_gen (
272 bbs_cipher_suite_t *cipher_suite,
273 const bbs_public_key pk,
274 const bbs_signature signature,
275 uint8_t *proof,
276 const uint8_t *header,
277 uint64_t header_len,
278 const uint8_t *presentation_header,
279 uint64_t presentation_header_len,
280 const uint64_t *disclosed_indexes,
281 uint64_t disclosed_indexes_len,
282 uint64_t num_messages,
283 ...
284 );
285
315 bbs_cipher_suite_t *cipher_suite,
316 const bbs_public_key pk,
317 const uint8_t *proof,
318 uint64_t proof_len,
319 const uint8_t *header,
320 uint64_t header_len,
321 const uint8_t *presentation_header,
322 uint64_t presentation_header_len,
323 const uint64_t *disclosed_indexes,
324 uint64_t disclosed_indexes_len,
325 uint64_t num_messages,
326 ...
327 );
328
335
340#define bbs_sha256_keygen_full(...) bbs_keygen_full(bbs_sha256_cipher_suite,__VA_ARGS__)
341
346#define bbs_sha256_keygen(...) bbs_keygen(bbs_sha256_cipher_suite,__VA_ARGS__)
347
352#define bbs_sha256_sk_to_pk(...) bbs_sk_to_pk(bbs_sha256_cipher_suite,__VA_ARGS__)
353
358#define bbs_sha256_sign(...) bbs_sign(bbs_sha256_cipher_suite,__VA_ARGS__)
359
364#define bbs_sha256_verify(...) bbs_verify(bbs_sha256_cipher_suite,__VA_ARGS__)
365
370#define bbs_sha256_proof_gen(...) bbs_proof_gen(bbs_sha256_cipher_suite,__VA_ARGS__)
371
376#define bbs_sha256_proof_verify(...) bbs_proof_verify(bbs_sha256_cipher_suite,__VA_ARGS__)
377
384
390#define bbs_shake256_keygen_full(...) bbs_keygen_full(bbs_shake256_cipher_suite,__VA_ARGS__)
395#define bbs_shake256_keygen(...) bbs_keygen(bbs_shake256_cipher_suite,__VA_ARGS__)
396
401#define bbs_shake256_sk_to_pk(...) bbs_sk_to_pk(bbs_shake256_cipher_suite,__VA_ARGS__)
402
407#define bbs_shake256_sign(...) bbs_sign(bbs_shake256_cipher_suite,__VA_ARGS__)
408
413#define bbs_shake256_verify(...) bbs_verify(bbs_shake256_cipher_suite,__VA_ARGS__)
414
419#define bbs_shake256_proof_gen(...) bbs_proof_gen(bbs_shake256_cipher_suite,__VA_ARGS__)
420
425#define bbs_shake256_proof_verify(...) bbs_proof_verify(bbs_shake256_cipher_suite,__VA_ARGS__)
426
427#endif
bbs_cipher_suite_t * bbs_shake256_cipher_suite
Definition bbs.c:87
int bbs_sign(bbs_cipher_suite_t *cipher_suite, const bbs_secret_key sk, const bbs_public_key pk, bbs_signature signature, const uint8_t *header, uint64_t header_len, uint64_t num_messages,...)
Create a signature.
Definition bbs.c:249
uint8_t bbs_public_key[BBS_PK_LEN]
BBS public key.
Definition bbs.h:77
#define BBS_PK_LEN
Octet string length of public key.
Definition bbs.h:28
int bbs_proof_gen(bbs_cipher_suite_t *cipher_suite, const bbs_public_key pk, const bbs_signature signature, uint8_t *proof, const uint8_t *header, uint64_t header_len, const uint8_t *presentation_header, uint64_t presentation_header_len, const uint64_t *disclosed_indexes, uint64_t disclosed_indexes_len, uint64_t num_messages,...)
Create a proof over a signature.
Definition bbs.c:1066
int bbs_sk_to_pk(bbs_cipher_suite_t *cipher_suite, const bbs_secret_key sk, bbs_public_key pk)
Definition bbs.c:216
bbs_cipher_suite_t * bbs_sha256_cipher_suite
Definition bbs.c:61
int bbs_proof_verify(bbs_cipher_suite_t *cipher_suite, const bbs_public_key pk, const uint8_t *proof, uint64_t proof_len, const uint8_t *header, uint64_t header_len, const uint8_t *presentation_header, uint64_t presentation_header_len, const uint64_t *disclosed_indexes, uint64_t disclosed_indexes_len, uint64_t num_messages,...)
Verify a proof over a signature.
Definition bbs.c:1125
int bbs_verify(bbs_cipher_suite_t *cipher_suite, const bbs_public_key pk, const bbs_signature signature, const uint8_t *header, uint64_t header_len, uint64_t num_messages,...)
Verify a signature.
Definition bbs.c:445
uint8_t bbs_signature[BBS_SIG_LEN]
BBS signature.
Definition bbs.h:85
struct bbs_cipher_suite bbs_cipher_suite_t
BBS cipher suite.
Definition bbs.h:93
#define BBS_SK_LEN
Octet string length of secret key.
Definition bbs.h:23
int bbs_keygen_full(bbs_cipher_suite_t *cipher_suite, bbs_secret_key sk, bbs_public_key pk)
Definition bbs.c:91
int bbs_deinit(void)
Definition bbs.c:209
#define BBS_SIG_LEN
Octet string length of signature.
Definition bbs.h:33
int bbs_init(void)
Definition bbs.c:193
int bbs_keygen(bbs_cipher_suite_t *cipher_suite, bbs_secret_key sk, const uint8_t *key_material, uint16_t key_material_len, const uint8_t *key_info, uint16_t key_info_len, const uint8_t *key_dst, uint8_t key_dst_len)
Definition bbs.c:127
uint8_t bbs_secret_key[BBS_SK_LEN]
BBS secret key.
Definition bbs.h:69