[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated: -more helper functions for merch
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated: -more helper functions for merchant |
Date: |
Tue, 10 Dec 2024 13:35:19 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
The following commit(s) were added to refs/heads/master by this push:
new 0c4f43dd5 -more helper functions for merchant
0c4f43dd5 is described below
commit 0c4f43dd5fec6456e5bd9f5a69380ce7c6b357ca
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Dec 10 13:34:52 2024 +0100
-more helper functions for merchant
---
contrib/gana | 2 +-
src/include/taler_crypto_lib.h | 38 ++++++++++++-
src/include/taler_json_lib.h | 9 +++
src/json/json_helper.c | 124 +++++++++++++++++++++++++++++++++++++++++
src/util/tokens.c | 35 ++++++++++++
5 files changed, 206 insertions(+), 2 deletions(-)
diff --git a/contrib/gana b/contrib/gana
index 4a422477b..7215dcc4d 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 4a422477b82fbe24a8cb623bbc2f085f3e4f7411
+Subproject commit 7215dcc4d54e1868cda7fd4f595bef8c7c3ab8cc
diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h
index 2616154e4..7447c600a 100644
--- a/src/include/taler_crypto_lib.h
+++ b/src/include/taler_crypto_lib.h
@@ -1467,7 +1467,7 @@ TALER_denom_ewv_rsa_singleton (void);
/**
- * Make a (deep) copy of the given @a bi_src to
+ * Make a copy of the given @a bi_src to
* @a bi_dst.
*
* @param[out] bi_dst target to copy to
@@ -2390,6 +2390,40 @@ struct TALER_TokenIssuePublicKey
};
+/**
+ * Free internals of @a token_pub, but not @a token_pub itself.
+ *
+ * @param[in] token_pub key to free
+ */
+void
+TALER_token_issue_pub_free (struct TALER_TokenIssuePublicKey *token_pub);
+
+
+/**
+ * Make a copy of the given @a tip_src to @a tip_dst.
+ *
+ * @param[out] tip_dst target to copy to
+ * @param tip_src public key to copy
+ */
+void
+TALER_token_issue_pub_copy (
+ struct TALER_TokenIssuePublicKey *tip_dst,
+ const struct TALER_TokenIssuePublicKey *tip_src);
+
+
+/**
+ * Compare two token issue public keys.
+ *
+ * @param tip1 first key to compare
+ * @param tip2 second key to compare
+ * @return 0 if the keys are equal, otherwise -1 or 1
+ */
+int
+TALER_token_issue_pub_cmp (
+ struct TALER_TokenIssuePublicKey *tip1,
+ const struct TALER_TokenIssuePublicKey *tip2);
+
+
/**
* Hash of a public key used to issue tokens for a token family.
*/
@@ -6252,6 +6286,7 @@ struct TALER_AgeCommitmentProof *
TALER_age_commitment_proof_duplicate (
const struct TALER_AgeCommitmentProof *acp);
+
/**
* @brief helper function to copy a struct TALER_AgeCommitmentProof
*
@@ -6263,6 +6298,7 @@ TALER_age_commitment_proof_deep_copy (
struct TALER_AgeCommitmentProof *nacp,
const struct TALER_AgeCommitmentProof *acp);
+
/**
* @brief For age-withdraw, clients have to prove that the public keys for all
* age groups larger than the allowed maximum age group are derived by scalar
diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h
index 7682ad492..8c06e7122 100644
--- a/src/include/taler_json_lib.h
+++ b/src/include/taler_json_lib.h
@@ -444,6 +444,15 @@ struct GNUNET_JSON_Specification
TALER_JSON_spec_denom_pub (const char *field,
struct TALER_DenominationPublicKey *pk);
+/**
+ * Generate line in parser specification for token issue public key.
+ *
+ * @param[out] pk key to initialize
+ * @return corresponding field spec
+ */
+struct GNUNET_JSON_Specification
+TALER_JSON_spec_token_pub (struct TALER_TokenIssuePublicKey *pk);
+
/**
* Generate line in parser specification for error codes.
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index bbf8723d0..6a6e8c908 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -696,6 +696,130 @@ TALER_JSON_spec_denom_pub (const char *field,
}
+/**
+ * Parse given JSON object to token issue public key.
+ *
+ * @param cls closure, NULL
+ * @param root the json object representing data
+ * @param[out] spec where to write the data
+ * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
+ */
+static enum GNUNET_GenericReturnValue
+parse_token_pub (void *cls,
+ json_t *root,
+ struct GNUNET_JSON_Specification *spec)
+{
+ struct TALER_TokenIssuePublicKey *token_pub = spec->ptr;
+ struct GNUNET_CRYPTO_BlindSignPublicKey *bsign_pub;
+ const char *cipher;
+ struct GNUNET_JSON_Specification dspec[] = {
+ GNUNET_JSON_spec_string ("cipher",
+ &cipher),
+ GNUNET_JSON_spec_end ()
+ };
+ const char *emsg;
+ unsigned int eline;
+
+ (void) cls;
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (root,
+ dspec,
+ &emsg,
+ &eline))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+
+ bsign_pub = GNUNET_new (struct GNUNET_CRYPTO_BlindSignPublicKey);
+ bsign_pub->rc = 1;
+ bsign_pub->cipher = string_to_cipher (cipher);
+ switch (bsign_pub->cipher)
+ {
+ case GNUNET_CRYPTO_BSA_INVALID:
+ break;
+ case GNUNET_CRYPTO_BSA_RSA:
+ {
+ struct GNUNET_JSON_Specification ispec[] = {
+ GNUNET_JSON_spec_rsa_public_key (
+ "rsa_pub",
+ &bsign_pub->details.rsa_public_key),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (root,
+ ispec,
+ &emsg,
+ &eline))
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (bsign_pub);
+ return GNUNET_SYSERR;
+ }
+ token_pub->public_key = bsign_pub;
+ return GNUNET_OK;
+ }
+ case GNUNET_CRYPTO_BSA_CS:
+ {
+ struct GNUNET_JSON_Specification ispec[] = {
+ GNUNET_JSON_spec_fixed ("cs_pub",
+ &bsign_pub->details.cs_public_key,
+ sizeof (bsign_pub->details.cs_public_key)),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (root,
+ ispec,
+ &emsg,
+ &eline))
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (bsign_pub);
+ return GNUNET_SYSERR;
+ }
+ token_pub->public_key = bsign_pub;
+ return GNUNET_OK;
+ }
+ }
+ GNUNET_break_op (0);
+ GNUNET_free (bsign_pub);
+ return GNUNET_SYSERR;
+}
+
+
+/**
+ * Cleanup data left from parsing token issue public key.
+ *
+ * @param cls closure, NULL
+ * @param[out] spec where to free the data
+ */
+static void
+clean_token_pub (void *cls,
+ struct GNUNET_JSON_Specification *spec)
+{
+ struct TALER_TokenIssuePublicKey *token_pub = spec->ptr;
+
+ (void) cls;
+ TALER_token_issue_pub_free (token_pub);
+}
+
+
+struct GNUNET_JSON_Specification
+TALER_JSON_spec_token_pub (struct TALER_TokenIssuePublicKey *pk)
+{
+ struct GNUNET_JSON_Specification ret = {
+ .parser = &parse_token_pub,
+ .cleaner = &clean_token_pub,
+ .ptr = pk
+ };
+
+ pk->public_key = NULL;
+ return ret;
+}
+
+
/**
* Parse given JSON object partially into a denomination public key.
*
diff --git a/src/util/tokens.c b/src/util/tokens.c
index 122663bf4..133c67fb6 100644
--- a/src/util/tokens.c
+++ b/src/util/tokens.c
@@ -236,3 +236,38 @@ TALER_token_issue_sig_unblind (
}
return GNUNET_OK;
}
+
+
+void
+TALER_token_issue_pub_free (struct TALER_TokenIssuePublicKey *token_pub)
+{
+ if (NULL != token_pub->public_key)
+ {
+ GNUNET_CRYPTO_blind_sign_pub_decref (token_pub->public_key);
+ token_pub->public_key = NULL;
+ }
+}
+
+
+int
+TALER_token_issue_pub_cmp (
+ struct TALER_TokenIssuePublicKey *tip1,
+ const struct TALER_TokenIssuePublicKey *tip2)
+{
+ if (tip1->public_key->cipher !=
+ tip2->public_key->cipher)
+ return (tip1->public_key->cipher >
+ tip2->public_key->cipher) ? 1 : -1;
+ return GNUNET_CRYPTO_bsign_pub_cmp (tip1->public_key,
+ tip2->public_key);
+}
+
+
+void
+TALER_token_issue_pub_copy (
+ struct TALER_TokenIssuePublicKey *tip_dst,
+ const struct TALER_TokenIssuePublicKey *tip_src)
+{
+ tip_dst->public_key
+ = GNUNET_CRYPTO_bsign_pub_incref (tip_src->public_key);
+}
--
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: -more helper functions for merchant,
gnunet <=