exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

kyc_signatures.c (2166B)


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