exchange

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

commit 6dbfa41e3fc6657eff28d11166d24301cdfa93ff
parent 8f3973b300fdbeb722b1692dc5b2817fb3f447e5
Author: Antoine A <>
Date:   Thu,  2 Jul 2026 12:12:55 +0200

common: new signature for prepared transfer API

Diffstat:
Msrc/bank-lib/bank_api_registration.c | 23+++++++++++++++++------
Msrc/include/taler/taler_bank_service.h | 4+++-
Msrc/include/taler/taler_crypto_lib.h | 54+++++++++++++++++++++++-------------------------------
Msrc/include/taler/taler_signatures.h | 12+++++++++---
Msrc/util/wallet_signatures.c | 127++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
5 files changed, 158 insertions(+), 62 deletions(-)

diff --git a/src/bank-lib/bank_api_registration.c b/src/bank-lib/bank_api_registration.c @@ -21,6 +21,7 @@ */ #include "bank_api_common.h" #include <microhttpd.h> /* just for HTTP status codes */ +#include "taler/taler_json_lib.h" #include "taler/taler_signatures.h" #include "taler/taler_curl_lib.h" @@ -283,24 +284,32 @@ struct TALER_BANK_RegistrationHandle * TALER_BANK_registration ( struct GNUNET_CURL_Context *ctx, const char *base_url, + const struct TALER_FullPayto *credit_account, const struct TALER_Amount *credit_amount, enum TALER_BANK_RegistrationType type, const union TALER_AccountPublicKeyP *account_pub, - const struct TALER_ReserveMapAuthorizationPrivateKeyP *authorization_priv, + const struct TALER_PreparedTransferAuthorizationPrivateKeyP * + authorization_priv, bool recurrent, TALER_BANK_RegistrationCallback res_cb, void *res_cb_cls) { - struct TALER_ReserveMapAuthorizationPublicKeyP authorization_pub; - struct TALER_ReserveMapAuthorizationSignatureP authorization_sig; + struct TALER_PreparedTransferAuthorizationPublicKeyP authorization_pub; + struct TALER_PreparedTransferAuthorizationSignatureP authorization_sig; struct TALER_BANK_RegistrationHandle *rh; const char *type_str; json_t *reg_obj; CURL *eh; - TALER_wallet_reserve_map_authorization_sign (account_pub, - authorization_priv, - &authorization_sig); + TALER_wallet_prepared_transfer_registration_sign (*credit_account, + credit_amount, + type == + TALER_BANK_REGISTRATION_TYPE_RESERVE, + recurrent, + + account_pub, + authorization_priv, + &authorization_sig); GNUNET_CRYPTO_eddsa_key_get_public (&authorization_priv->eddsa_priv, &authorization_pub.eddsa_pub); @@ -318,6 +327,8 @@ TALER_BANK_registration ( } reg_obj = GNUNET_JSON_PACK ( + TALER_JSON_pack_full_payto ("credit_account", + *credit_account), TALER_JSON_pack_amount ("credit_amount", credit_amount), GNUNET_JSON_pack_string ("type", diff --git a/src/include/taler/taler_bank_service.h b/src/include/taler/taler_bank_service.h @@ -1281,10 +1281,12 @@ struct TALER_BANK_RegistrationHandle * TALER_BANK_registration ( struct GNUNET_CURL_Context *ctx, const char *base_url, + const struct TALER_FullPayto *credit_account, const struct TALER_Amount *credit_amount, enum TALER_BANK_RegistrationType type, const union TALER_AccountPublicKeyP *account_pub, - const struct TALER_ReserveMapAuthorizationPrivateKeyP *authorization_priv, + const struct TALER_PreparedTransferAuthorizationPrivateKeyP * + authorization_priv, bool recurrent, TALER_BANK_RegistrationCallback res_cb, void *res_cb_cls); diff --git a/src/include/taler/taler_crypto_lib.h b/src/include/taler/taler_crypto_lib.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2024 Taler Systems SA + Copyright (C) 2014-2026 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -199,10 +199,10 @@ struct TALER_ReserveSignatureP /** - * @brief Type of public keys for Taler wire transfer + * @brief Type of public keys for Taler prepared transfer * subject reserve key mapping authorizations. */ -struct TALER_ReserveMapAuthorizationPublicKeyP +struct TALER_PreparedTransferAuthorizationPublicKeyP { /** * Taler uses EdDSA for reserves. @@ -211,10 +211,10 @@ struct TALER_ReserveMapAuthorizationPublicKeyP }; /** - * @brief Type of private keys for Taler wire transfer + * @brief Type of private keys for Taler prepared transfer * subject reserve key mapping authorizations. */ -struct TALER_ReserveMapAuthorizationPrivateKeyP +struct TALER_PreparedTransferAuthorizationPrivateKeyP { /** * Taler uses EdDSA for reserves. @@ -224,10 +224,10 @@ struct TALER_ReserveMapAuthorizationPrivateKeyP /** - * @brief Type of signatures used with Taler wire transfer + * @brief Type of signatures used with Taler prepared transfer * subject reserve key mapping authorizations. */ -struct TALER_ReserveMapAuthorizationSignatureP +struct TALER_PreparedTransferAuthorizationSignatureP { /** * Taler uses EdDSA for reserves. @@ -4936,36 +4936,28 @@ TALER_wallet_order_unclaim_verify ( const struct GNUNET_CRYPTO_EddsaSignature *nsig); -/** - * Create reserve map authorization signature. - * - * @param account_pub account key to authorize mapping to - * @param auth_priv private key for the authorization, corresponds to - * the wire transfer subject - * @param[out] auth_sig set to the signature made with purpose - * #TALER_SIGNATURE_WALLET_RESERVE_MAP_AUTHORIZATION - */ void -TALER_wallet_reserve_map_authorization_sign ( +TALER_wallet_prepared_transfer_registration_sign ( + const struct TALER_FullPayto credit_account, + const struct TALER_Amount *credit_amount, + // enum TALER_BANK_RegistrationType type, TODO solve the include cycle + bool is_reserve, + bool recurrent, const union TALER_AccountPublicKeyP *account_pub, - const struct TALER_ReserveMapAuthorizationPrivateKeyP *auth_priv, - struct TALER_ReserveMapAuthorizationSignatureP *auth_sig); + const struct TALER_PreparedTransferAuthorizationPrivateKeyP *auth_priv, + struct TALER_PreparedTransferAuthorizationSignatureP *auth_sig); -/** - * Verify reserve map authorization signature. - * - * @param account_pub account key to authorize mapping to - * @param auth_pub public key of the authorization, corresponds to - * the wire transfer subject - * @param auth_sig signature made with purpose - * #TALER_SIGNATURE_WALLET_RESERVE_MAP_AUTHORIZATION - */ enum GNUNET_GenericReturnValue -TALER_wallet_reserve_map_authorization_verify ( +TALER_wallet_prepared_transfer_registration_verify ( + const struct TALER_FullPayto credit_account, + const struct TALER_Amount *credit_amount, + // enum TALER_BANK_RegistrationType type, TODO solve the include cycle + bool is_reserve, + bool recurrent, const union TALER_AccountPublicKeyP *account_pub, - const struct TALER_ReserveMapAuthorizationPublicKeyP *auth_pub, - const struct TALER_ReserveMapAuthorizationSignatureP *auth_sig); + const struct TALER_PreparedTransferAuthorizationPublicKeyP *auth_pub, + const struct TALER_PreparedTransferAuthorizationSignatureP *auth_sig); /* ********************* merchant signing ************************** */ diff --git a/src/include/taler/taler_signatures.h b/src/include/taler/taler_signatures.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2022 Taler Systems SA + Copyright (C) 2014-2026 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -413,9 +413,15 @@ /** - * Signature used to set an account public key as new target of a given wire transfer subject identified by the respective authorization key. Used when shortening wire transfer subjects as per DD80. The public keypair used for signing corresponds to the wire transfer subject, while the account key is the reserve public key or the merchant public key the wire transfer should be mapped to. Note that despite its name, this signature is not only created by wallets, but also by merchant backends. + * Signature used to register a prepared transfer identified by the respective authorization key. */ -#define TALER_SIGNATURE_WALLET_RESERVE_MAP_AUTHORIZATION 1224 +#define TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER 1224 + + +/** + * Signature used to unregister a prepared transfer identified by the respective authorization key. + */ +#define TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_UNREGISTER 1225 /** diff --git a/src/util/wallet_signatures.c b/src/util/wallet_signatures.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2021-2023 Taler Systems SA + Copyright (C) 2021-2026 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -2196,38 +2196,77 @@ TALER_wallet_order_unclaim_verify ( GNUNET_NETWORK_STRUCT_BEGIN /** - * Message signed by reserve map authorization key. + * Message signed by prepared transfer authorization key. */ -struct TALER_ReserveMapAuthorizationPS +struct TALER_PreparedTransferRegisterPS { - /** - * Purpose is #TALER_SIGNATURE_WALLET_RESERVE_MAP_AUTHORIZATION - */ + * Purpose is #TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER + */ struct GNUNET_CRYPTO_SignaturePurpose purpose; - + struct TALER_FullPaytoHashP credit_account; + struct TALER_AmountNBO credit_amount; /** - * Account key to associate with the authorization key subject. - */ + * 1: reserve, 2: kyc + */ + uint32_t type; + /** + * 1: one-time, 2: recurrent + */ + uint16_t recurrent; + /** + * 1: EdDSA + */ + uint16_t alg; union TALER_AccountPublicKeyP account_pub; - }; + GNUNET_NETWORK_STRUCT_END void -TALER_wallet_reserve_map_authorization_sign ( +TALER_wallet_prepared_transfer_registration_sign ( + const struct TALER_FullPayto credit_account, + const struct TALER_Amount *credit_amount, + // enum TALER_BANK_RegistrationType type, TODO solve the include cycle + bool is_reserve, + bool recurrent, const union TALER_AccountPublicKeyP *account_pub, - const struct TALER_ReserveMapAuthorizationPrivateKeyP *auth_priv, - struct TALER_ReserveMapAuthorizationSignatureP *auth_sig) + const struct TALER_PreparedTransferAuthorizationPrivateKeyP *auth_priv, + struct TALER_PreparedTransferAuthorizationSignatureP *auth_sig) { - struct TALER_ReserveMapAuthorizationPS rcp = { + struct TALER_PreparedTransferRegisterPS rcp = { .purpose.size = htonl (sizeof (rcp)), - .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_MAP_AUTHORIZATION), + .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER) + , + .alg = htons (1), .account_pub = *account_pub }; + TALER_full_payto_hash (credit_account, + &rcp.credit_account); + TALER_amount_hton (&rcp.credit_amount, + credit_amount); + + if (is_reserve) + { + rcp.type = htonl (1); + } + else + { + rcp.type = htonl (2); + } + + if (recurrent) + { + rcp.recurrent = htons (2); + } + else + { + rcp.recurrent = htons (1); + } + GNUNET_assert (GNUNET_OK == GNUNET_CRYPTO_eddsa_sign_ ( &auth_priv->eddsa_priv, @@ -2237,23 +2276,69 @@ TALER_wallet_reserve_map_authorization_sign ( enum GNUNET_GenericReturnValue -TALER_wallet_reserve_map_authorization_verify ( +TALER_wallet_prepared_transfer_registration_verify ( + const struct TALER_FullPayto credit_account, + const struct TALER_Amount *credit_amount, + // enum TALER_BANK_RegistrationType type, TODO solve the include cycle + bool is_reserve, + bool recurrent, const union TALER_AccountPublicKeyP *account_pub, - const struct TALER_ReserveMapAuthorizationPublicKeyP *auth_pub, - const struct TALER_ReserveMapAuthorizationSignatureP *auth_sig) + const struct TALER_PreparedTransferAuthorizationPublicKeyP *auth_pub, + const struct TALER_PreparedTransferAuthorizationSignatureP *auth_sig) { - struct TALER_ReserveMapAuthorizationPS rcp = { + struct TALER_PreparedTransferRegisterPS rcp = { .purpose.size = htonl (sizeof (rcp)), - .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_RESERVE_MAP_AUTHORIZATION), + .purpose.purpose = htonl (TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER) + , + .alg = htonl (1), .account_pub = *account_pub }; + TALER_full_payto_hash (credit_account, + &rcp.credit_account); + TALER_amount_hton (&rcp.credit_amount, + credit_amount); + + if (is_reserve) + { + rcp.type = htonl (1); + } + else + { + rcp.type = htonl (2); + } + + if (recurrent) + { + rcp.recurrent = htonl (1); + } + else + { + rcp.recurrent = htonl (2); + } + return GNUNET_CRYPTO_eddsa_verify_ ( - TALER_SIGNATURE_WALLET_RESERVE_MAP_AUTHORIZATION, + TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_REGISTER, &rcp.purpose, &auth_sig->eddsa_signature, &auth_pub->eddsa_pub); } +GNUNET_NETWORK_STRUCT_BEGIN + +/** + * Message signed by prepared transfer authorization key. + */ +struct TALER_PreparedTransferUnregisterPS +{ + /** + * Purpose is #TALER_SIGNATURE_WALLET_PREPARED_TRANSFER_UNREGISTER + */ + struct GNUNET_CRYPTO_SignaturePurpose purpose; + struct GNUNET_TIME_TimestampNBO timestamp; +}; + +GNUNET_NETWORK_STRUCT_END + /* end of wallet_signatures.c */