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
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;
307 }
308 GNUNET_assert (0);
309 return -2;
310}
311
312
313int
315 const struct GNUNET_CRYPTO_BlindedMessage *bp1,
316 const struct GNUNET_CRYPTO_BlindedMessage *bp2)
317{
318 if (bp1->cipher != bp2->cipher)
319 return (bp1->cipher > bp2->cipher) ? 1 : -1;
320 switch (bp1->cipher)
321 {
323 GNUNET_break (0);
324 return 0;
330 return memcmp (bp1->details.rsa_blinded_message.blinded_msg,
336 }
337 GNUNET_assert (0);
338 return -2;
339}
340
341
344 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
345 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
347 ...)
348{
350 va_list ap;
351
352 va_start (ap,
353 cipher);
355 bsign_pub,
356 cipher,
357 ap);
358 va_end (ap);
359 return ret;
360}
361
362
365 struct GNUNET_CRYPTO_BlindSignPrivateKey **bsign_priv,
366 struct GNUNET_CRYPTO_BlindSignPublicKey **bsign_pub,
368 va_list ap)
369{
372
374 priv->rc = 1;
375 priv->cipher = cipher;
376 *bsign_priv = priv;
378 pub->rc = 1;
379 pub->cipher = cipher;
380 *bsign_pub = pub;
381 switch (cipher)
382 {
384 GNUNET_break (0);
385 break;
387 {
388 unsigned int bits;
389
390 bits = va_arg (ap,
391 unsigned int);
392 if (bits < 512)
393 {
394 GNUNET_break (0);
395 break;
396 }
399 }
400 if (NULL == priv->details.rsa_private_key)
401 {
402 GNUNET_break (0);
403 break;
404 }
405 pub->details.rsa_public_key
408 GNUNET_CRYPTO_rsa_public_key_hash (pub->details.rsa_public_key,
409 &pub->pub_key_hash);
410 return GNUNET_OK;
414 &priv->details.cs_private_key,
415 &pub->details.cs_public_key);
416 GNUNET_CRYPTO_hash (&pub->details.cs_public_key,
417 sizeof(pub->details.cs_public_key),
418 &pub->pub_key_hash);
419 return GNUNET_OK;
420 }
421 GNUNET_free (priv);
423 *bsign_priv = NULL;
424 *bsign_pub = NULL;
425 return GNUNET_SYSERR;
426}
427
428
431 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
432 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
433 const char *salt)
434{
436
438 biv->cipher = bsign_priv->cipher;
439 biv->rc = 1;
440 switch (bsign_priv->cipher)
441 {
443 GNUNET_break (0);
444 GNUNET_free (biv);
445 return NULL;
447 return biv;
449 {
450 struct GNUNET_CRYPTO_CsRSecret cspriv[2];
451
453 salt,
454 &bsign_priv->details.cs_private_key,
455 cspriv);
457 &biv->details.cs_values.r_pub[0]);
459 &biv->details.cs_values.r_pub[1]);
460 return biv;
461 }
462 }
463 GNUNET_break (0);
464 GNUNET_free (biv);
465 return NULL;
466}
467
468
471 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
472 const union GNUNET_CRYPTO_BlindingSecretP *bks,
473 const union GNUNET_CRYPTO_BlindSessionNonce *nonce,
474 const void *message,
475 size_t message_size,
476 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values)
477{
479
481 bm->cipher = bsign_pub->cipher;
482 bm->rc = 1;
483 switch (bsign_pub->cipher)
484 {
486 GNUNET_break (0);
487 GNUNET_free (bm);
488 return NULL;
490 if (GNUNET_YES !=
492 message,
493 message_size,
494 &bks->rsa_bks,
495 bsign_pub->details.rsa_public_key,
497 {
498 GNUNET_break (0);
499 GNUNET_free (bm);
500 return NULL;
501 }
502 return bm;
504 {
505 struct GNUNET_CRYPTO_CSPublicRPairP blinded_r_pub;
507
508 if (NULL == nonce)
509 {
510 GNUNET_break_op (0);
511 GNUNET_free (bm);
512 return NULL;
513 }
515 bs);
517 bs,
518 alg_values->details.cs_values.r_pub,
519 &bsign_pub->details.cs_public_key,
520 message,
521 message_size,
523 &blinded_r_pub);
525 (void) blinded_r_pub;
526 return bm;
527 }
528 }
529 GNUNET_break (0);
530 return NULL;
531}
532
533
536 const struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv,
537 const char *salt,
538 const struct GNUNET_CRYPTO_BlindedMessage *blinded_message)
539{
540 struct GNUNET_CRYPTO_BlindedSignature *blind_sig;
541
542 if (blinded_message->cipher != bsign_priv->cipher)
543 {
544 GNUNET_break (0);
545 return NULL;
546 }
547
548 blind_sig = GNUNET_new (struct GNUNET_CRYPTO_BlindedSignature);
549 blind_sig->cipher = bsign_priv->cipher;
550 blind_sig->rc = 1;
551 switch (bsign_priv->cipher)
552 {
554 GNUNET_break (0);
555 GNUNET_free (blind_sig);
556 return NULL;
560 bsign_priv->details.rsa_private_key,
561 &blinded_message->details.rsa_blinded_message);
562 if (NULL == blind_sig->details.blinded_rsa_signature)
563 {
564 GNUNET_break (0);
565 GNUNET_free (blind_sig);
566 return NULL;
567 }
568 return blind_sig;
570 {
571 struct GNUNET_CRYPTO_CsRSecret r[2];
572
574 &blinded_message->details.cs_blinded_message.nonce,
575 salt,
576 &bsign_priv->details.cs_private_key,
577 r);
579 &bsign_priv->details.cs_private_key,
580 r,
581 &blinded_message->details.cs_blinded_message,
582 &blind_sig->details.blinded_cs_answer);
583 }
584 return blind_sig;
585 }
586 GNUNET_break (0);
587 return NULL;
588}
589
590
593 const struct GNUNET_CRYPTO_BlindedSignature *blinded_sig,
594 const union GNUNET_CRYPTO_BlindingSecretP *bks,
595 const void *message,
596 size_t message_size,
597 const struct GNUNET_CRYPTO_BlindingInputValues *alg_values,
598 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub)
599{
601
602 if (blinded_sig->cipher != bsign_pub->cipher)
603 {
604 GNUNET_break (0);
605 return NULL;
606 }
607 if (blinded_sig->cipher != alg_values->cipher)
608 {
609 GNUNET_break (0);
610 return NULL;
611 }
613 ub_sig->cipher = blinded_sig->cipher;
614 ub_sig->rc = 1;
615 switch (bsign_pub->cipher)
616 {
618 GNUNET_break (0);
619 GNUNET_free (ub_sig);
620 return NULL;
622 ub_sig->details.rsa_signature
624 blinded_sig->details.blinded_rsa_signature,
625 &bks->rsa_bks,
626 bsign_pub->details.rsa_public_key);
627 if (NULL == ub_sig->details.rsa_signature)
628 {
629 GNUNET_break (0);
630 GNUNET_free (ub_sig);
631 return NULL;
632 }
633 return ub_sig;
635 {
637 struct GNUNET_CRYPTO_CsC c[2];
638 struct GNUNET_CRYPTO_CSPublicRPairP r_pub_blind;
639 unsigned int b;
640
642 bs);
644 bs,
645 alg_values->details.cs_values.r_pub,
646 &bsign_pub->details.cs_public_key,
647 message,
648 message_size,
649 c,
650 &r_pub_blind);
651 b = blinded_sig->details.blinded_cs_answer.b;
653 = r_pub_blind.r_pub[b];
655 &blinded_sig->details.blinded_cs_answer.s_scalar,
656 &bs[b],
657 &ub_sig->details.cs_signature.s_scalar);
658 return ub_sig;
659 }
660 }
661 GNUNET_break (0);
662 GNUNET_free (ub_sig);
663 return NULL;
664}
665
666
669 const struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub,
670 const struct GNUNET_CRYPTO_UnblindedSignature *ub_sig,
671 const void *message,
672 size_t message_size)
673{
674 if (bsign_pub->cipher != ub_sig->cipher)
675 {
676 GNUNET_break (0);
677 return GNUNET_SYSERR;
678 }
679 switch (bsign_pub->cipher)
680 {
682 GNUNET_break (0);
683 return GNUNET_NO;
685 if (GNUNET_OK !=
687 message_size,
688 ub_sig->details.rsa_signature,
689 bsign_pub->details.rsa_public_key))
690 {
691 GNUNET_break_op (0);
692 return GNUNET_NO;
693 }
694 return GNUNET_YES;
696 if (GNUNET_OK !=
698 &bsign_pub->details.cs_public_key,
699 message,
700 message_size))
701 {
702 GNUNET_break_op (0);
703 return GNUNET_NO;
704 }
705 return GNUNET_YES;
706 }
707 GNUNET_break (0);
708 return GNUNET_NO;
709}
710
711
712/* 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.