From 3eae999efc0cb923aebd2bf7214c5f4093217d4f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 31 Oct 2021 17:56:56 +0100 Subject: distinguish between blind and non-blind denomination signatures --- src/include/taler_crypto_lib.h | 64 +++++++++++++++++++++++++++++++---- src/include/taler_exchange_service.h | 2 +- src/include/taler_exchangedb_plugin.h | 6 ++-- src/include/taler_json_lib.h | 29 ++++++++++++++++ src/include/taler_pq_lib.h | 25 ++++++++++++++ 5 files changed, 116 insertions(+), 10 deletions(-) (limited to 'src/include') diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index af567ba02..69acfa0b3 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -523,6 +523,34 @@ struct TALER_DenominationSignature }; +/** + * @brief Type for *blinded* denomination signatures for Taler. + * Must be unblinded before it becomes valid. + */ +struct TALER_BlindedDenominationSignature +{ + + /** + * Type of the signature. + */ + enum TALER_DenominationCipher cipher; + + /** + * Details, depending on @e cipher. + */ + union + { + + /** + * If we use #TALER_DENOMINATION_RSA in @a cipher. + */ + struct GNUNET_CRYPTO_RsaSignature *blinded_rsa_signature; + + } details; + +}; + + /** * @brief Type of public signing keys for verifying blindly signed coins. */ @@ -662,6 +690,16 @@ void TALER_denom_sig_free (struct TALER_DenominationSignature *denom_sig); +/** + * Free internals of @a denom_sig, but not @a denom_sig itself. + * + * @param[in] denom_sig signature to free + */ +void +TALER_blinded_denom_sig_free ( + struct TALER_BlindedDenominationSignature *denom_sig); + + /** * Compute the hash of the given @a denom_pub. * @@ -697,6 +735,19 @@ TALER_denom_sig_deep_copy (struct TALER_DenominationSignature *denom_dst, const struct TALER_DenominationSignature *denom_src); +/** + * Make a (deep) copy of the given @a denom_src to + * @a denom_dst. + * + * @param[out] denom_dst target to copy to + * @param denom_str public key to copy + */ +void +TALER_blinded_denom_sig_deep_copy ( + struct TALER_BlindedDenominationSignature *denom_dst, + const struct TALER_BlindedDenominationSignature *denom_src); + + /** * Compare two denomination public keys. * @@ -1014,11 +1065,12 @@ TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk, * @return #GNUNET_OK on success */ enum GNUNET_GenericReturnValue -TALER_planchet_to_coin (const struct TALER_DenominationPublicKey *dk, - const struct GNUNET_CRYPTO_RsaSignature *blind_sig, - const struct TALER_PlanchetSecretsP *ps, - const struct TALER_CoinPubHash *c_hash, - struct TALER_FreshCoin *coin); +TALER_planchet_to_coin ( + const struct TALER_DenominationPublicKey *dk, + const struct TALER_BlindedDenominationSignature *blind_sig, + const struct TALER_PlanchetSecretsP *ps, + const struct TALER_CoinPubHash *c_hash, + struct TALER_FreshCoin *coin); /* ****************** Refresh crypto primitives ************* */ @@ -1215,7 +1267,7 @@ TALER_CRYPTO_helper_denom_poll (struct TALER_CRYPTO_DenominationHelper *dh); * @return signature, the value inside the structure will be NULL on failure, * see @a ec for details about the failure */ -struct TALER_DenominationSignature +struct TALER_BlindedDenominationSignature TALER_CRYPTO_helper_denom_sign ( struct TALER_CRYPTO_DenominationHelper *dh, const struct TALER_DenominationHash *h_denom_pub, diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h index 6daa120d4..361956cbe 100644 --- a/src/include/taler_exchange_service.h +++ b/src/include/taler_exchange_service.h @@ -1387,7 +1387,7 @@ typedef void (*TALER_EXCHANGE_Withdraw2Callback) ( void *cls, const struct TALER_EXCHANGE_HttpResponse *hr, - const struct GNUNET_CRYPTO_RsaSignature *blind_sig); + const struct TALER_BlindedDenominationSignature *blind_sig); /** diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h index aa67092ee..17df75281 100644 --- a/src/include/taler_exchangedb_plugin.h +++ b/src/include/taler_exchangedb_plugin.h @@ -696,9 +696,9 @@ struct TALER_EXCHANGEDB_CollectableBlindcoin { /** - * Our signature over the (blinded) coin. + * Our (blinded) signature over the (blinded) coin. */ - struct TALER_DenominationSignature sig; + struct TALER_BlindedDenominationSignature sig; /** * Hash of the denomination key (which coin was generated). @@ -1616,7 +1616,7 @@ struct TALER_EXCHANGEDB_RefreshRevealedCoin /** * Signature generated by the exchange over the coin (in blinded format). */ - struct TALER_DenominationSignature coin_sig; + struct TALER_BlindedDenominationSignature coin_sig; }; diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index e381a7a10..26df1f113 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -158,6 +158,21 @@ TALER_JSON_pack_denom_sig ( const struct TALER_DenominationSignature *sig); +/** + * Generate packer instruction for a JSON field of type + * blinded denomination signature (that needs to be + * unblinded before it becomes valid). + * + * @param name name of the field to add to the object + * @param sig signature + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_blinded_denom_sig ( + const char *name, + const struct TALER_BlindedDenominationSignature *sig); + + /** * Generate packer instruction for a JSON field of type * amount. @@ -327,6 +342,20 @@ TALER_JSON_spec_denom_sig (const char *field, struct TALER_DenominationSignature *sig); +/** + * Generate line in parser specification for a + * blinded denomination signature. + * + * @param field name of the field + * @param sig the blinded signature to initialize + * @return corresponding field spec + */ +struct GNUNET_JSON_Specification +TALER_JSON_spec_blinded_denom_sig ( + const char *field, + struct TALER_BlindedDenominationSignature *sig); + + /** * The expected field stores a possibly internationalized string. * Internationalization means that there is another field "$name_i18n" diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h index 07057722a..6e69cdf6d 100644 --- a/src/include/taler_pq_lib.h +++ b/src/include/taler_pq_lib.h @@ -77,6 +77,18 @@ TALER_PQ_query_param_denom_sig ( const struct TALER_DenominationSignature *denom_sig); +/** + * Generate query parameter for a blinded denomination signature. Internally, + * the various attributes of the signature will be serialized into on + * variable-size BLOB. + * + * @param x pointer to the query parameter to pass + */ +struct GNUNET_PQ_QueryParam +TALER_PQ_query_param_blinded_denom_sig ( + const struct TALER_BlindedDenominationSignature *denom_sig); + + /** * Generate query parameter for a JSON object (stored as a string * in the DB). Note that @a x must really be a JSON object or array, @@ -168,6 +180,19 @@ TALER_PQ_result_spec_denom_sig (const char *name, struct TALER_DenominationSignature *denom_sig); +/** + * Blinded denomination signature expected. + * + * @param name name of the field in the table + * @param[out] denom_sig where to store the denomination signature + * @return array entry for the result specification to use + */ +struct GNUNET_PQ_ResultSpec +TALER_PQ_result_spec_blinded_denom_sig ( + const char *name, + struct TALER_BlindedDenominationSignature *denom_sig); + + /** * json_t expected. * -- cgit v1.2.3