[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: Add abstractions: TALER_merchant
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: Add abstractions: TALER_merchant_pay_{sign,verify} |
Date: |
Sun, 17 Apr 2022 10:59:54 +0200 |
This is an automated email from the git hooks/post-receive script.
ttn pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new a7ad5a07 Add abstractions: TALER_merchant_pay_{sign,verify}
a7ad5a07 is described below
commit a7ad5a07e2eb80d942fcfd49a41330146ec36e45
Author: Thien-Thi Nguyen <ttn@gnuvola.org>
AuthorDate: Sun Apr 17 04:53:17 2022 -0400
Add abstractions: TALER_merchant_pay_{sign,verify}
Additionally, this change removes ‘struct TALER_PaymentResponsePS’
from the public API.
* src/include/taler_crypto_lib.h
(TALER_merchant_pay_sign): New func decl.
(TALER_merchant_pay_verify): New func decl.
* src/include/taler_signatures.h
(struct TALER_PaymentResponsePS): Delete.
* src/util/merchant_signatures.c
(struct TALER_PaymentResponsePS): Move here from taler_signatures.h.
(TALER_merchant_pay_sign): New func.
(TALER_merchant_pay_verify): New func.
---
src/include/taler_crypto_lib.h | 28 ++++++++++++++++++++++
src/include/taler_signatures.h | 18 --------------
src/util/merchant_signatures.c | 54 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 18 deletions(-)
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 0884bbf3..6be9db9a 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -4573,6 +4573,34 @@ TALER_merchant_wire_signature_make (
struct TALER_MerchantSignatureP *merch_sig);
+/**
+ * Sign a payment confirmation.
+ *
+ * @param h_contract_terms hash of the contact of the merchant with the
customer
+ * @param merch_priv private key to sign with
+ * @param[out] merch_sig where to write the signature
+ */
+void
+TALER_merchant_pay_sign (
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_MerchantPrivateKeyP *merch_priv,
+ struct GNUNET_CRYPTO_EddsaSignature *merch_sig);
+
+/**
+ * Verify payment confirmation signature.
+ *
+ * @param h_contract_terms hash of the contact of the merchant with the
customer
+ * @param merchant_pub public key of the merchant
+ * @param merchant_sig signature to verify
+ * @return #GNUNET_OK if the signature is valid
+ */
+enum GNUNET_GenericReturnValue
+TALER_merchant_pay_verify (
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantSignatureP *merchant_sig);
+
+
/* **************** /management/extensions offline signing **************** */
/**
diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h
index 45bdca59..249c01b6 100644
--- a/src/include/taler_signatures.h
+++ b/src/include/taler_signatures.h
@@ -440,24 +440,6 @@ struct TALER_ProposalDataPS
struct TALER_PrivateContractHashP hash;
};
-/**
- * Used by merchants to return signed responses to /pay requests.
- * Currently only used to return 200 OK signed responses.
- */
-struct TALER_PaymentResponsePS
-{
- /**
- * Set to #TALER_SIGNATURE_MERCHANT_PAYMENT_OK. Note that
- * unsuccessful payments are usually proven by some exchange's signature.
- */
- struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
-
- /**
- * Hash of the proposal data associated with this confirmation
- */
- struct TALER_PrivateContractHashP h_contract_terms;
-};
-
GNUNET_NETWORK_STRUCT_END
diff --git a/src/util/merchant_signatures.c b/src/util/merchant_signatures.c
index 4223b82b..0a7489f7 100644
--- a/src/util/merchant_signatures.c
+++ b/src/util/merchant_signatures.c
@@ -175,4 +175,58 @@ TALER_merchant_wire_signature_make (
}
+/**
+ * Used by merchants to return signed responses to /pay requests.
+ * Currently only used to return 200 OK signed responses.
+ */
+struct TALER_PaymentResponsePS
+{
+ /**
+ * Set to #TALER_SIGNATURE_MERCHANT_PAYMENT_OK. Note that
+ * unsuccessful payments are usually proven by some exchange's signature.
+ */
+ struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
+
+ /**
+ * Hash of the proposal data associated with this confirmation
+ */
+ struct TALER_PrivateContractHashP h_contract_terms;
+};
+
+void
+TALER_merchant_pay_sign (
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_MerchantPrivateKeyP *merch_priv,
+ struct GNUNET_CRYPTO_EddsaSignature *merch_sig)
+{
+ struct TALER_PaymentResponsePS mr = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK),
+ .purpose.size = htonl (sizeof (mr)),
+ .h_contract_terms = *h_contract_terms
+ };
+
+ GNUNET_CRYPTO_eddsa_sign (&merch_priv->eddsa_priv,
+ &mr,
+ merch_sig);
+}
+
+enum GNUNET_GenericReturnValue
+TALER_merchant_pay_verify (
+ const struct TALER_PrivateContractHashP *h_contract_terms,
+ const struct TALER_MerchantPublicKeyP *merchant_pub,
+ const struct TALER_MerchantSignatureP *merchant_sig)
+{
+ struct TALER_PaymentResponsePS pr = {
+ .purpose.purpose = htonl (TALER_SIGNATURE_MERCHANT_PAYMENT_OK),
+ .purpose.size = htonl (sizeof (pr)),
+ .h_contract_terms = *h_contract_terms
+ };
+
+ return
+ GNUNET_CRYPTO_eddsa_verify (TALER_SIGNATURE_MERCHANT_PAYMENT_OK,
+ &pr,
+ &merchant_sig->eddsa_sig,
+ &merchant_pub->eddsa_pub);
+}
+
/* end of merchant_signatures.c */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-exchange] branch master updated: Add abstractions: TALER_merchant_pay_{sign,verify},
gnunet <=