GNUnet 0.22.2
crypto_blind_sign.c
Go to the documentation of this file.
1/*
2 This file is part of GNUNET
3 Copyright (C) 2021, 2022, 2023 GNUnet e.V.
4
5 GNUNET is free software; you can redistribute it and/or modify it under the
6 terms of the GNU General Public License as published by the Free Software
7 Foundation; either version 3, or (at your option) any later version.
8
9 GNUNET is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along with
14 GNUNET; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
15*/
21#include "platform.h"
22#include "gnunet_util_lib.h"
23
24
25void
28{
29 GNUNET_assert (bm->rc > 0);
30 bm->rc--;
31 if (0 != bm->rc)
32 return;
33 switch (bm->cipher)
34 {
36 GNUNET_break (0);
37 break;
40 break;
43 break;
44 }
45 GNUNET_free (bm);
46}
47
48
49void
51 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
52{
53 GNUNET_assert (bsign_priv->rc > 0);
54 bsign_priv->rc--;
55 if (0 != bsign_priv->rc)
56 return;
57 switch (bsign_priv->cipher)
58 {
60 GNUNET_break (0);
61 break;
63 if (NULL != bsign_priv->details.rsa_private_key)
64 {
66 bsign_priv->details.rsa_private_key = NULL;
67 }
69 break;
72 break;
73 }
74 GNUNET_free (bsign_priv);
75}
76
77
78void
80 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
81{
82 GNUNET_assert (bsign_pub->rc > 0);
83 bsign_pub->rc--;
84 if (0 != bsign_pub->rc)
85 return;
86 switch (bsign_pub->cipher)
87 {
89 GNUNET_break (0);
90 break;
92 if (NULL != bsign_pub->details.rsa_public_key)
93 {
95 bsign_pub->details.rsa_public_key = NULL;
96 }
98 break;
100 break;
101 }
102 GNUNET_free (bsign_pub);
103}
104
105
106void
109{
110 GNUNET_assert (ub_sig->rc > 0);
111 ub_sig->rc--;
112 if (0 != ub_sig->rc)
113 return;
114 switch (ub_sig->cipher)
115 {
117 GNUNET_break (0);
118 break;
120 if (NULL != ub_sig->details.rsa_signature)
121 {
123 ub_sig->details.rsa_signature = NULL;
124 }
126 break;
129 break;
130 }
131 GNUNET_free (ub_sig);
132}
133
134
135void
137 struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
138{
139 GNUNET_assert (blind_sig->rc > 0);
140 blind_sig->rc--;
141 if (0 != blind_sig->rc)
142 return;
143 switch (blind_sig->cipher)
144 {
146 GNUNET_break (0);
147 break;
149 if (NULL != blind_sig->details.blinded_rsa_signature)
150 {
152 blind_sig->details.blinded_rsa_signature);
153 blind_sig->details.blinded_rsa_signature = NULL;
154 }
156 break;
159 break;
160 }
161 GNUNET_free (blind_sig);
162}
163
164
165void
168{
169 GNUNET_assert (bm->rc > 0);
170 bm->rc--;
171 if (0 != bm->rc)
172 return;
173 switch (bm->cipher)
174 {
176 GNUNET_break (0);
177 break;
180 break;
182 break;
183 }
184 GNUNET_free (bm);
185}
186
187
191{
192 bm->rc++;
193 return bm;
194}
195
196
200{
201 bm->rc++;
202 return bm;
203}
204
205
208 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
209{
210 bsign_pub->rc++;
211 return bsign_pub;
212}
213
214
217 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
218{
219 bsign_priv->rc++;
220 return bsign_priv;
221}
222
223
226{
227 ub_sig->rc++;
228 return ub_sig;
229}
230
231
234 struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
235{
236 blind_sig->rc++;
237 return blind_sig;
238}
239
240
241int
243 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1,
244 const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2)
245{
246 if (bp1->cipher != bp2->cipher)
247 return (bp1->cipher > bp2->cipher) ? 1 : -1;
248 switch (bp1->cipher)
249 {
251 GNUNET_break (0);
252 return 0;
254 return GNUNET_memcmp (&bp1->pub_key_hash,
255 &bp2->pub_key_hash);
257 return GNUNET_memcmp (&bp1->pub_key_hash,
258 &bp2->pub_key_hash);
259 }
260 GNUNET_assert (0);
261 return -2;
262}
263
264
265int
267 const struct GNUNET_CRYPTO_UnblindedSignature *sig1,
268 const struct GNUNET_CRYPTO_UnblindedSignature *sig2)
269{
270 if (sig1->cipher != sig2->cipher)
271 return (sig1->cipher > sig2->cipher) ? 1 : -1;
272 switch (sig1->cipher)
273 {
275 GNUNET_break (0);
276 return 0;
279 sig2->details.rsa_signature);
281 return GNUNET_memcmp (&sig1->details.cs_signature,
282 &sig2->details.cs_signature);
283 }
284 GNUNET_assert (0);
285 return -2;
286}
287
288
289int
291 const struct GNUNET_CRYPTO_BlindedSignature *sig1,
292 const struct GNUNET_CRYPTO_BlindedSignature *sig2)
293{
294 if (sig1->cipher != sig2->cipher)
295 return (sig1->cipher > sig2->cipher) ? 1 : -1;
296 switch (sig1->cipher)
297 {
299 GNUNET_break (0);
300 return 0;
308 }
309 GNUNET_assert (0);
310 return -2;
311}
312
313
314int
316 const struct GNUNET_CRYPTO_BlindedMessage *bp1,
317 const struct GNUNET_CRYPTO_BlindedMessage *bp2)
318{
319 if (bp1->cipher != bp2->cipher)
320 return (bp1->cipher > bp2->cipher) ? 1 : -1;
321 switch (bp1->cipher)
322 {
324 GNUNET_break (0);
325 return 0;
331 return memcmp (bp1->details.rsa_blinded_message.blinded_msg,
337 }
338 GNUNET_assert (0);
339 return -2;
340}
341
342
345 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
346 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
348 ...)
349{
351 va_list ap;
352
353 va_start (ap,
354 cipher);
356 bsign_pub,
357 cipher,
358 ap);
359 va_end (ap);
360 return ret;
361}
362
363
366 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
367 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
369 va_list ap)
370{
373
375 priv->rc = 1;
376 priv->cipher = cipher;
377 *bsign_priv = priv;
379 pub->rc = 1;
380 pub->cipher = cipher;
381 *bsign_pub = pub;
382 switch (cipher)
383 {
385 GNUNET_break (0);
386 break;
388 {
389 unsigned int bits;
390
391 bits = va_arg (ap,
392 unsigned int);
393 if (bits < 512)
394 {
395 GNUNET_break (0);
396 break;
397 }
400 }
401 if (NULL == priv->details.rsa_private_key)
402 {
403 GNUNET_break (0);
404 break;
405 }
406 pub->details.rsa_public_key
409 GNUNET_CRYPTO_rsa_public_key_hash (pub->details.rsa_public_key,
410 &pub->pub_key_hash);
411 return GNUNET_OK;
415 &priv->details.cs_private_key,
416 &pub->details.cs_public_key);
417 GNUNET_CRYPTO_hash (&pub->details.cs_public_key,
418 sizeof(pub->details.cs_public_key),
419 &pub->pub_key_hash);
420 return GNUNET_OK;
421 }
422 GNUNET_free (priv);
424 *bsign_priv = NULL;
425 *bsign_pub = NULL;
426 return GNUNET_SYSERR;
427}
428
429
432 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
433 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
434 const char *salt)
435{
437
439 biv->cipher = bsign_priv->cipher;
440 biv->rc = 1;
441 switch (bsign_priv->cipher)
442 {
444 GNUNET_break (0);
445 GNUNET_free (biv);
446 return NULL;
448 return biv;
450 {
451 struct GNUNET_CRYPTO_CsRSecret cspriv[2];
452
454 salt,
455 &bsign_priv->details.cs_private_key,
456 cspriv);
458 &biv->details.cs_values.r_pub[0]);
460 &biv->details.cs_values.r_pub[1]);
461 return biv;
462 }
463 }
464 GNUNET_break (0);
465 GNUNET_free (biv);
466 return NULL;
467}
468
469
472 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
473 const union GNUNET_CRYPTO_BlindingSecretP *bks,
474 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
475 const void *message,
476 size_t message_size,
477 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values)
478{
480
482 bm->cipher = bsign_pub->cipher;
483 bm->rc = 1;
484 switch (bsign_pub->cipher)
485 {
487 GNUNET_break (0);
488 GNUNET_free (bm);
489 return NULL;
491 if (GNUNET_YES !=
493 message,
494 message_size,
495 &bks->rsa_bks,
496 bsign_pub->details.rsa_public_key,
498 {
499 GNUNET_break (0);
500 GNUNET_free (bm);
501 return NULL;
502 }
503 return bm;
505 {
506 struct GNUNET_CRYPTO_CSPublicRPairP blinded_r_pub;
508
509 if (NULL == nonce)
510 {
511 GNUNET_break_op (0);
512 GNUNET_free (bm);
513 return NULL;
514 }
516 bs);
518 bs,
519 alg_values->details.cs_values.r_pub,
520 &bsign_pub->details.cs_public_key,
521 message,
522 message_size,
524 &blinded_r_pub);
526 (void) blinded_r_pub;
527 return bm;
528 }
529 }
530 GNUNET_break (0);
531 return NULL;
532}
533
534
537 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
538 const char *salt,
539 const struct GNUNET_CRYPTO_BlindedMessage *blinded_message)
540{
541 struct GNUNET_CRYPTO_BlindedSignature *blind_sig;
542
543 if (blinded_message->cipher != bsign_priv->cipher)
544 {
545 GNUNET_break (0);
546 return NULL;
547 }
548
549 blind_sig = GNUNET_new (struct GNUNET_CRYPTO_BlindedSignature);
550 blind_sig->cipher = bsign_priv->cipher;
551 blind_sig->rc = 1;
552 switch (bsign_priv->cipher)
553 {
555 GNUNET_break (0);
556 GNUNET_free (blind_sig);
557 return NULL;
561 bsign_priv->details.rsa_private_key,
562 &blinded_message->details.rsa_blinded_message);
563 if (NULL == blind_sig->details.blinded_rsa_signature)
564 {
565 GNUNET_break (0);
566 GNUNET_free (blind_sig);
567 return NULL;
568 }
569 return blind_sig;
571 {
572 struct GNUNET_CRYPTO_CsRSecret r[2];
573
575 &blinded_message->details.cs_blinded_message.nonce,
576 salt,
577 &bsign_priv->details.cs_private_key,
578 r);
580 &bsign_priv->details.cs_private_key,
581 r,
582 &blinded_message->details.cs_blinded_message,
583 &blind_sig->details.blinded_cs_answer);
584 }
585 return blind_sig;
586 }
587 GNUNET_break (0);
588 return NULL;
589}
590
591
594 const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig,
595 const union GNUNET_CRYPTO_BlindingSecretP *bks,
596 const void *message,
597 size_t message_size,
598 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values,
599 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
600{
602
603 if (blinded_sig->cipher != bsign_pub->cipher)
604 {
605 GNUNET_break (0);
606 return NULL;
607 }
608 if (blinded_sig->cipher != alg_values->cipher)
609 {
610 GNUNET_break (0);
611 return NULL;
612 }
614 ub_sig->cipher = blinded_sig->cipher;
615 ub_sig->rc = 1;
616 switch (bsign_pub->cipher)
617 {
619 GNUNET_break (0);
620 GNUNET_free (ub_sig);
621 return NULL;
623 ub_sig->details.rsa_signature
625 blinded_sig->details.blinded_rsa_signature,
626 &bks->rsa_bks,
627 bsign_pub->details.rsa_public_key);
628 if (NULL == ub_sig->details.rsa_signature)
629 {
630 GNUNET_break (0);
631 GNUNET_free (ub_sig);
632 return NULL;
633 }
634 return ub_sig;
636 {
638 struct GNUNET_CRYPTO_CsC c[2];
639 struct GNUNET_CRYPTO_CSPublicRPairP r_pub_blind;
640 unsigned int b;
641
643 bs);
645 bs,
646 alg_values->details.cs_values.r_pub,
647 &bsign_pub->details.cs_public_key,
648 message,
649 message_size,
650 c,
651 &r_pub_blind);
652 b = blinded_sig->details.blinded_cs_answer.b;
654 = r_pub_blind.r_pub[b];
656 &blinded_sig->details.blinded_cs_answer.s_scalar,
657 &bs[b],
658 &ub_sig->details.cs_signature.s_scalar);
659 return ub_sig;
660 }
661 }
662 GNUNET_break (0);
663 GNUNET_free (ub_sig);
664 return NULL;
665}
666
667
670 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
671 const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig,
672 const void *message,
673 size_t message_size)
674{
675 if (bsign_pub->cipher != ub_sig->cipher)
676 {
677 GNUNET_break (0);
678 return GNUNET_SYSERR;
679 }
680 switch (bsign_pub->cipher)
681 {
683 GNUNET_break (0);
684 return GNUNET_NO;
686 if (GNUNET_OK !=
688 message_size,
689 ub_sig->details.rsa_signature,
690 bsign_pub->details.rsa_public_key))
691 {
692 GNUNET_break_op (0);
693 return GNUNET_NO;
694 }
695 return GNUNET_YES;
697 if (GNUNET_OK !=
699 &bsign_pub->details.cs_public_key,
700 message,
701 message_size))
702 {
703 GNUNET_break_op (0);
704 return GNUNET_NO;
705 }
706 return GNUNET_YES;
707 }
708 GNUNET_break (0);
709 return GNUNET_NO;
710}
711
712
713/* end of crypto_blind_sign.c */
static int ret
Final status code.
Definition: gnunet-arm.c:93
static struct GNUNET_CRYPTO_EddsaPublicKey pub
Definition: gnunet-scrypt.c:47
static struct GNUNET_CRYPTO_PowSalt salt
Salt for PoW calculations.
Definition: gnunet-scrypt.c:34
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
struct GNUNET_CRYPTO_BlindSignPrivateKey * GNUNET_CRYPTO_bsign_priv_incref(struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
Increment reference counter of the given bsign_priv.
void GNUNET_CRYPTO_blinded_message_decref(struct GNUNET_CRYPTO_BlindedMessage *bm)
Decrement reference counter of a bm, and free it if it reaches zero.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sign_keys_create(struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher,...)
Initialize public-private key pair for blind signatures.
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:1015
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_rsa_blind(const void *message, size_t message_size, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey, struct GNUNET_CRYPTO_RsaBlindedMessage *bm)
Blinds the given message with the given blinding key.
Definition: crypto_rsa.c:807
struct GNUNET_CRYPTO_BlindedSignature * GNUNET_CRYPTO_blind_sig_incref(struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
Increment reference counter of the given blind_sig.
void GNUNET_CRYPTO_cs_r_get_public(const struct GNUNET_CRYPTO_CsRSecret *r_priv, struct GNUNET_CRYPTO_CsRPublic *r_pub)
Extract the public R of the given secret r.
Definition: crypto_cs.c:98
struct GNUNET_CRYPTO_RsaPrivateKey * GNUNET_CRYPTO_rsa_private_key_create(unsigned int len)
Create a new private key.
Definition: crypto_rsa.c:144
void GNUNET_CRYPTO_rsa_private_key_free(struct GNUNET_CRYPTO_RsaPrivateKey *key)
Free memory occupied by the private key.
Definition: crypto_rsa.c:173
int GNUNET_CRYPTO_bsign_pub_cmp(const struct GNUNET_CRYPTO_BlindSignPublicKey *bp1, const struct GNUNET_CRYPTO_BlindSignPublicKey *bp2)
Compare two denomination public keys.
struct GNUNET_CRYPTO_UnblindedSignature * GNUNET_CRYPTO_blind_sig_unblind(const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig, const union GNUNET_CRYPTO_BlindingSecretP *bks, const void *message, size_t message_size, const struct GNUNET_CRYPTO_BlindingInputValues *alg_values, const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Unblind blind signature.
struct GNUNET_CRYPTO_BlindedSignature * GNUNET_CRYPTO_blind_sign(const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, const char *salt, const struct GNUNET_CRYPTO_BlindedMessage *blinded_message)
Create blind signature.
void GNUNET_CRYPTO_cs_r_derive(const struct GNUNET_CRYPTO_CsSessionNonce *nonce, const char *seed, const struct GNUNET_CRYPTO_CsPrivateKey *lts, struct GNUNET_CRYPTO_CsRSecret r[2])
Derive a new secret r pair r0 and r1.
Definition: crypto_cs.c:79
GNUNET_CRYPTO_BlindSignatureAlgorithm
Types of public keys used for blind signatures.
struct GNUNET_CRYPTO_UnblindedSignature * GNUNET_CRYPTO_ub_sig_incref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Increment reference counter of the given ub_sig.
int GNUNET_CRYPTO_ub_sig_cmp(const struct GNUNET_CRYPTO_UnblindedSignature *sig1, const struct GNUNET_CRYPTO_UnblindedSignature *sig2)
Compare two denomination signatures.
struct GNUNET_CRYPTO_BlindedMessage * GNUNET_CRYPTO_message_blind_to_sign(const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, const union GNUNET_CRYPTO_BlindingSecretP *bks, const union GNUNET_CRYPTO_BlindSessionNonce *nonce, const void *message, size_t message_size, const struct GNUNET_CRYPTO_BlindingInputValues *alg_values)
Blind message for blind signing with dk using blinding secret coin_bks.
int GNUNET_CRYPTO_blinded_message_cmp(const struct GNUNET_CRYPTO_BlindedMessage *bp1, const struct GNUNET_CRYPTO_BlindedMessage *bp2)
Compare two blinded messages.
int GNUNET_CRYPTO_rsa_signature_cmp(const struct GNUNET_CRYPTO_RsaSignature *s1, const struct GNUNET_CRYPTO_RsaSignature *s2)
Compare the values of two signatures.
Definition: crypto_rsa.c:602
int GNUNET_CRYPTO_blind_sig_cmp(const struct GNUNET_CRYPTO_BlindedSignature *sig1, const struct GNUNET_CRYPTO_BlindedSignature *sig2)
Compare two blinded denomination signatures.
void GNUNET_CRYPTO_cs_private_key_get_public(const struct GNUNET_CRYPTO_CsPrivateKey *priv, struct GNUNET_CRYPTO_CsPublicKey *pub)
Extract the public key of the given private key.
Definition: crypto_cs.c:52
void GNUNET_CRYPTO_cs_unblind(const struct GNUNET_CRYPTO_CsBlindS *blinded_signature_scalar, const struct GNUNET_CRYPTO_CsBlindingSecret *bs, struct GNUNET_CRYPTO_CsS *signature_scalar)
Unblind a blind-signed signature using a c that was blinded.
Definition: crypto_cs.c:318
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sign_keys_create_va(struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv, struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub, enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, va_list ap)
Initialize public-private key pair for blind signatures.
void GNUNET_CRYPTO_rsa_public_key_hash(const struct GNUNET_CRYPTO_RsaPublicKey *key, struct GNUNET_HashCode *hc)
Compute hash over the public key.
Definition: crypto_rsa.c:407
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:268
void GNUNET_CRYPTO_cs_calc_blinded_c(const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], const struct GNUNET_CRYPTO_CsRPublic r_pub[2], const struct GNUNET_CRYPTO_CsPublicKey *pub, const void *msg, size_t msg_len, struct GNUNET_CRYPTO_CsC blinded_c[2], struct GNUNET_CRYPTO_CSPublicRPairP *r_pub_blind)
Calculate two blinded c's.
Definition: crypto_cs.c:240
void GNUNET_CRYPTO_blinding_input_values_decref(struct GNUNET_CRYPTO_BlindingInputValues *bm)
Decrement reference counter of the given bi, and free it if it reaches zero.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_blind_sig_verify(const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig, const void *message, size_t message_size)
Verify signature made blindly.
struct GNUNET_CRYPTO_BlindingInputValues * GNUNET_CRYPTO_blinding_input_values_incref(struct GNUNET_CRYPTO_BlindingInputValues *bm)
Increment reference counter of the given bi.
void GNUNET_CRYPTO_unblinded_sig_decref(struct GNUNET_CRYPTO_UnblindedSignature *ub_sig)
Decrement reference counter of a ub_sig, and free it if it reaches zero.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_sign_blinded(const struct GNUNET_CRYPTO_RsaPrivateKey *key, const struct GNUNET_CRYPTO_RsaBlindedMessage *bm)
Sign a blinded value, which must be a full domain hash of a message.
Definition: crypto_rsa.c:970
struct GNUNET_CRYPTO_BlindedMessage * GNUNET_CRYPTO_blinded_message_incref(struct GNUNET_CRYPTO_BlindedMessage *bm)
Increment reference counter of the given bm.
void GNUNET_CRYPTO_blinded_sig_decref(struct GNUNET_CRYPTO_BlindedSignature *blind_sig)
Decrement reference counter of a blind_sig, and free it if it reaches zero.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_cs_verify(const struct GNUNET_CRYPTO_CsSignature *sig, const struct GNUNET_CRYPTO_CsPublicKey *pub, const void *msg, size_t msg_len)
Verify whether the given message corresponds to the given signature and the signature is valid with r...
Definition: crypto_cs.c:330
GNUNET_GenericReturnValue
Named constants for return values.
struct GNUNET_CRYPTO_BlindSignPublicKey * GNUNET_CRYPTO_bsign_pub_incref(struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Increment reference counter of the given bsign_pub.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_unblind(const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaBlindingKeySecret *bks, struct GNUNET_CRYPTO_RsaPublicKey *pkey)
Unblind a blind-signed signature.
Definition: crypto_rsa.c:1118
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_private_key_get_public(const struct GNUNET_CRYPTO_RsaPrivateKey *priv)
Extract the public key of the given private key.
Definition: crypto_rsa.c:233
void GNUNET_CRYPTO_blind_sign_pub_decref(struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
Decrement reference counter of a bsign_pub, and free it if it reaches zero.
void GNUNET_CRYPTO_cs_sign_derive(const struct GNUNET_CRYPTO_CsPrivateKey *priv, const struct GNUNET_CRYPTO_CsRSecret r[2], const struct GNUNET_CRYPTO_CsBlindedMessage *bm, struct GNUNET_CRYPTO_CsBlindSignature *cs_blind_sig)
Sign a blinded c.
Definition: crypto_cs.c:284
void GNUNET_CRYPTO_cs_private_key_generate(struct GNUNET_CRYPTO_CsPrivateKey *priv)
Create a new random private key.
Definition: crypto_cs.c:45
void GNUNET_CRYPTO_blind_sign_priv_decref(struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv)
Decrement reference counter of a bsign_priv, and free it if it reaches zero.
enum GNUNET_GenericReturnValue GNUNET_CRYPTO_rsa_verify(const void *message, size_t message_size, const struct GNUNET_CRYPTO_RsaSignature *sig, const struct GNUNET_CRYPTO_RsaPublicKey *public_key)
Verify whether the given hash corresponds to the given signature and the signature is valid with resp...
Definition: crypto_rsa.c:1199
struct GNUNET_CRYPTO_BlindingInputValues * GNUNET_CRYPTO_get_blinding_input_values(const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv, const union GNUNET_CRYPTO_BlindSessionNonce *nonce, const char *salt)
Compute blinding input values for a given nonce and salt.
void GNUNET_CRYPTO_cs_blinding_secrets_derive(const struct GNUNET_CRYPTO_CsBlindingNonce *blind_seed, struct GNUNET_CRYPTO_CsBlindingSecret bs[2])
Derives new random blinding factors.
Definition: crypto_cs.c:108
@ GNUNET_CRYPTO_BSA_INVALID
Invalid type of signature.
@ GNUNET_CRYPTO_BSA_CS
Clause Blind Schnorr signature.
@ GNUNET_CRYPTO_BSA_RSA
RSA blind signature.
@ GNUNET_OK
@ GNUNET_YES
@ GNUNET_NO
@ GNUNET_SYSERR
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
Type of private signing keys for blind signing.
struct GNUNET_CRYPTO_CsPrivateKey cs_private_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_RsaPrivateKey * rsa_private_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
union GNUNET_CRYPTO_BlindSignPrivateKey::@17 details
Details, depending on cipher.
Type of public signing keys for blind signatures.
union GNUNET_CRYPTO_BlindSignPublicKey::@16 details
Details, depending on cipher.
unsigned int rc
Reference counter.
struct GNUNET_HashCode pub_key_hash
Hash of the public key.
struct GNUNET_CRYPTO_CsPublicKey cs_public_key
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the public key.
struct GNUNET_CRYPTO_RsaPublicKey * rsa_public_key
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
Blinded message ready for blind signing.
unsigned int rc
Reference counter.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the sign blinded message.
struct GNUNET_CRYPTO_CsBlindedMessage cs_blinded_message
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindedMessage::@18 details
Details, depending on cipher.
struct GNUNET_CRYPTO_RsaBlindedMessage rsa_blinded_message
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
Type for blinded signatures.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CsBlindSignature blinded_cs_answer
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindedSignature::@15 details
Details, depending on cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
struct GNUNET_CRYPTO_RsaSignature * blinded_rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
Input needed for blinding a message.
unsigned int rc
Reference counter.
struct GNUNET_CRYPTO_CSPublicRPairP cs_values
If we use GNUNET_CRYPTO_BSA_CS in cipher.
union GNUNET_CRYPTO_BlindingInputValues::@19 details
Details, depending on cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
Pair of Public R values for Cs denominations.
struct GNUNET_CRYPTO_CsRPublic r_pub[2]
struct GNUNET_CRYPTO_CsBlindS s_scalar
The blinded s scalar calculated from c_b.
unsigned int b
To make ROS problem harder, the signer chooses an unpredictable b and only calculates signature of c_...
struct GNUNET_CRYPTO_CsC c[2]
The Clause Schnorr c_0 and c_1 containing the blinded message.
struct GNUNET_CRYPTO_CsSessionNonce nonce
Nonce used in initial request.
Secret used for blinding (alpha and beta).
Schnorr c to be signed.
the private r used in the signature
struct GNUNET_CRYPTO_CsS s_scalar
Schnorr signatures are composed of a scalar s and a curve point.
struct GNUNET_CRYPTO_CsRPublic r_point
Curve point of the Schnorr signature.
size_t blinded_msg_size
Size of the blinded_msg to be signed.
void * blinded_msg
Blinded message to be signed Note: is malloc()'ed!
Type of (unblinded) signatures.
struct GNUNET_CRYPTO_RsaSignature * rsa_signature
If we use GNUNET_CRYPTO_BSA_RSA in cipher.
unsigned int rc
Reference counter.
union GNUNET_CRYPTO_UnblindedSignature::@14 details
Details, depending on cipher.
struct GNUNET_CRYPTO_CsSignature cs_signature
If we use GNUNET_CRYPTO_BSA_CS in cipher.
enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher
Type of the signature.
Nonce used to deterministiacally derive input values used in multi-round blind signature protocols.
struct GNUNET_CRYPTO_CsSessionNonce cs_nonce
Nonce used when signing with CS.
Type of blinding secrets.
struct GNUNET_CRYPTO_CsBlindingNonce nonce
Clause Schnorr nonce.
struct GNUNET_CRYPTO_RsaBlindingKeySecret rsa_bks
Variant for RSA for blind signatures.