kyc_signatures.c (2138B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2024 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 kyc_signatures.c 18 * @brief Utility functions for KYC account holders 19 * @author Christian Grothoff 20 */ 21 #include "taler/taler_util.h" 22 #include "taler/taler_signatures.h" 23 24 25 GNUNET_NETWORK_STRUCT_BEGIN 26 27 /** 28 * @brief Format used to generate the signature on a 29 * KYC authorization. 30 */ 31 struct TALER_KycQueryPS 32 { 33 /** 34 * Purpose must be #TALER_SIGNATURE_KYC_AUTH. 35 * Used for an EdDSA signature with the `union TALER_AccountPublicKeyP`. 36 */ 37 struct GNUNET_CRYPTO_SignaturePurpose purpose; 38 39 }; 40 41 GNUNET_NETWORK_STRUCT_END 42 43 44 void 45 TALER_account_kyc_auth_sign ( 46 const union TALER_AccountPrivateKeyP *account_priv, 47 union TALER_AccountSignatureP *account_sig) 48 { 49 struct TALER_KycQueryPS aq = { 50 .purpose.purpose = htonl (TALER_SIGNATURE_KYC_AUTH), 51 .purpose.size = htonl (sizeof (aq)) 52 }; 53 54 GNUNET_CRYPTO_eddsa_sign ( 55 &account_priv->reserve_priv.eddsa_priv, 56 &aq, 57 &account_sig->reserve_sig.eddsa_signature); 58 } 59 60 61 enum GNUNET_GenericReturnValue 62 TALER_account_kyc_auth_verify ( 63 const union TALER_AccountPublicKeyP *account_pub, 64 const union TALER_AccountSignatureP *account_sig) 65 { 66 struct TALER_KycQueryPS aq = { 67 .purpose.purpose = htonl (TALER_SIGNATURE_KYC_AUTH), 68 .purpose.size = htonl (sizeof (aq)) 69 }; 70 71 return GNUNET_CRYPTO_eddsa_verify ( 72 TALER_SIGNATURE_KYC_AUTH, 73 &aq, 74 &account_sig->reserve_sig.eddsa_signature, 75 &account_pub->reserve_pub.eddsa_pub); 76 } 77 78 79 /* end of kyc_signatures.c */