taler_crypto_lib.h (234619B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-2026 Taler Systems SA 4 5 TALER 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 TALER 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 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file include/taler/taler_crypto_lib.h 18 * @brief taler-specific crypto functions 19 * @author Sree Harsha Totakura <sreeharsha@totakura.in> 20 * @author Christian Grothoff <christian@grothoff.org> 21 * @author Özgür Kesim <oec-taler@kesim.org> 22 */ 23 #include <gnunet/gnunet_common.h> 24 #if ! defined (__TALER_UTIL_LIB_H_INSIDE__) 25 #error "Only <taler_util.h> can be included directly." 26 #endif 27 28 #ifndef TALER_CRYPTO_LIB_H 29 #define TALER_CRYPTO_LIB_H 30 31 #include <gnunet/gnunet_util_lib.h> 32 #include <taler/taler_error_codes.h> 33 #include <gcrypt.h> 34 #include <jansson.h> 35 36 37 /** 38 * Maximum number of coins we allow per operation. 39 * This limit is due to the 64-bit encoding of the bitvector 40 * of choices made for CS values and thus should not be changed 41 * casually... 42 */ 43 #define TALER_MAX_COINS 64 44 45 /** 46 * Cut-and-choose size for refreshing. Client looses the gamble (of 47 * unaccountable transfers) with probability 1/TALER_CNC_KAPPA. Refresh cost 48 * increases linearly with TALER_CNC_KAPPA, and 3 is sufficient up to a 49 * income/sales tax of 66% of total transaction value. As there is 50 * no good reason to change this security parameter, we declare it 51 * fixed and part of the protocol. 52 */ 53 #define TALER_CNC_KAPPA 3 54 #define TALER_CNC_KAPPA_STR "3" 55 #define TALER_CNC_KAPPA_MINUS_ONE_STR "2" 56 57 58 /** 59 * Account owner signature for KYC. 60 */ 61 #define TALER_HTTP_HEADER_ACCOUNT_OWNER_SIGNATURE "Account-Owner-Signature" 62 63 /** 64 * Account owner public key for KYC. 65 */ 66 #define TALER_HTTP_HEADER_ACCOUNT_OWNER_PUBKEY "Account-Owner-Pub" 67 68 /** 69 * Possible algorithms for confirmation code generation. 70 */ 71 enum TALER_MerchantConfirmationAlgorithm 72 { 73 74 /** 75 * No purchase confirmation. 76 */ 77 TALER_MCA_NONE = 0, 78 79 /** 80 * Purchase confirmation without payment 81 */ 82 TALER_MCA_WITHOUT_PRICE = 1, 83 84 /** 85 * Purchase confirmation with payment 86 */ 87 TALER_MCA_WITH_PRICE = 2, 88 89 /** 90 * ECDSA (NIST P-256) signature over the order's challenge 91 */ 92 TALER_MCA_ECDSA_CHALLENGE = 3, 93 94 /** 95 * EdDSA (Ed25519) signature over the order's challenge 96 */ 97 TALER_MCA_EDDSA_CHALLENGE = 4 98 99 }; 100 101 102 /* ****************** Coin crypto primitives ************* */ 103 104 GNUNET_NETWORK_STRUCT_BEGIN 105 106 /** 107 * @brief Type of public keys for Taler security modules (software or hardware). 108 * Note that there are usually at least two security modules (RSA and EdDSA), 109 * each with its own private key. 110 */ 111 struct TALER_SecurityModulePublicKeyP 112 { 113 /** 114 * Taler uses EdDSA for security modules. 115 */ 116 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 117 }; 118 119 /** 120 * @brief Set of the public keys of the security modules 121 */ 122 struct TALER_SecurityModulePublicKeySetP 123 { 124 /** 125 * Public key of the RSA security module 126 */ 127 struct TALER_SecurityModulePublicKeyP rsa; 128 129 /** 130 * Public key of the CS security module 131 */ 132 struct TALER_SecurityModulePublicKeyP cs; 133 134 /** 135 * Public key of the eddsa security module 136 */ 137 struct TALER_SecurityModulePublicKeyP eddsa; 138 }; 139 140 /** 141 * @brief Type of private keys for Taler security modules (software or hardware). 142 */ 143 struct TALER_SecurityModulePrivateKeyP 144 { 145 /** 146 * Taler uses EdDSA for security modules. 147 */ 148 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 149 }; 150 151 152 /** 153 * @brief Type of signatures used for Taler security modules (software or hardware). 154 */ 155 struct TALER_SecurityModuleSignatureP 156 { 157 /** 158 * Taler uses EdDSA for security modules. 159 */ 160 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 161 }; 162 163 164 /** 165 * @brief Type of public keys for Taler reserves. 166 */ 167 struct TALER_ReservePublicKeyP 168 { 169 /** 170 * Taler uses EdDSA for reserves. 171 */ 172 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 173 }; 174 175 /** 176 * @brief Type of hashes of public keys for Taler reserves. 177 */ 178 struct TALER_HashReservePublicKeyP 179 { 180 /** 181 * Hash of the public key. 182 */ 183 struct GNUNET_HashCode hash; 184 }; 185 186 187 /** 188 * @brief Type of private keys for Taler reserves. 189 */ 190 struct TALER_ReservePrivateKeyP 191 { 192 /** 193 * Taler uses EdDSA for reserves. 194 */ 195 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 196 }; 197 198 199 /** 200 * @brief Type of signatures used with Taler reserves. 201 */ 202 struct TALER_ReserveSignatureP 203 { 204 /** 205 * Taler uses EdDSA for reserves. 206 */ 207 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 208 }; 209 210 211 /** 212 * @brief Type of public keys for Taler prepared transfer 213 * subject reserve key mapping authorizations. 214 */ 215 struct TALER_PreparedTransferAuthorizationPublicKeyP 216 { 217 /** 218 * Taler uses EdDSA for reserves. 219 */ 220 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 221 }; 222 223 /** 224 * @brief Type of private keys for Taler prepared transfer 225 * subject reserve key mapping authorizations. 226 */ 227 struct TALER_PreparedTransferAuthorizationPrivateKeyP 228 { 229 /** 230 * Taler uses EdDSA for reserves. 231 */ 232 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 233 }; 234 235 236 /** 237 * @brief Type of signatures used with Taler prepared transfer 238 * subject reserve key mapping authorizations. 239 */ 240 struct TALER_PreparedTransferAuthorizationSignatureP 241 { 242 /** 243 * Taler uses EdDSA for reserves. 244 */ 245 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 246 }; 247 248 249 /** 250 * @brief Type of public keys to for merchant authorizations. 251 * Merchants can issue refunds using the corresponding 252 * private key. 253 */ 254 struct TALER_MerchantPublicKeyP 255 { 256 /** 257 * Taler uses EdDSA for merchants. 258 */ 259 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 260 }; 261 262 263 /** 264 * @brief Type of a token used for symmetric access 265 * control to the KYC process of an account. 266 */ 267 struct TALER_AccountAccessTokenP 268 { 269 /** 270 * Random bytes with enough entropy to prevent brute-force 271 * attacks. 272 */ 273 uint32_t token[32 / sizeof (uint32_t)]; 274 }; 275 276 /** 277 * @brief Type of public keys to for KYC authorizations. 278 * Either a merchant's public key or a reserve public 279 * key will do. 280 */ 281 union TALER_AccountPublicKeyP 282 { 283 /** 284 * Public key of merchants. 285 */ 286 struct TALER_MerchantPublicKeyP merchant_pub; 287 288 /** 289 * Public key of reserves. 290 */ 291 struct TALER_ReservePublicKeyP reserve_pub; 292 }; 293 294 295 /** 296 * @brief Type of signatures made by merchants. 297 */ 298 struct TALER_MerchantSignatureP 299 { 300 /** 301 * Taler uses EdDSA for merchants. 302 */ 303 struct GNUNET_CRYPTO_EddsaSignature eddsa_sig; 304 }; 305 306 307 /** 308 * @brief Type of signatures for KYC authorizations. 309 * Either a merchant's signature or a reserve signature 310 * will do. 311 */ 312 union TALER_AccountSignatureP 313 { 314 /** 315 * Signature of merchants. 316 */ 317 struct TALER_MerchantSignatureP merchant_sig; 318 319 /** 320 * Signature of reserves. 321 */ 322 struct TALER_ReserveSignatureP reserve_sig; 323 }; 324 325 326 /** 327 * @brief Type of private keys for merchant authorizations. 328 * Merchants can issue refunds using the corresponding 329 * private key. 330 */ 331 struct TALER_MerchantPrivateKeyP 332 { 333 /** 334 * Taler uses EdDSA for merchants. 335 */ 336 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 337 }; 338 339 340 /** 341 * @brief Type of private keys to for KYC authorizations. 342 * Either a merchant's private key or a reserve private 343 * key will do. 344 */ 345 union TALER_AccountPrivateKeyP 346 { 347 /** 348 * Private key of merchants. 349 */ 350 struct TALER_MerchantPrivateKeyP merchant_priv; 351 352 /** 353 * Private key of reserves. 354 */ 355 struct TALER_ReservePrivateKeyP reserve_priv; 356 }; 357 358 359 /** 360 * @brief Type of transfer public keys used during refresh 361 * operations. 362 */ 363 struct TALER_TransferPublicKeyP 364 { 365 /** 366 * Taler uses ECDHE for transfer keys. 367 */ 368 struct GNUNET_CRYPTO_EcdhePublicKey ecdhe_pub; 369 }; 370 371 372 /** 373 * @brief Type of transfer private keys used during refresh 374 * operations. 375 */ 376 struct TALER_TransferPrivateKeyP 377 { 378 /** 379 * Taler uses ECDHE for melting session keys. 380 */ 381 struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_priv; 382 }; 383 384 385 /** 386 * @brief Type of public keys used for contract 387 * encryption. 388 */ 389 struct TALER_ContractDiffiePublicP 390 { 391 /** 392 * Taler uses ECDHE for contract encryption. 393 */ 394 struct GNUNET_CRYPTO_EcdhePublicKey ecdhe_pub; 395 }; 396 397 398 /** 399 * @brief Type of private keys used for contract 400 * encryption. 401 */ 402 struct TALER_ContractDiffiePrivateP 403 { 404 /** 405 * Taler uses ECDHE for contract encryption. 406 */ 407 struct GNUNET_CRYPTO_EcdhePrivateKey ecdhe_priv; 408 }; 409 410 411 /** 412 * @brief Type of online public keys used by the exchange to sign 413 * messages. 414 */ 415 struct TALER_ExchangePublicKeyP 416 { 417 /** 418 * Taler uses EdDSA for online exchange message signing. 419 */ 420 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 421 }; 422 423 424 /** 425 * @brief Type of online public keys used by the exchange to 426 * sign messages. 427 */ 428 struct TALER_ExchangePrivateKeyP 429 { 430 /** 431 * Taler uses EdDSA for online signatures sessions. 432 */ 433 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 434 }; 435 436 437 /** 438 * @brief Type of signatures used by the exchange to sign messages online. 439 */ 440 struct TALER_ExchangeSignatureP 441 { 442 /** 443 * Taler uses EdDSA for online signatures sessions. 444 */ 445 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 446 }; 447 448 449 /** 450 * @brief Type of the offline master public key used by the exchange. 451 */ 452 struct TALER_MasterPublicKeyP 453 { 454 /** 455 * Taler uses EdDSA for the long-term offline master key. 456 */ 457 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 458 }; 459 460 461 /** 462 * @brief Type of the offline master public keys used by the exchange. 463 */ 464 struct TALER_MasterPrivateKeyP 465 { 466 /** 467 * Taler uses EdDSA for the long-term offline master key. 468 */ 469 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 470 }; 471 472 473 /** 474 * @brief Type of signatures by the offline master public key used by the exchange. 475 */ 476 struct TALER_MasterSignatureP 477 { 478 /** 479 * Taler uses EdDSA for the long-term offline master key. 480 */ 481 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 482 }; 483 484 485 /** 486 * @brief Type of the private key used by the auditor. 487 */ 488 struct TALER_AuditorPrivateKeyP 489 { 490 /** 491 * Taler uses EdDSA for the auditor's signing key. 492 */ 493 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 494 }; 495 496 497 /** 498 * @brief Type of the public key used by the auditor. 499 */ 500 struct TALER_AuditorPublicKeyP 501 { 502 /** 503 * Taler uses EdDSA for the auditor's signing key. 504 */ 505 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 506 }; 507 508 509 /** 510 * @brief Type of signatures used by the auditor. 511 */ 512 struct TALER_AuditorSignatureP 513 { 514 /** 515 * Taler uses EdDSA signatures for auditors. 516 */ 517 struct GNUNET_CRYPTO_EddsaSignature eddsa_sig; 518 }; 519 520 521 /** 522 * @brief Type of public keys for Taler coins. The same key material is used 523 * for EdDSA and ECDHE operations. 524 */ 525 struct TALER_CoinSpendPublicKeyP 526 { 527 /** 528 * Taler uses EdDSA for coins when signing deposit requests. 529 */ 530 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 531 532 }; 533 534 535 /** 536 * @brief Type of private keys for Taler coins. The same key material is used 537 * for EdDSA and ECDHE operations. 538 */ 539 struct TALER_CoinSpendPrivateKeyP 540 { 541 /** 542 * Taler uses EdDSA for coins when signing deposit requests. 543 */ 544 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 545 }; 546 547 /** 548 * @brief Type of signatures made with Taler coins. 549 */ 550 struct TALER_CoinSpendSignatureP 551 { 552 /** 553 * Taler uses EdDSA for coins. 554 */ 555 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 556 }; 557 558 559 /** 560 * @brief Type of private keys for age commitment in coins. 561 */ 562 struct TALER_AgeCommitmentPrivateKeyP 563 { 564 #ifdef AGE_RESTRICTION_WITH_ECDSA 565 /** 566 * Taler uses EcDSA for coins when signing age verification attestation. 567 */ 568 struct GNUNET_CRYPTO_EcdsaPrivateKey priv; 569 #else 570 /** 571 * Taler uses Edx25519 for coins when signing age verification attestation. 572 */ 573 struct GNUNET_CRYPTO_Edx25519PrivateKey priv; 574 #endif 575 }; 576 577 578 /** 579 * @brief Type of public keys for age commitment in coins. 580 */ 581 struct TALER_AgeCommitmentPublicKeyP 582 { 583 #ifdef AGE_RESTRICTION_WITH_ECDSA 584 /** 585 * Taler uses EcDSA for coins when signing age verification attestation. 586 */ 587 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 588 #else 589 /** 590 * Taler uses Edx25519 for coins when signing age verification attestation. 591 */ 592 struct GNUNET_CRYPTO_Edx25519PublicKey pub; 593 #endif 594 }; 595 596 597 /** 598 * @brief This is the running SHA512-hash over all 599 * `TALER_BlindedCoinHashP` values of an array of coins. 600 * Note that each `TALER_BlindedCoinHashP` itself 601 * captures the hash of the corresponding denomination's 602 * public key. 603 */ 604 struct TALER_HashBlindedPlanchetsP 605 { 606 struct GNUNET_HashCode hash; 607 }; 608 609 610 /** 611 * @brief Type of online public keys used by the wallet to establish a purse and the associated contract meta data. 612 */ 613 struct TALER_PurseContractPublicKeyP 614 { 615 /** 616 * Taler uses EdDSA for purse message signing. 617 */ 618 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 619 }; 620 621 622 /** 623 * @brief Type of online private keys used by the wallet to 624 * bind a purse to a particular contract (and other meta data). 625 */ 626 struct TALER_PurseContractPrivateKeyP 627 { 628 /** 629 * Taler uses EdDSA for online signatures sessions. 630 */ 631 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 632 }; 633 634 635 /** 636 * @brief Type of signatures used by the wallet to sign purse creation messages online. 637 */ 638 struct TALER_PurseContractSignatureP 639 { 640 /** 641 * Taler uses EdDSA for online signatures sessions. 642 */ 643 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 644 }; 645 646 647 /** 648 * @brief Type of online public keys used by the wallet to 649 * sign a merge of a purse into an account. 650 */ 651 struct TALER_PurseMergePublicKeyP 652 { 653 /** 654 * Taler uses EdDSA for purse message signing. 655 */ 656 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 657 }; 658 659 660 /** 661 * @brief Type of online private keys used by the wallet to 662 * sign a merge of a purse into an account. 663 */ 664 struct TALER_PurseMergePrivateKeyP 665 { 666 /** 667 * Taler uses EdDSA for online signatures sessions. 668 */ 669 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 670 }; 671 672 673 /** 674 * @brief Type of signatures used by the wallet to sign purse merge requests online. 675 */ 676 struct TALER_PurseMergeSignatureP 677 { 678 /** 679 * Taler uses EdDSA for online signatures sessions. 680 */ 681 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 682 }; 683 684 685 /** 686 * @brief Type of online public keys used by AML officers. 687 */ 688 struct TALER_AmlOfficerPublicKeyP 689 { 690 /** 691 * Taler uses EdDSA for AML decision signing. 692 */ 693 struct GNUNET_CRYPTO_EddsaPublicKey eddsa_pub; 694 }; 695 696 697 /** 698 * @brief Type of online private keys used to identify 699 * AML officers. 700 */ 701 struct TALER_AmlOfficerPrivateKeyP 702 { 703 /** 704 * Taler uses EdDSA for AML decision signing. 705 */ 706 struct GNUNET_CRYPTO_EddsaPrivateKey eddsa_priv; 707 }; 708 709 710 /** 711 * @brief Type of signatures used by AML officers. 712 */ 713 struct TALER_AmlOfficerSignatureP 714 { 715 /** 716 * Taler uses EdDSA for AML decision signing. 717 */ 718 struct GNUNET_CRYPTO_EddsaSignature eddsa_signature; 719 }; 720 721 /** 722 * @since vDOLDPLUS 723 * 724 * The seed from which a specific batch of fresh coin material is 725 * derived from #TALER_PublicRefreshMasterSeedP for a refresh request. 726 */ 727 struct TALER_PrivateRefreshBatchSeedP 728 { 729 /** 730 * The seed is a hash code. 731 */ 732 struct GNUNET_HashCode batch_seed; 733 }; 734 735 /** 736 * @since vDOLDPLUS 737 * 738 * From a #TALER_PublicRefreshMasterSeedP, we derive first 739 * kappa many seeds for batches of n coins in the struct 740 * #TALER_KappaPrivateRefreshBatchSeedsP. Each batch seed is 741 * used to derive n individual fresh coin master secrets. 742 */ 743 struct TALER_KappaPrivateRefreshBatchSeedsP 744 { 745 /** 746 * A tuple of #TALER_CNC_KAPPA many batch seeds. 747 */ 748 struct TALER_PrivateRefreshBatchSeedP tuple[TALER_CNC_KAPPA]; 749 }; 750 751 /** 752 * @since vDOLDPLUS 753 * 754 * The public master seed from which private coin seeds are derived 755 * for new fresh coin candidates, using the old coins private key. 756 * 757 * Note that this value has changed its meaning from v27. 758 */ 759 struct TALER_PublicRefreshMasterSeedP 760 { 761 /** 762 * The seed is a hash code. 763 */ 764 struct GNUNET_HashCode r_seed; 765 }; 766 767 /** 768 * @since v27 769 * @deprecated after vDOLDPLUS 770 * 771 * A batch seed is signed by the old coin's private key 772 * and from that signature n fresh coin's secrets are derived. 773 */ 774 struct TALER_PublicRefreshNonceP 775 { 776 /** 777 * The seed is a hash code. 778 */ 779 struct GNUNET_HashCode batch_seed; 780 }; 781 782 /** 783 * @since v27 784 * @deprecated after vDOLDPLUS 785 * 786 * From a #TALER_PublicRefreshMasterSeedP, we derive first 787 * kappa many seeds for batches of n coins in the struct 788 * #TALER_KappaPublicRefreshNoncesP. 789 * Each batch seed is signed by the old coin's private key and 790 * the signatures are used to derive n individual fresh coin master secrets. 791 */ 792 struct TALER_KappaPublicRefreshNoncesP 793 { 794 /** 795 * A tuple of #TALER_CNC_KAPPA many batch seeds. 796 */ 797 struct TALER_PublicRefreshNonceP tuple[TALER_CNC_KAPPA]; 798 }; 799 800 801 /** 802 * Commitment value for the refresh protocol. 803 * See #TALER_refresh_get_commitment() and 804 */ 805 struct TALER_RefreshCommitmentP 806 { 807 /** 808 * The commitment is a hash code. 809 */ 810 struct GNUNET_HashCode session_hash; 811 }; 812 813 814 /** 815 * Symmetric key we use to encrypt KYC attributes 816 * in our database. 817 */ 818 struct TALER_AttributeEncryptionKeyP 819 { 820 /** 821 * The key is a hash code. 822 */ 823 struct GNUNET_HashCode hash; 824 }; 825 826 827 /** 828 * Token used for access control to the merchant's unclaimed 829 * orders. 830 */ 831 struct TALER_ClaimTokenP 832 { 833 /** 834 * The token is a 128-bit UUID. 835 */ 836 struct GNUNET_Uuid token; 837 }; 838 839 840 /** 841 * Salt used to hash a merchant's payto:// URI to 842 * compute the "h_wire" (say for deposit requests). 843 */ 844 struct TALER_WireSaltP 845 { 846 /** 847 * Actual 128-bit salt value. 848 */ 849 uint32_t salt[4]; 850 }; 851 852 853 /** 854 * Hash used to represent an CS public key. Does not include age 855 * restrictions and is ONLY for CS. Used ONLY for interactions with the CS 856 * security module. 857 */ 858 struct TALER_CsPubHashP 859 { 860 /** 861 * Actual hash value. 862 */ 863 struct GNUNET_HashCode hash; 864 }; 865 866 867 /** 868 * Hash used to represent an RSA public key. Does not include age 869 * restrictions and is ONLY for RSA. Used ONLY for interactions with the RSA 870 * security module. 871 */ 872 struct TALER_RsaPubHashP 873 { 874 /** 875 * Actual hash value. 876 */ 877 struct GNUNET_HashCode hash; 878 }; 879 880 881 /** 882 * Master seed material for the deriviation of all secrets 883 * for a batch of coins in a withdraw request. 884 */ 885 struct TALER_WithdrawMasterSeedP 886 { 887 /** 888 * Seed material. 889 */ 890 uint32_t seed_data[8]; 891 892 }; 893 894 895 /** 896 * The tuple of TALER_CNC_KAPPA many seeds 897 * for candidates for a batch of age-restricted coins. 898 */ 899 struct TALER_KappaWithdrawMasterSeedP 900 { 901 struct TALER_WithdrawMasterSeedP tuple[TALER_CNC_KAPPA]; 902 }; 903 904 905 /** 906 * Tuple of secrets for TALER_CNC_KAPPA-1 many coin candidates, 907 * that need to be disclosed during the /reveal-melt step. 908 */ 909 struct TALER_RevealWithdrawMasterSeedsP 910 { 911 struct TALER_WithdrawMasterSeedP tuple[TALER_CNC_KAPPA - 1]; 912 }; 913 914 915 /** 916 * Master key material for the deriviation of 917 * private coins and blinding factors during 918 * withdraw or refresh. 919 */ 920 struct TALER_PlanchetMasterSecretP 921 { 922 923 /** 924 * Key material. 925 */ 926 uint32_t key_data[8]; 927 928 }; 929 930 931 /** 932 * Master key material for the deriviation of 933 * blinding factors. 934 */ 935 struct TALER_BlindingMasterSeedP 936 { 937 938 /** 939 * Key material. 940 */ 941 uint32_t key_data[8]; 942 943 }; 944 945 /** 946 * Hash used to represent a denomination public key 947 * and associated age restrictions (if any). 948 */ 949 struct TALER_DenominationHashP 950 { 951 /** 952 * Actual hash value. 953 */ 954 struct GNUNET_HashCode hash; 955 }; 956 957 958 /** 959 * Hash used to represent the private part 960 * of a contract between merchant and consumer. 961 */ 962 struct TALER_PrivateContractHashP 963 { 964 /** 965 * Actual hash value. 966 */ 967 struct GNUNET_HashCode hash; 968 }; 969 970 971 /** 972 * Hash used to represent the salted hash of a 973 * merchant's bank account. 974 */ 975 struct TALER_MerchantWireHashP 976 { 977 /** 978 * Actual hash value. 979 */ 980 struct GNUNET_HashCode hash; 981 }; 982 983 984 /** 985 * payto:// URI representing a bank account, excluding receiver name 986 * (and also otherwise normalized, so without BIC, etc.). 987 */ 988 struct TALER_NormalizedPayto 989 { 990 /** 991 * Actual string value. 992 */ 993 char *normalized_payto; 994 }; 995 996 997 /** 998 * payto:// URI representing a bank account, including receiver name, 999 * not normalized. 1000 */ 1001 struct TALER_FullPayto 1002 { 1003 /** 1004 * Actual string value. 1005 */ 1006 char *full_payto; 1007 }; 1008 1009 1010 /** 1011 * Hash used to represent the unsalted hash of a full 1012 * payto:// URI representing a bank account. 1013 */ 1014 struct TALER_FullPaytoHashP 1015 { 1016 /** 1017 * Actual hash value. 1018 */ 1019 struct GNUNET_ShortHashCode hash; 1020 }; 1021 1022 1023 /** 1024 * Hash used to represent the unsalted hash of a normalized 1025 * payto:// URI representing a bank account. 1026 */ 1027 struct TALER_NormalizedPaytoHashP 1028 { 1029 /** 1030 * Actual hash value. 1031 */ 1032 struct GNUNET_ShortHashCode hash; 1033 }; 1034 1035 1036 /** 1037 * Hash used to represent a commitment to a blinded 1038 * coin, i.e. the hash of the envelope. 1039 */ 1040 struct TALER_BlindedCoinHashP 1041 { 1042 /** 1043 * Actual hash value. 1044 */ 1045 struct GNUNET_HashCode hash; 1046 }; 1047 1048 1049 /** 1050 * Hash used to represent the hash of the public 1051 * key of a coin (without blinding). 1052 */ 1053 struct TALER_CoinPubHashP 1054 { 1055 /** 1056 * Actual hash value. 1057 */ 1058 struct GNUNET_HashCode hash; 1059 }; 1060 1061 1062 /** 1063 * @brief Value that uniquely identifies a reward. 1064 */ 1065 struct TALER_RewardIdentifierP 1066 { 1067 /** 1068 * The tip identifier is a SHA-512 hash code. 1069 */ 1070 struct GNUNET_HashCode hash; 1071 }; 1072 1073 1074 /** 1075 * @brief Value that uniquely identifies a tip pick up operation. 1076 */ 1077 struct TALER_PickupIdentifierP 1078 { 1079 /** 1080 * The pickup identifier is a SHA-512 hash code. 1081 */ 1082 struct GNUNET_HashCode hash; 1083 }; 1084 1085 1086 /** 1087 * Set of the fees applying to a denomination. 1088 */ 1089 struct TALER_DenomFeeSetNBOP 1090 { 1091 1092 /** 1093 * The fee the exchange charges when a coin of this type is withdrawn. 1094 * (can be zero). 1095 */ 1096 struct TALER_AmountNBO withdraw; 1097 1098 /** 1099 * The fee the exchange charges when a coin of this type is deposited. 1100 * (can be zero). 1101 */ 1102 struct TALER_AmountNBO deposit; 1103 1104 /** 1105 * The fee the exchange charges when a coin of this type is refreshed. 1106 * (can be zero). 1107 */ 1108 struct TALER_AmountNBO refresh; 1109 1110 /** 1111 * The fee the exchange charges when a coin of this type is refunded. 1112 * (can be zero). Note that refund fees are charged to the customer; 1113 * if a refund is given, the deposit fee is also refunded. 1114 */ 1115 struct TALER_AmountNBO refund; 1116 1117 }; 1118 1119 1120 /** 1121 * Set of the fees applying for a given 1122 * time-range and wire method. 1123 */ 1124 struct TALER_WireFeeSetNBOP 1125 { 1126 1127 /** 1128 * The fee the exchange charges for wiring funds 1129 * to a merchant. 1130 */ 1131 struct TALER_AmountNBO wire; 1132 1133 /** 1134 * The fee the exchange charges for closing a reserve 1135 * and wiring the funds back to the origin account. 1136 */ 1137 struct TALER_AmountNBO closing; 1138 1139 }; 1140 1141 1142 /** 1143 * Set of the fees applying globally for a given 1144 * time-range. 1145 */ 1146 struct TALER_GlobalFeeSetNBOP 1147 { 1148 1149 /** 1150 * The fee the exchange charges for returning the history of a reserve or 1151 * account. 1152 */ 1153 struct TALER_AmountNBO history; 1154 1155 /** 1156 * The fee the exchange charges for keeping an account or reserve open for a 1157 * year. 1158 */ 1159 struct TALER_AmountNBO account; 1160 1161 /** 1162 * The fee the exchange charges if a purse is abandoned and this was not 1163 * covered by the account limit. 1164 */ 1165 struct TALER_AmountNBO purse; 1166 }; 1167 1168 1169 /** 1170 * @brief Age commitment of a coin. 1171 */ 1172 struct TALER_AgeCommitmentHashP 1173 { 1174 /** 1175 * The commitment is a SHA-256 hash code. 1176 */ 1177 struct GNUNET_ShortHashCode shash; 1178 }; 1179 1180 1181 /** 1182 * @brief Signature of an age with the private key for the corresponding age group of an age commitment. 1183 */ 1184 struct TALER_AgeAttestationP 1185 { 1186 #ifdef AGE_RESTRICTION_WITH_ECDSA 1187 struct GNUNET_CRYPTO_EcdsaSignature signature; 1188 #else 1189 struct GNUNET_CRYPTO_Edx25519Signature signature; 1190 #endif 1191 }; 1192 1193 1194 /** 1195 * @brief KYC measure authorization hash. 1196 * Hashes over the AccountAccessToken, the 1197 * row ID and the offset. Used in the 1198 * ID of /kyc-upload/ and /kyc-start/. 1199 */ 1200 struct TALER_KycMeasureAuthorizationHashP 1201 { 1202 /** 1203 * The hash is a SHA-256 hash code. 1204 */ 1205 struct GNUNET_ShortHashCode shash; 1206 }; 1207 1208 1209 /** 1210 * @brief Hash used for client authenticiation. Computed with a 1211 * `struct TALER_MerchantAuthenticationSaltP`. 1212 */ 1213 struct TALER_MerchantAuthenticationHashP 1214 { 1215 /** 1216 * The authentication hash is a SHA-512 hash code. 1217 * All zeros if authentication is off. 1218 */ 1219 struct GNUNET_HashCode hash; 1220 }; 1221 1222 1223 /** 1224 * @brief Salt used for client authenticiation. 1225 */ 1226 struct TALER_MerchantAuthenticationSaltP 1227 { 1228 /** 1229 * The authentication salt is a 256-bit value. 1230 */ 1231 uint32_t salt[256 / 8 / sizeof(uint32_t)]; /* = 8 */ 1232 }; 1233 1234 1235 /** 1236 * @brief Hash over an order request, used for the idempotency check. 1237 */ 1238 struct TALER_MerchantPostDataHashP 1239 { 1240 /** 1241 * The authentication hash is a SHA-512 hash code. 1242 */ 1243 struct GNUNET_HashCode hash; 1244 }; 1245 1246 1247 GNUNET_NETWORK_STRUCT_END 1248 1249 1250 /** 1251 * Compute the internal @a auth_hash a merchant stores to 1252 * authenticate an instance user from the @a salt and 1253 * a @a passphrase. Merchant-backend internal. 1254 * 1255 * @param[out] auth_hash set to the authentication hash 1256 * @param salt salt to use 1257 * @param passphrase passphrase to hash 1258 */ 1259 void 1260 TALER_merchant_instance_auth_hash_with_salt ( 1261 struct TALER_MerchantAuthenticationHashP *auth_hash, 1262 struct TALER_MerchantAuthenticationSaltP *salt, 1263 const char *passphrase); 1264 1265 1266 /** 1267 * Compute RFC 3548 base32 decoding of @a val and write 1268 * result to @a udata. 1269 * 1270 * @param val value to decode 1271 * @param val_size number of bytes in @a val 1272 * @param key is the val in bits 1273 * @param key_len is the size of @a key 1274 */ 1275 int 1276 TALER_rfc3548_base32decode (const char *val, 1277 size_t val_size, 1278 void *key, 1279 size_t key_len); 1280 1281 1282 /* ************** ECDSA over NIST P-256 ***************** */ 1283 1284 /** 1285 * @brief Private key for ECDSA over NIST P-256. 1286 * 1287 * Note that this is a different curve from the one behind 1288 * #GNUNET_CRYPTO_EcdsaPrivateKey, which uses Ed25519. 1289 */ 1290 struct TALER_EcdsaP256PrivateKeyP 1291 { 1292 /** 1293 * The private scalar. 1294 */ 1295 unsigned char d[32]; 1296 }; 1297 1298 1299 /** 1300 * @brief Public key for ECDSA over NIST P-256, as a compressed SEC1 1301 * point: a 0x02 or 0x03 prefix encoding the parity of Y, followed by 1302 * the 32 bytes of X. 1303 */ 1304 struct TALER_EcdsaP256PublicKeyP 1305 { 1306 /** 1307 * The compressed public point. 1308 */ 1309 unsigned char q[33]; 1310 }; 1311 1312 1313 /** 1314 * @brief Signature for ECDSA over NIST P-256: the scalars r and s, 1315 * each zero-padded to a fixed 32 bytes. Only the canonical "low-s" 1316 * form is produced and accepted. 1317 */ 1318 struct TALER_EcdsaP256SignatureP 1319 { 1320 /** 1321 * The scalars r and s, in that order. 1322 */ 1323 unsigned char r_s[64]; 1324 }; 1325 1326 1327 /** 1328 * Create a fresh ECDSA key pair over NIST P-256. 1329 * 1330 * @param[out] priv set to the private key 1331 * @param[out] pub set to the corresponding public key 1332 * @return #GNUNET_OK on success 1333 */ 1334 enum GNUNET_GenericReturnValue 1335 TALER_ecdsa_p256_key_create ( 1336 struct TALER_EcdsaP256PrivateKeyP *priv, 1337 struct TALER_EcdsaP256PublicKeyP *pub); 1338 1339 1340 /** 1341 * Sign the already-hashed @a hash with @a priv. 1342 * 1343 * @param priv private key to sign with 1344 * @param hash 256-bit digest of the message to sign 1345 * @param[out] sig set to the signature, in canonical low-s form 1346 * @return #GNUNET_OK on success 1347 */ 1348 enum GNUNET_GenericReturnValue 1349 TALER_ecdsa_p256_sign ( 1350 const struct TALER_EcdsaP256PrivateKeyP *priv, 1351 const struct GNUNET_ShortHashCode *hash, 1352 struct TALER_EcdsaP256SignatureP *sig); 1353 1354 1355 /** 1356 * Verify @a sig over the already-hashed @a hash under @a pub. 1357 * Signatures that are not in canonical low-s form are rejected, as 1358 * are public keys that do not decode to a point on the curve. 1359 * 1360 * @param pub public key to verify against 1361 * @param hash 256-bit digest of the signed message 1362 * @param sig signature to check 1363 * @return #GNUNET_OK if @a sig is valid 1364 */ 1365 enum GNUNET_GenericReturnValue 1366 TALER_ecdsa_p256_verify ( 1367 const struct TALER_EcdsaP256PublicKeyP *pub, 1368 const struct GNUNET_ShortHashCode *hash, 1369 const struct TALER_EcdsaP256SignatureP *sig); 1370 1371 1372 /* ********* POS confirmations signing a challenge ******** */ 1373 1374 /** 1375 * Length of a challenge generated by an offline verifier. 1376 */ 1377 #define TALER_POS_CHALLENGE_LENGTH 32 1378 1379 1380 /** 1381 * @brief Challenge generated by an offline verifier (such as an 1382 * unattended appliance or an electronic tag) and signed by the 1383 * merchant backend once the corresponding order was paid. 1384 */ 1385 struct TALER_PosChallengeP 1386 { 1387 /** 1388 * Unpredictable value chosen by the offline verifier. 1389 */ 1390 unsigned char challenge[TALER_POS_CHALLENGE_LENGTH]; 1391 }; 1392 1393 1394 /** 1395 * Domain separation prefix for challenge-signature POS confirmations. 1396 * The signed message is this prefix (without the terminator) directly 1397 * followed by the 32 raw challenge bytes. 1398 * 1399 * The trailing version is part of the separation: offline verifiers 1400 * hard-code this construction, so any future change to what gets 1401 * signed must bump it rather than reuse it, leaving signatures of the 1402 * two constructions mutually unacceptable. 1403 */ 1404 #define TALER_POS_CHALLENGE_SALT "taler-pos-challenge-v1" 1405 1406 1407 /** 1408 * @brief Builds POS confirmation token to verify payment. 1409 * 1410 * Only for the time-based (TOTP) algorithms; the challenge-signature 1411 * algorithms are handled by #TALER_build_pos_confirmation_sig(). 1412 * 1413 * @param pos_key encoded key for verification payment 1414 * @param pos_alg algorithm to compute the payment verification 1415 * @param total of the order paid 1416 * @param ts is the time given 1417 * @return POS token on success, NULL otherwise 1418 */ 1419 char * 1420 TALER_build_pos_confirmation ( 1421 const char *pos_key, 1422 enum TALER_MerchantConfirmationAlgorithm pos_alg, 1423 const struct TALER_Amount *total, 1424 struct GNUNET_TIME_Timestamp ts); 1425 1426 1427 /** 1428 * @brief Builds a POS confirmation that signs the order's challenge. 1429 * 1430 * The counterpart to #TALER_build_pos_confirmation() for the 1431 * challenge-signature algorithms, which are bound to a challenge from 1432 * the offline verifier instead of to the current time. 1433 * 1434 * @param pos_key Crockford base32-encoded private key of the device 1435 * @param pos_alg algorithm to use, must be 1436 * #TALER_MCA_ECDSA_CHALLENGE or #TALER_MCA_EDDSA_CHALLENGE 1437 * @param challenge challenge to bind the signature to 1438 * @return Crockford base32-encoded signature, NULL otherwise 1439 */ 1440 char * 1441 TALER_build_pos_confirmation_sig ( 1442 const char *pos_key, 1443 enum TALER_MerchantConfirmationAlgorithm pos_alg, 1444 const struct TALER_PosChallengeP *challenge); 1445 1446 1447 /** 1448 * @brief Generate a key pair for a challenge-signature OTP device. 1449 * 1450 * The private key never leaves the merchant backend; only @a pos_pub 1451 * is handed to the merchant to configure the offline verifier. 1452 * 1453 * @param pos_alg algorithm to generate the key pair for, must be 1454 * #TALER_MCA_ECDSA_CHALLENGE or #TALER_MCA_EDDSA_CHALLENGE 1455 * @param[out] pos_key set to the Crockford base32-encoded private key, 1456 * to be freed by the caller 1457 * @param[out] pos_pub set to the Crockford base32-encoded public key, 1458 * to be freed by the caller 1459 * @return #GNUNET_OK on success 1460 */ 1461 enum GNUNET_GenericReturnValue 1462 TALER_otp_device_key_create ( 1463 enum TALER_MerchantConfirmationAlgorithm pos_alg, 1464 char **pos_key, 1465 char **pos_pub); 1466 1467 1468 /** 1469 * @brief Verify a challenge-signature POS confirmation. 1470 * 1471 * This is what an offline verifier does; the merchant backend itself 1472 * only ever signs. Provided here so that both sides of the protocol 1473 * can be tested against one implementation. 1474 * 1475 * @param pos_pub Crockford base32-encoded public key of the device 1476 * @param pos_alg algorithm the device uses, must be 1477 * #TALER_MCA_ECDSA_CHALLENGE or #TALER_MCA_EDDSA_CHALLENGE 1478 * @param challenge challenge the confirmation should be bound to 1479 * @param pos_confirmation Crockford base32-encoded signature to check 1480 * @return #GNUNET_OK if @a pos_confirmation is valid 1481 */ 1482 enum GNUNET_GenericReturnValue 1483 TALER_check_pos_confirmation_sig ( 1484 const char *pos_pub, 1485 enum TALER_MerchantConfirmationAlgorithm pos_alg, 1486 const struct TALER_PosChallengeP *challenge, 1487 const char *pos_confirmation); 1488 1489 1490 /** 1491 * Set of the fees applying to a denomination. 1492 */ 1493 struct TALER_DenomFeeSet 1494 { 1495 1496 /** 1497 * The fee the exchange charges when a coin of this type is withdrawn. 1498 * (can be zero). 1499 */ 1500 struct TALER_Amount withdraw; 1501 1502 /** 1503 * The fee the exchange charges when a coin of this type is deposited. 1504 * (can be zero). 1505 */ 1506 struct TALER_Amount deposit; 1507 1508 /** 1509 * The fee the exchange charges when a coin of this type is refreshed. 1510 * (can be zero). 1511 */ 1512 struct TALER_Amount refresh; 1513 1514 /** 1515 * The fee the exchange charges when a coin of this type is refunded. 1516 * (can be zero). Note that refund fees are charged to the customer; 1517 * if a refund is given, the deposit fee is also refunded. 1518 */ 1519 struct TALER_Amount refund; 1520 1521 }; 1522 1523 1524 /** 1525 * Set of the fees applying for a given time-range and wire method. 1526 */ 1527 struct TALER_WireFeeSet 1528 { 1529 1530 /** 1531 * The fee the exchange charges for wiring funds to a merchant. 1532 */ 1533 struct TALER_Amount wire; 1534 1535 /** 1536 * The fee the exchange charges for closing a reserve 1537 * and wiring the funds back to the origin account. 1538 */ 1539 struct TALER_Amount closing; 1540 1541 }; 1542 1543 1544 /** 1545 * Set of the fees applying globally for a given 1546 * time-range. 1547 */ 1548 struct TALER_GlobalFeeSet 1549 { 1550 1551 /** 1552 * The fee the exchange charges for returning the 1553 * history of a reserve or account. 1554 */ 1555 struct TALER_Amount history; 1556 1557 /** 1558 * The fee the exchange charges for keeping 1559 * an account or reserve open for a year. 1560 */ 1561 struct TALER_Amount account; 1562 1563 /** 1564 * The fee the exchange charges if a purse 1565 * is abandoned and this was not covered by 1566 * the account limit. 1567 */ 1568 struct TALER_Amount purse; 1569 }; 1570 1571 1572 /** 1573 * Convert fee set from host to network byte order. 1574 * 1575 * @param[out] nbo where to write the result 1576 * @param fees fee set to convert 1577 */ 1578 void 1579 TALER_denom_fee_set_hton (struct TALER_DenomFeeSetNBOP *nbo, 1580 const struct TALER_DenomFeeSet *fees); 1581 1582 1583 /** 1584 * Convert fee set from network to host network byte order. 1585 * 1586 * @param[out] fees where to write the result 1587 * @param nbo fee set to convert 1588 */ 1589 void 1590 TALER_denom_fee_set_ntoh (struct TALER_DenomFeeSet *fees, 1591 const struct TALER_DenomFeeSetNBOP *nbo); 1592 1593 1594 /** 1595 * Convert global fee set from host to network byte order. 1596 * 1597 * @param[out] nbo where to write the result 1598 * @param fees fee set to convert 1599 */ 1600 void 1601 TALER_global_fee_set_hton (struct TALER_GlobalFeeSetNBOP *nbo, 1602 const struct TALER_GlobalFeeSet *fees); 1603 1604 1605 /** 1606 * Convert global fee set from network to host network byte order. 1607 * 1608 * @param[out] fees where to write the result 1609 * @param nbo fee set to convert 1610 */ 1611 void 1612 TALER_global_fee_set_ntoh (struct TALER_GlobalFeeSet *fees, 1613 const struct TALER_GlobalFeeSetNBOP *nbo); 1614 1615 1616 /** 1617 * Compare global fee sets. 1618 * 1619 * @param f1 first set to compare 1620 * @param f2 second set to compare 1621 * @return 0 if sets are equal 1622 */ 1623 int 1624 TALER_global_fee_set_cmp (const struct TALER_GlobalFeeSet *f1, 1625 const struct TALER_GlobalFeeSet *f2); 1626 1627 1628 /** 1629 * Convert wire fee set from host to network byte order. 1630 * 1631 * @param[out] nbo where to write the result 1632 * @param fees fee set to convert 1633 */ 1634 void 1635 TALER_wire_fee_set_hton (struct TALER_WireFeeSetNBOP *nbo, 1636 const struct TALER_WireFeeSet *fees); 1637 1638 1639 /** 1640 * Convert wire fee set from network to host network byte order. 1641 * 1642 * @param[out] fees where to write the result 1643 * @param nbo fee set to convert 1644 */ 1645 void 1646 TALER_wire_fee_set_ntoh (struct TALER_WireFeeSet *fees, 1647 const struct TALER_WireFeeSetNBOP *nbo); 1648 1649 1650 /** 1651 * Compare wire fee sets. 1652 * 1653 * @param f1 first set to compare 1654 * @param f2 second set to compare 1655 * @return 0 if sets are equal 1656 */ 1657 int 1658 TALER_wire_fee_set_cmp (const struct TALER_WireFeeSet *f1, 1659 const struct TALER_WireFeeSet *f2); 1660 1661 1662 /** 1663 * Hash @a rsa. 1664 * 1665 * @param rsa key to hash 1666 * @param[out] h_rsa where to write the result 1667 */ 1668 void 1669 TALER_rsa_pub_hash (const struct GNUNET_CRYPTO_RsaPublicKey *rsa, 1670 struct TALER_RsaPubHashP *h_rsa); 1671 1672 1673 /** 1674 * Hash @a cs. 1675 * 1676 * @param cs key to hash 1677 * @param[out] h_cs where to write the result 1678 */ 1679 void 1680 TALER_cs_pub_hash (const struct GNUNET_CRYPTO_CsPublicKey *cs, 1681 struct TALER_CsPubHashP *h_cs); 1682 1683 1684 /** 1685 * @brief Type of (unblinded) coin signatures for Taler. 1686 */ 1687 struct TALER_DenominationSignature 1688 { 1689 /** 1690 * Denominations use blind signatures. 1691 */ 1692 struct GNUNET_CRYPTO_UnblindedSignature *unblinded_sig; 1693 }; 1694 1695 1696 /** 1697 * @brief Type for *blinded* denomination signatures for Taler. 1698 * Must be unblinded before it becomes valid. 1699 */ 1700 struct TALER_BlindedDenominationSignature 1701 { 1702 /** 1703 * Denominations use blind signatures. 1704 */ 1705 struct GNUNET_CRYPTO_BlindedSignature *blinded_sig; 1706 }; 1707 1708 1709 /* *************** Age Restriction *********************************** */ 1710 1711 1712 /** 1713 * @brief Type of a list of age groups, represented as bit mask. 1714 * 1715 * The bits set in the mask mark the edges at the beginning of a next age 1716 * group. F.e. for the age groups 1717 * 0-7, 8-9, 10-11, 12-13, 14-15, 16-17, 18-21, 21-* 1718 * the following bits are set: 1719 * 1720 * 31 24 16 8 0 1721 * | | | | | 1722 * oooooooo oo1oo1o1 o1o1o1o1 ooooooo1 1723 * 1724 * A value of 0 means that the exchange does not support 1725 * age-restrictions. 1726 * 1727 * For a non-0 age mask, the 0th bit always must be set, otherwise the age 1728 * mask is considered invalid. 1729 */ 1730 struct TALER_AgeMask 1731 { 1732 uint32_t bits; 1733 }; 1734 1735 1736 #define TALER_AgeCommitmentHashP_isNullOrZero(ph) ((NULL == ph) || \ 1737 GNUNET_is_zero (ph)) 1738 1739 /** 1740 * @brief Type of public signing keys for verifying blindly signed coins. 1741 */ 1742 struct TALER_DenominationPublicKey 1743 { 1744 1745 /** 1746 * Age restriction mask used for the key. 1747 */ 1748 struct TALER_AgeMask age_mask; 1749 1750 /** 1751 * Type of the public key. 1752 */ 1753 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub_key; 1754 1755 }; 1756 1757 1758 /** 1759 * @brief Type of private signing keys for blind signing of coins. 1760 */ 1761 struct TALER_DenominationPrivateKey 1762 { 1763 1764 struct GNUNET_CRYPTO_BlindSignPrivateKey *bsign_priv_key; 1765 1766 }; 1767 1768 1769 /** 1770 * @brief Blinded planchet send to exchange for blind signing. 1771 */ 1772 struct TALER_BlindedPlanchet 1773 { 1774 /** 1775 * A blinded message. 1776 */ 1777 struct GNUNET_CRYPTO_BlindedMessage *blinded_message; 1778 1779 }; 1780 1781 1782 /** 1783 * @brief Public information about a coin (including the public key 1784 * of the coin, the denomination key and the signature with 1785 * the denomination key). 1786 */ 1787 struct TALER_CoinPublicInfo 1788 { 1789 /** 1790 * The coin's public key. 1791 */ 1792 struct TALER_CoinSpendPublicKeyP coin_pub; 1793 1794 /** 1795 * Hash of the public key representing the denomination of the coin that is 1796 * being deposited. 1797 */ 1798 struct TALER_DenominationHashP denom_pub_hash; 1799 1800 /** 1801 * Hash of the age commitment. If no age commitment was provided, it must be 1802 * set to all zeroes. 1803 */ 1804 struct TALER_AgeCommitmentHashP h_age_commitment; 1805 1806 /** 1807 * True, if age commitment is not applicable. 1808 */ 1809 bool no_age_commitment; 1810 1811 /** 1812 * (Unblinded) signature over @e coin_pub with @e denom_pub, 1813 * which demonstrates that the coin is valid. 1814 */ 1815 struct TALER_DenominationSignature denom_sig; 1816 }; 1817 1818 1819 /** 1820 * Details for one of the /deposit operations that the 1821 * exchange combined into a single wire transfer. 1822 */ 1823 struct TALER_TrackTransferDetails 1824 { 1825 /** 1826 * Hash of the proposal data. 1827 */ 1828 struct TALER_PrivateContractHashP h_contract_terms; 1829 1830 /** 1831 * Which coin was deposited? 1832 */ 1833 struct TALER_CoinSpendPublicKeyP coin_pub; 1834 1835 /** 1836 * Value of the deposit (including fee), after refunds. 1837 */ 1838 struct TALER_Amount coin_value; 1839 1840 /** 1841 * Fee charged by the exchange for the deposit, 1842 * possibly reduced (or waived) due to refunds. 1843 */ 1844 struct TALER_Amount coin_fee; 1845 1846 /** 1847 * Total amount of refunds applied to this coin. 1848 */ 1849 struct TALER_Amount refund_total; 1850 1851 }; 1852 1853 1854 /** 1855 * @brief Inputs needed from the exchange for blind signing. 1856 */ 1857 struct TALER_ExchangeBlindingValues 1858 { 1859 1860 /** 1861 * Input values. 1862 */ 1863 struct GNUNET_CRYPTO_BlindingInputValues *blinding_inputs; 1864 }; 1865 1866 /** 1867 * @brief Response to a blinding prepare request. 1868 * 1869 */ 1870 struct TALER_BlindingPrepareResponse 1871 { 1872 /** 1873 * Type of signature 1874 */ 1875 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; 1876 1877 /** 1878 * Number of entries in @e details. 1879 */ 1880 size_t num; 1881 1882 /** 1883 * Details, depending on @e cipher. 1884 */ 1885 union 1886 { 1887 /** 1888 * Array @a num public pairs, if we use #GNUNET_CRYPTO_BSA_CS in @a cipher. 1889 */ 1890 struct GNUNET_CRYPTO_CSPublicRPairP *cs; 1891 1892 } details; 1893 1894 }; 1895 1896 /** 1897 * Return the alg value singleton for creation of 1898 * blinding secrets for RSA. 1899 * 1900 * @return singleton to use for RSA blinding 1901 */ 1902 const struct TALER_ExchangeBlindingValues * 1903 TALER_denom_ewv_rsa_singleton (void); 1904 1905 1906 /** 1907 * Make a copy of the given @a bi_src to 1908 * @a bi_dst. 1909 * 1910 * @param[out] bi_dst target to copy to 1911 * @param bi_src blinding input values to copy 1912 */ 1913 void 1914 TALER_denom_ewv_copy ( 1915 struct TALER_ExchangeBlindingValues *bi_dst, 1916 const struct TALER_ExchangeBlindingValues *bi_src); 1917 1918 1919 /** 1920 * Create private key for a Taler coin. 1921 * @param ps planchet secret to derive coin priv key 1922 * @param alg_values includes algorithm specific values 1923 * @param[out] coin_priv private key to initialize 1924 */ 1925 void 1926 TALER_planchet_setup_coin_priv ( 1927 const struct TALER_PlanchetMasterSecretP *ps, 1928 const struct TALER_ExchangeBlindingValues *alg_values, 1929 struct TALER_CoinSpendPrivateKeyP *coin_priv); 1930 1931 1932 /** 1933 * @brief Method to derive withdraw /csr nonce 1934 * 1935 * @param ps seed for the coins' planchet 1936 * @param[out] nonce withdraw nonce included in the request to generate R_0 and R_1 1937 */ 1938 void 1939 TALER_cs_withdraw_nonce_derive ( 1940 const struct TALER_PlanchetMasterSecretP *ps, 1941 struct GNUNET_CRYPTO_CsSessionNonce *nonce); 1942 1943 1944 /** 1945 * @brief Method to derive a seed for blinding from a seed for withdraw 1946 * 1947 * @param seed input withdraw seed 1948 * @param[out] blinding_seed derived blinding seed 1949 */ 1950 void 1951 TALER_cs_withdraw_seed_to_blinding_seed ( 1952 const struct TALER_WithdrawMasterSeedP *seed, 1953 struct TALER_BlindingMasterSeedP *blinding_seed); 1954 1955 /** 1956 * @brief Method to derive a seed for blinding from a seed for refresh 1957 * 1958 * @param seed input refresh seed 1959 * @param coin_priv the private key of the old coin 1960 * @param[out] blinding_seed derived blinding seed 1961 */ 1962 void 1963 TALER_cs_refresh_seed_to_blinding_seed ( 1964 const struct TALER_PublicRefreshMasterSeedP *seed, 1965 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 1966 struct TALER_BlindingMasterSeedP *blinding_seed); 1967 1968 1969 /** 1970 * @brief Method to derive a /blinding-prepare nonce for a particular index 1971 * 1972 * @param seed blinding master seed for the nonce 1973 * @param for_melt true if this nonce is for a melt operation 1974 * @param index of the particular coin (in the array of coins in the actual operation) 1975 * @param[out] nonce nonce included in the request to generate R_0 and R_1 1976 */ 1977 void 1978 TALER_cs_nonce_derive_indexed ( 1979 const struct TALER_BlindingMasterSeedP *seed, 1980 bool for_melt, 1981 uint32_t index, 1982 struct GNUNET_CRYPTO_CsSessionNonce *nonce); 1983 1984 1985 /** 1986 * @brief Method to derive a batch of CS nonces 1987 * 1988 * @param seed blinding master seed for the nonces 1989 * @param for_melt true if the nonces are for a melt operation 1990 * @param num number of nonces to derive 1991 * @param indices array @e num of coin indices, which contribute to the corresponding nonce 1992 * @param[out] nonces array @e num of nonces 1993 */ 1994 void 1995 TALER_cs_derive_nonces_from_seed ( 1996 const struct TALER_BlindingMasterSeedP *seed, 1997 bool for_melt, 1998 size_t num, 1999 const uint32_t indices[static num], 2000 struct GNUNET_CRYPTO_CsSessionNonce nonces[static num]); 2001 2002 2003 /** 2004 * @brief Method to derive a batch of blind session nonces 2005 * 2006 * @param seed blinding master seed for the nonces 2007 * @param for_melt true if the nonces are for a melt operation 2008 * @param num number of nonces to derive 2009 * @param is_cs array @e num of booleans, with true value on indices with CS denominations. 2010 * @param[out] nonces array @e num of nonces, only for CS 2011 */ 2012 void 2013 TALER_cs_derive_blind_nonces_from_seed ( 2014 const struct TALER_BlindingMasterSeedP *seed, 2015 bool for_melt, 2016 size_t num, 2017 const bool is_cs[static num], 2018 union GNUNET_CRYPTO_BlindSessionNonce nonces[static num]); 2019 2020 2021 /** 2022 * @brief Method to derive a batch of blind session nonces only for CS 2023 * 2024 * @param seed blinding master seed for the nonces 2025 * @param for_melt true if the nonces are for a melt operation 2026 * @param num number of nonces to derive 2027 * @param indices array @e num of coin indices, which contribute to the corresponding nonce 2028 * @param[out] nonces array @e num of nonces, only for CS 2029 */ 2030 void 2031 TALER_cs_derive_only_cs_blind_nonces_from_seed ( 2032 const struct TALER_BlindingMasterSeedP *seed, 2033 bool for_melt, 2034 size_t num, 2035 const uint32_t indices[static num], 2036 union GNUNET_CRYPTO_BlindSessionNonce nonces[static num]); 2037 2038 2039 /** 2040 * Initialize denomination public-private key pair. 2041 * 2042 * For #GNUNET_CRYPTO_BSA_RSA, an additional "unsigned int" 2043 * argument with the number of bits for 'n' (e.g. 2048) must 2044 * be passed. 2045 * 2046 * @param[out] denom_priv where to write the private key 2047 * @param[out] denom_pub where to write the public key 2048 * @param cipher which type of cipher to use 2049 * @param ... RSA key size (eg. 2048/3072/4096) 2050 * @return #GNUNET_OK on success, #GNUNET_NO if parameters were invalid 2051 */ 2052 enum GNUNET_GenericReturnValue 2053 TALER_denom_priv_create (struct TALER_DenominationPrivateKey *denom_priv, 2054 struct TALER_DenominationPublicKey *denom_pub, 2055 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher, 2056 ...); 2057 2058 2059 /** 2060 * Free internals of @a denom_pub, but not @a denom_pub itself. 2061 * 2062 * @param[in] denom_pub key to free 2063 */ 2064 void 2065 TALER_denom_pub_free (struct TALER_DenominationPublicKey *denom_pub); 2066 2067 2068 /** 2069 * Free internals of @a ewv, but not @a ewv itself. 2070 * 2071 * @param[in] ewv input values to free 2072 */ 2073 void 2074 TALER_denom_ewv_free (struct TALER_ExchangeBlindingValues *ewv); 2075 2076 2077 /** 2078 * Free internals of @a denom_priv, but not @a denom_priv itself. 2079 * 2080 * @param[in] denom_priv key to free 2081 */ 2082 void 2083 TALER_denom_priv_free (struct TALER_DenominationPrivateKey *denom_priv); 2084 2085 2086 /** 2087 * Free internals of @a denom_sig, but not @a denom_sig itself. 2088 * 2089 * @param[in] denom_sig signature to free 2090 */ 2091 void 2092 TALER_denom_sig_free (struct TALER_DenominationSignature *denom_sig); 2093 2094 2095 /** 2096 * Blind coin for blind signing with @a dk using blinding secret @a coin_bks. 2097 * 2098 * NOTE: As a particular oddity, the @a blinded_planchet is only partially 2099 * initialized by this function in the case of CS-denominations. Here, the 2100 * 'nonce' must be initialized separately! 2101 * 2102 * @param dk denomination public key to blind for 2103 * @param coin_bks blinding secret to use 2104 * @param nonce nonce used to derive session values, 2105 * could be NULL for ciphers that do not use it 2106 * @param age_commitment_hash hash of the age commitment to be used for the coin. NULL if no commitment is made. 2107 * @param coin_pub public key of the coin to blind 2108 * @param alg_values algorithm specific values to blind the planchet 2109 * @param[out] c_hash resulting hashed coin 2110 * @param[out] blinded_planchet planchet data to initialize 2111 * @return #GNUNET_OK on success 2112 */ 2113 enum GNUNET_GenericReturnValue 2114 TALER_denom_blind (const struct TALER_DenominationPublicKey *dk, 2115 const union GNUNET_CRYPTO_BlindingSecretP *coin_bks, 2116 const union GNUNET_CRYPTO_BlindSessionNonce *nonce, 2117 const struct TALER_AgeCommitmentHashP *age_commitment_hash, 2118 const struct TALER_CoinSpendPublicKeyP *coin_pub, 2119 const struct TALER_ExchangeBlindingValues *alg_values, 2120 struct TALER_CoinPubHashP *c_hash, 2121 struct TALER_BlindedPlanchet *blinded_planchet); 2122 2123 2124 /** 2125 * Create blinded signature. 2126 * 2127 * @param[out] denom_sig where to write the signature 2128 * @param denom_priv private key to use for signing 2129 * @param for_melt true to use the HKDF for melt 2130 * @param blinded_planchet the planchet already blinded 2131 * @return #GNUNET_OK on success 2132 */ 2133 enum GNUNET_GenericReturnValue 2134 TALER_denom_sign_blinded (struct TALER_BlindedDenominationSignature *denom_sig, 2135 const struct TALER_DenominationPrivateKey *denom_priv, 2136 bool for_melt, 2137 const struct TALER_BlindedPlanchet *blinded_planchet); 2138 2139 2140 /** 2141 * Unblind blinded signature. 2142 * 2143 * @param[out] denom_sig where to write the unblinded signature 2144 * @param bdenom_sig the blinded signature 2145 * @param bks blinding secret to use 2146 * @param c_hash hash of the coin's public key for verification of the signature 2147 * @param alg_values algorithm specific values 2148 * @param denom_pub public key used for signing 2149 * @return #GNUNET_OK on success 2150 */ 2151 enum GNUNET_GenericReturnValue 2152 TALER_denom_sig_unblind ( 2153 struct TALER_DenominationSignature *denom_sig, 2154 const struct TALER_BlindedDenominationSignature *bdenom_sig, 2155 const union GNUNET_CRYPTO_BlindingSecretP *bks, 2156 const struct TALER_CoinPubHashP *c_hash, 2157 const struct TALER_ExchangeBlindingValues *alg_values, 2158 const struct TALER_DenominationPublicKey *denom_pub); 2159 2160 2161 /** 2162 * Free internals of @a denom_sig, but not @a denom_sig itself. 2163 * 2164 * @param[in] denom_sig signature to free 2165 */ 2166 void 2167 TALER_blinded_denom_sig_free ( 2168 struct TALER_BlindedDenominationSignature *denom_sig); 2169 2170 2171 /** 2172 * Compute the hash of the given @a denom_pub. 2173 * 2174 * @param denom_pub public key to hash 2175 * @param[out] denom_hash resulting hash value 2176 */ 2177 void 2178 TALER_denom_pub_hash (const struct TALER_DenominationPublicKey *denom_pub, 2179 struct TALER_DenominationHashP *denom_hash); 2180 2181 2182 /** 2183 * Make a (deep) copy of the given @a denom_src to 2184 * @a denom_dst. 2185 * 2186 * @param[out] denom_dst target to copy to 2187 * @param denom_src public key to copy 2188 */ 2189 void 2190 TALER_denom_pub_copy (struct TALER_DenominationPublicKey *denom_dst, 2191 const struct TALER_DenominationPublicKey *denom_src); 2192 2193 2194 /** 2195 * Make a (deep) copy of the given @a denom_src to 2196 * @a denom_dst. 2197 * 2198 * @param[out] denom_dst target to copy to 2199 * @param denom_src public key to copy 2200 */ 2201 void 2202 TALER_denom_sig_copy (struct TALER_DenominationSignature *denom_dst, 2203 const struct TALER_DenominationSignature *denom_src); 2204 2205 2206 /** 2207 * Make a (deep) copy of the given @a denom_src to 2208 * @a denom_dst. 2209 * 2210 * @param[out] denom_dst target to copy to 2211 * @param denom_src public key to copy 2212 */ 2213 void 2214 TALER_blinded_denom_sig_copy ( 2215 struct TALER_BlindedDenominationSignature *denom_dst, 2216 const struct TALER_BlindedDenominationSignature *denom_src); 2217 2218 2219 /** 2220 * Compare two denomination public keys. 2221 * 2222 * @param denom1 first key 2223 * @param denom2 second key 2224 * @return 0 if the keys are equal, otherwise -1 or 1 2225 */ 2226 int 2227 TALER_denom_pub_cmp (const struct TALER_DenominationPublicKey *denom1, 2228 const struct TALER_DenominationPublicKey *denom2); 2229 2230 2231 /** 2232 * Compare two denomination signatures. 2233 * 2234 * @param sig1 first signature 2235 * @param sig2 second signature 2236 * @return 0 if the keys are equal, otherwise -1 or 1 2237 */ 2238 int 2239 TALER_denom_sig_cmp (const struct TALER_DenominationSignature *sig1, 2240 const struct TALER_DenominationSignature *sig2); 2241 2242 2243 /** 2244 * Compare two blinded denomination signatures. 2245 * 2246 * @param sig1 first signature 2247 * @param sig2 second signature 2248 * @return 0 if the keys are equal, otherwise -1 or 1 2249 */ 2250 int 2251 TALER_blinded_denom_sig_cmp ( 2252 const struct TALER_BlindedDenominationSignature *sig1, 2253 const struct TALER_BlindedDenominationSignature *sig2); 2254 2255 2256 /** 2257 * Compare two blinded planchets. 2258 * 2259 * @param bp1 first blinded planchet 2260 * @param bp2 second blinded planchet 2261 * @return 0 if the keys are equal, otherwise -1 or 1 2262 */ 2263 int 2264 TALER_blinded_planchet_cmp ( 2265 const struct TALER_BlindedPlanchet *bp1, 2266 const struct TALER_BlindedPlanchet *bp2); 2267 2268 2269 /** 2270 * Verify signature made with a denomination public key 2271 * over a coin. 2272 * 2273 * @param denom_pub public denomination key 2274 * @param denom_sig signature made with the private key 2275 * @param c_hash hash over the coin 2276 * @return #GNUNET_OK if the signature is valid 2277 */ 2278 enum GNUNET_GenericReturnValue 2279 TALER_denom_pub_verify (const struct TALER_DenominationPublicKey *denom_pub, 2280 const struct TALER_DenominationSignature *denom_sig, 2281 const struct TALER_CoinPubHashP *c_hash); 2282 2283 2284 /** 2285 * Encrypts KYC attributes for storage in the database. 2286 * 2287 * @param key encryption key to use 2288 * @param attr set of attributes to encrypt 2289 * @param[out] enc_attr encrypted attribute data 2290 * @param[out] enc_attr_size number of bytes in @a enc_attr 2291 */ 2292 void 2293 TALER_CRYPTO_kyc_attributes_encrypt ( 2294 const struct TALER_AttributeEncryptionKeyP *key, 2295 const json_t *attr, 2296 void **enc_attr, 2297 size_t *enc_attr_size); 2298 2299 2300 /** 2301 * Encrypts KYC attributes for storage in the database. 2302 * 2303 * @param key encryption key to use 2304 * @param enc_attr encrypted attribute data 2305 * @param enc_attr_size number of bytes in @a enc_attr 2306 * @return set of decrypted attributes, NULL on failure 2307 */ 2308 json_t * 2309 TALER_CRYPTO_kyc_attributes_decrypt ( 2310 const struct TALER_AttributeEncryptionKeyP *key, 2311 const void *enc_attr, 2312 size_t enc_attr_size); 2313 2314 2315 /** 2316 * Check if a coin is valid; that is, whether the denomination key exists, 2317 * is not expired, and the signature is correct. 2318 * 2319 * @param coin_public_info the coin public info to check for validity 2320 * @param denom_pub denomination key, must match @a coin_public_info's `denom_pub_hash` 2321 * @return #GNUNET_YES if the coin is valid, 2322 * #GNUNET_NO if it is invalid 2323 * #GNUNET_SYSERR if an internal error occurred 2324 */ 2325 enum GNUNET_GenericReturnValue 2326 TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info, 2327 const struct TALER_DenominationPublicKey *denom_pub); 2328 2329 2330 /** 2331 * Compute the hash of a blinded coin. 2332 * 2333 * @param blinded_planchet blinded planchet 2334 * @param denom_hash hash of the denomination public key 2335 * @param[out] bch where to write the hash 2336 */ 2337 void 2338 TALER_coin_ev_hash (const struct TALER_BlindedPlanchet *blinded_planchet, 2339 const struct TALER_DenominationHashP *denom_hash, 2340 struct TALER_BlindedCoinHashP *bch); 2341 2342 2343 /** 2344 * Compute the hash of a coin. 2345 * 2346 * @param coin_pub public key of the coin 2347 * @param age_commitment_hash hash of the age commitment vector. NULL, if no age commitment was set 2348 * @param[out] coin_h where to write the hash 2349 */ 2350 void 2351 TALER_coin_pub_hash (const struct TALER_CoinSpendPublicKeyP *coin_pub, 2352 const struct TALER_AgeCommitmentHashP *age_commitment_hash, 2353 struct TALER_CoinPubHashP *coin_h); 2354 2355 2356 /** 2357 * Hashes the @a access_token, @a row and @a offset 2358 * to compute an authorization hash used in the 2359 * /kyc-upload/ and /kyc-start/ endpoints. 2360 * 2361 * @param access_token the access token 2362 * @param row the database row 2363 * @param offset the offset of the measure in the array 2364 * @param[out] mah set to the hash 2365 */ 2366 void 2367 TALER_kyc_measure_authorization_hash ( 2368 const struct TALER_AccountAccessTokenP *access_token, 2369 uint64_t row, 2370 uint32_t offset, 2371 struct TALER_KycMeasureAuthorizationHashP *mah); 2372 2373 2374 /** 2375 * Compute the hash of a full payto URI. 2376 * 2377 * @param fpayto URI to hash 2378 * @param[out] h_fpayto where to write the hash 2379 */ 2380 void 2381 TALER_full_payto_hash (const struct TALER_FullPayto fpayto, 2382 struct TALER_FullPaytoHashP *h_fpayto); 2383 2384 2385 /** 2386 * Compute the hash of a normalized payto URI. 2387 * 2388 * @param npayto normalized URI to hash 2389 * @param[out] h_npayto where to write the hash 2390 */ 2391 void 2392 TALER_normalized_payto_hash (const struct TALER_NormalizedPayto npayto, 2393 struct TALER_NormalizedPaytoHashP *h_npayto); 2394 2395 2396 /** 2397 * Details about a planchet that the customer wants to obtain 2398 * a withdrawal authorization. This is the information that 2399 * will need to be sent to the exchange to obtain the blind 2400 * signature required to turn a planchet into a coin. 2401 */ 2402 struct TALER_PlanchetDetail 2403 { 2404 /** 2405 * Hash of the denomination public key. 2406 */ 2407 struct TALER_DenominationHashP denom_pub_hash; 2408 2409 /** 2410 * The blinded planchet 2411 */ 2412 struct TALER_BlindedPlanchet blinded_planchet; 2413 }; 2414 2415 2416 /** 2417 * Information about a (fresh) coin, returned from the API when we 2418 * finished creating a coin. Note that @e sig needs to be freed 2419 * using the appropriate code. 2420 */ 2421 struct TALER_FreshCoin 2422 { 2423 2424 /** 2425 * The exchange's signature over the coin's public key. 2426 */ 2427 struct TALER_DenominationSignature sig; 2428 2429 /** 2430 * The coin's private key. 2431 */ 2432 struct TALER_CoinSpendPrivateKeyP coin_priv; 2433 2434 /** 2435 * Optional hash of an age commitment bound to this coin, maybe NULL. 2436 */ 2437 const struct TALER_AgeCommitmentHashP *h_age_commitment; 2438 }; 2439 2440 2441 /** 2442 * Details about an encrypted contract. 2443 */ 2444 struct TALER_EncryptedContract 2445 { 2446 2447 /** 2448 * Signature of the client affiming this encrypted contract. 2449 */ 2450 struct TALER_PurseContractSignatureP econtract_sig; 2451 2452 /** 2453 * Contract decryption key for the purse. 2454 */ 2455 struct TALER_ContractDiffiePublicP contract_pub; 2456 2457 /** 2458 * Encrypted contract, can be NULL. 2459 */ 2460 void *econtract; 2461 2462 /** 2463 * Number of bytes in @e econtract. 2464 */ 2465 size_t econtract_size; 2466 2467 }; 2468 2469 2470 GNUNET_NETWORK_STRUCT_BEGIN 2471 2472 /** 2473 * @brief Secret used to decrypt the key to decrypt link secrets. 2474 */ 2475 struct TALER_TransferSecretP 2476 { 2477 /** 2478 * Secret used to derive private inputs for refreshed coins. 2479 * Must be (currently) a hash as this is what 2480 * GNUNET_CRYPTO_ecc_ecdh() returns to us. 2481 */ 2482 struct GNUNET_HashCode key; 2483 }; 2484 2485 2486 /** 2487 * Length of the raw value in the Taler wire transfer identifier 2488 * (in binary representation). 2489 */ 2490 #define TALER_BANK_TRANSFER_IDENTIFIER_LEN 32 2491 2492 /** 2493 * #TALER_BANK_TRANSFER_IDENTIFIER_LEN as a string. 2494 */ 2495 #define TALER_BANK_TRANSFER_IDENTIFIER_LEN_STR "32" 2496 2497 2498 /** 2499 * Raw value of a wire transfer subjects, without the checksum. 2500 */ 2501 struct TALER_WireTransferIdentifierRawP 2502 { 2503 2504 /** 2505 * Raw value. Note that typical payment systems (SEPA, ACH) support 2506 * at least two lines of 27 ASCII characters to encode a transaction 2507 * subject or "details", for a total of 54 characters. (The payment 2508 * system protocols often support more lines, but the forms presented 2509 * to customers are usually limited to 54 characters.) 2510 * 2511 * With a Base32-encoding of 5 bit per character, this gives us 270 2512 * bits or (rounded down) 33 bytes. So we use the first 32 bytes to 2513 * encode the actual value (i.e. a 256-bit / 32-byte public key or 2514 * a hash code), and the last byte for a minimalistic checksum. 2515 */ 2516 uint8_t raw[TALER_BANK_TRANSFER_IDENTIFIER_LEN]; 2517 }; 2518 2519 2520 /** 2521 * Raw value of a wire transfer subject for a wad. 2522 */ 2523 struct TALER_WadIdentifierP 2524 { 2525 2526 /** 2527 * Wad identifier, in binary encoding. 2528 */ 2529 uint8_t raw[24]; 2530 }; 2531 2532 2533 /** 2534 * Binary information encoded in Crockford's Base32 in wire transfer 2535 * subjects of transfers from Taler to a merchant. The actual value 2536 * is chosen by the exchange and has no particular semantics, other than 2537 * being unique so that the exchange can lookup details about the wire 2538 * transfer when needed. 2539 */ 2540 struct TALER_WireTransferIdentifierP 2541 { 2542 2543 /** 2544 * Raw value. 2545 */ 2546 struct TALER_WireTransferIdentifierRawP raw; 2547 2548 /** 2549 * Checksum using CRC8 over the @e raw data. 2550 */ 2551 uint8_t crc8; 2552 }; 2553 2554 2555 GNUNET_NETWORK_STRUCT_END 2556 2557 2558 /** 2559 * @since v27 2560 * @deprecated after vDOLDPLUS 2561 * 2562 * The signature of the old coin over a public nonce, 2563 * provided during the /reveal-melt operation as 2564 * a) proof of ownership of the old coin 2565 * b) seed to derive the fresh coin's secret material from 2566 * (private key, blinding nonces, age restriction) 2567 * The signature is for purpose TALER_SIGNATURE_WALLET_COIN_LINK 2568 */ 2569 struct TALER_PrivateRefreshNonceSignatureP 2570 { 2571 /** 2572 * It is actually a signature of the coin 2573 */ 2574 struct TALER_CoinSpendSignatureP coin_sig; 2575 }; 2576 2577 /** 2578 * @since v27 2579 * @deprecated after vDOLDPLUS 2580 * 2581 * Sign a public nonce with the old coin, to prove 2582 * coin ownership, with purpose 2583 * TALER_SIGNATURE_WALLET_COIN_LINK 2584 * 2585 * @param old_coin_priv private key of the old coin 2586 * @param nonce nonce to sign 2587 * @param num_denoms_h number of elements in @e denoms_h 2588 * @param denoms_h array @e num_denoms_h of pointers to hashes of denomination public keys 2589 * @param kappa_index the index of this nonce in the TALER_CNC_KAPPA array of nonces. 2590 * @param[out] sig the signature to write to. 2591 */ 2592 void 2593 TALER_wallet_refresh_nonce_sign ( 2594 const struct TALER_CoinSpendPrivateKeyP *old_coin_priv, 2595 const struct TALER_PublicRefreshNonceP *nonce, 2596 size_t num_denoms_h, 2597 const struct TALER_DenominationHashP *denoms_h[static num_denoms_h], 2598 uint8_t kappa_index, 2599 struct TALER_PrivateRefreshNonceSignatureP *sig); 2600 2601 2602 /** 2603 * @since v27 2604 * @deprecated after vDOLDPLUS 2605 * 2606 * Verify the signature on a public nonce, provided by the old coin, 2607 * to prove coin ownership during a melt/refresh operation. 2608 * 2609 * @param old_coin_pub public key of the old coin 2610 * @param nonce nonce to sign 2611 * @param num_denoms_h number of elements in @e denoms_h 2612 * @param denoms_h array @e num_denoms_h of pointers to hashes of denomination public keys 2613 * @param kappa_index the index of this nonce in the TALER_CNC_KAPPA array of nonces. 2614 * @param sig signature over the nonce by the old coin's private key 2615 * return GNUNET_OK when the signature is valid. 2616 */ 2617 enum GNUNET_GenericReturnValue 2618 TALER_wallet_refresh_nonce_verify ( 2619 const struct TALER_CoinSpendPublicKeyP *old_coin_pub, 2620 const struct TALER_PublicRefreshNonceP *nonce, 2621 size_t num_denoms_h, 2622 struct TALER_DenominationHashP *const denoms_h[static num_denoms_h], 2623 uint8_t kappa_index, 2624 const struct TALER_PrivateRefreshNonceSignatureP *sig); 2625 2626 2627 /** 2628 * @since v27 2629 * @deprecated after vDOLDPLUS 2630 * 2631 * From a given signature for a refresh nonce, 2632 * derive a fresh master secret for the planchet 2633 * of a fresh coin. 2634 * 2635 * @param sig the signature of the old coin 2636 * @param num_secrets the number of secrets to derive 2637 * @param[out] secrets the master secrets for @a num fresh coins 2638 */ 2639 void 2640 TALER_refresh_signature_to_secrets_v27 ( 2641 const struct TALER_PrivateRefreshNonceSignatureP *sig, 2642 size_t num_secrets, 2643 struct TALER_PlanchetMasterSecretP secrets[static num_secrets]); 2644 2645 2646 /** 2647 * Setup information for a fresh coin, deriving the coin planchet secrets from 2648 * which we will later derive the private key and the blinding factor. The 2649 * planchet secrets derivation is based on the @a secret_seed with a KDF 2650 * salted by the @a coin_num_salt. 2651 * 2652 * @param secret_seed seed to use for KDF to derive coin keys 2653 * @param coin_num_salt number of the coin to include in KDF 2654 * @param[out] ps value to initialize 2655 */ 2656 void 2657 TALER_transfer_secret_to_planchet_secret ( 2658 const struct TALER_TransferSecretP *secret_seed, 2659 uint32_t coin_num_salt, 2660 struct TALER_PlanchetMasterSecretP *ps); 2661 2662 2663 /** 2664 * Setup secret information for fresh a coin to be 2665 * withdrawn. 2666 * 2667 * @param[out] ps value to initialize 2668 */ 2669 void 2670 TALER_planchet_master_setup_random ( 2671 struct TALER_PlanchetMasterSecretP *ps); 2672 2673 /** 2674 * Setup secret seed information for a batch of fresh coins to be 2675 * withdrawn. 2676 * 2677 * @param[out] seed value to initialize 2678 */ 2679 void 2680 TALER_withdraw_master_seed_setup_random ( 2681 struct TALER_WithdrawMasterSeedP *seed); 2682 2683 2684 /** 2685 * Setup the seeds for a batch of age-restricted coins from a seed. 2686 * The withdraw of provably age-restricted coins requires TALER_CNC_KAPPA many 2687 * candidates during the initial /withdraw. 2688 * 2689 * @param seed The input seed 2690 * @param[out] tuple tuples of secrets to fill 2691 */ 2692 void 2693 TALER_withdraw_expand_kappa_seed ( 2694 const struct TALER_WithdrawMasterSeedP *seed, 2695 struct TALER_KappaWithdrawMasterSeedP *tuple); 2696 2697 2698 /** 2699 * Setup the secrets for a batch of coins from a seed. 2700 * Note that if the number of coins is one, the secret will 2701 * be a copy of the seed. 2702 * 2703 * @param num_coins The number of coins, i.e. elements in @e secrets 2704 * @param seed The input seed 2705 * @param[out] secrets Array of @e num_coins secrets to fill 2706 */ 2707 void 2708 TALER_withdraw_expand_secrets ( 2709 size_t num_coins, 2710 const struct TALER_WithdrawMasterSeedP *seed, 2711 struct TALER_PlanchetMasterSecretP secrets[static num_coins]); 2712 2713 2714 /** 2715 * Setup secret seed for fresh coins to be refreshed. 2716 * 2717 * @param[out] rms value to initialize 2718 */ 2719 void 2720 TALER_refresh_master_setup_random ( 2721 struct TALER_PublicRefreshMasterSeedP *rms); 2722 2723 2724 /** 2725 * @since vDOLDPLUS 2726 * 2727 * Expand a master refresh seed using the old coins private 2728 * into kappa many batch seeds, key each of which expands into 2729 * private refresh seeds for n coins. 2730 * 2731 * @param refresh_master_seed master seed to expand from 2732 * @param coin_priv the old coin's private key to expand from. 2733 * @param[out] kappa_refresh_seeds tuple of #TALER_CNC_KAPPA many batch nonces 2734 */ 2735 void 2736 TALER_refresh_expand_seed_to_kappa_batch_seeds ( 2737 const struct TALER_PublicRefreshMasterSeedP *refresh_master_seed, 2738 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 2739 struct TALER_KappaPrivateRefreshBatchSeedsP *kappa_refresh_seeds); 2740 2741 /** 2742 * @since vDOLDPLUS 2743 * 2744 * Expands a secret seed for a batch of coin candidates for refresh 2745 * to the array of transfer private keys. 2746 * 2747 * @param batch_seed secret seed for a batch of coin candidates 2748 * @param num_transfer_pks number of elements in @a transfer_pks 2749 * @param[out] transfer_pks output array of transfer private keys 2750 */ 2751 void 2752 TALER_refresh_expand_batch_seed_to_transfer_private_keys ( 2753 const struct TALER_PrivateRefreshBatchSeedP *batch_seed, 2754 size_t num_transfer_pks, 2755 struct TALER_TransferPrivateKeyP transfer_pks[num_transfer_pks]); 2756 2757 /** 2758 * @since vDOLDPLUS 2759 * 2760 * Expands a secret seed for a batch of coin candidates for refresh 2761 * to the array of transfer secrets. 2762 * 2763 * This is a simple helper function that calls under the hood 2764 * TALER_refresh_expand_batch_seed_to_transfer_private_keys 2765 * and TALER_link_reveal_transfer_secret. 2766 * 2767 * @param batch_seed secret seed for a batch of coin candidates 2768 * @param coin_pub the old coin's public key 2769 * @param num_transfer_secrets number of elements in @a planchet_secrets 2770 * @param[out] transfer_secrets output array of transfer secrets 2771 */ 2772 void 2773 TALER_refresh_expand_batch_seed_to_transfer_secrets ( 2774 const struct TALER_PrivateRefreshBatchSeedP *batch_seed, 2775 const struct TALER_CoinSpendPublicKeyP *coin_pub, 2776 size_t num_transfer_secrets, 2777 struct TALER_TransferSecretP transfer_secrets[num_transfer_secrets]); 2778 2779 2780 /** 2781 * @since vDOLDPLUS 2782 * 2783 * Expands a secret seed for a batch of coin candidates for refresh 2784 * to the array of planchet master secrets. 2785 * 2786 * This is a simple helper function that calls under the hood 2787 * TALER_refresh_expand_batch_seed_to_transfer_private_keys, 2788 * TALER_link_reveal_transfer_secret and 2789 * TALER_transfer_secret_to_planchet_secret. 2790 * 2791 * @param batch_seed secret seed for a batch of coin candidates 2792 * @param coin_pub the old coin's public key 2793 * @param num_planchet_secrets number of elements in @a planchet_secrets 2794 * @param[out] planchet_secrets output array of planchet master secrets 2795 */ 2796 void 2797 TALER_refresh_expand_batch_seed_to_planchet_master_secrets ( 2798 const struct TALER_PrivateRefreshBatchSeedP *batch_seed, 2799 const struct TALER_CoinSpendPublicKeyP *coin_pub, 2800 size_t num_planchet_secrets, 2801 struct TALER_PlanchetMasterSecretP planchet_secrets[num_planchet_secrets]); 2802 2803 /** 2804 * @since vDOLDPLUS 2805 * 2806 * Expands a secret seed for a batch of coin candidates for refresh 2807 * to the array of planchet secrets and the array of transfer public keys. 2808 * 2809 * This is a simple helper function that calls under the hood 2810 * TALER_refresh_expand_batch_seed_to_transfer_private_keys, 2811 * TALER_link_reveal_transfer_secret and 2812 * TALER_transfer_secret_to_planchet_secret 2813 * and the public key generation. 2814 * 2815 * @param batch_seed secret seed for a batch of coin candidates 2816 * @param coin_pub the old coin's public key 2817 * @param num number of elements in @a transfer_secrets and @a transfer_pubs 2818 * @param[out] planchet_secrets output array of transfer planchet_secrets 2819 * @param[out] transfer_pubs output array of transfer public keys 2820 */ 2821 void 2822 TALER_refresh_expand_batch_seed_to_transfer_data ( 2823 const struct TALER_PrivateRefreshBatchSeedP *batch_seed, 2824 const struct TALER_CoinSpendPublicKeyP *coin_pub, 2825 size_t num, 2826 struct TALER_PlanchetMasterSecretP planchet_secrets[num], 2827 struct TALER_TransferPublicKeyP transfer_pubs[num]); 2828 2829 /** 2830 * @since v27 2831 * @deprecated after vDOLDPLUS 2832 * 2833 * Expand a refresh seed into kappa many batch seeds, each 2834 * of which expands into nonces for n coins. 2835 * 2836 * @param refresh_seed master seed to expand from 2837 * @param[out] kappa_nonces tuple of #TALER_CNC_KAPPA many batch nonces 2838 */ 2839 void 2840 TALER_refresh_expand_kappa_nonces_v27 ( 2841 const struct TALER_PublicRefreshMasterSeedP *refresh_seed, 2842 struct TALER_KappaPublicRefreshNoncesP *kappa_nonces); 2843 2844 2845 /** 2846 * Create a blinding secret @a bks given the client's @a ps and the alg_values 2847 * from the exchange. 2848 * 2849 * @param ps secret to derive blindings from 2850 * @param alg_values withdraw values containing cipher and additional CS values 2851 * @param[out] bks blinding secrets 2852 */ 2853 void 2854 TALER_planchet_blinding_secret_create ( 2855 const struct TALER_PlanchetMasterSecretP *ps, 2856 const struct TALER_ExchangeBlindingValues *alg_values, 2857 union GNUNET_CRYPTO_BlindingSecretP *bks); 2858 2859 2860 /** 2861 * Prepare a planchet for withdrawal. Creates and blinds a coin. 2862 * 2863 * @param dk denomination key for the coin to be created 2864 * @param alg_values algorithm specific values 2865 * @param bks blinding secrets 2866 * @param nonce session nonce used to get @a alg_values 2867 * @param coin_priv coin private key 2868 * @param ach hash of age commitment to bind to this coin, maybe NULL 2869 * @param[out] c_hash set to the hash of the public key of the coin (needed later) 2870 * @param[out] pd set to the planchet detail for TALER_MERCHANT_tip_pickup() and 2871 * other withdraw operations, `pd->blinded_planchet.cipher` will be set 2872 * to cipher from @a dk 2873 * @return #GNUNET_OK on success 2874 */ 2875 enum GNUNET_GenericReturnValue 2876 TALER_planchet_prepare ( 2877 const struct TALER_DenominationPublicKey *dk, 2878 const struct TALER_ExchangeBlindingValues *alg_values, 2879 const union GNUNET_CRYPTO_BlindingSecretP *bks, 2880 const union GNUNET_CRYPTO_BlindSessionNonce *nonce, 2881 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 2882 const struct TALER_AgeCommitmentHashP *ach, 2883 struct TALER_CoinPubHashP *c_hash, 2884 struct TALER_PlanchetDetail *pd); 2885 2886 2887 /** 2888 * Frees blinded message inside blinded planchet depending on `blinded_planchet->cipher`. 2889 * Does not free the @a blinded_planchet itself! 2890 * 2891 * @param[in] blinded_planchet blinded planchet 2892 */ 2893 void 2894 TALER_blinded_planchet_free (struct TALER_BlindedPlanchet *blinded_planchet); 2895 2896 2897 /** 2898 * Frees blinded message inside planchet detail @a pd. 2899 * 2900 * @param[in] pd planchet detail to free 2901 */ 2902 void 2903 TALER_planchet_detail_free (struct TALER_PlanchetDetail *pd); 2904 2905 2906 /** 2907 * Obtain a coin from the planchet's secrets and the blind signature 2908 * of the exchange. 2909 * 2910 * @param dk denomination key, must match what was given to #TALER_planchet_prepare() 2911 * @param blind_sig blind signature from the exchange 2912 * @param bks blinding key secret 2913 * @param coin_priv private key of the coin 2914 * @param ach hash of age commitment that is bound to this coin, maybe NULL 2915 * @param c_hash hash of the coin's public key for verification of the signature 2916 * @param alg_values values obtained from the exchange for the withdrawal 2917 * @param[out] coin set to the details of the fresh coin 2918 * @return #GNUNET_OK on success 2919 */ 2920 enum GNUNET_GenericReturnValue 2921 TALER_planchet_to_coin ( 2922 const struct TALER_DenominationPublicKey *dk, 2923 const struct TALER_BlindedDenominationSignature *blind_sig, 2924 const union GNUNET_CRYPTO_BlindingSecretP *bks, 2925 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 2926 const struct TALER_AgeCommitmentHashP *ach, 2927 const struct TALER_CoinPubHashP *c_hash, 2928 const struct TALER_ExchangeBlindingValues *alg_values, 2929 struct TALER_FreshCoin *coin); 2930 2931 2932 /** 2933 * Add the hash of the @a bp (in some canonicalized form) 2934 * to the @a hash_context. 2935 * 2936 * @param bp blinded planchet to hash 2937 * @param[in,out] hash_context hash context to use 2938 */ 2939 void 2940 TALER_blinded_planchet_hash_ (const struct TALER_BlindedPlanchet *bp, 2941 struct GNUNET_HashContext *hash_context); 2942 2943 2944 /** 2945 * Given the coin and the transfer private keys, compute the 2946 * transfer secret. (Technically, we only need one of the two 2947 * private keys, but the caller currently trivially only has 2948 * the two private keys, so we derive one of the public keys 2949 * internally to this function.) 2950 * 2951 * @param coin_priv coin key 2952 * @param trans_priv transfer private key 2953 * @param[out] ts computed transfer secret 2954 */ 2955 void 2956 TALER_link_derive_transfer_secret ( 2957 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 2958 const struct TALER_TransferPrivateKeyP *trans_priv, 2959 struct TALER_TransferSecretP *ts); 2960 2961 2962 /** 2963 * Decrypt the shared @a secret from the information in the 2964 * @a trans_priv and @a coin_pub. 2965 * 2966 * @param trans_priv transfer private key 2967 * @param coin_pub coin public key 2968 * @param[out] transfer_secret set to the shared secret 2969 */ 2970 void 2971 TALER_link_reveal_transfer_secret ( 2972 const struct TALER_TransferPrivateKeyP *trans_priv, 2973 const struct TALER_CoinSpendPublicKeyP *coin_pub, 2974 struct TALER_TransferSecretP *transfer_secret); 2975 2976 2977 /** 2978 * Decrypt the shared @a secret from the information in the 2979 * @a trans_priv and @a coin_pub. 2980 * 2981 * @param trans_pub transfer private key 2982 * @param coin_priv coin public key 2983 * @param[out] transfer_secret set to the shared secret 2984 */ 2985 void 2986 TALER_link_recover_transfer_secret ( 2987 const struct TALER_TransferPublicKeyP *trans_pub, 2988 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 2989 struct TALER_TransferSecretP *transfer_secret); 2990 2991 2992 /** 2993 * Information about a coin to be created during a refresh operation. 2994 */ 2995 struct TALER_RefreshCoinData 2996 { 2997 2998 /** 2999 * The denomination's public key. 3000 */ 3001 const struct TALER_DenominationPublicKey *dk; 3002 3003 /** 3004 * The blinded planchet (details depend on cipher). 3005 */ 3006 struct TALER_BlindedPlanchet blinded_planchet; 3007 3008 }; 3009 3010 3011 /** 3012 * One of the #TALER_CNC_KAPPA commitments. 3013 */ 3014 struct TALER_RefreshCommitmentEntry 3015 { 3016 /** 3017 * Transfer public key of this commitment. 3018 */ 3019 struct TALER_TransferPublicKeyP transfer_pub; 3020 3021 /** 3022 * Array of @e num_new_coins new coins to be created. 3023 */ 3024 struct TALER_RefreshCoinData *new_coins; 3025 }; 3026 3027 3028 /** 3029 * Helper struct to carry kappa many `TALER_HashBlindedPlanchetP`. 3030 */ 3031 struct TALER_KappaHashBlindedPlanchetsP 3032 { 3033 struct TALER_HashBlindedPlanchetsP tuple[TALER_CNC_KAPPA]; 3034 }; 3035 3036 /** 3037 * Helper struct to carry information about TALER_CNC_KAPPA 3038 * many batches of transfer public keys 3039 */ 3040 struct TALER_KappaTransferPublicKeys 3041 { 3042 /** 3043 * Number of elements in each @e batch 3044 */ 3045 size_t num_transfer_pubs; 3046 3047 /** 3048 * Pointers to the individual batches of @e num_transfer_pubs 3049 */ 3050 const struct TALER_TransferPublicKeyP *batch[TALER_CNC_KAPPA]; 3051 }; 3052 3053 3054 /** 3055 * @since vDOLDPLUS 3056 * 3057 * Compute the commitment for a /melt operation from 3058 * the respective public inputs. 3059 * 3060 * @param[out] rc set to the value the wallet must commit to 3061 * @param refresh_seed refresh master seed to include 3062 * @param blinding_seed blinding master seed for CS denominations, might be NULL 3063 * @param k_transfer_pubs TALER_CNC_KAPPA many batches of n transfer public keys, 3064 * @param k_bps_h TALER_CNC_KAPPA many hashes of blinded coin envelopes, 3065 * one for each batch of n coin candidates. 3066 * Note that these were over planchets and denominations. 3067 * @param coin_pub public key of the coin to be melted 3068 * @param amount_with_fee amount to be melted, including fee 3069 */ 3070 void 3071 TALER_refresh_get_commitment ( 3072 struct TALER_RefreshCommitmentP *rc, 3073 const struct TALER_PublicRefreshMasterSeedP *refresh_seed, 3074 const struct TALER_BlindingMasterSeedP *blinding_seed, 3075 const struct TALER_KappaTransferPublicKeys *k_transfer_pubs, 3076 const struct TALER_KappaHashBlindedPlanchetsP *k_bps_h, 3077 const struct TALER_CoinSpendPublicKeyP *coin_pub, 3078 const struct TALER_Amount *amount_with_fee); 3079 3080 /** 3081 * @since v27 3082 * @deprecated vDOLDPLUS 3083 * 3084 * Note: this function is only relevant for the exchange as it has to 3085 * support clients that still use v27 of the refresh protocol. 3086 * 3087 * Compute the commitment for a /melt operation from 3088 * the respective public inputs, for refreshes of v27. 3089 * 3090 * @param[out] rc set to the value the wallet must commit to 3091 * @param refresh_seed refresh master seed to include 3092 * @param blinding_seed blinding master seed for CS denominations, might be NULL 3093 * @param k_bps_h TALER_CNC_KAPPA many hashes of blinded coin envelopes, 3094 * one for each batch of n coin candidates. 3095 * Note that these were over planchets and denominations. 3096 * @param coin_pub public key of the coin to be melted 3097 * @param amount_with_fee amount to be melted, including fee 3098 */ 3099 #define TALER_refresh_get_commitment_v27(rc, \ 3100 refresh_seed, \ 3101 blinding_seed, \ 3102 k_bps_h, \ 3103 coin_pub, \ 3104 amount_with_fee) \ 3105 TALER_refresh_get_commitment ((rc), \ 3106 (refresh_seed), \ 3107 (blinding_seed), \ 3108 NULL, \ 3109 (k_bps_h), \ 3110 (coin_pub), \ 3111 (amount_with_fee)) 3112 3113 3114 /** 3115 * Encrypt contract for transmission to a party that will 3116 * merge it into a reserve. 3117 * 3118 * @param purse_pub public key of the purse 3119 * @param contract_priv private key of the contract 3120 * @param merge_priv merge capability to include 3121 * @param contract_terms contract terms to encrypt 3122 * @param[out] econtract set to encrypted contract 3123 * @param[out] econtract_size set to number of bytes in @a econtract 3124 */ 3125 void 3126 TALER_CRYPTO_contract_encrypt_for_merge ( 3127 const struct TALER_PurseContractPublicKeyP *purse_pub, 3128 const struct TALER_ContractDiffiePrivateP *contract_priv, 3129 const struct TALER_PurseMergePrivateKeyP *merge_priv, 3130 const json_t *contract_terms, 3131 void **econtract, 3132 size_t *econtract_size); 3133 3134 3135 /** 3136 * Decrypt contract for the party that will 3137 * merge it into a reserve. 3138 * 3139 * @param purse_pub public key of the purse 3140 * @param contract_priv private key of the contract 3141 * @param econtract encrypted contract 3142 * @param econtract_size number of bytes in @a econtract 3143 * @param[out] merge_priv set to merge capability 3144 * @return decrypted contract terms, or NULL on failure 3145 */ 3146 json_t * 3147 TALER_CRYPTO_contract_decrypt_for_merge ( 3148 const struct TALER_ContractDiffiePrivateP *contract_priv, 3149 const struct TALER_PurseContractPublicKeyP *purse_pub, 3150 const void *econtract, 3151 size_t econtract_size, 3152 struct TALER_PurseMergePrivateKeyP *merge_priv); 3153 3154 3155 /** 3156 * Encrypt contract for transmission to a party that will 3157 * pay for it. 3158 * 3159 * @param purse_pub public key of the purse 3160 * @param contract_priv private key of the contract 3161 * @param contract_terms contract terms to encrypt 3162 * @param[out] econtract set to encrypted contract 3163 * @param[out] econtract_size set to number of bytes in @a econtract 3164 */ 3165 void 3166 TALER_CRYPTO_contract_encrypt_for_deposit ( 3167 const struct TALER_PurseContractPublicKeyP *purse_pub, 3168 const struct TALER_ContractDiffiePrivateP *contract_priv, 3169 const json_t *contract_terms, 3170 void **econtract, 3171 size_t *econtract_size); 3172 3173 3174 /** 3175 * Decrypt contract for the party that will pay for it. 3176 * 3177 * @param contract_priv private key of the contract 3178 * @param econtract encrypted contract 3179 * @param econtract_size number of bytes in @a econtract 3180 * @return decrypted contract terms, or NULL on failure 3181 */ 3182 json_t * 3183 TALER_CRYPTO_contract_decrypt_for_deposit ( 3184 const struct TALER_ContractDiffiePrivateP *contract_priv, 3185 const void *econtract, 3186 size_t econtract_size); 3187 3188 3189 /* ***************** Token crypto primitives ************* */ 3190 3191 3192 /** 3193 * Public key used to verify (blind) signature of issued coins. 3194 */ 3195 struct TALER_TokenIssuePublicKey 3196 { 3197 /** 3198 * RSA or CS blind sign public key. 3199 */ 3200 struct GNUNET_CRYPTO_BlindSignPublicKey *public_key; 3201 }; 3202 3203 3204 /** 3205 * Free internals of @a token_pub, but not @a token_pub itself. 3206 * 3207 * @param[in] token_pub key to free 3208 */ 3209 void 3210 TALER_token_issue_pub_free (struct TALER_TokenIssuePublicKey *token_pub); 3211 3212 3213 /** 3214 * Make a copy of the given @a tip_src to @a tip_dst. 3215 * 3216 * @param[out] tip_dst target to copy to 3217 * @param tip_src public key to copy 3218 */ 3219 void 3220 TALER_token_issue_pub_copy ( 3221 struct TALER_TokenIssuePublicKey *tip_dst, 3222 const struct TALER_TokenIssuePublicKey *tip_src); 3223 3224 3225 /** 3226 * Compare two token issue public keys. 3227 * 3228 * @param tip1 first key to compare 3229 * @param tip2 second key to compare 3230 * @return 0 if the keys are equal, otherwise -1 or 1 3231 */ 3232 int 3233 TALER_token_issue_pub_cmp ( 3234 struct TALER_TokenIssuePublicKey *tip1, 3235 const struct TALER_TokenIssuePublicKey *tip2); 3236 3237 3238 /** 3239 * Hash of a public key used to issue tokens for a token family. 3240 */ 3241 struct TALER_TokenIssuePublicKeyHashP 3242 { 3243 /** 3244 * Public key hash. 3245 */ 3246 struct GNUNET_HashCode hash; 3247 }; 3248 3249 3250 /** 3251 * Private key used to issue tokens by sign blinded 3252 * token public keys (provided by wallet). 3253 */ 3254 struct TALER_TokenIssuePrivateKey 3255 { 3256 /** 3257 * RSA or CS blind sign private key. 3258 */ 3259 struct GNUNET_CRYPTO_BlindSignPrivateKey *private_key; 3260 }; 3261 3262 3263 /** 3264 * Unblinded signature created using merchants token issue private key. 3265 */ 3266 struct TALER_TokenIssueSignature 3267 { 3268 struct GNUNET_CRYPTO_UnblindedSignature *signature; 3269 }; 3270 3271 3272 /** 3273 * Blinded signature created using merchants token issue private key. 3274 */ 3275 struct TALER_BlindedTokenIssueSignature 3276 { 3277 struct GNUNET_CRYPTO_BlindedSignature *signature; 3278 }; 3279 3280 3281 /** 3282 * The public key of a token. An EdDSA public key generated by the wallet 3283 * and blindly signed by the merchant using the @struct TALER_TokenIssuePrivateKey. 3284 */ 3285 struct TALER_TokenUsePublicKeyP 3286 { 3287 struct GNUNET_CRYPTO_EddsaPublicKey public_key; 3288 }; 3289 3290 3291 /** 3292 * Has of the public key of a token. 3293 */ 3294 struct TALER_TokenUsePublicKeyHashP 3295 { 3296 struct GNUNET_HashCode hash; 3297 }; 3298 3299 3300 /** 3301 * The private key of a token. An EdDSA private key generated by the wallet. 3302 * Used to create a struct TALER_TokenUseSignatureP to confirm the usage of a token. 3303 */ 3304 struct TALER_TokenUsePrivateKeyP 3305 { 3306 struct GNUNET_CRYPTO_EddsaPrivateKey private_key; 3307 }; 3308 3309 3310 /** 3311 * Signature made by the wallet using the token private key (EdDSA). 3312 */ 3313 struct TALER_TokenUseSignatureP 3314 { 3315 struct GNUNET_CRYPTO_EddsaSignature signature; 3316 }; 3317 3318 3319 /** 3320 * Master key material for the deriviation of tokens and 3321 * blinding factors during token envelope creation. 3322 */ 3323 struct TALER_TokenUseMasterSecretP 3324 { 3325 3326 /** 3327 * Key material. 3328 */ 3329 uint32_t key_data[8]; 3330 3331 }; 3332 3333 3334 /** 3335 * Inputs needed from the merchant for blind signing tokens. 3336 */ 3337 struct TALER_TokenUseMerchantValues 3338 { 3339 3340 /** 3341 * Input values. 3342 */ 3343 struct GNUNET_CRYPTO_BlindingInputValues *blinding_inputs; 3344 }; 3345 3346 3347 /** 3348 * The blinded token use public key of a token. Ready to be signed by the merchant. 3349 */ 3350 struct TALER_TokenEnvelope 3351 { 3352 /** 3353 * Blinded public key of the token. 3354 */ 3355 struct GNUNET_CRYPTO_BlindedMessage *blinded_pub; 3356 }; 3357 3358 3359 /** 3360 * Free internals of @a issue_sig, but not @a issue_sig itself. 3361 * 3362 * @param[in] issue_sig signature to free 3363 */ 3364 void 3365 TALER_token_issue_sig_free (struct TALER_TokenIssueSignature *issue_sig); 3366 3367 3368 /** 3369 * Free internals of @a issue_sig, but not @a issue_sig itself. 3370 * 3371 * @param[in] issue_sig signature to free 3372 */ 3373 void 3374 TALER_blinded_issue_sig_free ( 3375 struct TALER_BlindedTokenIssueSignature *issue_sig); 3376 3377 3378 /** 3379 * Setup secret seed information for fresh tokens to be 3380 * issued. 3381 * 3382 * @param[out] master value to initialize 3383 */ 3384 void 3385 TALER_token_use_setup_random (struct TALER_TokenUseMasterSecretP *master); 3386 3387 3388 /** 3389 * Create private key for a token. 3390 * 3391 * @param master secret to derive token use private key from 3392 * @param alg_values includes algorithm specific values 3393 * @param[out] token_priv private key to initialize 3394 */ 3395 void 3396 TALER_token_use_setup_priv ( 3397 const struct TALER_TokenUseMasterSecretP *master, 3398 const struct TALER_TokenUseMerchantValues *alg_values, 3399 struct TALER_TokenUsePrivateKeyP *token_priv); 3400 3401 3402 /** 3403 * Create a token use blinding secret @a bks given the wallets 3404 * @a master secret and the alg_values from the merchant. 3405 * 3406 * @param master secret to derive blindings from 3407 * @param alg_values withdraw values containing cipher and additional CS values 3408 * @param[out] bks blinding secrets 3409 */ 3410 void 3411 TALER_token_use_blinding_secret_create ( 3412 const struct TALER_TokenUseMasterSecretP *master, 3413 const struct TALER_TokenUseMerchantValues *alg_values, 3414 union GNUNET_CRYPTO_BlindingSecretP *bks); 3415 3416 3417 /** 3418 * Return the alg value singleton for creation of 3419 * blinding secrets for RSA. 3420 * 3421 * @return singleton to use for RSA blinding 3422 */ 3423 const struct TALER_TokenUseMerchantValues * 3424 TALER_token_blind_input_rsa_singleton (void); 3425 3426 3427 /** 3428 * Make a (deep) copy of the given @a bi_src to 3429 * @a bi_dst. 3430 * 3431 * @param[out] bi_dst target to copy to 3432 * @param bi_src blinding input values to copy 3433 */ 3434 void 3435 TALER_token_blind_input_copy (struct TALER_TokenUseMerchantValues *bi_dst, 3436 const struct TALER_TokenUseMerchantValues *bi_src) 3437 ; 3438 3439 3440 /** 3441 * Issue a new token by blindly signing a token envelope with 3442 * the token issue private key. 3443 * 3444 * @param issue_priv private key to use for signing 3445 * @param envelope token envelope to sign over 3446 * @param[out] issue_sig where to write the signature 3447 * @return #GNUNET_OK on success 3448 */ 3449 enum GNUNET_GenericReturnValue 3450 TALER_token_issue_sign (const struct TALER_TokenIssuePrivateKey *issue_priv, 3451 const struct TALER_TokenEnvelope *envelope, 3452 struct TALER_BlindedTokenIssueSignature *issue_sig); 3453 3454 3455 /** 3456 * Verify a token issue signature made by the merchant. 3457 * 3458 * @param use_pub token use public key 3459 * @param issue_pub public key of the token issue 3460 * @param ub_sig signature to verify 3461 * @return #GNUNET_OK if the signature is valid 3462 */ 3463 enum GNUNET_GenericReturnValue 3464 TALER_token_issue_verify (const struct TALER_TokenUsePublicKeyP *use_pub, 3465 const struct TALER_TokenIssuePublicKey *issue_pub, 3466 const struct TALER_TokenIssueSignature *ub_sig); 3467 3468 /** 3469 * Unblind blinded signature. 3470 * 3471 * @param[out] issue_sig where to write the unblinded signature 3472 * @param blinded_sig the blinded signature 3473 * @param secret blinding secret to use 3474 * @param use_pub_hash token use public key hash for verification of the signature 3475 * @param alg_values algorithm specific values 3476 * @param issue_pub public key used for signing 3477 * @return #GNUNET_OK on success or #GNUNET_SYSERR on failure 3478 */ 3479 enum GNUNET_GenericReturnValue 3480 TALER_token_issue_sig_unblind ( 3481 struct TALER_TokenIssueSignature *issue_sig, 3482 const struct TALER_BlindedTokenIssueSignature *blinded_sig, 3483 const union GNUNET_CRYPTO_BlindingSecretP *secret, 3484 const struct TALER_TokenUsePublicKeyHashP *use_pub_hash, 3485 const struct TALER_TokenUseMerchantValues *alg_values, 3486 const struct TALER_TokenIssuePublicKey *issue_pub); 3487 3488 3489 /* **************** AML officer signatures **************** */ 3490 3491 /** 3492 * Sign KYC authorization. Simple authentication, doesn't actually sign 3493 * anything. 3494 * 3495 * @param account_priv private key of account owner 3496 * @param[out] account_sig where to write the signature 3497 */ 3498 void 3499 TALER_account_kyc_auth_sign ( 3500 const union TALER_AccountPrivateKeyP *account_priv, 3501 union TALER_AccountSignatureP *account_sig); 3502 3503 3504 /** 3505 * Verify KYC authorization authorization. 3506 * 3507 * @param account_pub public key of account owner 3508 * @param account_sig signature to verify 3509 * @return #GNUNET_OK if the signature is valid 3510 */ 3511 enum GNUNET_GenericReturnValue 3512 TALER_account_kyc_auth_verify ( 3513 const union TALER_AccountPublicKeyP *account_pub, 3514 const union TALER_AccountSignatureP *account_sig); 3515 3516 3517 /** 3518 * Sign AML query. Simple authentication, doesn't actually 3519 * sign anything. 3520 * 3521 * @param officer_priv private key of AML officer 3522 * @param[out] officer_sig where to write the signature 3523 */ 3524 void 3525 TALER_officer_aml_query_sign ( 3526 const struct TALER_AmlOfficerPrivateKeyP *officer_priv, 3527 struct TALER_AmlOfficerSignatureP *officer_sig); 3528 3529 3530 /** 3531 * Verify AML query authorization. 3532 * 3533 * @param officer_pub public key of AML officer 3534 * @param officer_sig signature to verify 3535 * @return #GNUNET_OK if the signature is valid 3536 */ 3537 enum GNUNET_GenericReturnValue 3538 TALER_officer_aml_query_verify ( 3539 const struct TALER_AmlOfficerPublicKeyP *officer_pub, 3540 const struct TALER_AmlOfficerSignatureP *officer_sig); 3541 3542 3543 /** 3544 * Sign AML decision. 3545 * 3546 * @param justification human-readable justification 3547 * @param decision_time when was the decision made 3548 * @param h_payto payto URI hash of the account the 3549 * decision is about 3550 * @param new_rules new KYC rules to apply to the account 3551 * Must be a "LegitimizationRuleSet". 3552 * @param properties properties of the account, can be NULL 3553 * @param new_measures new measures to apply immediately, NULL for none 3554 * @param to_investigate true if the account should be investigated by AML staff 3555 * @param officer_priv private key of AML officer 3556 * @param[out] officer_sig where to write the signature 3557 */ 3558 void 3559 TALER_officer_aml_decision_sign ( 3560 const char *justification, 3561 struct GNUNET_TIME_Timestamp decision_time, 3562 const struct TALER_NormalizedPaytoHashP *h_payto, 3563 const json_t *new_rules, 3564 const json_t *properties, 3565 const char *new_measures, 3566 bool to_investigate, 3567 const struct TALER_AmlOfficerPrivateKeyP *officer_priv, 3568 struct TALER_AmlOfficerSignatureP *officer_sig); 3569 3570 3571 /** 3572 * Verify AML decision. 3573 * 3574 * @param justification human-readable justification 3575 * @param decision_time when was the decision made 3576 * @param h_payto payto URI hash of the account the 3577 * decision is about 3578 * @param new_rules new KYC rules to apply to the account 3579 * @param properties properties of the account, can be NULL 3580 * @param new_measures new measures to apply immediately, NULL for none 3581 * @param to_investigate true if the account should be investigated by AML staff 3582 * @param officer_pub public key of AML officer 3583 * @param officer_sig signature to verify 3584 * @param attributes_expiration expiration time of attributes, 3585 * #GNUNET_TIME_UNIT_ZERO_ABS if no attributes given 3586 * @param attributes attributes set by the AMLO, may be NULL 3587 * @return #GNUNET_OK if the signature is valid 3588 */ 3589 enum GNUNET_GenericReturnValue 3590 TALER_officer_aml_decision_verify ( 3591 const char *justification, 3592 struct GNUNET_TIME_Timestamp decision_time, 3593 const struct TALER_NormalizedPaytoHashP *h_payto, 3594 const json_t *new_rules, 3595 const json_t *properties, 3596 const char *new_measures, 3597 bool to_investigate, 3598 const struct TALER_AmlOfficerPublicKeyP *officer_pub, 3599 const struct TALER_AmlOfficerSignatureP *officer_sig, 3600 struct GNUNET_TIME_Timestamp attributes_expiration, 3601 const json_t *attributes); 3602 3603 3604 /** 3605 * Verify AML decision, given only the hash of the attributes. 3606 * 3607 * Same as #TALER_officer_aml_decision_verify(), except that the attributes 3608 * are passed pre-hashed. The auditor needs this: the exchange stores the 3609 * attributes of an AML decision only in encrypted form, but records their 3610 * hash in `aml_history.kyc_attributes_hash`, so the auditor can re-check the 3611 * signature without ever seeing the personal data. 3612 * 3613 * @param justification human-readable justification 3614 * @param decision_time when was the decision made 3615 * @param h_payto payto URI hash of the account the 3616 * decision is about 3617 * @param new_rules new KYC rules to apply to the account 3618 * @param properties properties of the account, can be NULL 3619 * @param new_measures new measures to apply immediately, NULL for none 3620 * @param to_investigate true if the account should be investigated by AML staff 3621 * @param officer_pub public key of AML officer 3622 * @param officer_sig signature to verify 3623 * @param attributes_expiration expiration time of attributes, 3624 * #GNUNET_TIME_UNIT_ZERO_ABS if no attributes given 3625 * @param h_attributes hash over the attributes set by the AMLO, 3626 * NULL if no attributes were set 3627 * @return #GNUNET_OK if the signature is valid 3628 */ 3629 enum GNUNET_GenericReturnValue 3630 TALER_officer_aml_decision_verify_hashed ( 3631 const char *justification, 3632 struct GNUNET_TIME_Timestamp decision_time, 3633 const struct TALER_NormalizedPaytoHashP *h_payto, 3634 const json_t *new_rules, 3635 const json_t *properties, 3636 const char *new_measures, 3637 bool to_investigate, 3638 const struct TALER_AmlOfficerPublicKeyP *officer_pub, 3639 const struct TALER_AmlOfficerSignatureP *officer_sig, 3640 struct GNUNET_TIME_Timestamp attributes_expiration, 3641 const struct GNUNET_HashCode *h_attributes); 3642 3643 3644 /* **************** Helper-based RSA operations **************** */ 3645 3646 /** 3647 * Handle for talking to an Denomination key signing helper. 3648 */ 3649 struct TALER_CRYPTO_RsaDenominationHelper; 3650 3651 /** 3652 * Function called with information about available keys for signing. Usually 3653 * only called once per key upon connect. Also called again in case a key is 3654 * being revoked, in that case with an @a end_time of zero. 3655 * 3656 * @param cls closure 3657 * @param section_name name of the denomination type in the configuration; 3658 * NULL if the key has been revoked or purged 3659 * @param start_time when does the key become available for signing; 3660 * zero if the key has been revoked or purged 3661 * @param validity_duration how long does the key remain available for signing; 3662 * zero if the key has been revoked or purged 3663 * @param h_rsa hash of the RSA @a denom_pub that is available (or was purged) 3664 * @param bs_pub the public key itself, NULL if the key was revoked or purged 3665 * @param sm_pub public key of the security module, NULL if the key was revoked or purged 3666 * @param sm_sig signature from the security module, NULL if the key was revoked or purged 3667 * The signature was already verified against @a sm_pub. 3668 */ 3669 typedef void 3670 (*TALER_CRYPTO_RsaDenominationKeyStatusCallback)( 3671 void *cls, 3672 const char *section_name, 3673 struct GNUNET_TIME_Timestamp start_time, 3674 struct GNUNET_TIME_Relative validity_duration, 3675 const struct TALER_RsaPubHashP *h_rsa, 3676 struct GNUNET_CRYPTO_BlindSignPublicKey *bs_pub, 3677 const struct TALER_SecurityModulePublicKeyP *sm_pub, 3678 const struct TALER_SecurityModuleSignatureP *sm_sig); 3679 3680 3681 /** 3682 * Initiate connection to an denomination key helper. 3683 * 3684 * @param cfg configuration to use 3685 * @param section configuration section prefix to use, usually 'taler' or 'donau' 3686 * @param dkc function to call with key information 3687 * @param dkc_cls closure for @a dkc 3688 * @return NULL on error (such as bad @a cfg). 3689 */ 3690 struct TALER_CRYPTO_RsaDenominationHelper * 3691 TALER_CRYPTO_helper_rsa_connect ( 3692 const struct GNUNET_CONFIGURATION_Handle *cfg, 3693 const char *section, 3694 TALER_CRYPTO_RsaDenominationKeyStatusCallback dkc, 3695 void *dkc_cls); 3696 3697 3698 /** 3699 * Function to call to 'poll' for updates to the available key material. 3700 * Should be called whenever it is important that the key material status is 3701 * current, like when handling a "/keys" request. This function basically 3702 * briefly checks if there are messages from the helper announcing changes to 3703 * denomination keys. 3704 * 3705 * @param dh helper process connection 3706 */ 3707 void 3708 TALER_CRYPTO_helper_rsa_poll (struct TALER_CRYPTO_RsaDenominationHelper *dh); 3709 3710 3711 /** 3712 * Information needed for an RSA signature request. 3713 */ 3714 struct TALER_CRYPTO_RsaSignRequest 3715 { 3716 /** 3717 * Hash of the RSA public key. 3718 */ 3719 const struct TALER_RsaPubHashP *h_rsa; 3720 3721 /** 3722 * Message to be (blindly) signed. 3723 */ 3724 const void *msg; 3725 3726 /** 3727 * Number of bytes in @e msg. 3728 */ 3729 size_t msg_size; 3730 }; 3731 3732 3733 /** 3734 * Request helper @a dh to batch sign messages in @a rsrs using the public key 3735 * corresponding to the keys in @a rsrs. 3736 * 3737 * This operation will block until all the signatures have been obtained. Should 3738 * this process receive a signal (that is not ignored) while the operation is 3739 * pending, the operation will fail. Note that the helper may still believe 3740 * that it created the signature. Thus, signals may result in a small 3741 * differences in the signature counters. Retrying in this case may work. 3742 * 3743 * Note that in case of errors, the @a bss array may still have been partially 3744 * filled with signatures, which in this case must be freed by the caller. 3745 * 3746 * @param dh helper process connection 3747 * @param rsrs array with details about the requested signatures 3748 * @param rsrs_length length of the @a rsrs array 3749 * @param[out] bss array set to the blind signatures, must be of length @a rsrs_length! 3750 * @return #TALER_EC_NONE on success 3751 */ 3752 enum TALER_ErrorCode 3753 TALER_CRYPTO_helper_rsa_batch_sign ( 3754 struct TALER_CRYPTO_RsaDenominationHelper *dh, 3755 unsigned int rsrs_length, 3756 const struct TALER_CRYPTO_RsaSignRequest rsrs[static rsrs_length], 3757 struct TALER_BlindedDenominationSignature bss[static rsrs_length]); 3758 3759 3760 /** 3761 * Ask the helper to revoke the public key associated with @a h_denom_pub. 3762 * Will cause the helper to tell all clients that the key is now unavailable, 3763 * and to create a replacement key. 3764 * 3765 * This operation will block until the revocation request has been 3766 * transmitted. Should this process receive a signal (that is not ignored) 3767 * while the operation is pending, the operation may fail. If the key is 3768 * unknown, this function will also appear to have succeeded. To be sure that 3769 * the revocation worked, clients must watch the denomination key status 3770 * callback. 3771 * 3772 * @param dh helper to process connection 3773 * @param h_rsa hash of the RSA public key to revoke 3774 */ 3775 void 3776 TALER_CRYPTO_helper_rsa_revoke ( 3777 struct TALER_CRYPTO_RsaDenominationHelper *dh, 3778 const struct TALER_RsaPubHashP *h_rsa); 3779 3780 3781 /** 3782 * Close connection to @a dh. 3783 * 3784 * @param[in] dh connection to close 3785 */ 3786 void 3787 TALER_CRYPTO_helper_rsa_disconnect ( 3788 struct TALER_CRYPTO_RsaDenominationHelper *dh); 3789 3790 3791 /* **************** Helper-based CS operations **************** */ 3792 3793 /** 3794 * Handle for talking to an Denomination key signing helper. 3795 */ 3796 struct TALER_CRYPTO_CsDenominationHelper; 3797 3798 /** 3799 * Function called with information about available keys for signing. Usually 3800 * only called once per key upon connect. Also called again in case a key is 3801 * being revoked, in that case with an @a end_time of zero. 3802 * 3803 * @param cls closure 3804 * @param section_name name of the denomination type in the configuration; 3805 * NULL if the key has been revoked or purged 3806 * @param start_time when does the key become available for signing; 3807 * zero if the key has been revoked or purged 3808 * @param validity_duration how long does the key remain available for signing; 3809 * zero if the key has been revoked or purged 3810 * @param h_cs hash of the CS @a denom_pub that is available (or was purged) 3811 * @param bsign_pub the public key itself, NULL if the key was revoked or purged 3812 * @param sm_pub public key of the security module, NULL if the key was revoked or purged 3813 * @param sm_sig signature from the security module, NULL if the key was revoked or purged 3814 * The signature was already verified against @a sm_pub. 3815 */ 3816 typedef void 3817 (*TALER_CRYPTO_CsDenominationKeyStatusCallback)( 3818 void *cls, 3819 const char *section_name, 3820 struct GNUNET_TIME_Timestamp start_time, 3821 struct GNUNET_TIME_Relative validity_duration, 3822 const struct TALER_CsPubHashP *h_cs, 3823 struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub, 3824 const struct TALER_SecurityModulePublicKeyP *sm_pub, 3825 const struct TALER_SecurityModuleSignatureP *sm_sig); 3826 3827 3828 /** 3829 * Initiate connection to an denomination key helper. 3830 * 3831 * @param cfg configuration to use 3832 * @param section configuration section prefix to use, usually 'taler' or 'donau' 3833 * @param dkc function to call with key information 3834 * @param dkc_cls closure for @a dkc 3835 * @return NULL on error (such as bad @a cfg). 3836 */ 3837 struct TALER_CRYPTO_CsDenominationHelper * 3838 TALER_CRYPTO_helper_cs_connect ( 3839 const struct GNUNET_CONFIGURATION_Handle *cfg, 3840 const char *section, 3841 TALER_CRYPTO_CsDenominationKeyStatusCallback dkc, 3842 void *dkc_cls); 3843 3844 3845 /** 3846 * Function to call to 'poll' for updates to the available key material. 3847 * Should be called whenever it is important that the key material status is 3848 * current, like when handling a "/keys" request. This function basically 3849 * briefly checks if there are messages from the helper announcing changes to 3850 * denomination keys. 3851 * 3852 * @param dh helper process connection 3853 */ 3854 void 3855 TALER_CRYPTO_helper_cs_poll (struct TALER_CRYPTO_CsDenominationHelper *dh); 3856 3857 3858 /** 3859 * Information about what we should sign over. 3860 */ 3861 struct TALER_CRYPTO_CsSignRequest 3862 { 3863 /** 3864 * Hash of the CS public key to use to sign. 3865 */ 3866 const struct TALER_CsPubHashP *h_cs; 3867 3868 /** 3869 * Blinded planchet containing c and the nonce. 3870 */ 3871 const struct GNUNET_CRYPTO_CsBlindedMessage *blinded_planchet; 3872 3873 }; 3874 3875 3876 /** 3877 * Request helper @a dh to sign batch of @a reqs requests. 3878 * 3879 * This operation will block until the signature has been obtained. Should 3880 * this process receive a signal (that is not ignored) while the operation is 3881 * pending, the operation will fail. Note that the helper may still believe 3882 * that it created the signature. Thus, signals may result in a small 3883 * differences in the signature counters. Retrying in this case may work. 3884 * 3885 * @param dh helper process connection 3886 * @param reqs information about the keys to sign with and the values to sign 3887 * @param reqs_length length of the @a reqs array 3888 * @param for_melt true if this is for a melt operation 3889 * @param[out] bss array set to the blind signatures, must be of length @a reqs_length! 3890 * @return #TALER_EC_NONE on success 3891 */ 3892 enum TALER_ErrorCode 3893 TALER_CRYPTO_helper_cs_batch_sign ( 3894 struct TALER_CRYPTO_CsDenominationHelper *dh, 3895 unsigned int reqs_length, 3896 const struct TALER_CRYPTO_CsSignRequest reqs[static reqs_length], 3897 bool for_melt, 3898 struct TALER_BlindedDenominationSignature bss[static reqs_length]); 3899 3900 3901 /** 3902 * Ask the helper to revoke the public key associated with @a h_cs. 3903 * Will cause the helper to tell all clients that the key is now unavailable, 3904 * and to create a replacement key. 3905 * 3906 * This operation will block until the revocation request has been 3907 * transmitted. Should this process receive a signal (that is not ignored) 3908 * while the operation is pending, the operation may fail. If the key is 3909 * unknown, this function will also appear to have succeeded. To be sure that 3910 * the revocation worked, clients must watch the denomination key status 3911 * callback. 3912 * 3913 * @param dh helper to process connection 3914 * @param h_cs hash of the CS public key to revoke 3915 */ 3916 void 3917 TALER_CRYPTO_helper_cs_revoke ( 3918 struct TALER_CRYPTO_CsDenominationHelper *dh, 3919 const struct TALER_CsPubHashP *h_cs); 3920 3921 3922 /** 3923 * Information about what we should derive for. 3924 */ 3925 struct TALER_CRYPTO_CsDeriveRequest 3926 { 3927 /** 3928 * Hash of the CS public key to use to sign. 3929 */ 3930 const struct TALER_CsPubHashP *h_cs; 3931 3932 /** 3933 * Nonce to use for the /csr request. 3934 */ 3935 const struct GNUNET_CRYPTO_CsSessionNonce *nonce; 3936 }; 3937 3938 3939 /** 3940 * Ask the helper to derive R using the information from @a cdrs. 3941 * 3942 * This operation will block until the R has been obtained. Should 3943 * this process receive a signal (that is not ignored) while the operation is 3944 * pending, the operation will fail. Note that the helper may still believe 3945 * that it created the signature. Thus, signals may result in a small 3946 * differences in the signature counters. Retrying in this case may work. 3947 * 3948 * @param dh helper to process connection 3949 * @param cdrs_length length of the @a cdrs array 3950 * @param cdrs array with derivation input data 3951 * @param for_melt true if this is for a melt operation 3952 * @param[out] crps array set to the pair of R values, must be of length @a cdrs_length 3953 * @return set to the error code (or #TALER_EC_NONE on success) 3954 */ 3955 enum TALER_ErrorCode 3956 TALER_CRYPTO_helper_cs_r_batch_derive ( 3957 struct TALER_CRYPTO_CsDenominationHelper *dh, 3958 unsigned int cdrs_length, 3959 const struct TALER_CRYPTO_CsDeriveRequest cdrs[static cdrs_length], 3960 bool for_melt, 3961 struct GNUNET_CRYPTO_CSPublicRPairP crps[static cdrs_length]); 3962 3963 3964 /** 3965 * Close connection to @a dh. 3966 * 3967 * @param[in] dh connection to close 3968 */ 3969 void 3970 TALER_CRYPTO_helper_cs_disconnect ( 3971 struct TALER_CRYPTO_CsDenominationHelper *dh); 3972 3973 /** 3974 * Handle for talking to an online key signing helper. 3975 */ 3976 struct TALER_CRYPTO_ExchangeSignHelper; 3977 3978 /** 3979 * Function called with information about available keys for signing. Usually 3980 * only called once per key upon connect. Also called again in case a key is 3981 * being revoked, in that case with an @a end_time of zero. 3982 * 3983 * @param cls closure 3984 * @param start_time when does the key become available for signing; 3985 * zero if the key has been revoked or purged 3986 * @param validity_duration how long does the key remain available for signing; 3987 * zero if the key has been revoked or purged 3988 * @param exchange_pub the public key itself, NULL if the key was revoked or purged 3989 * @param sm_pub public key of the security module, NULL if the key was revoked or purged 3990 * @param sm_sig signature from the security module, NULL if the key was revoked or purged 3991 * The signature was already verified against @a sm_pub. 3992 */ 3993 typedef void 3994 (*TALER_CRYPTO_ExchangeKeyStatusCallback)( 3995 void *cls, 3996 struct GNUNET_TIME_Timestamp start_time, 3997 struct GNUNET_TIME_Relative validity_duration, 3998 const struct TALER_ExchangePublicKeyP *exchange_pub, 3999 const struct TALER_SecurityModulePublicKeyP *sm_pub, 4000 const struct TALER_SecurityModuleSignatureP *sm_sig); 4001 4002 4003 /** 4004 * Initiate connection to an online signing key helper. 4005 * 4006 * @param cfg configuration to use 4007 * @param section configuration section prefix to use, usually 'taler' or 'donau' 4008 * @param ekc function to call with key information 4009 * @param ekc_cls closure for @a ekc 4010 * @return NULL on error (such as bad @a cfg). 4011 */ 4012 struct TALER_CRYPTO_ExchangeSignHelper * 4013 TALER_CRYPTO_helper_esign_connect ( 4014 const struct GNUNET_CONFIGURATION_Handle *cfg, 4015 const char *section, 4016 TALER_CRYPTO_ExchangeKeyStatusCallback ekc, 4017 void *ekc_cls); 4018 4019 4020 /** 4021 * Function to call to 'poll' for updates to the available key material. 4022 * Should be called whenever it is important that the key material status is 4023 * current, like when handling a "/keys" request. This function basically 4024 * briefly checks if there are messages from the helper announcing changes to 4025 * exchange online signing keys. 4026 * 4027 * @param esh helper process connection 4028 */ 4029 void 4030 TALER_CRYPTO_helper_esign_poll (struct TALER_CRYPTO_ExchangeSignHelper *esh); 4031 4032 4033 /** 4034 * Request helper @a esh to sign @a msg using the current online 4035 * signing key. 4036 * 4037 * This operation will block until the signature has been obtained. Should 4038 * this process receive a signal (that is not ignored) while the operation is 4039 * pending, the operation will fail. Note that the helper may still believe 4040 * that it created the signature. Thus, signals may result in a small 4041 * differences in the signature counters. Retrying in this case may work. 4042 * 4043 * @param esh helper process connection 4044 * @param purpose message to sign (must extend beyond the purpose) 4045 * @param[out] exchange_pub set to the public key used for the signature upon success 4046 * @param[out] exchange_sig set to the signature upon success 4047 * @return the error code (or #TALER_EC_NONE on success) 4048 */ 4049 enum TALER_ErrorCode 4050 TALER_CRYPTO_helper_esign_sign_ ( 4051 struct TALER_CRYPTO_ExchangeSignHelper *esh, 4052 const struct GNUNET_CRYPTO_SignaturePurpose *purpose, 4053 struct TALER_ExchangePublicKeyP *exchange_pub, 4054 struct TALER_ExchangeSignatureP *exchange_sig); 4055 4056 4057 /** 4058 * Request helper @a esh to sign @a msg using the current online 4059 * signing key. 4060 * 4061 * This operation will block until the signature has been obtained. Should 4062 * this process receive a signal (that is not ignored) while the operation is 4063 * pending, the operation will fail. Note that the helper may still believe 4064 * that it created the signature. Thus, signals may result in a small 4065 * differences in the signature counters. Retrying in this case may work. 4066 * 4067 * @param esh helper process connection 4068 * @param ps message to sign (MUST begin with a purpose) 4069 * @param[out] epub set to the public key used for the signature upon success 4070 * @param[out] esig set to the signature upon success 4071 * @return the error code (or #TALER_EC_NONE on success) 4072 */ 4073 #define TALER_CRYPTO_helper_esign_sign(esh,ps,epub,esig) ( \ 4074 /* check size is set correctly */ \ 4075 GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps)), \ 4076 /* check 'ps' begins with the purpose */ \ 4077 GNUNET_static_assert (((void*) (ps)) == \ 4078 ((void*) &(ps)->purpose)), \ 4079 TALER_CRYPTO_helper_esign_sign_ (esh, \ 4080 &(ps)->purpose, \ 4081 epub, \ 4082 esig) ) 4083 4084 4085 /** 4086 * Ask the helper to revoke the public key @a exchange_pub . 4087 * Will cause the helper to tell all clients that the key is now unavailable, 4088 * and to create a replacement key. 4089 * 4090 * This operation will block until the revocation request has been 4091 * transmitted. Should this process receive a signal (that is not ignored) 4092 * while the operation is pending, the operation may fail. If the key is 4093 * unknown, this function will also appear to have succeeded. To be sure that 4094 * the revocation worked, clients must watch the signing key status callback. 4095 * 4096 * @param esh helper to process connection 4097 * @param exchange_pub the public key to revoke 4098 */ 4099 void 4100 TALER_CRYPTO_helper_esign_revoke ( 4101 struct TALER_CRYPTO_ExchangeSignHelper *esh, 4102 const struct TALER_ExchangePublicKeyP *exchange_pub); 4103 4104 4105 /** 4106 * Close connection to @a esh. 4107 * 4108 * @param[in] esh connection to close 4109 */ 4110 void 4111 TALER_CRYPTO_helper_esign_disconnect ( 4112 struct TALER_CRYPTO_ExchangeSignHelper *esh); 4113 4114 4115 /* ********************* wallet signing ************************** */ 4116 4117 4118 /** 4119 * Sign a request to create a purse. 4120 * 4121 * @param purse_expiration when should the purse expire 4122 * @param h_contract_terms contract the two parties agree on 4123 * @param merge_pub public key defining the merge capability 4124 * @param min_age age restriction to apply for deposits into the purse 4125 * @param amount total amount in the purse (including fees) 4126 * @param purse_priv key identifying the purse 4127 * @param[out] purse_sig resulting signature 4128 */ 4129 void 4130 TALER_wallet_purse_create_sign ( 4131 struct GNUNET_TIME_Timestamp purse_expiration, 4132 const struct TALER_PrivateContractHashP *h_contract_terms, 4133 const struct TALER_PurseMergePublicKeyP *merge_pub, 4134 uint32_t min_age, 4135 const struct TALER_Amount *amount, 4136 const struct TALER_PurseContractPrivateKeyP *purse_priv, 4137 struct TALER_PurseContractSignatureP *purse_sig); 4138 4139 4140 /** 4141 * Verify a purse creation request. 4142 * 4143 * @param purse_expiration when should the purse expire 4144 * @param h_contract_terms contract the two parties agree on 4145 * @param merge_pub public key defining the merge capability 4146 * @param min_age age restriction to apply for deposits into the purse 4147 * @param amount total amount in the purse (including fees) 4148 * @param purse_pub purse’s public key 4149 * @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_CREATE 4150 * @return #GNUNET_OK if the signature is valid 4151 */ 4152 enum GNUNET_GenericReturnValue 4153 TALER_wallet_purse_create_verify ( 4154 struct GNUNET_TIME_Timestamp purse_expiration, 4155 const struct TALER_PrivateContractHashP *h_contract_terms, 4156 const struct TALER_PurseMergePublicKeyP *merge_pub, 4157 uint32_t min_age, 4158 const struct TALER_Amount *amount, 4159 const struct TALER_PurseContractPublicKeyP *purse_pub, 4160 const struct TALER_PurseContractSignatureP *purse_sig); 4161 4162 4163 /** 4164 * Sign a request to delete a purse. 4165 * 4166 * @param purse_priv key identifying the purse 4167 * @param[out] purse_sig resulting signature 4168 */ 4169 void 4170 TALER_wallet_purse_delete_sign ( 4171 const struct TALER_PurseContractPrivateKeyP *purse_priv, 4172 struct TALER_PurseContractSignatureP *purse_sig); 4173 4174 4175 /** 4176 * Verify a purse deletion request. 4177 * 4178 * @param purse_pub purse’s public key 4179 * @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_DELETE 4180 * @return #GNUNET_OK if the signature is valid 4181 */ 4182 enum GNUNET_GenericReturnValue 4183 TALER_wallet_purse_delete_verify ( 4184 const struct TALER_PurseContractPublicKeyP *purse_pub, 4185 const struct TALER_PurseContractSignatureP *purse_sig); 4186 4187 4188 /** 4189 * Sign a request to upload an encrypted contract. 4190 * 4191 * @param econtract encrypted contract 4192 * @param econtract_size number of bytes in @a econtract 4193 * @param contract_pub public key for the DH-encryption 4194 * @param purse_priv key identifying the purse 4195 * @param[out] purse_sig resulting signature 4196 */ 4197 void 4198 TALER_wallet_econtract_upload_sign ( 4199 const void *econtract, 4200 size_t econtract_size, 4201 const struct TALER_ContractDiffiePublicP *contract_pub, 4202 const struct TALER_PurseContractPrivateKeyP *purse_priv, 4203 struct TALER_PurseContractSignatureP *purse_sig); 4204 4205 4206 /** 4207 * Verify a signature over encrypted contract. 4208 * 4209 * @param econtract encrypted contract 4210 * @param econtract_size number of bytes in @a econtract 4211 * @param contract_pub public key for the DH-encryption 4212 * @param purse_pub purse’s public key 4213 * @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_CREATE 4214 * @return #GNUNET_OK if the signature is valid 4215 */ 4216 enum GNUNET_GenericReturnValue 4217 TALER_wallet_econtract_upload_verify ( 4218 const void *econtract, 4219 size_t econtract_size, 4220 const struct TALER_ContractDiffiePublicP *contract_pub, 4221 const struct TALER_PurseContractPublicKeyP *purse_pub, 4222 const struct TALER_PurseContractSignatureP *purse_sig); 4223 4224 4225 /** 4226 * Verify a signature over encrypted contract. 4227 * 4228 * @param h_econtract hashed encrypted contract 4229 * @param contract_pub public key for the DH-encryption 4230 * @param purse_pub purse’s public key 4231 * @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_CREATE 4232 * @return #GNUNET_OK if the signature is valid 4233 */ 4234 enum GNUNET_GenericReturnValue 4235 TALER_wallet_econtract_upload_verify2 ( 4236 const struct GNUNET_HashCode *h_econtract, 4237 const struct TALER_ContractDiffiePublicP *contract_pub, 4238 const struct TALER_PurseContractPublicKeyP *purse_pub, 4239 const struct TALER_PurseContractSignatureP *purse_sig); 4240 4241 4242 /** 4243 * Sign a request to inquire about a purse's status. 4244 * 4245 * @param purse_priv key identifying the purse 4246 * @param[out] purse_sig resulting signature 4247 */ 4248 void 4249 TALER_wallet_purse_status_sign ( 4250 const struct TALER_PurseContractPrivateKeyP *purse_priv, 4251 struct TALER_PurseContractSignatureP *purse_sig); 4252 4253 4254 /** 4255 * Verify a purse status request signature. 4256 * 4257 * @param purse_pub purse’s public key 4258 * @param purse_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_STATUS 4259 * @return #GNUNET_OK if the signature is valid 4260 */ 4261 enum GNUNET_GenericReturnValue 4262 TALER_wallet_purse_status_verify ( 4263 const struct TALER_PurseContractPublicKeyP *purse_pub, 4264 const struct TALER_PurseContractSignatureP *purse_sig); 4265 4266 4267 /** 4268 * Sign a request to deposit a coin into a purse. 4269 * 4270 * @param exchange_base_url URL of the exchange hosting the purse 4271 * @param purse_pub purse’s public key 4272 * @param amount amount of the coin's value to transfer to the purse 4273 * @param h_denom_pub hash of the coin's denomination 4274 * @param h_age_commitment hash of the coin's age commitment 4275 * @param coin_priv key identifying the coin to be deposited 4276 * @param[out] coin_sig resulting signature 4277 */ 4278 void 4279 TALER_wallet_purse_deposit_sign ( 4280 const char *exchange_base_url, 4281 const struct TALER_PurseContractPublicKeyP *purse_pub, 4282 const struct TALER_Amount *amount, 4283 const struct TALER_DenominationHashP *h_denom_pub, 4284 const struct TALER_AgeCommitmentHashP *h_age_commitment, 4285 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 4286 struct TALER_CoinSpendSignatureP *coin_sig); 4287 4288 4289 /** 4290 * Verify a purse deposit request. 4291 * 4292 * @param exchange_base_url URL of the exchange hosting the purse 4293 * @param purse_pub purse’s public key 4294 * @param amount amount of the coin's value to transfer to the purse 4295 * @param h_denom_pub hash of the coin's denomination 4296 * @param h_age_commitment hash of the coin's age commitment 4297 * @param coin_pub key identifying the coin that is being deposited 4298 * @param[out] coin_sig resulting signature 4299 * @return #GNUNET_OK if the signature is valid 4300 */ 4301 enum GNUNET_GenericReturnValue 4302 TALER_wallet_purse_deposit_verify ( 4303 const char *exchange_base_url, 4304 const struct TALER_PurseContractPublicKeyP *purse_pub, 4305 const struct TALER_Amount *amount, 4306 const struct TALER_DenominationHashP *h_denom_pub, 4307 const struct TALER_AgeCommitmentHashP *h_age_commitment, 4308 const struct TALER_CoinSpendPublicKeyP *coin_pub, 4309 const struct TALER_CoinSpendSignatureP *coin_sig); 4310 4311 4312 /** 4313 * Sign a request by a purse to merge it into an account. 4314 * 4315 * @param reserve_uri identifies the location of the reserve 4316 * @param merge_timestamp time when the merge happened 4317 * @param purse_pub key identifying the purse 4318 * @param merge_priv key identifying the merge capability 4319 * @param[out] merge_sig resulting signature 4320 */ 4321 void 4322 TALER_wallet_purse_merge_sign ( 4323 const struct TALER_NormalizedPayto reserve_uri, 4324 struct GNUNET_TIME_Timestamp merge_timestamp, 4325 const struct TALER_PurseContractPublicKeyP *purse_pub, 4326 const struct TALER_PurseMergePrivateKeyP *merge_priv, 4327 struct TALER_PurseMergeSignatureP *merge_sig); 4328 4329 4330 /** 4331 * Verify a purse merge request. 4332 * 4333 * @param reserve_uri identifies the location of the reserve 4334 * @param merge_timestamp time when the merge happened 4335 * @param purse_pub public key of the purse to merge 4336 * @param merge_pub public key of the merge capability 4337 * @param merge_sig the signature made with purpose #TALER_SIGNATURE_WALLET_PURSE_MERGE 4338 * @return #GNUNET_OK if the signature is valid 4339 */ 4340 enum GNUNET_GenericReturnValue 4341 TALER_wallet_purse_merge_verify ( 4342 const struct TALER_NormalizedPayto reserve_uri, 4343 struct GNUNET_TIME_Timestamp merge_timestamp, 4344 const struct TALER_PurseContractPublicKeyP *purse_pub, 4345 const struct TALER_PurseMergePublicKeyP *merge_pub, 4346 const struct TALER_PurseMergeSignatureP *merge_sig); 4347 4348 4349 /** 4350 * Flags for a merge signature. 4351 */ 4352 enum TALER_WalletAccountMergeFlags 4353 { 4354 4355 /** 4356 * A mode must be set. None is not a legal mode! 4357 */ 4358 TALER_WAMF_MODE_NONE = 0, 4359 4360 /** 4361 * We are merging a fully paid-up purse into a reserve. 4362 */ 4363 TALER_WAMF_MODE_MERGE_FULLY_PAID_PURSE = 1, 4364 4365 /** 4366 * We are creating a fresh purse, from the contingent 4367 * of free purses that our account brings. 4368 */ 4369 TALER_WAMF_MODE_CREATE_FROM_PURSE_QUOTA = 2, 4370 4371 /** 4372 * The account owner is willing to pay the purse_fee for the purse to be 4373 * created from the account balance. 4374 */ 4375 TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE = 3, 4376 4377 /** 4378 * Bitmask to AND the full flags with to get the mode. 4379 */ 4380 TALER_WAMF_MERGE_MODE_MASK = 3 4381 4382 }; 4383 4384 4385 /** 4386 * Sign a request by an account to merge a purse. 4387 * 4388 * @param merge_timestamp time when the merge happened 4389 * @param purse_pub public key of the purse to merge 4390 * @param purse_expiration when should the purse expire 4391 * @param h_contract_terms contract the two parties agree on 4392 * @param amount total amount in the purse (including fees) 4393 * @param purse_fee purse fee the reserve will pay, 4394 * only used if @a flags is #TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE 4395 * @param min_age age restriction to apply for deposits into the purse 4396 * @param flags flags for the operation 4397 * @param reserve_priv key identifying the reserve 4398 * @param[out] reserve_sig resulting signature 4399 */ 4400 void 4401 TALER_wallet_account_merge_sign ( 4402 struct GNUNET_TIME_Timestamp merge_timestamp, 4403 const struct TALER_PurseContractPublicKeyP *purse_pub, 4404 struct GNUNET_TIME_Timestamp purse_expiration, 4405 const struct TALER_PrivateContractHashP *h_contract_terms, 4406 const struct TALER_Amount *amount, 4407 const struct TALER_Amount *purse_fee, 4408 uint32_t min_age, 4409 enum TALER_WalletAccountMergeFlags flags, 4410 const struct TALER_ReservePrivateKeyP *reserve_priv, 4411 struct TALER_ReserveSignatureP *reserve_sig); 4412 4413 4414 /** 4415 * Verify an account's request to merge a purse. 4416 * 4417 * @param merge_timestamp time when the merge happened 4418 * @param purse_pub public key of the purse to merge 4419 * @param purse_expiration when should the purse expire 4420 * @param h_contract_terms contract the two parties agree on 4421 * @param amount total amount in the purse (including fees) 4422 * @param purse_fee purse fee the reserve will pay, 4423 * only used if @a flags is #TALER_WAMF_MODE_CREATE_WITH_PURSE_FEE 4424 * @param min_age age restriction to apply for deposits into the purse 4425 * @param flags flags for the operation 4426 * @param reserve_pub account’s public key 4427 * @param reserve_sig the signature made with purpose #TALER_SIGNATURE_WALLET_ACCOUNT_MERGE 4428 * @return #GNUNET_OK if the signature is valid 4429 */ 4430 enum GNUNET_GenericReturnValue 4431 TALER_wallet_account_merge_verify ( 4432 struct GNUNET_TIME_Timestamp merge_timestamp, 4433 const struct TALER_PurseContractPublicKeyP *purse_pub, 4434 struct GNUNET_TIME_Timestamp purse_expiration, 4435 const struct TALER_PrivateContractHashP *h_contract_terms, 4436 const struct TALER_Amount *amount, 4437 const struct TALER_Amount *purse_fee, 4438 uint32_t min_age, 4439 enum TALER_WalletAccountMergeFlags flags, 4440 const struct TALER_ReservePublicKeyP *reserve_pub, 4441 const struct TALER_ReserveSignatureP *reserve_sig); 4442 4443 4444 /** 4445 * Sign a request to keep a reserve open. 4446 * 4447 * @param reserve_payment how much to pay from the 4448 * reserve's own balance for opening the reserve 4449 * @param request_timestamp when was the request created 4450 * @param reserve_expiration desired expiration time for the reserve 4451 * @param purse_limit minimum number of purses the client 4452 * wants to have concurrently open for this reserve 4453 * @param reserve_priv key identifying the reserve 4454 * @param[out] reserve_sig resulting signature 4455 */ 4456 void 4457 TALER_wallet_reserve_open_sign ( 4458 const struct TALER_Amount *reserve_payment, 4459 struct GNUNET_TIME_Timestamp request_timestamp, 4460 struct GNUNET_TIME_Timestamp reserve_expiration, 4461 uint32_t purse_limit, 4462 const struct TALER_ReservePrivateKeyP *reserve_priv, 4463 struct TALER_ReserveSignatureP *reserve_sig); 4464 4465 4466 /** 4467 * Verify a request to keep a reserve open. 4468 * 4469 * @param reserve_payment how much to pay from the 4470 * reserve's own balance for opening the reserve 4471 * @param request_timestamp when was the request created 4472 * @param reserve_expiration desired expiration time for the reserve 4473 * @param purse_limit minimum number of purses the client 4474 * wants to have concurrently open for this reserve 4475 * @param reserve_pub key identifying the reserve 4476 * @param reserve_sig resulting signature 4477 * @return #GNUNET_OK if the signature is valid 4478 */ 4479 enum GNUNET_GenericReturnValue 4480 TALER_wallet_reserve_open_verify ( 4481 const struct TALER_Amount *reserve_payment, 4482 struct GNUNET_TIME_Timestamp request_timestamp, 4483 struct GNUNET_TIME_Timestamp reserve_expiration, 4484 uint32_t purse_limit, 4485 const struct TALER_ReservePublicKeyP *reserve_pub, 4486 const struct TALER_ReserveSignatureP *reserve_sig); 4487 4488 4489 /** 4490 * Sign to deposit coin to pay for keeping a reserve open. 4491 * 4492 * @param coin_contribution how much the coin should contribute 4493 * @param h_denom_pub hash over the denomination public key of the coin 4494 * @param h_age_commitment hash over the age commitment, NULL if coin 4495 * is not age restricted 4496 * @param reserve_sig signature over the reserve open operation 4497 * @param coin_priv private key of the coin 4498 * @param[out] coin_sig signature by the coin 4499 */ 4500 void 4501 TALER_wallet_reserve_open_deposit_sign ( 4502 const struct TALER_Amount *coin_contribution, 4503 const struct TALER_DenominationHashP *h_denom_pub, 4504 const struct TALER_AgeCommitmentHashP *h_age_commitment, 4505 const struct TALER_ReserveSignatureP *reserve_sig, 4506 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 4507 struct TALER_CoinSpendSignatureP *coin_sig); 4508 4509 4510 /** 4511 * Verify signature that deposits coin to pay for keeping a reserve open. 4512 * 4513 * @param coin_contribution how much the coin should contribute 4514 * @param h_denom_pub hash over the denomination public key of the coin 4515 * @param h_age_commitment hash over the age commitment, NULL if coin 4516 * is not age restricted 4517 * @param reserve_sig signature over the reserve open operation 4518 * @param coin_pub public key of the coin 4519 * @param coin_sig signature by the coin 4520 * @return #GNUNET_OK if the signature is valid 4521 */ 4522 enum GNUNET_GenericReturnValue 4523 TALER_wallet_reserve_open_deposit_verify ( 4524 const struct TALER_Amount *coin_contribution, 4525 const struct TALER_DenominationHashP *h_denom_pub, 4526 const struct TALER_AgeCommitmentHashP *h_age_commitment, 4527 const struct TALER_ReserveSignatureP *reserve_sig, 4528 const struct TALER_CoinSpendPublicKeyP *coin_pub, 4529 const struct TALER_CoinSpendSignatureP *coin_sig); 4530 4531 4532 /** 4533 * Sign a request to close a reserve. 4534 * 4535 * @param request_timestamp when was the request created 4536 * @param h_payto where to send the funds (NULL allowed to send 4537 * to origin of the reserve) 4538 * @param reserve_priv key identifying the reserve 4539 * @param[out] reserve_sig resulting signature 4540 */ 4541 void 4542 TALER_wallet_reserve_close_sign ( 4543 struct GNUNET_TIME_Timestamp request_timestamp, 4544 const struct TALER_FullPaytoHashP *h_payto, 4545 const struct TALER_ReservePrivateKeyP *reserve_priv, 4546 struct TALER_ReserveSignatureP *reserve_sig); 4547 4548 4549 /** 4550 * Verify wallet request to close an account. 4551 * 4552 * @param request_timestamp when was the request created 4553 * @param h_payto where to send the funds (NULL/all zeros 4554 * allowed to send to origin of the reserve) 4555 * @param reserve_pub account’s public key 4556 * @param reserve_sig the signature made with purpose #TALER_SIGNATURE_WALLET_RESERVE_CLOSE 4557 * @return #GNUNET_OK if the signature is valid 4558 */ 4559 enum GNUNET_GenericReturnValue 4560 TALER_wallet_reserve_close_verify ( 4561 struct GNUNET_TIME_Timestamp request_timestamp, 4562 const struct TALER_FullPaytoHashP *h_payto, 4563 const struct TALER_ReservePublicKeyP *reserve_pub, 4564 const struct TALER_ReserveSignatureP *reserve_sig); 4565 4566 4567 /** 4568 * Sign a request by a wallet to perform a KYC check. 4569 * 4570 * @param reserve_priv key identifying the wallet/account 4571 * @param balance_threshold the balance threshold the wallet is about to cross 4572 * @param[out] reserve_sig resulting signature 4573 */ 4574 void 4575 TALER_wallet_account_setup_sign ( 4576 const struct TALER_ReservePrivateKeyP *reserve_priv, 4577 const struct TALER_Amount *balance_threshold, 4578 struct TALER_ReserveSignatureP *reserve_sig); 4579 4580 4581 /** 4582 * Verify account setup request. 4583 * 4584 * @param reserve_pub reserve the setup request was for 4585 * @param balance_threshold the balance threshold the wallet is about to cross 4586 * @param reserve_sig resulting signature 4587 * @return #GNUNET_OK if the signature is valid 4588 */ 4589 enum GNUNET_GenericReturnValue 4590 TALER_wallet_account_setup_verify ( 4591 const struct TALER_ReservePublicKeyP *reserve_pub, 4592 const struct TALER_Amount *balance_threshold, 4593 const struct TALER_ReserveSignatureP *reserve_sig); 4594 4595 4596 /** 4597 * Sign request to the exchange to confirm certain 4598 * @a details about the owner of a reserve. 4599 * 4600 * @param request_timestamp when was the request created 4601 * @param details which attributes are requested 4602 * @param reserve_priv private key of the reserve 4603 * @param[out] reserve_sig where to store the signature 4604 */ 4605 void 4606 TALER_wallet_reserve_attest_request_sign ( 4607 struct GNUNET_TIME_Timestamp request_timestamp, 4608 const json_t *details, 4609 const struct TALER_ReservePrivateKeyP *reserve_priv, 4610 struct TALER_ReserveSignatureP *reserve_sig); 4611 4612 4613 /** 4614 * Verify request to the exchange to confirm certain 4615 * @a details about the owner of a reserve. 4616 * 4617 * @param request_timestamp when was the request created 4618 * @param details which attributes are requested 4619 * @param reserve_pub public key of the reserve 4620 * @param reserve_sig where to store the signature 4621 * @return #GNUNET_OK if the signature is valid 4622 */ 4623 enum GNUNET_GenericReturnValue 4624 TALER_wallet_reserve_attest_request_verify ( 4625 struct GNUNET_TIME_Timestamp request_timestamp, 4626 const json_t *details, 4627 const struct TALER_ReservePublicKeyP *reserve_pub, 4628 const struct TALER_ReserveSignatureP *reserve_sig); 4629 4630 4631 /** 4632 * Hash used to represent an extension to a deposit. 4633 * Not used in the current code, but kept for compatibility. 4634 */ 4635 struct TALER_ExtensionPolicyHashP 4636 { 4637 /** 4638 * Actual hash value. 4639 */ 4640 struct GNUNET_HashCode hash; 4641 }; 4642 4643 4644 /** 4645 * Sign a deposit permission. Function for wallets. 4646 * 4647 * @param amount the amount to be deposited 4648 * @param deposit_fee the deposit fee we expect to pay 4649 * @param h_wire hash of the merchant’s account details 4650 * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) 4651 * @param wallet_data_hash hash over wallet inputs into the contract (maybe NULL) 4652 * @param h_age_commitment hash over the age commitment, if applicable to the denomination (maybe NULL) 4653 * @param h_policy hash over the policy extension, use NULL for now 4654 * @param h_denom_pub hash of the coin denomination's public key 4655 * @param coin_priv coin’s private key 4656 * @param wallet_timestamp timestamp when the contract was finalized, must not be too far in the future 4657 * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) 4658 * @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed); must not be after the @a wire_deadline 4659 * @param[out] coin_sig set to the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_DEPOSIT 4660 */ 4661 void 4662 TALER_wallet_deposit_sign ( 4663 const struct TALER_Amount *amount, 4664 const struct TALER_Amount *deposit_fee, 4665 const struct TALER_MerchantWireHashP *h_wire, 4666 const struct TALER_PrivateContractHashP *h_contract_terms, 4667 const struct GNUNET_HashCode *wallet_data_hash, 4668 const struct TALER_AgeCommitmentHashP *h_age_commitment, 4669 const struct TALER_ExtensionPolicyHashP *h_policy, 4670 const struct TALER_DenominationHashP *h_denom_pub, 4671 struct GNUNET_TIME_Timestamp wallet_timestamp, 4672 const struct TALER_MerchantPublicKeyP *merchant_pub, 4673 struct GNUNET_TIME_Timestamp refund_deadline, 4674 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 4675 struct TALER_CoinSpendSignatureP *coin_sig); 4676 4677 4678 /** 4679 * Verify a deposit permission. 4680 * 4681 * @param amount the amount to be deposited 4682 * @param deposit_fee the deposit fee we expect to pay 4683 * @param h_wire hash of the merchant’s account details 4684 * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) 4685 * @param wallet_data_hash hash over wallet inputs into the contract (maybe NULL) 4686 * @param h_age_commitment hash over the age commitment (maybe all zeroes, if not applicable to the denomination) 4687 * @param h_policy hash over the policy extension 4688 * @param h_denom_pub hash of the coin denomination's public key 4689 * @param wallet_timestamp timestamp when the contract was finalized, must not be too far in the future 4690 * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) 4691 * @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed); must not be after the @a wire_deadline 4692 * @param coin_pub coin’s public key 4693 * @param coin_sig the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_DEPOSIT 4694 * @return #GNUNET_OK if the signature is valid 4695 */ 4696 enum GNUNET_GenericReturnValue 4697 TALER_wallet_deposit_verify ( 4698 const struct TALER_Amount *amount, 4699 const struct TALER_Amount *deposit_fee, 4700 const struct TALER_MerchantWireHashP *h_wire, 4701 const struct TALER_PrivateContractHashP *h_contract_terms, 4702 const struct GNUNET_HashCode *wallet_data_hash, 4703 const struct TALER_AgeCommitmentHashP *h_age_commitment, 4704 const struct TALER_ExtensionPolicyHashP *h_policy, 4705 const struct TALER_DenominationHashP *h_denom_pub, 4706 struct GNUNET_TIME_Timestamp wallet_timestamp, 4707 const struct TALER_MerchantPublicKeyP *merchant_pub, 4708 struct GNUNET_TIME_Timestamp refund_deadline, 4709 const struct TALER_CoinSpendPublicKeyP *coin_pub, 4710 const struct TALER_CoinSpendSignatureP *coin_sig); 4711 4712 4713 /** 4714 * Sign a melt request. 4715 * 4716 * @param amount_with_fee the amount to be melted (with fee) 4717 * @param melt_fee the melt fee we expect to pay 4718 * @param rc refresh session we are committed to 4719 * @param h_denom_pub hash of the coin denomination's public key 4720 * @param h_age_commitment hash of the age commitment (may be NULL) 4721 * @param coin_priv coin’s private key 4722 * @param[out] coin_sig set to the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_MELT 4723 */ 4724 void 4725 TALER_wallet_melt_sign ( 4726 const struct TALER_Amount *amount_with_fee, 4727 const struct TALER_Amount *melt_fee, 4728 const struct TALER_RefreshCommitmentP *rc, 4729 const struct TALER_DenominationHashP *h_denom_pub, 4730 const struct TALER_AgeCommitmentHashP *h_age_commitment, 4731 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 4732 struct TALER_CoinSpendSignatureP *coin_sig); 4733 4734 4735 /** 4736 * Verify a melt request. 4737 * 4738 * @param amount_with_fee the amount to be melted (with fee) 4739 * @param melt_fee the melt fee we expect to pay 4740 * @param rc refresh session we are committed to 4741 * @param h_denom_pub hash of the coin denomination's public key 4742 * @param h_age_commitment hash of the age commitment (may be NULL) 4743 * @param coin_pub coin’s public key 4744 * @param coin_sig the signature made with purpose #TALER_SIGNATURE_WALLET_COIN_MELT 4745 * @return #GNUNET_OK if the signature is valid 4746 */ 4747 enum GNUNET_GenericReturnValue 4748 TALER_wallet_melt_verify ( 4749 const struct TALER_Amount *amount_with_fee, 4750 const struct TALER_Amount *melt_fee, 4751 const struct TALER_RefreshCommitmentP *rc, 4752 const struct TALER_DenominationHashP *h_denom_pub, 4753 const struct TALER_AgeCommitmentHashP *h_age_commitment, 4754 const struct TALER_CoinSpendPublicKeyP *coin_pub, 4755 const struct TALER_CoinSpendSignatureP *coin_sig); 4756 4757 4758 /** 4759 * Sign link data. 4760 * 4761 * @param h_denom_pub hash of the denomiantion public key of the new coin 4762 * @param transfer_pub transfer public key 4763 * @param bch blinded coin hash 4764 * @param old_coin_priv private key to sign with 4765 * @param[out] coin_sig resulting signature 4766 */ 4767 void 4768 TALER_wallet_link_sign ( 4769 const struct TALER_DenominationHashP *h_denom_pub, 4770 const struct TALER_TransferPublicKeyP *transfer_pub, 4771 const struct TALER_BlindedCoinHashP *bch, 4772 const struct TALER_CoinSpendPrivateKeyP *old_coin_priv, 4773 struct TALER_CoinSpendSignatureP *coin_sig); 4774 4775 4776 /** 4777 * Verify link signature. 4778 * 4779 * @param h_denom_pub hash of the denomiantion public key of the new coin 4780 * @param transfer_pub transfer public key 4781 * @param h_coin_ev hash of the coin envelope 4782 * @param old_coin_pub old coin key that the link signature is for 4783 * @param coin_sig resulting signature 4784 * @return #GNUNET_OK if the signature is valid 4785 */ 4786 enum GNUNET_GenericReturnValue 4787 TALER_wallet_link_verify ( 4788 const struct TALER_DenominationHashP *h_denom_pub, 4789 const struct TALER_TransferPublicKeyP *transfer_pub, 4790 const struct TALER_BlindedCoinHashP *h_coin_ev, 4791 const struct TALER_CoinSpendPublicKeyP *old_coin_pub, 4792 const struct TALER_CoinSpendSignatureP *coin_sig); 4793 4794 4795 /** 4796 * Sign withdraw request, pre-v26 of the protocol 4797 * @note: this function will be removed in future releases. 4798 * 4799 * @param h_denom_pub hash of the denomiantion public key of the coin to withdraw 4800 * @param amount_with_fee amount to debit the reserve for 4801 * @param bch blinded coin hash 4802 * @param reserve_priv private key to sign with 4803 * @param[out] reserve_sig resulting signature 4804 */ 4805 void 4806 TALER_wallet_withdraw_sign_pre26 ( 4807 const struct TALER_DenominationHashP *h_denom_pub, 4808 const struct TALER_Amount *amount_with_fee, 4809 const struct TALER_BlindedCoinHashP *bch, 4810 const struct TALER_ReservePrivateKeyP *reserve_priv, 4811 struct TALER_ReserveSignatureP *reserve_sig); 4812 4813 4814 /** 4815 * Verify withdraw request, pre-v26 of the protocol 4816 * @note: this function will be removed in future releases. 4817 * 4818 * @param h_denom_pub hash of the denomiantion public key of the coin to withdraw 4819 * @param amount_with_fee amount to debit the reserve for 4820 * @param bch blinded coin hash 4821 * @param reserve_pub public key of the reserve 4822 * @param reserve_sig resulting signature 4823 * @return #GNUNET_OK if the signature is valid 4824 */ 4825 enum GNUNET_GenericReturnValue 4826 TALER_wallet_withdraw_verify_pre26 ( 4827 const struct TALER_DenominationHashP *h_denom_pub, 4828 const struct TALER_Amount *amount_with_fee, 4829 const struct TALER_BlindedCoinHashP *bch, 4830 const struct TALER_ReservePublicKeyP *reserve_pub, 4831 const struct TALER_ReserveSignatureP *reserve_sig); 4832 4833 4834 /** 4835 * @brief Calculate the hash of a reserve public key 4836 * 4837 * @param reserve_pub public key of the reserve 4838 * @return hash value 4839 */ 4840 struct TALER_HashReservePublicKeyP 4841 TALER_wallet_hash_reserve_pub ( 4842 const struct TALER_ReservePublicKeyP *reserve_pub); 4843 4844 /** 4845 * @brief Calculate the hash of a batch of blinded planchets 4846 * 4847 * @param num_planchets Number of planchets in @e planchets 4848 * @param blinded_planchets Array @e num_planchets of blinded coin planchets 4849 * @param h_denom_pubs Array @e num_planchets of hashes of corresponding denomination public keys 4850 * @param[out] h_planchets Calculated hash 4851 */ 4852 void 4853 TALER_wallet_blinded_planchets_hash ( 4854 size_t num_planchets, 4855 const struct TALER_BlindedPlanchet blinded_planchets[static num_planchets], 4856 const struct TALER_DenominationHashP h_denom_pubs[static num_planchets], 4857 struct TALER_HashBlindedPlanchetsP *h_planchets); 4858 4859 4860 /** 4861 * @brief Calculate the hash of a batch of blinded planchets from details. 4862 * These contain the information about the denomination, too. 4863 * 4864 * @param num_planchets Number of planchets in @e planchets 4865 * @param planchet_details Array @e num_planchets of blinded coin planchets details 4866 * @param[out] h_planchets Calculated hash 4867 */ 4868 void 4869 TALER_wallet_blinded_planchet_details_hash ( 4870 size_t num_planchets, 4871 const struct TALER_PlanchetDetail planchet_details[static num_planchets], 4872 struct TALER_HashBlindedPlanchetsP *h_planchets); 4873 4874 4875 /** 4876 * @brief Sign the a withdraw request with the reserve's private key. 4877 * 4878 * @param amount total amount to withdraw, excluding fees 4879 * @param fee total amount of fees 4880 * @param h_planchets running hash over all coins' TALER_BlindingCoinHash values 4881 * @param blinding_seed blinding_seed used in a prior call to /blinding-prepare, if any of the denomination is of cipher type Clause-Schnorr, might be NULL 4882 * @param mask age mask to apply, or NULL, if not applicable. 4883 * @param max_age maximum age (in years) to commit to. Must be 0 if age restriction does not apply 4884 * @param reserve_priv private key to sign with 4885 * @param[out] reserve_sig resulting signature 4886 */ 4887 void 4888 TALER_wallet_withdraw_sign ( 4889 const struct TALER_Amount *amount, 4890 const struct TALER_Amount *fee, 4891 const struct TALER_HashBlindedPlanchetsP *h_planchets, 4892 const struct TALER_BlindingMasterSeedP *blinding_seed, 4893 const struct TALER_AgeMask *mask, 4894 uint8_t max_age, 4895 const struct TALER_ReservePrivateKeyP *reserve_priv, 4896 struct TALER_ReserveSignatureP *reserve_sig); 4897 4898 4899 /** 4900 * @brief Sign a withdraw request with no age restriction, using the reserve's public key 4901 * 4902 * @param amount total amount to withdraw, excluding fees 4903 * @param fee total amount of fees 4904 * @param h_planchets running hash over all coins' TALER_BlindingCoinHash values 4905 * @param blinding_seed blinding_seed used in a prior call to /blinding-prepare, if any of the denomination is of cipher type Clause-Schnorr, might be NULL 4906 * @param reserve_priv private key to sign with 4907 * @param reserve_sig resulting signature 4908 * @return #GNUNET_OK if the signature is valid 4909 */ 4910 #define TALER_wallet_withdraw_sign_without_age(amount, \ 4911 fee, \ 4912 h_planchets, \ 4913 blinding_seed, \ 4914 reserve_priv, \ 4915 reserve_sig) \ 4916 TALER_wallet_withdraw_sign ((amount), \ 4917 (fee), \ 4918 (h_planchets), \ 4919 (blinding_seed), \ 4920 NULL, \ 4921 0, \ 4922 (reserve_priv), \ 4923 (reserve_sig)) 4924 4925 4926 /** 4927 * Verify withdraw request, with the reserve's public key 4928 * 4929 * @param amount total amount to withdraw, excluding fees 4930 * @param fee total amount of fees 4931 * @param h_planchets running hash over all coins' TALER_BlindingCoinHash values 4932 * @param blinding_seed blinding_seed used in a prior call to /blinding-prepare, if any of the denomination is of cipher type Clause-Schnorr, might be NULL 4933 * @param mask age mask to apply, or NULL, if not applicable. 4934 * @param max_age maximum age (in years) to commit to. Must be 0 if age restriction does not apply 4935 * @param reserve_pub public key of the reserve 4936 * @param reserve_sig resulting signature 4937 * @return #GNUNET_OK if the signature is valid 4938 */ 4939 enum GNUNET_GenericReturnValue 4940 TALER_wallet_withdraw_verify ( 4941 const struct TALER_Amount *amount, 4942 const struct TALER_Amount *fee, 4943 const struct TALER_HashBlindedPlanchetsP *h_planchets, 4944 const struct TALER_BlindingMasterSeedP *blinding_seed, 4945 const struct TALER_AgeMask *mask, 4946 uint8_t max_age, 4947 const struct TALER_ReservePublicKeyP *reserve_pub, 4948 const struct TALER_ReserveSignatureP *reserve_sig); 4949 4950 4951 /** 4952 * Verify withdraw request with no age restriction, 4953 * using the reserve's public key 4954 * 4955 * @param amount total amount to withdraw, excluding fees 4956 * @param fee total amount of fees 4957 * @param h_planchets running hash over all coins' TALER_BlindingCoinHash values 4958 * @param blinding_seed seed used in a prior call to /blinding-prepare, if any of the denomination is of cipher type Clause-Schnorr, might be NULL 4959 * @param reserve_pub public key of the reserve 4960 * @param reserve_sig resulting signature 4961 * @return #GNUNET_OK if the signature is valid 4962 */ 4963 #define TALER_wallet_withdraw_verify_without_age(amount, \ 4964 fee, \ 4965 h_planchets, \ 4966 blinding_seed, \ 4967 reserve_pub, \ 4968 reserve_sig) \ 4969 TALER_wallet_withdraw_verify ((amount), \ 4970 (fee), \ 4971 (h_planchets), \ 4972 (blinding_seed), \ 4973 NULL, \ 4974 0, \ 4975 (reserve_pub), \ 4976 (reserve_sig)) 4977 4978 4979 /** 4980 * Verify exchange melt confirmation. 4981 * 4982 * @param rc refresh session this is about 4983 * @param noreveal_index gamma value chosen by the exchange 4984 * @param exchange_pub public signing key used 4985 * @param exchange_sig signature to check 4986 * @return #GNUNET_OK if the signature is valid 4987 */ 4988 enum GNUNET_GenericReturnValue 4989 TALER_exchange_melt_confirmation_verify ( 4990 const struct TALER_RefreshCommitmentP *rc, 4991 uint32_t noreveal_index, 4992 const struct TALER_ExchangePublicKeyP *exchange_pub, 4993 const struct TALER_ExchangeSignatureP *exchange_sig); 4994 4995 4996 /** 4997 * Verify recoup signature. 4998 * 4999 * @param h_denom_pub hash of the denomiantion public key of the coin 5000 * @param coin_bks blinding factor used when withdrawing the coin 5001 * @param coin_pub coin key of the coin to be recouped 5002 * @param coin_sig resulting signature 5003 * @return #GNUNET_OK if the signature is valid 5004 */ 5005 enum GNUNET_GenericReturnValue 5006 TALER_wallet_recoup_verify ( 5007 const struct TALER_DenominationHashP *h_denom_pub, 5008 const union GNUNET_CRYPTO_BlindingSecretP *coin_bks, 5009 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5010 const struct TALER_CoinSpendSignatureP *coin_sig); 5011 5012 5013 /** 5014 * Create recoup signature. 5015 * 5016 * @param h_denom_pub hash of the denomiantion public key of the coin 5017 * @param coin_bks blinding factor used when withdrawing the coin 5018 * @param coin_priv coin key of the coin to be recouped 5019 * @param[out] coin_sig resulting signature 5020 */ 5021 void 5022 TALER_wallet_recoup_sign ( 5023 const struct TALER_DenominationHashP *h_denom_pub, 5024 const union GNUNET_CRYPTO_BlindingSecretP *coin_bks, 5025 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 5026 struct TALER_CoinSpendSignatureP *coin_sig); 5027 5028 5029 /** 5030 * Verify recoup-refresh signature. 5031 * 5032 * @param h_denom_pub hash of the denomiantion public key of the coin 5033 * @param coin_bks blinding factor used when withdrawing the coin 5034 * @param coin_pub coin key of the coin to be recouped 5035 * @param coin_sig resulting signature 5036 * @return #GNUNET_OK if the signature is valid 5037 */ 5038 enum GNUNET_GenericReturnValue 5039 TALER_wallet_recoup_refresh_verify ( 5040 const struct TALER_DenominationHashP *h_denom_pub, 5041 const union GNUNET_CRYPTO_BlindingSecretP *coin_bks, 5042 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5043 const struct TALER_CoinSpendSignatureP *coin_sig); 5044 5045 5046 /** 5047 * Create recoup-refresh signature. 5048 * 5049 * @param h_denom_pub hash of the denomiantion public key of the coin 5050 * @param coin_bks blinding factor used when withdrawing the coin 5051 * @param coin_priv coin key of the coin to be recouped 5052 * @param[out] coin_sig resulting signature 5053 */ 5054 void 5055 TALER_wallet_recoup_refresh_sign ( 5056 const struct TALER_DenominationHashP *h_denom_pub, 5057 const union GNUNET_CRYPTO_BlindingSecretP *coin_bks, 5058 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 5059 struct TALER_CoinSpendSignatureP *coin_sig); 5060 5061 5062 /** 5063 * Verify reserve history request signature. 5064 * 5065 * @param start_off start of the requested range 5066 * @param reserve_pub reserve the history request was for 5067 * @param reserve_sig resulting signature 5068 * @return #GNUNET_OK if the signature is valid 5069 */ 5070 enum GNUNET_GenericReturnValue 5071 TALER_wallet_reserve_history_verify ( 5072 uint64_t start_off, 5073 const struct TALER_ReservePublicKeyP *reserve_pub, 5074 const struct TALER_ReserveSignatureP *reserve_sig); 5075 5076 5077 /** 5078 * Create reserve status request signature. 5079 * 5080 * @param start_off start of the requested range 5081 * @param reserve_priv private key of the reserve the history request is for 5082 * @param[out] reserve_sig resulting signature 5083 */ 5084 void 5085 TALER_wallet_reserve_history_sign ( 5086 uint64_t start_off, 5087 const struct TALER_ReservePrivateKeyP *reserve_priv, 5088 struct TALER_ReserveSignatureP *reserve_sig); 5089 5090 5091 /** 5092 * Verify coin history request signature. 5093 * 5094 * @param start_off start of the requested range 5095 * @param coin_pub coin the history request was for 5096 * @param coin_sig resulting signature 5097 * @return #GNUNET_OK if the signature is valid 5098 */ 5099 enum GNUNET_GenericReturnValue 5100 TALER_wallet_coin_history_verify ( 5101 uint64_t start_off, 5102 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5103 const struct TALER_CoinSpendSignatureP *coin_sig); 5104 5105 5106 /** 5107 * Create coin status request signature. 5108 * 5109 * @param start_off start of the requested range 5110 * @param coin_priv private key of the coin the history request is for 5111 * @param[out] coin_sig resulting signature 5112 */ 5113 void 5114 TALER_wallet_coin_history_sign ( 5115 uint64_t start_off, 5116 const struct TALER_CoinSpendPrivateKeyP *coin_priv, 5117 struct TALER_CoinSpendSignatureP *coin_sig); 5118 5119 5120 /** 5121 * Create token use request signature. 5122 * 5123 * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) 5124 * @param wallet_data_hash hash over wallet inputs into the contract 5125 * @param token_use_priv token use private key 5126 * @param[out] token_sig set to the signature made with purpose #TALER_SIGNATURE_WALLET_TOKEN_USE 5127 */ 5128 void 5129 TALER_wallet_token_use_sign ( 5130 const struct TALER_PrivateContractHashP *h_contract_terms, 5131 const struct GNUNET_HashCode *wallet_data_hash, 5132 const struct TALER_TokenUsePrivateKeyP *token_use_priv, 5133 struct TALER_TokenUseSignatureP *token_sig); 5134 5135 5136 /** 5137 * Verify token use signature. 5138 * 5139 * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) 5140 * @param wallet_data_hash hash over wallet inputs into the contract 5141 * @param token_use_pub token use private key 5142 * @param token_sig the signature made with purpose #TALER_SIGNATURE_WALLET_TOKEN_USE 5143 */ 5144 enum GNUNET_GenericReturnValue 5145 TALER_wallet_token_use_verify ( 5146 const struct TALER_PrivateContractHashP *h_contract_terms, 5147 const struct GNUNET_HashCode *wallet_data_hash, 5148 const struct TALER_TokenUsePublicKeyP *token_use_pub, 5149 const struct TALER_TokenUseSignatureP *token_sig); 5150 5151 5152 /** 5153 * Create order unclaim request signature. 5154 * 5155 * @param h_contract hash of the contact to unclaim 5156 * @param nonce_priv private key of the claim nonce 5157 * @param[out] nsig set to the signature made with purpose #TALER_SIGNATURE_WALLET_ORDER_UNCLAIM 5158 */ 5159 void 5160 TALER_wallet_order_unclaim_sign ( 5161 const struct GNUNET_HashCode *h_contract, 5162 const struct GNUNET_CRYPTO_EddsaPrivateKey *nonce_priv, 5163 struct GNUNET_CRYPTO_EddsaSignature *nsig); 5164 5165 5166 /** 5167 * Verify order unclaim signature. 5168 * 5169 * @param h_contract hash of the contact to be unclaimed 5170 * @param nonce nonce from the contract 5171 * @param nsig signature made with purpose #TALER_SIGNATURE_WALLET_ORDER_UNCLAIM 5172 */ 5173 enum GNUNET_GenericReturnValue 5174 TALER_wallet_order_unclaim_verify ( 5175 const struct GNUNET_HashCode *h_contract, 5176 const struct GNUNET_CRYPTO_EddsaPublicKey *nonce, 5177 const struct GNUNET_CRYPTO_EddsaSignature *nsig); 5178 5179 5180 /** 5181 * Transfer type requested at registration. 5182 */ 5183 enum TALER_BankRegistrationType 5184 { 5185 5186 /** 5187 * Invalid / uninitialized registration type. 5188 */ 5189 TALER_BANK_REGISTRATION_TYPE_INVALID = 0, 5190 5191 /** 5192 * Standard reserve withdrawal. 5193 */ 5194 TALER_BANK_REGISTRATION_TYPE_RESERVE = 1, 5195 5196 /** 5197 * KYC authentication transfer. 5198 */ 5199 TALER_BANK_REGISTRATION_TYPE_KYC = 2 5200 5201 }; 5202 5203 5204 void 5205 TALER_wallet_prepared_transfer_registration_sign ( 5206 const struct TALER_FullPayto credit_account, 5207 const struct TALER_Amount *credit_amount, 5208 enum TALER_BankRegistrationType type, 5209 bool recurrent, 5210 const union TALER_AccountPublicKeyP *account_pub, 5211 const struct TALER_PreparedTransferAuthorizationPrivateKeyP *auth_priv, 5212 struct TALER_PreparedTransferAuthorizationSignatureP *auth_sig); 5213 5214 5215 enum GNUNET_GenericReturnValue 5216 TALER_wallet_prepared_transfer_registration_verify ( 5217 const struct TALER_FullPayto credit_account, 5218 const struct TALER_Amount *credit_amount, 5219 enum TALER_BankRegistrationType type, 5220 bool recurrent, 5221 const union TALER_AccountPublicKeyP *account_pub, 5222 const struct TALER_PreparedTransferAuthorizationPublicKeyP *auth_pub, 5223 const struct TALER_PreparedTransferAuthorizationSignatureP *auth_sig); 5224 5225 5226 /* ********************* merchant signing ************************** */ 5227 5228 5229 /** 5230 * Create merchant signature approving a refund. 5231 * 5232 * @param coin_pub coin to be refunded 5233 * @param h_contract_terms contract to be refunded 5234 * @param rtransaction_id unique ID for this (partial) refund 5235 * @param amount amount to be refunded 5236 * @param merchant_priv private key to sign with 5237 * @param[out] merchant_sig where to write the signature 5238 */ 5239 void 5240 TALER_merchant_refund_sign ( 5241 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5242 const struct TALER_PrivateContractHashP *h_contract_terms, 5243 uint64_t rtransaction_id, 5244 const struct TALER_Amount *amount, 5245 const struct TALER_MerchantPrivateKeyP *merchant_priv, 5246 struct TALER_MerchantSignatureP *merchant_sig); 5247 5248 5249 /** 5250 * Verify merchant signature approving a refund. 5251 * 5252 * @param coin_pub coin to be refunded 5253 * @param h_contract_terms contract to be refunded 5254 * @param rtransaction_id unique ID for this (partial) refund 5255 * @param amount amount to be refunded 5256 * @param merchant_pub public key of the merchant 5257 * @param merchant_sig signature to verify 5258 * @return #GNUNET_OK if the signature is valid 5259 */ 5260 enum GNUNET_GenericReturnValue 5261 TALER_merchant_refund_verify ( 5262 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5263 const struct TALER_PrivateContractHashP *h_contract_terms, 5264 uint64_t rtransaction_id, 5265 const struct TALER_Amount *amount, 5266 const struct TALER_MerchantPublicKeyP *merchant_pub, 5267 const struct TALER_MerchantSignatureP *merchant_sig); 5268 5269 5270 /* ********************* exchange deposit signing ************************* */ 5271 5272 /** 5273 * Sign a deposit. 5274 * 5275 * @param h_contract_terms hash of contract terms 5276 * @param h_wire hash of the merchant account details 5277 * @param coin_pub coin to be deposited 5278 * @param merchant_priv private key to sign with 5279 * @param[out] merchant_sig where to write the signature 5280 */ 5281 void 5282 TALER_merchant_deposit_sign ( 5283 const struct TALER_PrivateContractHashP *h_contract_terms, 5284 const struct TALER_MerchantWireHashP *h_wire, 5285 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5286 const struct TALER_MerchantPrivateKeyP *merchant_priv, 5287 struct TALER_MerchantSignatureP *merchant_sig); 5288 5289 5290 /** 5291 * Verify a deposit. 5292 * 5293 * @param merchant merchant public key 5294 * @param coin_pub public key of the deposited coin 5295 * @param h_contract_terms hash of contract terms 5296 * @param h_wire hash of the merchant account details 5297 * @param merchant_sig signature of the merchant 5298 * @return #GNUNET_OK if the signature is valid 5299 */ 5300 enum GNUNET_GenericReturnValue 5301 TALER_merchant_deposit_verify ( 5302 const struct TALER_MerchantPublicKeyP *merchant, 5303 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5304 const struct TALER_PrivateContractHashP *h_contract_terms, 5305 const struct TALER_MerchantWireHashP *h_wire, 5306 const struct TALER_MerchantSignatureP *merchant_sig); 5307 5308 5309 /* ********************* exchange online signing ************************** */ 5310 5311 5312 /** 5313 * Signature of a function that signs the message in @a purpose with the 5314 * exchange's signing key. 5315 * 5316 * The @a purpose data is the beginning of the data of which the signature is 5317 * to be created. The `size` field in @a purpose must correctly indicate the 5318 * number of bytes of the data structure, including its header. * 5319 * @param purpose the message to sign 5320 * @param[out] pub set to the current public signing key of the exchange 5321 * @param[out] sig signature over purpose using current signing key 5322 * @return #TALER_EC_NONE on success 5323 */ 5324 typedef enum TALER_ErrorCode 5325 (*TALER_ExchangeSignCallback)( 5326 const struct GNUNET_CRYPTO_SignaturePurpose *purpose, 5327 struct TALER_ExchangePublicKeyP *pub, 5328 struct TALER_ExchangeSignatureP *sig); 5329 5330 5331 /** 5332 * Signature of a function that signs the message in @a purpose with the 5333 * exchange's signing key. 5334 * 5335 * The @a purpose data is the beginning of the data of which the signature is 5336 * to be created. The `size` field in @a purpose must correctly indicate the 5337 * number of bytes of the data structure, including its header. * 5338 * @param cls closure 5339 * @param purpose the message to sign 5340 * @param[out] pub set to the current public signing key of the exchange 5341 * @param[out] sig signature over purpose using current signing key 5342 * @return #TALER_EC_NONE on success 5343 */ 5344 typedef enum TALER_ErrorCode 5345 (*TALER_ExchangeSignCallback2)( 5346 void *cls, 5347 const struct GNUNET_CRYPTO_SignaturePurpose *purpose, 5348 struct TALER_ExchangePublicKeyP *pub, 5349 struct TALER_ExchangeSignatureP *sig); 5350 5351 5352 /** 5353 * Create deposit confirmation signature. 5354 * 5355 * @param scb function to call to create the signature 5356 * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) 5357 * @param h_wire hash of the merchant’s account details 5358 * @param h_policy hash over the policy extension, can be NULL 5359 * @param exchange_timestamp timestamp when the contract was finalized, must not be too far off 5360 * @param wire_deadline date until which the exchange should wire the funds 5361 * @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed); must not be after the @a wire_deadline 5362 * @param total_without_fee the total amount to be deposited after fees over all coins 5363 * @param num_coins length of @a coin_sigs array 5364 * @param coin_sigs signatures of the deposited coins 5365 * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) 5366 * @param[out] pub where to write the public key 5367 * @param[out] sig where to write the signature 5368 * @return #TALER_EC_NONE on success 5369 */ 5370 enum TALER_ErrorCode 5371 TALER_exchange_online_deposit_confirmation_sign ( 5372 TALER_ExchangeSignCallback scb, 5373 const struct TALER_PrivateContractHashP *h_contract_terms, 5374 const struct TALER_MerchantWireHashP *h_wire, 5375 const struct TALER_ExtensionPolicyHashP *h_policy, 5376 struct GNUNET_TIME_Timestamp exchange_timestamp, 5377 struct GNUNET_TIME_Timestamp wire_deadline, 5378 struct GNUNET_TIME_Timestamp refund_deadline, 5379 const struct TALER_Amount *total_without_fee, 5380 unsigned int num_coins, 5381 const struct TALER_CoinSpendSignatureP *coin_sigs[static num_coins], 5382 const struct TALER_MerchantPublicKeyP *merchant_pub, 5383 struct TALER_ExchangePublicKeyP *pub, 5384 struct TALER_ExchangeSignatureP *sig); 5385 5386 5387 /** 5388 * Verify deposit confirmation signature. 5389 * 5390 * @param h_contract_terms hash of the contact of the merchant with the customer (further details are never disclosed to the exchange) 5391 * @param h_wire hash of the merchant’s account details 5392 * @param h_policy hash over the policy extension, can be NULL 5393 * @param exchange_timestamp timestamp when the contract was finalized, must not be too far off 5394 * @param wire_deadline date until which the exchange should wire the funds 5395 * @param refund_deadline date until which the merchant can issue a refund to the customer via the exchange (can be zero if refunds are not allowed); must not be after the @a wire_deadline 5396 * @param total_without_fee the total amount to be deposited after fees over all coins 5397 * @param num_coins length of @a coin_sigs array 5398 * @param coin_sigs signatures of the deposited coins 5399 * @param merchant_pub the public key of the merchant (used to identify the merchant for refund requests) 5400 * @param pub where to write the public key 5401 * @param sig where to write the signature 5402 * @return #GNUNET_OK if the signature is valid 5403 */ 5404 enum GNUNET_GenericReturnValue 5405 TALER_exchange_online_deposit_confirmation_verify ( 5406 const struct TALER_PrivateContractHashP *h_contract_terms, 5407 const struct TALER_MerchantWireHashP *h_wire, 5408 const struct TALER_ExtensionPolicyHashP *h_policy, 5409 struct GNUNET_TIME_Timestamp exchange_timestamp, 5410 struct GNUNET_TIME_Timestamp wire_deadline, 5411 struct GNUNET_TIME_Timestamp refund_deadline, 5412 const struct TALER_Amount *total_without_fee, 5413 unsigned int num_coins, 5414 const struct TALER_CoinSpendSignatureP *coin_sigs[static num_coins], 5415 const struct TALER_MerchantPublicKeyP *merchant_pub, 5416 const struct TALER_ExchangePublicKeyP *pub, 5417 const struct TALER_ExchangeSignatureP *sig); 5418 5419 5420 /** 5421 * Create refund confirmation signature. 5422 * 5423 * @param scb function to call to create the signature 5424 * @param h_contract_terms hash of contract being refunded 5425 * @param coin_pub public key of the coin receiving the refund 5426 * @param merchant public key of the merchant that granted the refund 5427 * @param rtransaction_id refund transaction ID used by the merchant 5428 * @param refund_amount amount refunded 5429 * @param[out] pub where to write the exchange public key 5430 * @param[out] sig where to write the exchange signature 5431 * @return #TALER_EC_NONE on success 5432 */ 5433 enum TALER_ErrorCode 5434 TALER_exchange_online_refund_confirmation_sign ( 5435 TALER_ExchangeSignCallback scb, 5436 const struct TALER_PrivateContractHashP *h_contract_terms, 5437 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5438 const struct TALER_MerchantPublicKeyP *merchant, 5439 uint64_t rtransaction_id, 5440 const struct TALER_Amount *refund_amount, 5441 struct TALER_ExchangePublicKeyP *pub, 5442 struct TALER_ExchangeSignatureP *sig); 5443 5444 5445 /** 5446 * Verify refund confirmation signature. 5447 * 5448 * @param h_contract_terms hash of contract being refunded 5449 * @param coin_pub public key of the coin receiving the refund 5450 * @param merchant public key of the merchant that granted the refund 5451 * @param rtransaction_id refund transaction ID used by the merchant 5452 * @param refund_amount amount refunded 5453 * @param pub where to write the public key 5454 * @param sig where to write the signature 5455 * @return #GNUNET_OK if the signature is valid 5456 */ 5457 enum GNUNET_GenericReturnValue 5458 TALER_exchange_online_refund_confirmation_verify ( 5459 const struct TALER_PrivateContractHashP *h_contract_terms, 5460 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5461 const struct TALER_MerchantPublicKeyP *merchant, 5462 uint64_t rtransaction_id, 5463 const struct TALER_Amount *refund_amount, 5464 const struct TALER_ExchangePublicKeyP *pub, 5465 const struct TALER_ExchangeSignatureP *sig); 5466 5467 5468 /** 5469 * Create refresh melt confirmation signature. 5470 * 5471 * @param scb function to call to create the signature 5472 * @param rc refresh commitment that identifies the melt operation 5473 * @param noreveal_index gamma cut-and-choose value chosen by the exchange 5474 * @param[out] pub where to write the exchange public key 5475 * @param[out] sig where to write the exchange signature 5476 * @return #TALER_EC_NONE on success 5477 */ 5478 enum TALER_ErrorCode 5479 TALER_exchange_online_melt_confirmation_sign ( 5480 TALER_ExchangeSignCallback scb, 5481 const struct TALER_RefreshCommitmentP *rc, 5482 uint32_t noreveal_index, 5483 struct TALER_ExchangePublicKeyP *pub, 5484 struct TALER_ExchangeSignatureP *sig); 5485 5486 5487 /** 5488 * Verify refresh melt confirmation signature. 5489 * 5490 * @param rc refresh commitment that identifies the melt operation 5491 * @param noreveal_index gamma cut-and-choose value chosen by the exchange 5492 * @param pub where to write the public key 5493 * @param sig where to write the signature 5494 * @return #GNUNET_OK if the signature is valid 5495 */ 5496 enum GNUNET_GenericReturnValue 5497 TALER_exchange_online_melt_confirmation_verify ( 5498 const struct TALER_RefreshCommitmentP *rc, 5499 uint32_t noreveal_index, 5500 const struct TALER_ExchangePublicKeyP *pub, 5501 const struct TALER_ExchangeSignatureP *sig); 5502 5503 5504 /** 5505 * Create exchange purse refund confirmation signature. 5506 * 5507 * @param scb function to call to create the signature 5508 * @param amount_without_fee refunded amount 5509 * @param refund_fee refund fee charged 5510 * @param coin_pub coin that was refunded 5511 * @param purse_pub public key of the expired purse 5512 * @param[out] pub where to write the public key 5513 * @param[out] sig where to write the signature 5514 * @return #TALER_EC_NONE on success 5515 */ 5516 enum TALER_ErrorCode 5517 TALER_exchange_online_purse_refund_sign ( 5518 TALER_ExchangeSignCallback scb, 5519 const struct TALER_Amount *amount_without_fee, 5520 const struct TALER_Amount *refund_fee, 5521 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5522 const struct TALER_PurseContractPublicKeyP *purse_pub, 5523 struct TALER_ExchangePublicKeyP *pub, 5524 struct TALER_ExchangeSignatureP *sig); 5525 5526 5527 /** 5528 * Verify signature of exchange affirming purse refund 5529 * from purse expiration. 5530 * 5531 * @param amount_without_fee refunded amount 5532 * @param refund_fee refund fee charged 5533 * @param coin_pub coin that was refunded 5534 * @param purse_pub public key of the expired purse 5535 * @param pub public key to verify signature against 5536 * @param sig signature to verify 5537 * @return #GNUNET_OK if the signature is valid 5538 */ 5539 enum GNUNET_GenericReturnValue 5540 TALER_exchange_online_purse_refund_verify ( 5541 const struct TALER_Amount *amount_without_fee, 5542 const struct TALER_Amount *refund_fee, 5543 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5544 const struct TALER_PurseContractPublicKeyP *purse_pub, 5545 const struct TALER_ExchangePublicKeyP *pub, 5546 const struct TALER_ExchangeSignatureP *sig); 5547 5548 5549 /** 5550 * Create exchange key set signature. 5551 * 5552 * @param scb function to call to create the signature 5553 * @param cls closure for @a scb 5554 * @param timestamp time when the key set was issued 5555 * @param hc hash over all the keys 5556 * @param[out] pub where to write the public key 5557 * @param[out] sig where to write the signature 5558 * @return #TALER_EC_NONE on success 5559 */ 5560 enum TALER_ErrorCode 5561 TALER_exchange_online_key_set_sign ( 5562 TALER_ExchangeSignCallback2 scb, 5563 void *cls, 5564 struct GNUNET_TIME_Timestamp timestamp, 5565 const struct GNUNET_HashCode *hc, 5566 struct TALER_ExchangePublicKeyP *pub, 5567 struct TALER_ExchangeSignatureP *sig); 5568 5569 5570 /** 5571 * Verify key set signature. 5572 * 5573 * @param timestamp time when the key set was issued 5574 * @param hc hash over all the keys 5575 * @param pub public key to verify signature against 5576 * @param sig signature to verify 5577 * @return #GNUNET_OK if the signature is valid 5578 */ 5579 enum GNUNET_GenericReturnValue 5580 TALER_exchange_online_key_set_verify ( 5581 struct GNUNET_TIME_Timestamp timestamp, 5582 const struct GNUNET_HashCode *hc, 5583 const struct TALER_ExchangePublicKeyP *pub, 5584 const struct TALER_ExchangeSignatureP *sig); 5585 5586 5587 /** 5588 * Hash normalized @a j JSON object or array and 5589 * store the result in @a hc. 5590 * 5591 * @param j JSON to hash 5592 * @param[out] hc where to write the hash 5593 */ 5594 void 5595 TALER_json_hash (const json_t *j, 5596 struct GNUNET_HashCode *hc); 5597 5598 5599 /** 5600 * Update the @a hash_context in the computation of the 5601 * h_details for a wire status signature. 5602 * 5603 * @param[in,out] hash_context context to update 5604 * @param h_contract_terms hash of the contract 5605 * @param execution_time when was the wire transfer initiated 5606 * @param coin_pub deposited coin 5607 * @param deposit_value contribution of the coin 5608 * @param deposit_fee how high was the deposit fee 5609 */ 5610 void 5611 TALER_exchange_online_wire_deposit_append ( 5612 struct GNUNET_HashContext *hash_context, 5613 const struct TALER_PrivateContractHashP *h_contract_terms, 5614 struct GNUNET_TIME_Timestamp execution_time, 5615 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5616 const struct TALER_Amount *deposit_value, 5617 const struct TALER_Amount *deposit_fee); 5618 5619 5620 /** 5621 * Create wire deposit signature. 5622 * 5623 * @param scb function to call to create the signature 5624 * @param total amount the merchant was credited 5625 * @param wire_fee fee charged by the exchange for the wire transfer 5626 * @param merchant_pub which merchant was credited 5627 * @param payto payto://-URI of the merchant account 5628 * @param h_details hash over the aggregation details 5629 * @param[out] pub where to write the public key 5630 * @param[out] sig where to write the signature 5631 * @return #TALER_EC_NONE on success 5632 */ 5633 enum TALER_ErrorCode 5634 TALER_exchange_online_wire_deposit_sign ( 5635 TALER_ExchangeSignCallback scb, 5636 const struct TALER_Amount *total, 5637 const struct TALER_Amount *wire_fee, 5638 const struct TALER_MerchantPublicKeyP *merchant_pub, 5639 const struct TALER_FullPayto payto, 5640 const struct GNUNET_HashCode *h_details, 5641 struct TALER_ExchangePublicKeyP *pub, 5642 struct TALER_ExchangeSignatureP *sig); 5643 5644 5645 /** 5646 * Verify wire deposit signature. 5647 * 5648 * @param total amount the merchant was credited 5649 * @param wire_fee fee charged by the exchange for the wire transfer 5650 * @param merchant_pub which merchant was credited 5651 * @param h_payto hash of the payto://-URI of the merchant account 5652 * @param h_details hash over the aggregation details 5653 * @param pub where to write the public key 5654 * @param sig where to write the signature 5655 * @return #GNUNET_OK if the signature is valid 5656 */ 5657 enum GNUNET_GenericReturnValue 5658 TALER_exchange_online_wire_deposit_verify ( 5659 const struct TALER_Amount *total, 5660 const struct TALER_Amount *wire_fee, 5661 const struct TALER_MerchantPublicKeyP *merchant_pub, 5662 const struct TALER_FullPaytoHashP *h_payto, 5663 const struct GNUNET_HashCode *h_details, 5664 const struct TALER_ExchangePublicKeyP *pub, 5665 const struct TALER_ExchangeSignatureP *sig); 5666 5667 5668 /** 5669 * Create wire confirmation signature. 5670 * 5671 * @param scb function to call to create the signature 5672 * @param h_wire hash of the merchant's account 5673 * @param h_contract_terms hash of the contract 5674 * @param wtid wire transfer this deposit was aggregated into 5675 * @param coin_pub public key of the deposited coin 5676 * @param execution_time when was wire transfer initiated 5677 * @param coin_contribution what was @a coin_pub's contribution to the wire transfer 5678 * @param[out] pub where to write the public key 5679 * @param[out] sig where to write the signature 5680 * @return #TALER_EC_NONE on success 5681 */ 5682 enum TALER_ErrorCode 5683 TALER_exchange_online_confirm_wire_sign ( 5684 TALER_ExchangeSignCallback scb, 5685 const struct TALER_MerchantWireHashP *h_wire, 5686 const struct TALER_PrivateContractHashP *h_contract_terms, 5687 const struct TALER_WireTransferIdentifierRawP *wtid, 5688 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5689 struct GNUNET_TIME_Timestamp execution_time, 5690 const struct TALER_Amount *coin_contribution, 5691 struct TALER_ExchangePublicKeyP *pub, 5692 struct TALER_ExchangeSignatureP *sig); 5693 5694 5695 /** 5696 * Verify confirm wire signature. 5697 * 5698 * @param h_wire hash of the merchant's account 5699 * @param h_contract_terms hash of the contract 5700 * @param wtid wire transfer this deposit was aggregated into 5701 * @param coin_pub public key of the deposited coin 5702 * @param execution_time when was wire transfer initiated 5703 * @param coin_contribution what was @a coin_pub's contribution to the wire transfer 5704 * @param pub where to write the public key 5705 * @param sig where to write the signature 5706 * @return #GNUNET_OK if the signature is valid 5707 */ 5708 enum GNUNET_GenericReturnValue 5709 TALER_exchange_online_confirm_wire_verify ( 5710 const struct TALER_MerchantWireHashP *h_wire, 5711 const struct TALER_PrivateContractHashP *h_contract_terms, 5712 const struct TALER_WireTransferIdentifierRawP *wtid, 5713 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5714 struct GNUNET_TIME_Timestamp execution_time, 5715 const struct TALER_Amount *coin_contribution, 5716 const struct TALER_ExchangePublicKeyP *pub, 5717 const struct TALER_ExchangeSignatureP *sig); 5718 5719 5720 /** 5721 * Create confirm recoup signature. 5722 * 5723 * @param scb function to call to create the signature 5724 * @param timestamp when was the recoup done 5725 * @param recoup_amount how much was recouped 5726 * @param coin_pub coin that was recouped 5727 * @param reserve_pub reserve that was credited 5728 * @param[out] pub where to write the public key 5729 * @param[out] sig where to write the signature 5730 * @return #TALER_EC_NONE on success 5731 */ 5732 enum TALER_ErrorCode 5733 TALER_exchange_online_confirm_recoup_sign ( 5734 TALER_ExchangeSignCallback scb, 5735 struct GNUNET_TIME_Timestamp timestamp, 5736 const struct TALER_Amount *recoup_amount, 5737 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5738 const struct TALER_ReservePublicKeyP *reserve_pub, 5739 struct TALER_ExchangePublicKeyP *pub, 5740 struct TALER_ExchangeSignatureP *sig); 5741 5742 5743 /** 5744 * Verify confirm recoup signature. 5745 * 5746 * @param timestamp when was the recoup done 5747 * @param recoup_amount how much was recouped 5748 * @param coin_pub coin that was recouped 5749 * @param reserve_pub reserve that was credited 5750 * @param pub where to write the public key 5751 * @param sig where to write the signature 5752 * @return #GNUNET_OK if the signature is valid 5753 */ 5754 enum GNUNET_GenericReturnValue 5755 TALER_exchange_online_confirm_recoup_verify ( 5756 struct GNUNET_TIME_Timestamp timestamp, 5757 const struct TALER_Amount *recoup_amount, 5758 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5759 const struct TALER_ReservePublicKeyP *reserve_pub, 5760 const struct TALER_ExchangePublicKeyP *pub, 5761 const struct TALER_ExchangeSignatureP *sig); 5762 5763 5764 /** 5765 * Create confirm recoup refresh signature. 5766 * 5767 * @param scb function to call to create the signature 5768 * @param timestamp when was the recoup done 5769 * @param recoup_amount how much was recouped 5770 * @param coin_pub coin that was recouped 5771 * @param old_coin_pub old coin that was credited 5772 * @param[out] pub where to write the public key 5773 * @param[out] sig where to write the signature 5774 * @return #TALER_EC_NONE on success 5775 */ 5776 enum TALER_ErrorCode 5777 TALER_exchange_online_confirm_recoup_refresh_sign ( 5778 TALER_ExchangeSignCallback scb, 5779 struct GNUNET_TIME_Timestamp timestamp, 5780 const struct TALER_Amount *recoup_amount, 5781 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5782 const struct TALER_CoinSpendPublicKeyP *old_coin_pub, 5783 struct TALER_ExchangePublicKeyP *pub, 5784 struct TALER_ExchangeSignatureP *sig); 5785 5786 5787 /** 5788 * Verify confirm recoup refresh signature. 5789 * 5790 * @param timestamp when was the recoup done 5791 * @param recoup_amount how much was recouped 5792 * @param coin_pub coin that was recouped 5793 * @param old_coin_pub old coin that was credited 5794 * @param pub where to write the public key 5795 * @param sig where to write the signature 5796 * @return #GNUNET_OK if the signature is valid 5797 */ 5798 enum GNUNET_GenericReturnValue 5799 TALER_exchange_online_confirm_recoup_refresh_verify ( 5800 struct GNUNET_TIME_Timestamp timestamp, 5801 const struct TALER_Amount *recoup_amount, 5802 const struct TALER_CoinSpendPublicKeyP *coin_pub, 5803 const struct TALER_CoinSpendPublicKeyP *old_coin_pub, 5804 const struct TALER_ExchangePublicKeyP *pub, 5805 const struct TALER_ExchangeSignatureP *sig); 5806 5807 5808 /** 5809 * Create denomination unknown signature. 5810 * 5811 * @param scb function to call to create the signature 5812 * @param timestamp when was the error created 5813 * @param h_denom_pub hash of denomination that is unknown 5814 * @param[out] pub where to write the public key 5815 * @param[out] sig where to write the signature 5816 * @return #TALER_EC_NONE on success 5817 */ 5818 enum TALER_ErrorCode 5819 TALER_exchange_online_denomination_unknown_sign ( 5820 TALER_ExchangeSignCallback scb, 5821 struct GNUNET_TIME_Timestamp timestamp, 5822 const struct TALER_DenominationHashP *h_denom_pub, 5823 struct TALER_ExchangePublicKeyP *pub, 5824 struct TALER_ExchangeSignatureP *sig); 5825 5826 5827 /** 5828 * Verify denomination unknown signature. 5829 * 5830 * @param timestamp when was the error created 5831 * @param h_denom_pub hash of denomination that is unknown 5832 * @param pub where to write the public key 5833 * @param sig where to write the signature 5834 * @return #GNUNET_OK if the signature is valid 5835 */ 5836 enum GNUNET_GenericReturnValue 5837 TALER_exchange_online_denomination_unknown_verify ( 5838 struct GNUNET_TIME_Timestamp timestamp, 5839 const struct TALER_DenominationHashP *h_denom_pub, 5840 const struct TALER_ExchangePublicKeyP *pub, 5841 const struct TALER_ExchangeSignatureP *sig); 5842 5843 5844 /** 5845 * Create denomination expired signature. 5846 * 5847 * @param scb function to call to create the signature 5848 * @param timestamp when was the error created 5849 * @param h_denom_pub hash of denomination that is expired 5850 * @param op character string describing the operation for which 5851 * the denomination is expired 5852 * @param[out] pub where to write the public key 5853 * @param[out] sig where to write the signature 5854 * @return #TALER_EC_NONE on success 5855 */ 5856 enum TALER_ErrorCode 5857 TALER_exchange_online_denomination_expired_sign ( 5858 TALER_ExchangeSignCallback scb, 5859 struct GNUNET_TIME_Timestamp timestamp, 5860 const struct TALER_DenominationHashP *h_denom_pub, 5861 const char *op, 5862 struct TALER_ExchangePublicKeyP *pub, 5863 struct TALER_ExchangeSignatureP *sig); 5864 5865 5866 /** 5867 * Verify denomination expired signature. 5868 * 5869 * @param timestamp when was the error created 5870 * @param h_denom_pub hash of denomination that is expired 5871 * @param op character string describing the operation for which 5872 * the denomination is expired 5873 * @param pub where to write the public key 5874 * @param sig where to write the signature 5875 * @return #GNUNET_OK if the signature is valid 5876 */ 5877 enum GNUNET_GenericReturnValue 5878 TALER_exchange_online_denomination_expired_verify ( 5879 struct GNUNET_TIME_Timestamp timestamp, 5880 const struct TALER_DenominationHashP *h_denom_pub, 5881 const char *op, 5882 const struct TALER_ExchangePublicKeyP *pub, 5883 const struct TALER_ExchangeSignatureP *sig); 5884 5885 5886 /** 5887 * Create reserve closure signature. 5888 * 5889 * @param scb function to call to create the signature 5890 * @param timestamp time when the reserve was closed 5891 * @param closing_amount amount left in the reserve 5892 * @param closing_fee closing fee charged 5893 * @param payto target of the wire transfer 5894 * @param wtid wire transfer subject used 5895 * @param reserve_pub public key of the closed reserve 5896 * @param[out] pub where to write the public key 5897 * @param[out] sig where to write the signature 5898 * @return #TALER_EC_NONE on success 5899 */ 5900 enum TALER_ErrorCode 5901 TALER_exchange_online_reserve_closed_sign ( 5902 TALER_ExchangeSignCallback scb, 5903 struct GNUNET_TIME_Timestamp timestamp, 5904 const struct TALER_Amount *closing_amount, 5905 const struct TALER_Amount *closing_fee, 5906 const struct TALER_FullPayto payto, 5907 const struct TALER_WireTransferIdentifierRawP *wtid, 5908 const struct TALER_ReservePublicKeyP *reserve_pub, 5909 struct TALER_ExchangePublicKeyP *pub, 5910 struct TALER_ExchangeSignatureP *sig); 5911 5912 5913 /** 5914 * Verify reserve closure signature. 5915 * 5916 * @param timestamp time when the reserve was closed 5917 * @param closing_amount amount left in the reserve 5918 * @param closing_fee closing fee charged 5919 * @param payto target of the wire transfer 5920 * @param wtid wire transfer subject used 5921 * @param reserve_pub public key of the closed reserve 5922 * @param pub the public key of the exchange to check against 5923 * @param sig the signature to check 5924 * @return #GNUNET_OK if the signature is valid 5925 */ 5926 enum GNUNET_GenericReturnValue 5927 TALER_exchange_online_reserve_closed_verify ( 5928 struct GNUNET_TIME_Timestamp timestamp, 5929 const struct TALER_Amount *closing_amount, 5930 const struct TALER_Amount *closing_fee, 5931 const struct TALER_FullPayto payto, 5932 const struct TALER_WireTransferIdentifierRawP *wtid, 5933 const struct TALER_ReservePublicKeyP *reserve_pub, 5934 const struct TALER_ExchangePublicKeyP *pub, 5935 const struct TALER_ExchangeSignatureP *sig); 5936 5937 5938 /** 5939 * Create signature by exchange affirming that a reserve 5940 * has had certain attributes verified via KYC. 5941 * 5942 * @param scb function to call to create the signature 5943 * @param attest_timestamp our time 5944 * @param expiration_time when does the KYC data expire 5945 * @param reserve_pub for which reserve are attributes attested 5946 * @param attributes JSON object with attributes being attested to 5947 * @param[out] pub where to write the public key 5948 * @param[out] sig where to write the signature 5949 * @return #TALER_EC_NONE on success 5950 */ 5951 enum TALER_ErrorCode 5952 TALER_exchange_online_reserve_attest_details_sign ( 5953 TALER_ExchangeSignCallback scb, 5954 struct GNUNET_TIME_Timestamp attest_timestamp, 5955 struct GNUNET_TIME_Timestamp expiration_time, 5956 const struct TALER_ReservePublicKeyP *reserve_pub, 5957 const json_t *attributes, 5958 struct TALER_ExchangePublicKeyP *pub, 5959 struct TALER_ExchangeSignatureP *sig); 5960 5961 5962 /** 5963 * Verify signature by exchange affirming that a reserve 5964 * has had certain attributes verified via KYC. 5965 * 5966 * @param attest_timestamp our time 5967 * @param expiration_time when does the KYC data expire 5968 * @param reserve_pub for which reserve are attributes attested 5969 * @param attributes JSON object with attributes being attested to 5970 * @param pub exchange public key 5971 * @param sig exchange signature to verify 5972 * @return #GNUNET_OK if the signature is valid 5973 */ 5974 enum GNUNET_GenericReturnValue 5975 TALER_exchange_online_reserve_attest_details_verify ( 5976 struct GNUNET_TIME_Timestamp attest_timestamp, 5977 struct GNUNET_TIME_Timestamp expiration_time, 5978 const struct TALER_ReservePublicKeyP *reserve_pub, 5979 const json_t *attributes, 5980 struct TALER_ExchangePublicKeyP *pub, 5981 struct TALER_ExchangeSignatureP *sig); 5982 5983 5984 /** 5985 * Create signature by exchange affirming that a purse was created. 5986 * 5987 * @param scb function to call to create the signature 5988 * @param exchange_time our time 5989 * @param purse_expiration when will the purse expire 5990 * @param amount_without_fee total amount to be put into the purse (without deposit fees) 5991 * @param total_deposited total currently in the purse 5992 * @param purse_pub public key of the purse 5993 * @param h_contract_terms hash of the contract for the purse 5994 * @param[out] pub where to write the public key 5995 * @param[out] sig where to write the signature 5996 * @return #TALER_EC_NONE on success 5997 */ 5998 enum TALER_ErrorCode 5999 TALER_exchange_online_purse_created_sign ( 6000 TALER_ExchangeSignCallback scb, 6001 struct GNUNET_TIME_Timestamp exchange_time, 6002 struct GNUNET_TIME_Timestamp purse_expiration, 6003 const struct TALER_Amount *amount_without_fee, 6004 const struct TALER_Amount *total_deposited, 6005 const struct TALER_PurseContractPublicKeyP *purse_pub, 6006 const struct TALER_PrivateContractHashP *h_contract_terms, 6007 struct TALER_ExchangePublicKeyP *pub, 6008 struct TALER_ExchangeSignatureP *sig); 6009 6010 6011 /** 6012 * Verify exchange signature about a purse creation and balance. 6013 * 6014 * @param exchange_time our time 6015 * @param purse_expiration when will the purse expire 6016 * @param amount_without_fee total amount to be put into the purse (without deposit fees) 6017 * @param total_deposited total currently in the purse 6018 * @param purse_pub public key of the purse 6019 * @param h_contract_terms hash of the contract for the purse 6020 * @param pub the public key of the exchange to check against 6021 * @param sig the signature to check 6022 * @return #GNUNET_OK if the signature is valid 6023 */ 6024 enum GNUNET_GenericReturnValue 6025 TALER_exchange_online_purse_created_verify ( 6026 struct GNUNET_TIME_Timestamp exchange_time, 6027 struct GNUNET_TIME_Timestamp purse_expiration, 6028 const struct TALER_Amount *amount_without_fee, 6029 const struct TALER_Amount *total_deposited, 6030 const struct TALER_PurseContractPublicKeyP *purse_pub, 6031 const struct TALER_PrivateContractHashP *h_contract_terms, 6032 const struct TALER_ExchangePublicKeyP *pub, 6033 const struct TALER_ExchangeSignatureP *sig); 6034 6035 6036 /** 6037 * Sign affirmation that a purse was merged. 6038 * 6039 * @param scb function to call to create the signature 6040 * @param exchange_time our time 6041 * @param purse_expiration when does the purse expire 6042 * @param amount_without_fee total amount that should be in the purse without deposit fees 6043 * @param purse_pub public key of the purse 6044 * @param h_contract_terms hash of the contract of the purse 6045 * @param reserve_pub reserve the purse will be merged into 6046 * @param exchange_url exchange at which the @a reserve_pub lives 6047 * @param[out] pub where to write the public key 6048 * @param[out] sig where to write the signature 6049 * @return #TALER_EC_NONE on success 6050 */ 6051 enum TALER_ErrorCode 6052 TALER_exchange_online_purse_merged_sign ( 6053 TALER_ExchangeSignCallback scb, 6054 struct GNUNET_TIME_Timestamp exchange_time, 6055 struct GNUNET_TIME_Timestamp purse_expiration, 6056 const struct TALER_Amount *amount_without_fee, 6057 const struct TALER_PurseContractPublicKeyP *purse_pub, 6058 const struct TALER_PrivateContractHashP *h_contract_terms, 6059 const struct TALER_ReservePublicKeyP *reserve_pub, 6060 const char *exchange_url, 6061 struct TALER_ExchangePublicKeyP *pub, 6062 struct TALER_ExchangeSignatureP *sig); 6063 6064 6065 /** 6066 * Verify affirmation that a purse will be merged. 6067 * 6068 * @param exchange_time our time 6069 * @param purse_expiration when does the purse expire 6070 * @param amount_without_fee total amount that should be in the purse without deposit fees 6071 * @param purse_pub public key of the purse 6072 * @param h_contract_terms hash of the contract of the purse 6073 * @param reserve_pub reserve the purse will be merged into 6074 * @param exchange_url exchange at which the @a reserve_pub lives 6075 * @param pub the public key of the exchange to check against 6076 * @param sig the signature to check 6077 * @return #GNUNET_OK if the signature is valid 6078 */ 6079 enum GNUNET_GenericReturnValue 6080 TALER_exchange_online_purse_merged_verify ( 6081 struct GNUNET_TIME_Timestamp exchange_time, 6082 struct GNUNET_TIME_Timestamp purse_expiration, 6083 const struct TALER_Amount *amount_without_fee, 6084 const struct TALER_PurseContractPublicKeyP *purse_pub, 6085 const struct TALER_PrivateContractHashP *h_contract_terms, 6086 const struct TALER_ReservePublicKeyP *reserve_pub, 6087 const char *exchange_url, 6088 const struct TALER_ExchangePublicKeyP *pub, 6089 const struct TALER_ExchangeSignatureP *sig); 6090 6091 6092 /** 6093 * Sign information about the status of a purse. 6094 * 6095 * @param scb function to call to create the signature 6096 * @param merge_timestamp when was the purse merged (can be never) 6097 * @param deposit_timestamp when was the purse fully paid up (can be never) 6098 * @param balance current balance of the purse 6099 * @param[out] pub where to write the public key 6100 * @param[out] sig where to write the signature 6101 * @return #TALER_EC_NONE on success 6102 */ 6103 enum TALER_ErrorCode 6104 TALER_exchange_online_purse_status_sign ( 6105 TALER_ExchangeSignCallback scb, 6106 struct GNUNET_TIME_Timestamp merge_timestamp, 6107 struct GNUNET_TIME_Timestamp deposit_timestamp, 6108 const struct TALER_Amount *balance, 6109 struct TALER_ExchangePublicKeyP *pub, 6110 struct TALER_ExchangeSignatureP *sig); 6111 6112 6113 /** 6114 * Verify signature over information about the status of a purse. 6115 * 6116 * @param merge_timestamp when was the purse merged (can be never) 6117 * @param deposit_timestamp when was the purse fully paid up (can be never) 6118 * @param balance current balance of the purse 6119 * @param exchange_pub the public key of the exchange to check against 6120 * @param exchange_sig the signature to check 6121 * @return #GNUNET_OK if the signature is valid 6122 */ 6123 enum GNUNET_GenericReturnValue 6124 TALER_exchange_online_purse_status_verify ( 6125 struct GNUNET_TIME_Timestamp merge_timestamp, 6126 struct GNUNET_TIME_Timestamp deposit_timestamp, 6127 const struct TALER_Amount *balance, 6128 const struct TALER_ExchangePublicKeyP *exchange_pub, 6129 const struct TALER_ExchangeSignatureP *exchange_sig); 6130 6131 6132 /** 6133 * Create withdraw confirmation signature, for a request with age restriction set. 6134 * 6135 * @param scb function to call to create the signature 6136 * @param h_planchets withdraw commitment that identifies the n*kappa blinded coins 6137 * @param noreveal_index gamma cut-and-choose value chosen by the exchange 6138 * @param[out] pub where to write the exchange public key 6139 * @param[out] sig where to write the exchange signature 6140 * @return #TALER_EC_NONE on success 6141 */ 6142 enum TALER_ErrorCode 6143 TALER_exchange_online_withdraw_age_confirmation_sign ( 6144 TALER_ExchangeSignCallback scb, 6145 const struct TALER_HashBlindedPlanchetsP *h_planchets, 6146 uint32_t noreveal_index, 6147 struct TALER_ExchangePublicKeyP *pub, 6148 struct TALER_ExchangeSignatureP *sig); 6149 6150 /** 6151 * Create withdraw confirmation signature, for a request without age restriction. 6152 * 6153 * @param scb function to call to create the signature 6154 * @param h_planchets withdraw commitment that identifies the n blinded coins 6155 * @param[out] pub where to write the exchange public key 6156 * @param[out] sig where to write the exchange signature 6157 * @return #TALER_EC_NONE on success 6158 */ 6159 enum TALER_ErrorCode 6160 TALER_exchange_online_withdraw_confirmation_sign ( 6161 TALER_ExchangeSignCallback scb, 6162 const struct TALER_HashBlindedPlanchetsP *h_planchets, 6163 struct TALER_ExchangePublicKeyP *pub, 6164 struct TALER_ExchangeSignatureP *sig); 6165 6166 6167 /** 6168 * Verify an exchange withdraw confirmation, for a request without age restriction 6169 * 6170 * @param h_planchets Commitment over all n coin candidates from the original request to withdraw 6171 * @param exchange_pub The public key used for signing 6172 * @param exchange_sig The signature from the exchange 6173 */ 6174 enum GNUNET_GenericReturnValue 6175 TALER_exchange_online_withdraw_confirmation_verify ( 6176 const struct TALER_HashBlindedPlanchetsP *h_planchets, 6177 const struct TALER_ExchangePublicKeyP *exchange_pub, 6178 const struct TALER_ExchangeSignatureP *exchange_sig); 6179 6180 /** 6181 * Verify an exchange withdraw confirmation, for a withdraw request with age restriction 6182 * 6183 * @param h_planchets Commitment over all n (or n*kappa) coin candidates from the original request to withdraw 6184 * @param noreveal_index The index returned by the exchange 6185 * @param exchange_pub The public key used for signing 6186 * @param exchange_sig The signature from the exchange 6187 */ 6188 enum GNUNET_GenericReturnValue 6189 TALER_exchange_online_withdraw_age_confirmation_verify ( 6190 const struct TALER_HashBlindedPlanchetsP *h_planchets, 6191 uint32_t noreveal_index, 6192 const struct TALER_ExchangePublicKeyP *exchange_pub, 6193 const struct TALER_ExchangeSignatureP *exchange_sig); 6194 6195 /* ********************* offline signing ************************** */ 6196 6197 6198 /** 6199 * Create AML officer status change signature. 6200 * 6201 * @param officer_pub public key of the AML officer 6202 * @param officer_name name of the officer 6203 * @param change_date when to affect the status change 6204 * @param is_active true to enable the officer 6205 * @param read_only true to only allow read-only access 6206 * @param master_priv private key to sign with 6207 * @param[out] master_sig where to write the signature 6208 */ 6209 void 6210 TALER_exchange_offline_aml_officer_status_sign ( 6211 const struct TALER_AmlOfficerPublicKeyP *officer_pub, 6212 const char *officer_name, 6213 struct GNUNET_TIME_Timestamp change_date, 6214 bool is_active, 6215 bool read_only, 6216 const struct TALER_MasterPrivateKeyP *master_priv, 6217 struct TALER_MasterSignatureP *master_sig); 6218 6219 6220 /** 6221 * Verify AML officer status change signature. 6222 * 6223 * @param officer_pub public key of the AML officer 6224 * @param officer_name name of the officer 6225 * @param change_date when to affect the status change 6226 * @param is_active true to enable the officer 6227 * @param read_only true to only allow read-only access 6228 * @param master_pub public key to verify against 6229 * @param master_sig the signature the signature 6230 * @return #GNUNET_OK if the signature is valid 6231 */ 6232 enum GNUNET_GenericReturnValue 6233 TALER_exchange_offline_aml_officer_status_verify ( 6234 const struct TALER_AmlOfficerPublicKeyP *officer_pub, 6235 const char *officer_name, 6236 struct GNUNET_TIME_Timestamp change_date, 6237 bool is_active, 6238 bool read_only, 6239 const struct TALER_MasterPublicKeyP *master_pub, 6240 const struct TALER_MasterSignatureP *master_sig); 6241 6242 6243 /** 6244 * Create auditor addition signature. 6245 * 6246 * @param auditor_pub public key of the auditor 6247 * @param auditor_url URL of the auditor 6248 * @param start_date when to enable the auditor (for replay detection) 6249 * @param master_priv private key to sign with 6250 * @param[out] master_sig where to write the signature 6251 */ 6252 void 6253 TALER_exchange_offline_auditor_add_sign ( 6254 const struct TALER_AuditorPublicKeyP *auditor_pub, 6255 const char *auditor_url, 6256 struct GNUNET_TIME_Timestamp start_date, 6257 const struct TALER_MasterPrivateKeyP *master_priv, 6258 struct TALER_MasterSignatureP *master_sig); 6259 6260 6261 /** 6262 * Verify auditor add signature. 6263 * 6264 * @param auditor_pub public key of the auditor 6265 * @param auditor_url URL of the auditor 6266 * @param start_date when to enable the auditor (for replay detection) 6267 * @param master_pub public key to verify against 6268 * @param master_sig the signature the signature 6269 * @return #GNUNET_OK if the signature is valid 6270 */ 6271 enum GNUNET_GenericReturnValue 6272 TALER_exchange_offline_auditor_add_verify ( 6273 const struct TALER_AuditorPublicKeyP *auditor_pub, 6274 const char *auditor_url, 6275 struct GNUNET_TIME_Timestamp start_date, 6276 const struct TALER_MasterPublicKeyP *master_pub, 6277 const struct TALER_MasterSignatureP *master_sig); 6278 6279 6280 /** 6281 * Create auditor deletion signature. 6282 * 6283 * @param auditor_pub public key of the auditor 6284 * @param end_date when to disable the auditor (for replay detection) 6285 * @param master_priv private key to sign with 6286 * @param[out] master_sig where to write the signature 6287 */ 6288 void 6289 TALER_exchange_offline_auditor_del_sign ( 6290 const struct TALER_AuditorPublicKeyP *auditor_pub, 6291 struct GNUNET_TIME_Timestamp end_date, 6292 const struct TALER_MasterPrivateKeyP *master_priv, 6293 struct TALER_MasterSignatureP *master_sig); 6294 6295 6296 /** 6297 * Verify auditor del signature. 6298 * 6299 * @param auditor_pub public key of the auditor 6300 * @param end_date when to disable the auditor (for replay detection) 6301 * @param master_pub public key to verify against 6302 * @param master_sig the signature the signature 6303 * @return #GNUNET_OK if the signature is valid 6304 */ 6305 enum GNUNET_GenericReturnValue 6306 TALER_exchange_offline_auditor_del_verify ( 6307 const struct TALER_AuditorPublicKeyP *auditor_pub, 6308 struct GNUNET_TIME_Timestamp end_date, 6309 const struct TALER_MasterPublicKeyP *master_pub, 6310 const struct TALER_MasterSignatureP *master_sig); 6311 6312 6313 /** 6314 * Create denomination revocation signature. 6315 * 6316 * @param h_denom_pub hash of public denomination key to revoke 6317 * @param master_priv private key to sign with 6318 * @param[out] master_sig where to write the signature 6319 */ 6320 void 6321 TALER_exchange_offline_denomination_revoke_sign ( 6322 const struct TALER_DenominationHashP *h_denom_pub, 6323 const struct TALER_MasterPrivateKeyP *master_priv, 6324 struct TALER_MasterSignatureP *master_sig); 6325 6326 6327 /** 6328 * Verify denomination revocation signature. 6329 * 6330 * @param h_denom_pub hash of public denomination key to revoke 6331 * @param master_pub public key to verify against 6332 * @param master_sig the signature the signature 6333 * @return #GNUNET_OK if the signature is valid 6334 */ 6335 enum GNUNET_GenericReturnValue 6336 TALER_exchange_offline_denomination_revoke_verify ( 6337 const struct TALER_DenominationHashP *h_denom_pub, 6338 const struct TALER_MasterPublicKeyP *master_pub, 6339 const struct TALER_MasterSignatureP *master_sig); 6340 6341 6342 /** 6343 * Create signkey revocation signature. 6344 * 6345 * @param exchange_pub public signing key to revoke 6346 * @param master_priv private key to sign with 6347 * @param[out] master_sig where to write the signature 6348 */ 6349 void 6350 TALER_exchange_offline_signkey_revoke_sign ( 6351 const struct TALER_ExchangePublicKeyP *exchange_pub, 6352 const struct TALER_MasterPrivateKeyP *master_priv, 6353 struct TALER_MasterSignatureP *master_sig); 6354 6355 6356 /** 6357 * Verify signkey revocation signature. 6358 * 6359 * @param exchange_pub public signkey key to revoke 6360 * @param master_pub public key to verify against 6361 * @param master_sig the signature the signature 6362 * @return #GNUNET_OK if the signature is valid 6363 */ 6364 enum GNUNET_GenericReturnValue 6365 TALER_exchange_offline_signkey_revoke_verify ( 6366 const struct TALER_ExchangePublicKeyP *exchange_pub, 6367 const struct TALER_MasterPublicKeyP *master_pub, 6368 const struct TALER_MasterSignatureP *master_sig); 6369 6370 6371 /** 6372 * Create signkey validity signature. 6373 * 6374 * @param exchange_pub public signing key to validate 6375 * @param start_sign starting point of validity for signing 6376 * @param end_sign end point (exclusive) for validity for signing 6377 * @param end_legal legal end point of signature validity 6378 * @param master_priv private key to sign with 6379 * @param[out] master_sig where to write the signature 6380 */ 6381 void 6382 TALER_exchange_offline_signkey_validity_sign ( 6383 const struct TALER_ExchangePublicKeyP *exchange_pub, 6384 struct GNUNET_TIME_Timestamp start_sign, 6385 struct GNUNET_TIME_Timestamp end_sign, 6386 struct GNUNET_TIME_Timestamp end_legal, 6387 const struct TALER_MasterPrivateKeyP *master_priv, 6388 struct TALER_MasterSignatureP *master_sig); 6389 6390 6391 /** 6392 * Verify signkey validitity signature. 6393 * 6394 * @param exchange_pub public signkey key to validate 6395 * @param start_sign starting point of validity for signing 6396 * @param end_sign end point (exclusive) for validity for signing 6397 * @param end_legal legal end point of signature validity 6398 * @param master_pub public key to verify against 6399 * @param master_sig the signature the signature 6400 * @return #GNUNET_OK if the signature is valid 6401 */ 6402 enum GNUNET_GenericReturnValue 6403 TALER_exchange_offline_signkey_validity_verify ( 6404 const struct TALER_ExchangePublicKeyP *exchange_pub, 6405 struct GNUNET_TIME_Timestamp start_sign, 6406 struct GNUNET_TIME_Timestamp end_sign, 6407 struct GNUNET_TIME_Timestamp end_legal, 6408 const struct TALER_MasterPublicKeyP *master_pub, 6409 const struct TALER_MasterSignatureP *master_sig); 6410 6411 6412 /** 6413 * Create denomination key validity signature. 6414 * 6415 * @param h_denom_pub hash of the denomination's public key 6416 * @param stamp_start when does the exchange begin signing with this key 6417 * @param stamp_expire_withdraw when does the exchange end signing with this key 6418 * @param stamp_expire_deposit how long does the exchange accept the deposit of coins with this key 6419 * @param stamp_expire_legal how long does the exchange preserve information for legal disputes with this key 6420 * @param coin_value what is the value of coins signed with this key 6421 * @param fees fees for this denomination 6422 * @param master_priv private key to sign with 6423 * @param[out] master_sig where to write the signature 6424 */ 6425 void 6426 TALER_exchange_offline_denom_validity_sign ( 6427 const struct TALER_DenominationHashP *h_denom_pub, 6428 struct GNUNET_TIME_Timestamp stamp_start, 6429 struct GNUNET_TIME_Timestamp stamp_expire_withdraw, 6430 struct GNUNET_TIME_Timestamp stamp_expire_deposit, 6431 struct GNUNET_TIME_Timestamp stamp_expire_legal, 6432 const struct TALER_Amount *coin_value, 6433 const struct TALER_DenomFeeSet *fees, 6434 const struct TALER_MasterPrivateKeyP *master_priv, 6435 struct TALER_MasterSignatureP *master_sig); 6436 6437 6438 /** 6439 * Verify denomination key validity signature. 6440 * 6441 * @param h_denom_pub hash of the denomination's public key 6442 * @param stamp_start when does the exchange begin signing with this key 6443 * @param stamp_expire_withdraw when does the exchange end signing with this key 6444 * @param stamp_expire_deposit how long does the exchange accept the deposit of coins with this key 6445 * @param stamp_expire_legal how long does the exchange preserve information for legal disputes with this key 6446 * @param coin_value what is the value of coins signed with this key 6447 * @param fees fees for this denomination 6448 * @param master_pub public key to verify against 6449 * @param master_sig the signature the signature 6450 * @return #GNUNET_OK if the signature is valid 6451 */ 6452 enum GNUNET_GenericReturnValue 6453 TALER_exchange_offline_denom_validity_verify ( 6454 const struct TALER_DenominationHashP *h_denom_pub, 6455 struct GNUNET_TIME_Timestamp stamp_start, 6456 struct GNUNET_TIME_Timestamp stamp_expire_withdraw, 6457 struct GNUNET_TIME_Timestamp stamp_expire_deposit, 6458 struct GNUNET_TIME_Timestamp stamp_expire_legal, 6459 const struct TALER_Amount *coin_value, 6460 const struct TALER_DenomFeeSet *fees, 6461 const struct TALER_MasterPublicKeyP *master_pub, 6462 const struct TALER_MasterSignatureP *master_sig); 6463 6464 6465 /** 6466 * Create offline signature about an exchange's partners. 6467 * 6468 * @param partner_pub master public key of the partner 6469 * @param start_date validity period start 6470 * @param end_date validity period end 6471 * @param wad_frequency how often will we do wad transfers to this partner 6472 * @param wad_fee what is the wad fee to this partner 6473 * @param partner_base_url what is the base URL of the @a partner_pub exchange 6474 * @param master_priv private key to sign with 6475 * @param[out] master_sig where to write the signature 6476 */ 6477 void 6478 TALER_exchange_offline_partner_details_sign ( 6479 const struct TALER_MasterPublicKeyP *partner_pub, 6480 struct GNUNET_TIME_Timestamp start_date, 6481 struct GNUNET_TIME_Timestamp end_date, 6482 struct GNUNET_TIME_Relative wad_frequency, 6483 const struct TALER_Amount *wad_fee, 6484 const char *partner_base_url, 6485 const struct TALER_MasterPrivateKeyP *master_priv, 6486 struct TALER_MasterSignatureP *master_sig); 6487 6488 6489 /** 6490 * Verify signature about an exchange's partners. 6491 * 6492 * @param partner_pub master public key of the partner 6493 * @param start_date validity period start 6494 * @param end_date validity period end 6495 * @param wad_frequency how often will we do wad transfers to this partner 6496 * @param wad_fee what is the wad fee to this partner 6497 * @param partner_base_url what is the base URL of the @a partner_pub exchange 6498 * @param master_pub public key to verify against 6499 * @param master_sig the signature the signature 6500 * @return #GNUNET_OK if the signature is valid 6501 */ 6502 enum GNUNET_GenericReturnValue 6503 TALER_exchange_offline_partner_details_verify ( 6504 const struct TALER_MasterPublicKeyP *partner_pub, 6505 struct GNUNET_TIME_Timestamp start_date, 6506 struct GNUNET_TIME_Timestamp end_date, 6507 struct GNUNET_TIME_Relative wad_frequency, 6508 const struct TALER_Amount *wad_fee, 6509 const char *partner_base_url, 6510 const struct TALER_MasterPublicKeyP *master_pub, 6511 const struct TALER_MasterSignatureP *master_sig); 6512 6513 6514 /** 6515 * Create offline signature about wiring profits to a 6516 * regular non-escrowed account of the exchange. 6517 * 6518 * @param wtid (random) wire transfer ID to be used 6519 * @param date when was the profit drain approved (not exact time of execution) 6520 * @param amount how much should be wired 6521 * @param account_section configuration section of the 6522 * exchange specifying the account to be debited 6523 * @param payto_uri target account to be credited 6524 * @param master_priv private key to sign with 6525 * @param[out] master_sig where to write the signature 6526 */ 6527 void 6528 TALER_exchange_offline_profit_drain_sign ( 6529 const struct TALER_WireTransferIdentifierRawP *wtid, 6530 struct GNUNET_TIME_Timestamp date, 6531 const struct TALER_Amount *amount, 6532 const char *account_section, 6533 const struct TALER_FullPayto payto_uri, 6534 const struct TALER_MasterPrivateKeyP *master_priv, 6535 struct TALER_MasterSignatureP *master_sig); 6536 6537 6538 /** 6539 * Verify offline signature about wiring profits to a 6540 * regular non-escrowed account of the exchange. 6541 * 6542 * @param wtid (random) wire transfer ID to be used 6543 * @param date when was the profit drain approved (not exact time of execution) 6544 * @param amount how much should be wired 6545 * @param account_section configuration section of the 6546 * exchange specifying the account to be debited 6547 * @param payto_uri target account to be credited 6548 * @param master_pub public key to verify signature against 6549 * @param master_sig the signature 6550 * @return #GNUNET_OK if the signature is valid 6551 */ 6552 enum GNUNET_GenericReturnValue 6553 TALER_exchange_offline_profit_drain_verify ( 6554 const struct TALER_WireTransferIdentifierRawP *wtid, 6555 struct GNUNET_TIME_Timestamp date, 6556 const struct TALER_Amount *amount, 6557 const char *account_section, 6558 const struct TALER_FullPayto payto_uri, 6559 const struct TALER_MasterPublicKeyP *master_pub, 6560 const struct TALER_MasterSignatureP *master_sig); 6561 6562 6563 /** 6564 * Create security module EdDSA signature. 6565 * 6566 * @param exchange_pub public signing key to validate 6567 * @param start_sign starting point of validity for signing 6568 * @param duration how long will the key be in use 6569 * @param secm_priv security module key to sign with 6570 * @param[out] secm_sig where to write the signature 6571 */ 6572 void 6573 TALER_exchange_secmod_eddsa_sign ( 6574 const struct TALER_ExchangePublicKeyP *exchange_pub, 6575 struct GNUNET_TIME_Timestamp start_sign, 6576 struct GNUNET_TIME_Relative duration, 6577 const struct TALER_SecurityModulePrivateKeyP *secm_priv, 6578 struct TALER_SecurityModuleSignatureP *secm_sig); 6579 6580 6581 /** 6582 * Create security module denomination signature. 6583 * 6584 * @param h_cs hash of the CS public key to sign 6585 * @param section_name name of the section in the configuration 6586 * @param start_sign starting point of validity for signing 6587 * @param duration how long will the key be in use 6588 * @param secm_priv security module key to sign with 6589 * @param[out] secm_sig where to write the signature 6590 */ 6591 void 6592 TALER_exchange_secmod_cs_sign ( 6593 const struct TALER_CsPubHashP *h_cs, 6594 const char *section_name, 6595 struct GNUNET_TIME_Timestamp start_sign, 6596 struct GNUNET_TIME_Relative duration, 6597 const struct TALER_SecurityModulePrivateKeyP *secm_priv, 6598 struct TALER_SecurityModuleSignatureP *secm_sig); 6599 6600 6601 /** 6602 * Verify security module EdDSA signature. 6603 * 6604 * @param exchange_pub public signing key to validate 6605 * @param start_sign starting point of validity for signing 6606 * @param duration how long will the key be in use 6607 * @param secm_pub public key to verify against 6608 * @param secm_sig the signature the signature 6609 * @return #GNUNET_OK if the signature is valid 6610 */ 6611 enum GNUNET_GenericReturnValue 6612 TALER_exchange_secmod_eddsa_verify ( 6613 const struct TALER_ExchangePublicKeyP *exchange_pub, 6614 struct GNUNET_TIME_Timestamp start_sign, 6615 struct GNUNET_TIME_Relative duration, 6616 const struct TALER_SecurityModulePublicKeyP *secm_pub, 6617 const struct TALER_SecurityModuleSignatureP *secm_sig); 6618 6619 6620 /** 6621 * Create security module denomination signature. 6622 * 6623 * @param h_rsa hash of the RSA public key to sign 6624 * @param section_name name of the section in the configuration 6625 * @param start_sign starting point of validity for signing 6626 * @param duration how long will the key be in use 6627 * @param secm_priv security module key to sign with 6628 * @param[out] secm_sig where to write the signature 6629 */ 6630 void 6631 TALER_exchange_secmod_rsa_sign ( 6632 const struct TALER_RsaPubHashP *h_rsa, 6633 const char *section_name, 6634 struct GNUNET_TIME_Timestamp start_sign, 6635 struct GNUNET_TIME_Relative duration, 6636 const struct TALER_SecurityModulePrivateKeyP *secm_priv, 6637 struct TALER_SecurityModuleSignatureP *secm_sig); 6638 6639 6640 /** 6641 * Verify security module denomination signature. 6642 * 6643 * @param h_rsa hash of the public key to validate 6644 * @param section_name name of the section in the configuration 6645 * @param start_sign starting point of validity for signing 6646 * @param duration how long will the key be in use 6647 * @param secm_pub public key to verify against 6648 * @param secm_sig the signature the signature 6649 * @return #GNUNET_OK if the signature is valid 6650 */ 6651 enum GNUNET_GenericReturnValue 6652 TALER_exchange_secmod_rsa_verify ( 6653 const struct TALER_RsaPubHashP *h_rsa, 6654 const char *section_name, 6655 struct GNUNET_TIME_Timestamp start_sign, 6656 struct GNUNET_TIME_Relative duration, 6657 const struct TALER_SecurityModulePublicKeyP *secm_pub, 6658 const struct TALER_SecurityModuleSignatureP *secm_sig); 6659 6660 6661 /** 6662 * Verify security module denomination signature. 6663 * 6664 * @param h_cs hash of the public key to validate 6665 * @param section_name name of the section in the configuration 6666 * @param start_sign starting point of validity for signing 6667 * @param duration how long will the key be in use 6668 * @param secm_pub public key to verify against 6669 * @param secm_sig the signature the signature 6670 * @return #GNUNET_OK if the signature is valid 6671 */ 6672 enum GNUNET_GenericReturnValue 6673 TALER_exchange_secmod_cs_verify ( 6674 const struct TALER_CsPubHashP *h_cs, 6675 const char *section_name, 6676 struct GNUNET_TIME_Timestamp start_sign, 6677 struct GNUNET_TIME_Relative duration, 6678 const struct TALER_SecurityModulePublicKeyP *secm_pub, 6679 const struct TALER_SecurityModuleSignatureP *secm_sig); 6680 6681 6682 /** 6683 * Create denomination key validity signature by the auditor. 6684 * 6685 * @param auditor_url BASE URL of the auditor's API 6686 * @param h_denom_pub hash of the denomination's public key 6687 * @param master_pub master public key of the exchange 6688 * @param stamp_start when does the exchange begin signing with this key 6689 * @param stamp_expire_withdraw when does the exchange end signing with this key 6690 * @param stamp_expire_deposit how long does the exchange accept the deposit of coins with this key 6691 * @param stamp_expire_legal how long does the exchange preserve information for legal disputes with this key 6692 * @param coin_value what is the value of coins signed with this key 6693 * @param fees fees the exchange charges for this denomination 6694 * @param auditor_priv private key to sign with 6695 * @param[out] auditor_sig where to write the signature 6696 */ 6697 void 6698 TALER_auditor_denom_validity_sign ( 6699 const char *auditor_url, 6700 const struct TALER_DenominationHashP *h_denom_pub, 6701 const struct TALER_MasterPublicKeyP *master_pub, 6702 struct GNUNET_TIME_Timestamp stamp_start, 6703 struct GNUNET_TIME_Timestamp stamp_expire_withdraw, 6704 struct GNUNET_TIME_Timestamp stamp_expire_deposit, 6705 struct GNUNET_TIME_Timestamp stamp_expire_legal, 6706 const struct TALER_Amount *coin_value, 6707 const struct TALER_DenomFeeSet *fees, 6708 const struct TALER_AuditorPrivateKeyP *auditor_priv, 6709 struct TALER_AuditorSignatureP *auditor_sig); 6710 6711 6712 /** 6713 * Verify denomination key validity signature from auditor. 6714 * 6715 * @param auditor_url BASE URL of the auditor's API 6716 * @param h_denom_pub hash of the denomination's public key 6717 * @param master_pub master public key of the exchange 6718 * @param stamp_start when does the exchange begin signing with this key 6719 * @param stamp_expire_withdraw when does the exchange end signing with this key 6720 * @param stamp_expire_deposit how long does the exchange accept the deposit of coins with this key 6721 * @param stamp_expire_legal how long does the exchange preserve information for legal disputes with this key 6722 * @param coin_value what is the value of coins signed with this key 6723 * @param fees fees the exchange charges for this denomination 6724 * @param auditor_pub public key to verify against 6725 * @param auditor_sig the signature the signature 6726 * @return #GNUNET_OK if the signature is valid 6727 */ 6728 enum GNUNET_GenericReturnValue 6729 TALER_auditor_denom_validity_verify ( 6730 const char *auditor_url, 6731 const struct TALER_DenominationHashP *h_denom_pub, 6732 const struct TALER_MasterPublicKeyP *master_pub, 6733 struct GNUNET_TIME_Timestamp stamp_start, 6734 struct GNUNET_TIME_Timestamp stamp_expire_withdraw, 6735 struct GNUNET_TIME_Timestamp stamp_expire_deposit, 6736 struct GNUNET_TIME_Timestamp stamp_expire_legal, 6737 const struct TALER_Amount *coin_value, 6738 const struct TALER_DenomFeeSet *fees, 6739 const struct TALER_AuditorPublicKeyP *auditor_pub, 6740 const struct TALER_AuditorSignatureP *auditor_sig); 6741 6742 6743 /* **************** /wire account offline signing **************** */ 6744 6745 6746 /** 6747 * Create wire fee signature. 6748 * 6749 * @param payment_method the payment method 6750 * @param start_time when do the fees start to apply 6751 * @param end_time when do the fees start to apply 6752 * @param fees the wire fees 6753 * @param master_priv private key to sign with 6754 * @param[out] master_sig where to write the signature 6755 */ 6756 void 6757 TALER_exchange_offline_wire_fee_sign ( 6758 const char *payment_method, 6759 struct GNUNET_TIME_Timestamp start_time, 6760 struct GNUNET_TIME_Timestamp end_time, 6761 const struct TALER_WireFeeSet *fees, 6762 const struct TALER_MasterPrivateKeyP *master_priv, 6763 struct TALER_MasterSignatureP *master_sig); 6764 6765 6766 /** 6767 * Verify wire fee signature. 6768 * 6769 * @param payment_method the payment method 6770 * @param start_time when do the fees start to apply 6771 * @param end_time when do the fees start to apply 6772 * @param fees the wire fees 6773 * @param master_pub public key to verify against 6774 * @param master_sig the signature the signature 6775 * @return #GNUNET_OK if the signature is valid 6776 */ 6777 enum GNUNET_GenericReturnValue 6778 TALER_exchange_offline_wire_fee_verify ( 6779 const char *payment_method, 6780 struct GNUNET_TIME_Timestamp start_time, 6781 struct GNUNET_TIME_Timestamp end_time, 6782 const struct TALER_WireFeeSet *fees, 6783 const struct TALER_MasterPublicKeyP *master_pub, 6784 const struct TALER_MasterSignatureP *master_sig); 6785 6786 6787 /** 6788 * Create global fees signature. 6789 * 6790 * @param start_time when do the fees start to apply 6791 * @param end_time when do the fees start to apply 6792 * @param fees the global fees 6793 * @param purse_timeout how long do unmerged purses stay around 6794 * @param history_expiration how long do we keep the history of an account 6795 * @param purse_account_limit how many concurrent purses are free per account holder 6796 * @param master_priv private key to sign with 6797 * @param[out] master_sig where to write the signature 6798 */ 6799 void 6800 TALER_exchange_offline_global_fee_sign ( 6801 struct GNUNET_TIME_Timestamp start_time, 6802 struct GNUNET_TIME_Timestamp end_time, 6803 const struct TALER_GlobalFeeSet *fees, 6804 struct GNUNET_TIME_Relative purse_timeout, 6805 struct GNUNET_TIME_Relative history_expiration, 6806 uint32_t purse_account_limit, 6807 const struct TALER_MasterPrivateKeyP *master_priv, 6808 struct TALER_MasterSignatureP *master_sig); 6809 6810 6811 /** 6812 * Verify global fees signature. 6813 * 6814 * @param start_time when do the fees start to apply 6815 * @param end_time when do the fees start to apply 6816 * @param fees the global fees 6817 * @param purse_timeout how long do unmerged purses stay around 6818 * @param history_expiration how long do we keep the history of an account 6819 * @param purse_account_limit how many concurrent purses are free per account holder 6820 * @param master_pub public key to verify against 6821 * @param master_sig the signature the signature 6822 * @return #GNUNET_OK if the signature is valid 6823 */ 6824 enum GNUNET_GenericReturnValue 6825 TALER_exchange_offline_global_fee_verify ( 6826 struct GNUNET_TIME_Timestamp start_time, 6827 struct GNUNET_TIME_Timestamp end_time, 6828 const struct TALER_GlobalFeeSet *fees, 6829 struct GNUNET_TIME_Relative purse_timeout, 6830 struct GNUNET_TIME_Relative history_expiration, 6831 uint32_t purse_account_limit, 6832 const struct TALER_MasterPublicKeyP *master_pub, 6833 const struct TALER_MasterSignatureP *master_sig); 6834 6835 6836 /** 6837 * Create wire account addition signature. 6838 * 6839 * @param payto_uri bank account 6840 * @param conversion_url URL of the conversion service, or NULL if none 6841 * @param open_banking_gateway open banking gateway service, NULL if unavailable 6842 * @param prepared_transfer_url prepared transfer service, NULL if unavailable 6843 * @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec 6844 * @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec 6845 * @param now timestamp to use for the signature (rounded) 6846 * @param master_priv private key to sign with 6847 * @param[out] master_sig where to write the signature 6848 */ 6849 void 6850 TALER_exchange_offline_wire_add_sign ( 6851 const struct TALER_FullPayto payto_uri, 6852 const char *conversion_url, 6853 const char *open_banking_gateway, 6854 const char *prepared_transfer_url, 6855 const json_t *debit_restrictions, 6856 const json_t *credit_restrictions, 6857 struct GNUNET_TIME_Timestamp now, 6858 const struct TALER_MasterPrivateKeyP *master_priv, 6859 struct TALER_MasterSignatureP *master_sig); 6860 6861 6862 /** 6863 * Verify wire account addition signature. 6864 * 6865 * @param payto_uri bank account 6866 * @param conversion_url URL of the conversion service, or NULL if none 6867 * @param open_banking_gateway open banking gateway service, NULL if unavailable 6868 * @param prepared_transfer_url prepared transfer service, NULL if unavailable 6869 * @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec 6870 * @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec 6871 * @param sign_time timestamp when signature was created 6872 * @param master_pub public key to verify against 6873 * @param master_sig the signature the signature 6874 * @return #GNUNET_OK if the signature is valid 6875 */ 6876 enum GNUNET_GenericReturnValue 6877 TALER_exchange_offline_wire_add_verify ( 6878 const struct TALER_FullPayto payto_uri, 6879 const char *conversion_url, 6880 const char *open_banking_gateway, 6881 const char *prepared_transfer_url, 6882 const json_t *debit_restrictions, 6883 const json_t *credit_restrictions, 6884 struct GNUNET_TIME_Timestamp sign_time, 6885 const struct TALER_MasterPublicKeyP *master_pub, 6886 const struct TALER_MasterSignatureP *master_sig); 6887 6888 6889 /** 6890 * Verify wire account addition signature for legacy (pre v33) APIs. 6891 * 6892 * @param payto_uri bank account 6893 * @param conversion_url URL of the conversion service, or NULL if none 6894 * @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec 6895 * @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec 6896 * @param sign_time timestamp when signature was created 6897 * @param master_pub public key to verify against 6898 * @param master_sig the signature the signature 6899 * @return #GNUNET_OK if the signature is valid 6900 */ 6901 enum GNUNET_GenericReturnValue 6902 TALER_exchange_offline_wire_add_verify_32 ( 6903 const struct TALER_FullPayto payto_uri, 6904 const char *conversion_url, 6905 const json_t *debit_restrictions, 6906 const json_t *credit_restrictions, 6907 struct GNUNET_TIME_Timestamp sign_time, 6908 const struct TALER_MasterPublicKeyP *master_pub, 6909 const struct TALER_MasterSignatureP *master_sig); 6910 6911 6912 /** 6913 * Create wire account removal signature. 6914 * 6915 * @param payto_uri bank account 6916 * @param now timestamp to use for the signature (rounded) 6917 * @param master_priv private key to sign with 6918 * @param[out] master_sig where to write the signature 6919 */ 6920 void 6921 TALER_exchange_offline_wire_del_sign ( 6922 const struct TALER_FullPayto payto_uri, 6923 struct GNUNET_TIME_Timestamp now, 6924 const struct TALER_MasterPrivateKeyP *master_priv, 6925 struct TALER_MasterSignatureP *master_sig); 6926 6927 6928 /** 6929 * Verify wire account deletion signature. 6930 * 6931 * @param payto_uri bank account 6932 * @param sign_time timestamp when signature was created 6933 * @param master_pub public key to verify against 6934 * @param master_sig the signature the signature 6935 * @return #GNUNET_OK if the signature is valid 6936 */ 6937 enum GNUNET_GenericReturnValue 6938 TALER_exchange_offline_wire_del_verify ( 6939 const struct TALER_FullPayto payto_uri, 6940 struct GNUNET_TIME_Timestamp sign_time, 6941 const struct TALER_MasterPublicKeyP *master_pub, 6942 const struct TALER_MasterSignatureP *master_sig); 6943 6944 6945 /** 6946 * Check the signature in @a master_sig. 6947 * 6948 * @param payto_uri URI that is signed 6949 * @param conversion_url URL of the conversion service, or NULL if none 6950 * @param open_banking_gateway open banking gateway service, NULL if unavailable 6951 * @param prepared_transfer_url prepare transfer gateway service, NULL if unavailable 6952 * @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec 6953 * @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec 6954 * @param master_pub master public key of the exchange 6955 * @param master_sig signature of the exchange 6956 * @return #GNUNET_OK if signature is valid 6957 */ 6958 enum GNUNET_GenericReturnValue 6959 TALER_exchange_wire_signature_check ( 6960 const struct TALER_FullPayto payto_uri, 6961 const char *conversion_url, 6962 const char *open_banking_gateway, 6963 const char *prepared_transfer_url, 6964 const json_t *debit_restrictions, 6965 const json_t *credit_restrictions, 6966 const struct TALER_MasterPublicKeyP *master_pub, 6967 const struct TALER_MasterSignatureP *master_sig); 6968 6969 6970 /** 6971 * Check the signature in @a master_sig. Pre v33 version. 6972 * 6973 * @param payto_uri URI that is signed 6974 * @param conversion_url URL of the conversion service, or NULL if none 6975 * @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec 6976 * @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec 6977 * @param master_pub master public key of the exchange 6978 * @param master_sig signature of the exchange 6979 * @return #GNUNET_OK if signature is valid 6980 */ 6981 enum GNUNET_GenericReturnValue 6982 TALER_exchange_wire_signature_check32 ( 6983 const struct TALER_FullPayto payto_uri, 6984 const char *conversion_url, 6985 const json_t *debit_restrictions, 6986 const json_t *credit_restrictions, 6987 const struct TALER_MasterPublicKeyP *master_pub, 6988 const struct TALER_MasterSignatureP *master_sig); 6989 6990 6991 /** 6992 * Create a signed wire statement for the given account. 6993 * 6994 * @param payto_uri account specification 6995 * @param conversion_url URL of the conversion service, or NULL if none 6996 * @param open_banking_gateway open banking gateway service, NULL if unavailable 6997 * @param prepared_transfer_url wire transfer gateway service, NULL if unavailable 6998 * @param debit_restrictions JSON encoding of debit restrictions on the account; see AccountRestriction in the spec 6999 * @param credit_restrictions JSON encoding of credit restrictions on the account; see AccountRestriction in the spec 7000 * @param master_priv private key to sign with 7001 * @param[out] master_sig where to write the signature 7002 */ 7003 void 7004 TALER_exchange_wire_signature_make ( 7005 const struct TALER_FullPayto payto_uri, 7006 const char *conversion_url, 7007 const char *open_banking_gateway, 7008 const char *prepared_transfer_url, 7009 const json_t *debit_restrictions, 7010 const json_t *credit_restrictions, 7011 const struct TALER_MasterPrivateKeyP *master_priv, 7012 struct TALER_MasterSignatureP *master_sig); 7013 7014 7015 /** 7016 * Compute the hash of the given wire details. The resulting 7017 * @a hc is what will be put into the contract between customer 7018 * and merchant for signing by both parties. 7019 * 7020 * @param payto_uri bank account 7021 * @param salt salt used to eliminate brute-force inversion 7022 * @param[out] hc set to the hash 7023 */ 7024 void 7025 TALER_merchant_wire_signature_hash ( 7026 const struct TALER_FullPayto payto_uri, 7027 const struct TALER_WireSaltP *salt, 7028 struct TALER_MerchantWireHashP *hc); 7029 7030 7031 /** 7032 * Check the signature in @a wire_s. 7033 * 7034 * @param payto_uri URL that is signed 7035 * @param salt the salt used to salt the @a payto_uri when hashing 7036 * @param merch_pub public key of the merchant 7037 * @param merch_sig signature of the merchant 7038 * @return #GNUNET_OK if signature is valid 7039 */ 7040 enum GNUNET_GenericReturnValue 7041 TALER_merchant_wire_signature_check ( 7042 const struct TALER_FullPayto payto_uri, 7043 const struct TALER_WireSaltP *salt, 7044 const struct TALER_MerchantPublicKeyP *merch_pub, 7045 const struct TALER_MerchantSignatureP *merch_sig); 7046 7047 7048 /** 7049 * Create a signed wire statement for the given account. 7050 * 7051 * @param payto_uri account specification 7052 * @param salt the salt used to salt the @a payto_uri when hashing 7053 * @param merch_priv private key to sign with 7054 * @param[out] merch_sig where to write the signature 7055 */ 7056 void 7057 TALER_merchant_wire_signature_make ( 7058 const struct TALER_FullPayto payto_uri, 7059 const struct TALER_WireSaltP *salt, 7060 const struct TALER_MerchantPrivateKeyP *merch_priv, 7061 struct TALER_MerchantSignatureP *merch_sig); 7062 7063 7064 /** 7065 * Sign a payment confirmation. 7066 * 7067 * @param h_contract_terms hash of the contact of the merchant with the customer 7068 * @param merch_priv private key to sign with 7069 * @param[out] merch_sig where to write the signature 7070 */ 7071 void 7072 TALER_merchant_pay_sign ( 7073 const struct TALER_PrivateContractHashP *h_contract_terms, 7074 const struct TALER_MerchantPrivateKeyP *merch_priv, 7075 struct TALER_MerchantSignatureP *merch_sig); 7076 7077 7078 /** 7079 * Verify payment confirmation signature. 7080 * 7081 * @param h_contract_terms hash of the contact of the merchant with the customer 7082 * @param merchant_pub public key of the merchant 7083 * @param merchant_sig signature to verify 7084 * @return #GNUNET_OK if the signature is valid 7085 */ 7086 enum GNUNET_GenericReturnValue 7087 TALER_merchant_pay_verify ( 7088 const struct TALER_PrivateContractHashP *h_contract_terms, 7089 const struct TALER_MerchantPublicKeyP *merchant_pub, 7090 const struct TALER_MerchantSignatureP *merchant_sig); 7091 7092 7093 /** 7094 * Sign contract sent by the merchant to the wallet. 7095 * 7096 * @param h_contract_terms hash of the contract terms 7097 * @param merchant_priv private key to sign with 7098 * @param[out] merchant_sig where to write the signature 7099 */ 7100 void 7101 TALER_merchant_contract_sign ( 7102 const struct TALER_PrivateContractHashP *h_contract_terms, 7103 const struct TALER_MerchantPrivateKeyP *merchant_priv, 7104 struct TALER_MerchantSignatureP *merchant_sig); 7105 7106 7107 /** 7108 * Verify contract signature sent by the merchant to the wallet. 7109 * 7110 * @param h_contract_terms hash of the contract terms 7111 * @param merchant_pub public key of the merchant 7112 * @param merchant_sig signature to check 7113 * @return #GNUNET_OK if the signature is valid 7114 */ 7115 enum GNUNET_GenericReturnValue 7116 TALER_merchant_contract_verify ( 7117 const struct TALER_PrivateContractHashP *h_contract_terms, 7118 const struct TALER_MerchantPublicKeyP *merchant_pub, 7119 struct TALER_MerchantSignatureP *merchant_sig); 7120 7121 7122 /** 7123 * @brief Representation of an age commitment: one public key per age group. 7124 * 7125 * The number of keys must be be the same as the number of bits set in the 7126 * corresponding age mask. 7127 */ 7128 struct TALER_AgeCommitment 7129 { 7130 7131 /** 7132 * The age mask defines the age groups that were a parameter during the 7133 * generation of this age commitment 7134 */ 7135 struct TALER_AgeMask mask; 7136 7137 /** 7138 * The number of public keys, which must be the same as the number of 7139 * groups in the mask. 7140 */ 7141 size_t num; 7142 7143 /** 7144 * The list of @e num public keys. In must have same size as the number of 7145 * age groups defined in the mask. 7146 * 7147 * A hash of this list is the hashed commitment that goes into FDC 7148 * calculation during the withdraw and refresh operations for new coins. That 7149 * way, the particular age commitment becomes mandatory and bound to a coin. 7150 * 7151 * The list has been allocated via GNUNET_malloc(). 7152 */ 7153 struct TALER_AgeCommitmentPublicKeyP *pubs; 7154 }; 7155 7156 7157 /** 7158 * @brief Proof for a particular age commitment, used in age attestation 7159 * 7160 * This struct is used in a call to TALER_age_commitment_attest to create an 7161 * attestation for a minimum age (if that minimum age is less or equal to the 7162 * committed age for this proof). It consists of a list private keys, one per 7163 * age group, for which the committed age is either lager or within that 7164 * particular group. 7165 */ 7166 struct TALER_AgeProof 7167 { 7168 /** 7169 * The number of private keys, which must be at most num_pub_keys. One minus 7170 * this number corresponds to the largest age group that is supported with 7171 * this age commitment. 7172 * **Note**, that this and the next field are only relevant on the wallet 7173 * side for attestation and derive operations. 7174 */ 7175 size_t num; 7176 7177 /** 7178 * List of @e num private keys. 7179 * 7180 * Note that the list can be _smaller_ than the corresponding list of public 7181 * keys. In that case, the wallet can sign off only for a subset of the age 7182 * groups. 7183 * 7184 * The list has been allocated via GNUNET_malloc. 7185 */ 7186 struct TALER_AgeCommitmentPrivateKeyP *privs; 7187 }; 7188 7189 7190 /** 7191 * @brief Commitment and Proof for a maximum age 7192 * 7193 * Calling TALER_age_restriction_commit on an (maximum) age value returns this 7194 * data structure. It consists of the proof, which is used to create 7195 * attestations for compatible minimum ages, and the commitment, which is used 7196 * to verify the attestations and derived commitments. 7197 * 7198 * The hash value of the commitment is bound to a particular coin with age 7199 * restriction. 7200 */ 7201 struct TALER_AgeCommitmentProof 7202 { 7203 /** 7204 * The commitment is used to verify a particular attestation. Its hash value 7205 * is bound to a particular coin with age restriction. This structure is 7206 * sent to the merchant in order to verify a particular attestation for a 7207 * minimum age. 7208 * In itself, it does not convey any information about the maximum age that 7209 * went into the call to TALER_age_restriction_commit. 7210 */ 7211 struct TALER_AgeCommitment commitment; 7212 7213 /** 7214 * The proof is used to create an attestation for a (compatible) minimum age. 7215 */ 7216 struct TALER_AgeProof proof; 7217 }; 7218 7219 7220 /** 7221 * @brief Generates a hash of the public keys in the age commitment. 7222 * 7223 * @param commitment the age commitment - one public key per age group 7224 * @param[out] hash resulting hash 7225 */ 7226 void 7227 TALER_age_commitment_hash ( 7228 const struct TALER_AgeCommitment *commitment, 7229 struct TALER_AgeCommitmentHashP *hash); 7230 7231 7232 /** 7233 * @brief Generates an age commitent for the given age. 7234 * 7235 * @param mask The age mask the defines the age groups 7236 * @param age The actual age for which an age commitment is generated 7237 * @param seed The seed that goes into the key generation. MUST be chosen uniformly random. 7238 * @param[out] comm_proof The generated age commitment, ->privs and ->pubs allocated via GNUNET_malloc() on success 7239 */ 7240 void 7241 TALER_age_restriction_commit ( 7242 const struct TALER_AgeMask *mask, 7243 uint8_t age, 7244 const struct GNUNET_HashCode *seed, 7245 struct TALER_AgeCommitmentProof *comm_proof); 7246 7247 7248 /** 7249 * @brief Derives another, equivalent age commitment with proof for a given one. 7250 * 7251 * @param orig Original age commitment with proof 7252 * @param salt Salt to randomly move the points on the elliptic curve in order to generate another, equivalent commitment. 7253 * @param[out] derived The resulting age commitment, ->priv and ->pub allocated via GNUNET_malloc() on success. 7254 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 7255 */ 7256 enum GNUNET_GenericReturnValue 7257 TALER_age_commitment_proof_derive ( 7258 const struct TALER_AgeCommitmentProof *orig, 7259 const struct GNUNET_HashCode *salt, 7260 struct TALER_AgeCommitmentProof *derived); 7261 7262 7263 /** 7264 * @brief Derives another, equivalent age commitment with proof for a given one, 7265 * for a given planchet secret of a new coin. 7266 * 7267 * @param orig Original age commitment with proof 7268 * @param secret Planchet secret for the new coin from which the new age commitment with proof is derived from 7269 * @param[out] derived The resulting age commitment, ->priv and ->pub allocated via GNUNET_malloc() on success. 7270 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 7271 */ 7272 enum GNUNET_GenericReturnValue 7273 TALER_age_commitment_proof_derive_from_secret ( 7274 const struct TALER_AgeCommitmentProof *orig, 7275 const struct TALER_PlanchetMasterSecretP *secret, 7276 struct TALER_AgeCommitmentProof *derived); 7277 7278 7279 /** 7280 * @brief Derives another, equivalent age commitment (without proof) for a given one. 7281 * 7282 * @param orig Original age commitment 7283 * @param salt Salt to randomly move the points on the elliptic curve in order to generate another, equivalent commitment. 7284 * @param[out] derived The resulting age commitment, ->pub allocated via GNUNET_malloc() on success. 7285 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 7286 */ 7287 enum GNUNET_GenericReturnValue 7288 TALER_age_commitment_derive ( 7289 const struct TALER_AgeCommitment *orig, 7290 const struct GNUNET_HashCode *salt, 7291 struct TALER_AgeCommitment *derived); 7292 7293 7294 /** 7295 * @brief Derives another, equivalent age commitment (without proof) for a given one, 7296 * from the planchet secret. 7297 * 7298 * @param orig Original age commitment 7299 * @param secret Planchet secret for the new coin from which the new age commitment is derived from 7300 * @param[out] derived The resulting age commitment, ->pub allocated via GNUNET_malloc() on success. 7301 * @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise 7302 */ 7303 enum GNUNET_GenericReturnValue 7304 TALER_age_commitment_derive_from_secret ( 7305 const struct TALER_AgeCommitment *orig, 7306 const struct TALER_PlanchetMasterSecretP *secret, 7307 struct TALER_AgeCommitment *derived); 7308 7309 7310 /** 7311 * @brief Provide attestation for a given age, from a given age commitment, if possible. 7312 * 7313 * @param comm_proof The age commitment to be used for attestation. For successful attestation, it must contain the private key for the corresponding age group. 7314 * @param age Age (not age group) for which the an attestation should be done 7315 * @param[out] attest Signature of the age with the appropriate key from the age commitment for the corresponding age group, if applicable. 7316 * @return #GNUNET_OK on success, #GNUNET_NO when no attestation can be made for that age with the given commitment, #GNUNET_SYSERR otherwise 7317 */ 7318 enum GNUNET_GenericReturnValue 7319 TALER_age_commitment_attest ( 7320 const struct TALER_AgeCommitmentProof *comm_proof, 7321 uint8_t age, 7322 struct TALER_AgeAttestationP *attest); 7323 7324 7325 /** 7326 * @brief Verify the attestation for an given age and age commitment 7327 * 7328 * @param commitment The age commitment that went into the attestation. Only the public keys are needed. 7329 * @param age Age (not age group) for which the an attestation should be done 7330 * @param attest Signature of the age with the appropriate key from the age commitment for the corresponding age group, if applicable. 7331 * @return #GNUNET_OK when the attestation was successful, #GNUNET_NO no attestation couldn't be verified, #GNUNET_SYSERR otherwise 7332 */ 7333 enum GNUNET_GenericReturnValue 7334 TALER_age_commitment_verify ( 7335 const struct TALER_AgeCommitment *commitment, 7336 uint8_t age, 7337 const struct TALER_AgeAttestationP *attest); 7338 7339 7340 /** 7341 * @brief helper function to free memory of a struct TALER_AgeCommitment 7342 * 7343 * @param ac the commitment from which all memory should be freed. 7344 */ 7345 void 7346 TALER_age_commitment_free ( 7347 struct TALER_AgeCommitment *ac); 7348 7349 7350 /** 7351 * @brief helper function to free memory of a struct TALER_AgeProof 7352 * 7353 * @param ap the proof of commitment from which all memory should be freed. 7354 */ 7355 void 7356 TALER_age_proof_free ( 7357 struct TALER_AgeProof *ap); 7358 7359 7360 /** 7361 * @brief helper function to free memory of a struct TALER_AgeCommitmentProof 7362 * 7363 * @param acp the commitment and its proof from which all memory should be freed. 7364 */ 7365 void 7366 TALER_age_commitment_proof_free ( 7367 struct TALER_AgeCommitmentProof *acp); 7368 7369 7370 /** 7371 * @brief helper function to allocate and copy a struct TALER_AgeCommitmentProof 7372 * 7373 * @param[in] acp The original age commitment proof 7374 * @return The deep copy of @e acp, allocated 7375 */ 7376 struct TALER_AgeCommitmentProof * 7377 TALER_age_commitment_proof_duplicate ( 7378 const struct TALER_AgeCommitmentProof *acp); 7379 7380 /** 7381 * @brief helper function to allocate and copy a struct TALER_AgeCommitment 7382 * 7383 * @param[in] ac The original age commitment 7384 * @return The deep copy of @e ac, allocated 7385 */ 7386 struct TALER_AgeCommitment * 7387 TALER_age_commitment_duplicate ( 7388 const struct TALER_AgeCommitment *ac); 7389 7390 7391 /** 7392 * @brief helper function to copy a struct TALER_AgeCommitmentProof 7393 * 7394 * @param[out] nacp The struct to copy the data into, with freshly allocated and copied keys. 7395 * @param[in] acp The original age commitment proof 7396 */ 7397 void 7398 TALER_age_commitment_proof_deep_copy ( 7399 struct TALER_AgeCommitmentProof *nacp, 7400 const struct TALER_AgeCommitmentProof *acp); 7401 7402 /** 7403 * @brief helper function to copy a struct TALER_AgeCommitment 7404 * 7405 * @param[out] nac The struct to copy the data into, with freshly allocated and copied keys. 7406 * @param[in] ac The original age commitment 7407 */ 7408 void 7409 TALER_age_commitment_deep_copy ( 7410 struct TALER_AgeCommitment *nac, 7411 const struct TALER_AgeCommitment*ac); 7412 7413 /** 7414 * @brief For age-withdraw, clients have to prove that the public keys for all 7415 * age groups larger than the allowed maximum age group are derived by scalar 7416 * multiplication from this Edx25519 public key (in Crockford Base32 encoding): 7417 * 7418 * DZJRF6HXN520505XDAWM8NMH36QV9J3VH77265WQ09EBQ76QSKCG 7419 * 7420 * Its private key was chosen randomly and then deleted. 7421 */ 7422 extern struct 7423 #ifndef AGE_RESTRICTION_WITH_ECDSA 7424 GNUNET_CRYPTO_Edx25519PublicKey 7425 #else 7426 GNUNET_CRYPTO_EcdsaPublicKey 7427 #endif 7428 TALER_age_commitment_base_public_key; 7429 7430 /** 7431 * @brief Similar to TALER_age_restriction_commit, but takes the coin's 7432 * private key as seed input and calculates the public keys in the slots larger 7433 * than the given age as derived from TALER_age_commitment_base_public_key. 7434 * 7435 * See https://docs.taler.net/core/api-exchange.html#withdraw-with-age-restriction 7436 * 7437 * @param secret The master secret of the coin from which we derive the age restriction 7438 * @param mask The age mask, defining the age groups 7439 * @param max_age The maximum age for this coin. 7440 * @param[out] comm_proof The commitment and proof for age restriction for age @a max_age 7441 */ 7442 void 7443 TALER_age_restriction_from_secret ( 7444 const struct TALER_PlanchetMasterSecretP *secret, 7445 const struct TALER_AgeMask *mask, 7446 const uint8_t max_age, 7447 struct TALER_AgeCommitmentProof *comm_proof); 7448 7449 7450 /** 7451 * Group of Denominations. These are the common fields of an array of 7452 * denominations. 7453 * 7454 * The corresponding JSON-blob will also contain an array of particular 7455 * denominations with only the timestamps, cipher-specific public key and the 7456 * master signature. 7457 */ 7458 struct TALER_DenominationGroup 7459 { 7460 7461 /** 7462 * Value of coins in this denomination group. 7463 */ 7464 struct TALER_Amount value; 7465 7466 /** 7467 * Fee structure for all coins in the group. 7468 */ 7469 struct TALER_DenomFeeSet fees; 7470 7471 /** 7472 * Cipher used for the denomination. 7473 */ 7474 enum GNUNET_CRYPTO_BlindSignatureAlgorithm cipher; 7475 7476 /** 7477 * Age mask for the denomination. 7478 */ 7479 struct TALER_AgeMask age_mask; 7480 7481 }; 7482 7483 7484 /** 7485 * Compute a unique key for the meta data of a denomination group. 7486 * 7487 * @param dg denomination group to evaluate 7488 * @param[out] key key to set 7489 */ 7490 void 7491 TALER_denomination_group_get_key ( 7492 const struct TALER_DenominationGroup *dg, 7493 struct GNUNET_HashCode *key); 7494 7495 7496 #endif