diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-03-27 19:58:40 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-03-27 19:58:40 +0100 |
commit | eae1896a4bfc02b5d7586f81bbedfea69b29acc8 (patch) | |
tree | c3927c09435b74fb547a37fe0c75d01dd7b7f234 /src/include | |
parent | 7730a083494c0d49705f87b32fc85dfa6ed6809a (diff) |
major rename-fest for more constent symbol names
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/Makefile.am | 2 | ||||
-rw-r--r-- | src/include/taler_crypto_lib.h | 70 | ||||
-rw-r--r-- | src/include/taler_json_lib.h | 32 | ||||
-rw-r--r-- | src/include/taler_mint_service.h | 6 | ||||
-rw-r--r-- | src/include/taler_mintdb_plugin.h | 1029 | ||||
-rw-r--r-- | src/include/taler_pq_lib.h | 188 | ||||
-rw-r--r-- | src/include/taler_signatures.h | 77 | ||||
-rw-r--r-- | src/include/taler_util.h | 14 |
8 files changed, 1320 insertions, 98 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 60f8a3491..4d4c6771e 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -8,4 +8,6 @@ talerinclude_HEADERS = \ taler_json_lib.h \ taler_util.h \ taler_mint_service.h \ + taler_mintdb_plugin.h \ + taler_pq_lib.h \ taler_signatures.h diff --git a/src/include/taler_crypto_lib.h b/src/include/taler_crypto_lib.h index 3156e63ed..cfd588a52 100644 --- a/src/include/taler_crypto_lib.h +++ b/src/include/taler_crypto_lib.h @@ -32,7 +32,7 @@ GNUNET_NETWORK_STRUCT_BEGIN /** * Type of public keys for Taler reserves. */ -struct TALER_ReservePublicKey +struct TALER_ReservePublicKeyP { /** * Taler uses EdDSA for reserves. @@ -44,7 +44,7 @@ struct TALER_ReservePublicKey /** * Type of private keys for Taler reserves. */ -struct TALER_ReservePrivateKey +struct TALER_ReservePrivateKeyP { /** * Taler uses EdDSA for reserves. @@ -56,7 +56,7 @@ struct TALER_ReservePrivateKey /** * Type of signatures used with Taler reserves. */ -struct TALER_ReserveSignature +struct TALER_ReserveSignatureP { /** * Taler uses EdDSA for reserves. @@ -70,7 +70,7 @@ struct TALER_ReserveSignature * Merchants can issue refunds using the corresponding * private key. */ -struct TALER_MerchantPublicKey +struct TALER_MerchantPublicKeyP { /** * Taler uses EdDSA for merchants. @@ -84,7 +84,7 @@ struct TALER_MerchantPublicKey * Merchants can issue refunds using the corresponding * private key. */ -struct TALER_MerchantPrivateKey +struct TALER_MerchantPrivateKeyP { /** * Taler uses EdDSA for merchants. @@ -97,7 +97,7 @@ struct TALER_MerchantPrivateKey * Type of transfer public keys used during refresh * operations. */ -struct TALER_TransferPublicKey +struct TALER_TransferPublicKeyP { /** * Taler uses ECDSA for transfer keys. @@ -111,7 +111,7 @@ struct TALER_TransferPublicKey * Type of transfer public keys used during refresh * operations. */ -struct TALER_TransferPrivateKey +struct TALER_TransferPrivateKeyP { /** * Taler uses ECDSA for melting session keys. @@ -125,7 +125,7 @@ struct TALER_TransferPrivateKey * Type of online public keys used by the mint to sign * messages. */ -struct TALER_MintPublicKey +struct TALER_MintPublicKeyP { /** * Taler uses EdDSA for online mint message signing. @@ -138,7 +138,7 @@ struct TALER_MintPublicKey * Type of online public keys used by the mint to * sign messages. */ -struct TALER_MintPrivateKey +struct TALER_MintPrivateKeyP { /** * Taler uses EdDSA for online signatures sessions. @@ -150,7 +150,7 @@ struct TALER_MintPrivateKey /** * Type of signatures used by the mint to sign messages online. */ -struct TALER_MintSignature +struct TALER_MintSignatureP { /** * Taler uses EdDSA for online signatures sessions. @@ -162,7 +162,7 @@ struct TALER_MintSignature /** * Type of the offline master public key used by the mint. */ -struct TALER_MasterPublicKey +struct TALER_MasterPublicKeyP { /** * Taler uses EdDSA for the long-term offline master key. @@ -174,7 +174,7 @@ struct TALER_MasterPublicKey /** * Type of the offline master public keys used by the mint. */ -struct TALER_MasterPrivateKey +struct TALER_MasterPrivateKeyP { /** * Taler uses EdDSA for the long-term offline master key. @@ -186,7 +186,7 @@ struct TALER_MasterPrivateKey /** * Type of signatures by the offline master public key used by the mint. */ -struct TALER_MasterSignature +struct TALER_MasterSignatureP { /** * Taler uses EdDSA for the long-term offline master key. @@ -199,7 +199,7 @@ struct TALER_MasterSignature /** * Type of public keys for Taler coins. */ -struct TALER_CoinSpendPublicKey +union TALER_CoinSpendPublicKeyP { /** * Taler uses ECDSA for coins. @@ -211,7 +211,7 @@ struct TALER_CoinSpendPublicKey /** * Type of private keys for Taler coins. */ -struct TALER_CoinSpendPrivateKey +union TALER_CoinSpendPrivateKeyP { /** * Taler uses ECDSA for coins. @@ -223,7 +223,7 @@ struct TALER_CoinSpendPrivateKey /** * Type of signatures made with Taler coins. */ -struct TALER_CoinSpendSignature +union TALER_CoinSpendSignatureP { /** * Taler uses ECDSA for coins. @@ -294,7 +294,7 @@ struct TALER_CoinPublicInfo /** * The coin's public key. */ - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; /** * Public key representing the denomination of the coin @@ -331,10 +331,10 @@ GNUNET_NETWORK_STRUCT_BEGIN /** * Secret used to decrypt the key to decrypt link secrets. */ -struct TALER_TransferSecret +struct TALER_TransferSecretP { /** - * Secret used to encrypt/decrypt the `struct TALER_LinkSecret`. + * Secret used to encrypt/decrypt the `struct TALER_LinkSecretP`. * Must be (currently) a hash as this is what * #GNUNET_CRYPTO_ecc_ecdh() returns to us. */ @@ -345,7 +345,7 @@ struct TALER_TransferSecret /** * Secret used to decrypt refresh links. */ -struct TALER_LinkSecret +struct TALER_LinkSecretP { /** * Secret used to decrypt the refresh link data. @@ -357,25 +357,25 @@ struct TALER_LinkSecret /** * Encrypted secret used to decrypt refresh links. */ -struct TALER_EncryptedLinkSecret +struct TALER_EncryptedLinkSecretP { /** * Encrypted secret, must be the given size! */ - char enc[sizeof (struct TALER_LinkSecret)]; + char enc[sizeof (struct TALER_LinkSecretP)]; }; /** * Representation of an refresh link in cleartext. */ -struct TALER_RefreshLinkDecrypted +struct TALER_RefreshLinkDecryptedP { /** * Private key of the coin. */ - struct TALER_CoinSpendPrivateKey coin_priv; + union TALER_CoinSpendPrivateKeyP coin_priv; /** * Blinding key. @@ -408,7 +408,7 @@ struct TALER_RefreshLinkEncrypted /** * Encrypted private key of the coin. */ - char coin_priv_enc[sizeof (struct TALER_CoinSpendPrivateKey)]; + char coin_priv_enc[sizeof (union TALER_CoinSpendPrivateKeyP)]; }; @@ -423,9 +423,9 @@ struct TALER_RefreshLinkEncrypted * @return #GNUNET_OK on success */ int -TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc, - const struct TALER_TransferSecret *trans_sec, - struct TALER_LinkSecret *secret); +TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecretP *secret_enc, + const struct TALER_TransferSecretP *trans_sec, + struct TALER_LinkSecretP *secret); /** @@ -438,9 +438,9 @@ TALER_transfer_decrypt (const struct TALER_EncryptedLinkSecret *secret_enc, * @return #GNUNET_OK on success */ int -TALER_transfer_encrypt (const struct TALER_LinkSecret *secret, - const struct TALER_TransferSecret *trans_sec, - struct TALER_EncryptedLinkSecret *secret_enc); +TALER_transfer_encrypt (const struct TALER_LinkSecretP *secret, + const struct TALER_TransferSecretP *trans_sec, + struct TALER_EncryptedLinkSecretP *secret_enc); /** @@ -450,9 +450,9 @@ TALER_transfer_encrypt (const struct TALER_LinkSecret *secret, * @param secret shared secret to use for decryption * @return NULL on error */ -struct TALER_RefreshLinkDecrypted * +struct TALER_RefreshLinkDecryptedP * TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input, - const struct TALER_LinkSecret *secret); + const struct TALER_LinkSecretP *secret); /** @@ -463,8 +463,8 @@ TALER_refresh_decrypt (const struct TALER_RefreshLinkEncrypted *input, * @return NULL on error (should never happen) */ struct TALER_RefreshLinkEncrypted * -TALER_refresh_encrypt (const struct TALER_RefreshLinkDecrypted *input, - const struct TALER_LinkSecret *secret); +TALER_refresh_encrypt (const struct TALER_RefreshLinkDecryptedP *input, + const struct TALER_LinkSecretP *secret); /** diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index c5515966f..dbf2293d0 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -18,15 +18,15 @@ * @brief helper functions for JSON processing using libjansson * @author Sree Harsha Totakura <sreeharsha@totakura.in> */ -#ifndef TALER_JSON_LIB_H_ -#define TALER_JSON_LIB_H_ +#ifndef TALER_json_LIB_H_ +#define TALER_json_LIB_H_ #include <jansson.h> /** * Print JSON parsing related error information */ -#define TALER_JSON_warn(error) \ +#define TALER_json_warn(error) \ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, \ "JSON parsing failed at %s:%u: %s (%s)\n", \ __FILE__, __LINE__, error.text, error.source) @@ -39,7 +39,7 @@ * @return a json object describing the amount */ json_t * -TALER_JSON_from_amount (const struct TALER_Amount *amount); +TALER_json_from_amount (const struct TALER_Amount *amount); /** @@ -49,7 +49,7 @@ TALER_JSON_from_amount (const struct TALER_Amount *amount); * @return a json string with the timestamp in @a stamp */ json_t * -TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp); +TALER_json_from_abs (struct GNUNET_TIME_Absolute stamp); /** @@ -60,7 +60,7 @@ TALER_JSON_from_abs (struct GNUNET_TIME_Absolute stamp); * @return the JSON reporesentation of the signature with purpose */ json_t * -TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, +TALER_json_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, const struct GNUNET_CRYPTO_EddsaSignature *signature); @@ -72,7 +72,7 @@ TALER_JSON_from_eddsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo * @return the JSON reporesentation of the signature with purpose */ json_t * -TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, +TALER_json_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, const struct GNUNET_CRYPTO_EcdsaSignature *signature); @@ -83,7 +83,7 @@ TALER_JSON_from_ecdsa_sig (const struct GNUNET_CRYPTO_EccSignaturePurpose *purpo * @return corresponding JSON encoding */ json_t * -TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk); +TALER_json_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk); /** @@ -93,7 +93,7 @@ TALER_JSON_from_rsa_public_key (struct GNUNET_CRYPTO_rsa_PublicKey *pk); * @return corresponding JSON encoding */ json_t * -TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig); +TALER_json_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig); /** @@ -105,7 +105,7 @@ TALER_JSON_from_rsa_signature (struct GNUNET_CRYPTO_rsa_Signature *sig); * @return json string that encodes @a data */ json_t * -TALER_JSON_from_data (const void *data, size_t size); +TALER_json_from_data (const void *data, size_t size); /** @@ -116,7 +116,7 @@ TALER_JSON_from_data (const void *data, size_t size); * @return json string that encodes @a hc */ json_t * -TALER_JSON_from_hash (const struct GNUNET_HashCode *hc); +TALER_json_from_hash (const struct GNUNET_HashCode *hc); /** @@ -127,7 +127,7 @@ TALER_JSON_from_hash (const struct GNUNET_HashCode *hc); * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_amount (json_t *json, +TALER_json_to_amount (json_t *json, struct TALER_Amount *r_amount); /** @@ -138,7 +138,7 @@ TALER_JSON_to_amount (json_t *json, * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_abs (json_t *json, +TALER_json_to_abs (json_t *json, struct GNUNET_TIME_Absolute *r_abs); /** @@ -150,7 +150,7 @@ TALER_JSON_to_abs (json_t *json, * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error */ int -TALER_JSON_to_data (json_t *json, +TALER_json_to_data (json_t *json, void *out, size_t out_size); @@ -162,10 +162,10 @@ TALER_JSON_to_data (json_t *json, * @return #GNUNET_YES if correctly formatted; #GNUNET_NO if not */ int -TALER_JSON_validate_wireformat (const char *type, +TALER_json_validate_wireformat (const char *type, const json_t *wire); -#endif /* TALER_JSON_LIB_H_ */ +#endif /* TALER_json_LIB_H_ */ /* End of taler_json_lib.h */ diff --git a/src/include/taler_mint_service.h b/src/include/taler_mint_service.h index 30aaad38e..774f40f54 100644 --- a/src/include/taler_mint_service.h +++ b/src/include/taler_mint_service.h @@ -42,7 +42,7 @@ struct TALER_MINT_SigningPublicKey /** * The signing public key */ - struct TALER_MintPublicKey key; + struct TALER_MintPublicKeyP key; /** * Validity start time @@ -140,7 +140,7 @@ struct TALER_MINT_Handle * TALER_MINT_connect (struct TALER_MINT_Context *ctx, const char *hostname, uint16_t port, - const struct TALER_MasterPublicKey *master_key); + const struct TALER_MasterPublicKeyP *master_key); /** * Disconnect from the mint @@ -287,7 +287,7 @@ TALER_MINT_deposit_submit_json_ (struct TALER_MINT_Handle *mint, struct TALER_BLIND_Signature *ubsig, uint64_t transaction_id, struct TALER_Amount *amount, - const struct TALER_MerchantPublicKey *merchant_pub, + const struct TALER_MerchantPublicKeyP *merchant_pub, const struct GNUNET_HashCode *h_contract, const struct GNUNET_HashCode *h_wire, const struct TALER_CoinSignature *csig, diff --git a/src/include/taler_mintdb_plugin.h b/src/include/taler_mintdb_plugin.h new file mode 100644 index 000000000..8c9f4af23 --- /dev/null +++ b/src/include/taler_mintdb_plugin.h @@ -0,0 +1,1029 @@ +/* + This file is part of TALER + Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors) + + 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 + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file mint/taler_mintdb_plugin.h + * @brief Low-level (statement-level) database access for the mint + * @author Florian Dold + * @author Christian Grothoff + */ +#ifndef TALER_MINTDB_PLUGIN_H +#define TALER_MINTDB_PLUGIN_H + +#include <gnunet/gnunet_util_lib.h> +#include "taler_util.h" + + +/** + * Information we keep on bank transfer(s) that established a reserve. + */ +struct BankTransfer +{ + + /** + * Public key of the reserve that was filled. + */ + struct TALER_ReservePublicKeyP reserve_pub; + + /** + * Amount that was transferred to the mint. + */ + struct TALER_Amount amount; + + /** + * Detailed wire information about the transaction. + */ + json_t *wire; + +}; + + +/** + * A summary of a Reserve + */ +struct Reserve +{ + /** + * The reserve's public key. This uniquely identifies the reserve + */ + struct TALER_ReservePublicKeyP pub; + + /** + * The balance amount existing in the reserve + */ + struct TALER_Amount balance; + + /** + * The expiration date of this reserve + */ + struct GNUNET_TIME_Absolute expiry; +}; + + +/** + * Information we keep for a withdrawn coin to reproduce + * the /withdraw operation if needed, and to have proof + * that a reserve was drained by this amount. + */ +struct CollectableBlindcoin +{ + + /** + * Our signature over the (blinded) coin. + */ + struct TALER_DenominationSignature sig; + + /** + * Denomination key (which coin was generated). + * FIXME: we should probably instead have the + * AMOUNT *including* fee in what is being signed + * as well! + */ + struct TALER_DenominationPublicKey denom_pub; + + /** + * Public key of the reserve that was drained. + */ + struct TALER_ReservePublicKeyP reserve_pub; + + /** + * Hash over the blinded message, needed to verify + * the @e reserve_sig. + */ + struct GNUNET_HashCode h_coin_envelope; + + /** + * Signature confirming the withdrawl, matching @e reserve_pub, + * @e denom_pub and @e h_coin_envelope. + */ + struct TALER_ReserveSignatureP reserve_sig; +}; + + + +/** + * Types of operations on a reserved. + */ +enum TALER_MINT_DB_ReserveOperation +{ + /** + * Money was deposited into the reserve via a bank transfer. + */ + TALER_MINT_DB_RO_BANK_TO_MINT = 0, + + /** + * A Coin was withdrawn from the reserve using /withdraw. + */ + TALER_MINT_DB_RO_WITHDRAW_COIN = 1 +}; + + +/** + * Reserve history as a linked list. Lists all of the transactions + * associated with this reserve (such as the bank transfers that + * established the reserve and all /withdraw operations we have done + * since). + */ +struct ReserveHistory +{ + + /** + * Next entry in the reserve history. + */ + struct ReserveHistory *next; + + /** + * Type of the event, determins @e details. + */ + enum TALER_MINT_DB_ReserveOperation type; + + /** + * Details of the operation, depending on @e type. + */ + union + { + + /** + * Details about a bank transfer to the mint. + */ + struct BankTransfer *bank; + + /** + * Details about a /withdraw operation. + */ + struct CollectableBlindcoin *withdraw; + + } details; + +}; + + +/** + * Specification for a /deposit operation. + */ +struct Deposit +{ + /** + * Information about the coin that is being deposited. + */ + struct TALER_CoinPublicInfo coin; + + /** + * ECDSA signature affirming that the customer intends + * this coin to be deposited at the merchant identified + * by @e h_wire in relation to the contract identified + * by @e h_contract. + */ + union TALER_CoinSpendSignatureP csig; + + /** + * Public key of the merchant. Enables later identification + * of the merchant in case of a need to rollback transactions. + */ + struct TALER_MerchantPublicKeyP merchant_pub; + + /** + * Hash over the contract between merchant and customer + * (remains unknown to the Mint). + */ + struct GNUNET_HashCode h_contract; + + /** + * Hash of the (canonical) representation of @e wire, used + * to check the signature on the request. Generated by + * the mint from the detailed wire data provided by the + * merchant. + */ + struct GNUNET_HashCode h_wire; + + /** + * Detailed wire information for executing the transaction. + */ + json_t *wire; + + /** + * Merchant-generated transaction ID to detect duplicate + * transactions. + */ + uint64_t transaction_id; + + /** + * Fraction of the coin's remaining value to be deposited, including + * depositing fee (if any). The coin is identified by @e coin_pub. + */ + struct TALER_Amount amount_with_fee; + +}; + + +/** + * Global information for a refreshing session. Includes + * dimensions of the operation, security parameters and + * client signatures from "/refresh/melt" and "/refresh/commit". + */ +struct RefreshSession +{ + + /** + * Number of coins we are melting. + */ + uint16_t num_oldcoins; + + /** + * Number of new coins we are creating. + */ + uint16_t num_newcoins; + + /** + * Index (smaller #TALER_CNC_KAPPA) which the mint has chosen to not + * have revealed during cut and choose. + */ + uint16_t noreveal_index; + +}; + + +/** + * Specification for coin in a /refresh/melt operation. + */ +struct RefreshMelt +{ + /** + * Information about the coin that is being melted. + */ + struct TALER_CoinPublicInfo coin; + + /** + * Signature over the melting operation. + */ + union TALER_CoinSpendSignatureP coin_sig; + + /** + * Hash of the refresh session this coin is melted into. + */ + struct GNUNET_HashCode session_hash; + + /** + * How much value is being melted? This amount includes the fees, + * so the final amount contributed to the melt is this value minus + * the fee for melting the coin. We include the fee in what is + * being signed so that we can verify a reserve's remaining total + * balance without needing to access the respective denomination key + * information each time. + */ + struct TALER_Amount amount_with_fee; + +}; + + +/** + * We have as many `struct RefreshCommitCoin` as there are new + * coins being created by the refresh (for each of the #TALER_CNC_KAPPA + * sets). These are the coins we ask the mint to sign if the + * respective set is selected. + */ +struct RefreshCommitCoin +{ + + /** + * Encrypted data allowing those able to decrypt it to derive + * the private keys of the new coins created by the refresh. + */ + struct TALER_RefreshLinkEncrypted *refresh_link; + + /** + * Blinded message to be signed (in envelope), with @e coin_env_size bytes. + */ + char *coin_ev; + + /** + * Number of bytes in @e coin_ev. + */ + size_t coin_ev_size; + +}; + + +GNUNET_NETWORK_STRUCT_BEGIN + +/** + * For each (old) coin being melted, we have a `struct + * RefreshCommitLink` that allows the user to find the shared secret + * to decrypt the respective refresh links for the new coins in the + * `struct RefreshCommitCoin`. + */ +struct RefreshCommitLink +{ + /** + * Transfer public key, used to decrypt the @e shared_secret_enc + * in combintation with the corresponding private key of the + * coin. + */ + struct TALER_TransferPublicKeyP transfer_pub; + + /** + * Encrypted shared secret to decrypt the link. + */ + struct TALER_EncryptedLinkSecretP shared_secret_enc; +}; + +GNUNET_NETWORK_STRUCT_END + + + +/** + * Linked list of refresh information linked to a coin. + */ +struct LinkDataList +{ + /** + * Information is stored in a NULL-terminated linked list. + */ + struct LinkDataList *next; + + /** + * Link data, used to recover the private key of the coin + * by the owner of the old coin. + */ + struct TALER_RefreshLinkEncrypted *link_data_enc; + + /** + * Denomination public key, determines the value of the coin. + */ + struct TALER_DenominationPublicKey denom_pub; + + /** + * Signature over the blinded envelope. + */ + struct TALER_DenominationSignature ev_sig; +}; + + +/** + * Specification for a /lock operation. + */ +struct Lock +{ + /** + * Information about the coin that is being locked. + */ + struct TALER_CoinPublicInfo coin; + + /** + * Signature over the locking operation. + */ + union TALER_CoinSpendSignatureP coin_sig; + + /** + * How much value is being locked? + */ + struct TALER_Amount amount; + + // FIXME: more needed... +}; + + +/** + * Enumeration to classify the different types of transactions + * that can be done with a coin. + */ +enum TALER_MINT_DB_TransactionType +{ + /** + * /deposit operation. + */ + TALER_MINT_DB_TT_DEPOSIT = 0, + + /** + * /refresh/melt operation. + */ + TALER_MINT_DB_TT_REFRESH_MELT = 1, + + /** + * /lock operation. + */ + TALER_MINT_DB_TT_LOCK = 2 +}; + + +/** + * List of transactions we performed for a particular coin. + */ +struct TALER_MINT_DB_TransactionList +{ + + /** + * Next pointer in the NULL-terminated linked list. + */ + struct TALER_MINT_DB_TransactionList *next; + + /** + * Type of the transaction, determines what is stored in @e details. + */ + enum TALER_MINT_DB_TransactionType type; + + /** + * Details about the transaction, depending on @e type. + */ + union + { + + /** + * Details if transaction was a /deposit operation. + */ + struct Deposit *deposit; + + /** + * Details if transaction was a /refresh/melt operation. + */ + struct RefreshMelt *melt; + + /** + * Details if transaction was a /lock operation. + */ + struct Lock *lock; + + } details; + +}; + + +/** + * Handle for a database session (per-thread, for transactions). + */ +struct TALER_MINTDB_Session; + + +/** + * The plugin API, returned from the plugin's "init" function. + * The argument given to "init" is simply a configuration handle. + */ +struct TALER_MINTDB_Plugin +{ + + /** + * Closure for all callbacks. + */ + void *cls; + + /** + * Name of the library which generated this plugin + */ + const char *library_name; + + /** + * Get the thread-local database-handle. + * Connect to the db if the connection does not exist yet. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param temporary #GNUNET_YES to use a temporary schema; #GNUNET_NO to use the + * database default one + * @param the database connection, or NULL on error + */ + struct TALER_MINTDB_Session * + (*get_session) (void *cls, + int temporary); + + + /** + * Drop the temporary taler schema. This is only useful for testcases. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure + */ + int + (*drop_temporary) (void *cls, + struct TALER_MINTDB_Session *db); + + + /** + * Create the necessary tables if they are not present + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param temporary should we use a temporary schema + * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure + */ + int + (*create_tables) (void *cls, + int temporary); + + + /** + * Start a transaction. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion connection to use + * @return #GNUNET_OK on success + */ + int + (*start) (void *cls, + struct TALER_MINTDB_Session *sesssion); + + + /** + * Commit a transaction. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion connection to use + * @return #GNUNET_OK on success + */ + int + (*commit) (void *cls, + struct TALER_MINTDB_Session *sesssion); + + + /** + * Abort/rollback a transaction. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion connection to use + */ + void + (*rollback) (void *cls, + struct TALER_MINTDB_Session *sesssion); + + + /** + * Get the summary of a reserve. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param db the database connection handle + * @param reserve the reserve data. The public key of the reserve should be set + * in this structure; it is used to query the database. The balance + * and expiration are then filled accordingly. + * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failure + */ + int + (*reserve_get) (void *cls, + struct TALER_MINTDB_Session *db, + struct Reserve *reserve); + + /* FIXME: add functions to add bank transfers to our DB + (and to test if we already did add one) (#3633/#3717) */ + + + /** + * Insert a incoming transaction into reserves. New reserves are also created + * through this function. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param db the database connection handle + * @param reserve the reserve structure. The public key of the reserve should + * be set here. Upon successful execution of this function, the + * balance and expiration of the reserve will be updated. + * @param balance the amount that has to be added to the reserve + * @param expiry the new expiration time for the reserve + * @return #GNUNET_OK upon success; #GNUNET_SYSERR upon failures + */ + int + (*reserves_in_insert) (void *cls, + struct TALER_MINTDB_Session *db, + struct Reserve *reserve, + const struct TALER_Amount *balance, + const struct GNUNET_TIME_Absolute expiry); + + + /** + * Locate the response for a /withdraw request under the + * key of the hash of the blinded message. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection to use + * @param h_blind hash of the blinded message + * @param collectable corresponding collectable coin (blind signature) + * if a coin is found + * @return #GNUNET_SYSERR on internal error + * #GNUNET_NO if the collectable was not found + * #GNUNET_YES on success + */ + int + (*get_collectable_blindcoin) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *h_blind, + struct CollectableBlindcoin *collectable); + + + /** + * Store collectable bit coin under the corresponding + * hash of the blinded message. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection to use + * @param h_blind hash of the blinded message + * @param withdraw amount by which the reserve will be withdrawn with this + * transaction + * @param collectable corresponding collectable coin (blind signature) + * if a coin is found + * @return #GNUNET_SYSERR on internal error + * #GNUNET_NO if the collectable was not found + * #GNUNET_YES on success + */ + int + (*insert_collectable_blindcoin) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *h_blind, + struct TALER_Amount withdraw, + const struct CollectableBlindcoin *collectable); + + + /** + * Get all of the transaction history associated with the specified + * reserve. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion connection to use + * @param reserve_pub public key of the reserve + * @return known transaction history (NULL if reserve is unknown) + */ + struct ReserveHistory * + (*get_reserve_history) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct TALER_ReservePublicKeyP *reserve_pub); + + + /** + * Free memory associated with the given reserve history. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param rh history to free. + */ + void + (*free_reserve_history) (void *cls, + struct ReserveHistory *rh); + + + /** + * Check if we have the specified deposit already in the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param deposit deposit to search for + * @return #GNUNET_YES if we know this operation, + * #GNUNET_NO if this deposit is unknown to us, + * #GNUNET_SYSERR on internal error + */ + int + (*have_deposit) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct Deposit *deposit); + + + /** + * Insert information about deposited coin into the + * database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion connection to the database + * @param deposit deposit information to store + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error + */ + int + (*insert_deposit) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct Deposit *deposit); + + + /** + * Lookup refresh session data under the given @a session_hash. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database handle to use + * @param session_hash hash over the melt to use for the lookup + * @param refresh_session[OUT] where to store the result + * @return #GNUNET_YES on success, + * #GNUNET_NO if not found, + * #GNUNET_SYSERR on DB failure + */ + int + (*get_refresh_session) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + struct RefreshSession *refresh_session); + + + /** + * Store new refresh session data under the given @a session_hash. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database handle to use + * @param session_hash hash over the melt to use to locate the session + * @param refresh_session session data to store + * @return #GNUNET_YES on success, + * #GNUNET_SYSERR on DB failure + */ + int + (*create_refresh_session) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + const struct RefreshSession *refresh_session); + + + /** + * Store the given /refresh/melt request in the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param oldcoin_index index of the coin to store + * @param melt coin melt operation details to store; includes + * the session hash of the melt + * @return #GNUNET_OK on success + * #GNUNET_SYSERR on internal error + */ + int + (*insert_refresh_melt) (void *cls, + struct TALER_MINTDB_Session *sesssion, + uint16_t oldcoin_index, + const struct RefreshMelt *melt); + + + /** + * Get information about melted coin details from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param session_hash hash to identify refresh session + * @param oldcoin_index index of the coin to retrieve + * @param melt melt data to fill in + * @return #GNUNET_OK on success + * #GNUNET_SYSERR on internal error + */ + int + (*get_refresh_melt) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + uint16_t oldcoin_index, + struct RefreshMelt *melt); + + + /** + * Store in the database which coin(s) we want to create + * in a given refresh operation. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param session_hash hash to identify refresh session + * @param num_newcoins number of coins to generate, size of the @a denom_pubs array + * @param denom_pubs array denominations of the coins to create + * @return #GNUNET_OK on success + * #GNUNET_SYSERR on internal error + */ + int + (*insert_refresh_order) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + uint16_t num_newcoins, + const struct TALER_DenominationPublicKey *denom_pubs); + + + /** + * Lookup in the database for the @a num_newcoins coins that we want to + * create in the given refresh operation. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param session_hash hash to identify refresh session + * @param num_newcoins size of the @a denom_pubs array + * @param denom_pubs[OUT] where to write @a num_newcoins denomination keys + * @return #GNUNET_OK on success + * #GNUNET_SYSERR on internal error + */ + int + (*get_refresh_order) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + uint16_t num_newcoins, + struct TALER_DenominationPublicKey *denom_pubs); + + + /** + * Store information about the commitments of the given index @a i + * for the given refresh session in the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection to use + * @param session_hash hash to identify refresh session + * @param i set index (1st dimension), relating to #TALER_CNC_KAPPA + * @param num_newcoins coin index size of the @a commit_coins array + * @param commit_coin array of coin commitments to store + * @return #GNUNET_OK on success + * #GNUNET_SYSERR on error + */ + int + (*insert_refresh_commit_coins) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + unsigned int i, + unsigned int num_newcoins, + const struct RefreshCommitCoin *commit_coins); + + + /** + * Obtain information about the commitment of the + * given coin of the given refresh session from the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection to use + * @param session_hash hash to identify refresh session + * @param i set index (1st dimension) + * @param num_coins size of the @a commit_coins array + * @param commit_coin[OUT] array of coin commitments to return + * @return #GNUNET_OK on success + * #GNUNET_NO if not found + * #GNUNET_SYSERR on error + */ + int + (*get_refresh_commit_coins) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + unsigned int i, + unsigned int num_coins, + struct RefreshCommitCoin *commit_coins); + + + /** + * Store the commitment to the given (encrypted) refresh link data + * for the given refresh session. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection to use + * @param session_hash hash to identify refresh session + * @param i set index (1st dimension), relating to #TALER_CNC_KAPPA + * @param num_links size of the @a commit_link array + * @param commit_links array of link information to store + * @return #GNUNET_SYSERR on internal error, #GNUNET_OK on success + */ + int + (*insert_refresh_commit_links) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + unsigned int i, + unsigned int num_links, + const struct RefreshCommitLink *commit_links); + + /** + * Obtain the commited (encrypted) refresh link data + * for the given refresh session. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection to use + * @param session_hash hash to identify refresh session + * @param i set index (1st dimension) + * @param num_links size of the @links array to return + * @param links[OUT] array link information to return + * @return #GNUNET_SYSERR on internal error, + * #GNUNET_NO if commitment was not found + * #GNUNET_OK on success + */ + int + (*get_refresh_commit_links) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + unsigned int i, + unsigned int num_links, + struct RefreshCommitLink *links); + + + /** + * Insert signature of a new coin generated during refresh into + * the database indexed by the refresh session and the index + * of the coin. This data is later used should an old coin + * be used to try to obtain the private keys during "/refresh/link". + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param session_hash hash to identify refresh session + * @param newcoin_index coin index + * @param ev_sig coin signature + * @return #GNUNET_OK on success + */ + int + (*insert_refresh_collectable) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct GNUNET_HashCode *session_hash, + uint16_t newcoin_index, + const struct TALER_DenominationSignature *ev_sig); + + + /** + * Obtain the link data of a coin, that is the encrypted link + * information, the denomination keys and the signatures. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param coin_pub public key to use to retrieve linkage data + * @return all known link data for the coin + */ + struct LinkDataList * + (*get_link_data_list) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const union TALER_CoinSpendPublicKeyP *coin_pub); + + + /** + * Free memory of the link data list. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param ldl link data list to release + */ + void + (*free_link_data_list) (void *cls, + struct LinkDataList *ldl); + + + /** + * Obtain shared secret and transfer public key from the public key of + * the coin. This information and the link information returned by + * #TALER_db_get_link() enable the owner of an old coin to determine + * the private keys of the new coins after the melt. + * + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param coin_pub public key of the coin + * @param transfer_pub[OUT] public transfer key + * @param shared_secret_enc[OUT] set to shared secret + * @return #GNUNET_OK on success, + * #GNUNET_NO on failure (not found) + * #GNUNET_SYSERR on internal failure (database issue) + */ + int + (*get_transfer) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const union TALER_CoinSpendPublicKeyP *coin_pub, + struct TALER_TransferPublicKeyP *transfer_pub, + struct TALER_EncryptedLinkSecretP *shared_secret_enc); + + + /** + * Test if the given /lock request is known to us. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param lock lock operation + * @return #GNUNET_YES if known, + * #GNUENT_NO if not, + * #GNUNET_SYSERR on internal error + */ + int + (*have_lock) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct Lock *lock); + + + /** + * Store the given /lock request in the database. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param lock lock operation + * @return #GNUNET_OK on success + * #GNUNET_SYSERR on internal error + */ + int + (*insert_lock) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const struct Lock *lock); + + + /** + * Compile a list of all (historic) transactions performed + * with the given coin (/refresh/melt and /deposit operations). + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param sesssion database connection + * @param coin_pub coin to investigate + * @return list of transactions, NULL if coin is fresh + */ + struct TALER_MINT_DB_TransactionList * + (*get_coin_transactions) (void *cls, + struct TALER_MINTDB_Session *sesssion, + const union TALER_CoinSpendPublicKeyP *coin_pub); + + + /** + * Free linked list of transactions. + * + * @param cls the @e cls of this struct with the plugin-specific state + * @param list list to free + */ + void + (*free_coin_transaction_list) (void *cls, + struct TALER_MINT_DB_TransactionList *list); + + +}; + + +#endif /* _NEURO_MINT_DB_H */ diff --git a/src/include/taler_pq_lib.h b/src/include/taler_pq_lib.h new file mode 100644 index 000000000..3cfd27f91 --- /dev/null +++ b/src/include/taler_pq_lib.h @@ -0,0 +1,188 @@ +/* + This file is part of TALER + Copyright (C) 2014 Christian Grothoff (and other contributing authors) + + 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 + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file pq/taler_pq_lib.h + * @brief helper functions for DB interactions + * @author Sree Harsha Totakura <sreeharsha@totakura.in> + * @author Florian Dold + * @author Christian Grothoff + */ +#ifndef TALER_PQ_LIB_H_ +#define TALER_PQ_LIB_H_ + +#include <libpq-fe.h> +#include "taler_util.h" + +/** + * Description of a DB query parameter. + */ +struct TALER_PQ_QueryParam +{ + /** + * Data or NULL + */ + const void *data; + + /** + * Size of @e data + */ + size_t size; + + /** + * Non-null if this is not the last parameter. + * This allows for null as sentinal value. + */ + int more; +}; + +/** + * End of query parameter specification. + */ +#define TALER_PQ_QUERY_PARAM_END { NULL, 0, 0 } + +/** + * Generate fixed-size query parameter with size given explicitly. + * + * @param x pointer to the query parameter to pass + * @param s number of bytes of @a x to use for the query + */ +#define TALER_PQ_QUERY_PARAM_PTR_SIZED(x, s) { (x), (s), 1 } + +/** + * Generate fixed-size query parameter with size determined + * by variable type. + * + * @param x pointer to the query parameter to pass. + */ +#define TALER_PQ_QUERY_PARAM_PTR(x) TALER_PQ_QUERY_PARAM_PTR_SIZED(x, sizeof (*(x))) + + +/** + * Description of a DB result cell. + */ +struct TALER_PQ_ResultSpec +{ + /** + * Destination for the data. + */ + void *dst; + + /** + * Allowed size for the data, 0 for variable-size + * (in this case, the type of @e dst is a `void **` + * and we need to allocate a buffer of the right size). + */ + size_t dst_size; + + /** + * Field name of the desired result. + */ + char *fname; + + /** + * Actual size of the result. + */ + size_t *result_size; + +}; + + +/** + * End of result parameter specification. + */ +#define TALER_PQ_RESULT_SPEC_END { NULL, 0, NULL, NULL } + +/** + * We expect a fixed-size result, with size given explicitly + * + * @param name name of the field in the table + * @param dst point to where to store the result + * @param s number of bytes we should use in @a dst + */ +#define TALER_PQ_RESULT_SPEC_SIZED(name, dst, s) { (void *) (dst), (s), (name), NULL } + +/** + * We expect a fixed-size result, with size determined by the type of `* dst` + * + * @param name name of the field in the table + * @param dst point to where to store the result, type fits expected result size + */ +#define TALER_PQ_RESULT_SPEC(name, dst) TALER_PQ_RESULT_SPEC_SIZED(name, dst, sizeof (*(dst))) + +/** + * Variable-size result expected. + * + * @param name name of the field in the table + * @param dst where to store the result (of type void **), to be allocated + * @param sptr pointer to a `size_t` for where to store the size of @a dst + */ +#define TALER_PQ_RESULT_SPEC_VAR(name, dst, sptr) { (void *) (dst), 0, (name), sptr } + + +/** + * Execute a prepared statement. + */ +PGresult * +TALER_PQ_exec_prepared (PGconn *db_conn, + const char *name, + const struct TALER_PQ_QueryParam *params); + + +/** + * Extract results from a query result according to the given specification. + * If colums are NULL, the destination is not modified, and GNUNET_NO + * is returned. + * + * @return + * #GNUNET_YES if all results could be extracted + * #GNUNET_NO if at least one result was NULL + * #GNUNET_SYSERR if a result was invalid (non-existing field) + */ +int +TALER_PQ_extract_result (PGresult *result, + struct TALER_PQ_ResultSpec *rs, + int row); + + +int +TALER_PQ_field_isnull (PGresult *result, + int row, + const char *fname); + + +int +TALER_PQ_extract_amount_nbo (PGresult *result, + int row, + const char *val_name, + const char *frac_name, + const char *curr_name, + struct TALER_AmountNBO *r_amount_nbo); + + +int +TALER_PQ_extract_amount (PGresult *result, + int row, + const char *val_name, + const char *frac_name, + const char *curr_name, + struct TALER_Amount *r_amount); + + + + +#endif /* TALER_PQ_LIB_H_ */ + +/* end of db/taler_pq_lib.h */ diff --git a/src/include/taler_signatures.h b/src/include/taler_signatures.h index 007a309f3..41b694d09 100644 --- a/src/include/taler_signatures.h +++ b/src/include/taler_signatures.h @@ -32,61 +32,61 @@ /** * Cut-and-choose size for refreshing. Client looses the gamble (of - * unaccountable transfers) with probability 1/KAPPA. Refresh cost - * increases linearly with KAPPA, and 3 is sufficient up to a + * unaccountable transfers) with probability 1/TALER_CNC_KAPPA. Refresh cost + * increases linearly with TALER_CNC_KAPPA, and 3 is sufficient up to a * income/sales tax of 66% of total transaction value. As there is * no good reason to change this security parameter, we declare it * fixed and part of the protocol. */ -#define KAPPA 3 +#define TALER_CNC_KAPPA 3 /** * Purpose for signing public keys signed * by the mint master key. */ -#define TALER_SIGNATURE_MASTER_SIGNKEY 1 +#define TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY 1 /** * Purpose for denomination keys signed * by the mint master key. */ -#define TALER_SIGNATURE_MASTER_DENOM 2 +#define TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY 2 /** * Purpose for the state of a reserve, * signed by the mint's signing key. */ -#define TALER_SIGNATURE_RESERVE_STATUS 3 +#define TALER_SIGNATURE_MINT_RESERVE_STATUS 3 /** * Signature where the reserve key * confirms a withdraw request. */ -#define TALER_SIGNATURE_WITHDRAW 4 +#define TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST 4 /** * Signature using a coin key confirming the melting of * a coin. */ -#define TALER_SIGNATURE_REFRESH_MELT_COIN 5 +#define TALER_SIGNATURE_COIN_MELT 5 /** * Signature where the mint (current signing key) * confirms the no-reveal index for cut-and-choose and * the validity of the melted coins. */ -#define TALER_SIGNATURE_REFRESH_MELT_RESPONSE 6 +#define TALER_SIGNATURE_MINT_MELT_RESPONSE 6 /** * Signature where the Mint confirms a deposit request. */ -#define TALER_SIGNATURE_MINT_DEPOSIT 7 +#define TALER_SIGNATURE_COIN_DEPOSIT 7 /** * Signature where the Mint confirms the full /keys response set. */ -#define TALER_SIGNATURE_KEYS_SET 8 +#define TALER_SIGNATURE_MINT_KEY_SET 8 /***********************/ @@ -104,11 +104,14 @@ /** * Signature made by the wallet of a user to confirm a deposit permission + * FIXME: this is #TALER_SIGNATURE_COIN_DEPOSIT already! */ #define TALER_SIGNATURE_WALLET_DEPOSIT 201 /** - * Signature made by the wallet of a user to confirm a incremental deposit permission + * Signature made by the wallet of a user to confirm a incremental + * deposit permission. + * FIXME: this MIGHT also be #TALER_SIGNATURE_COIN_DEPOSIT already! */ #define TALER_SIGNATURE_INCREMENTAL_WALLET_DEPOSIT 202 @@ -120,11 +123,11 @@ GNUNET_NETWORK_STRUCT_BEGIN * Format used for to generate the signature on a request to withdraw * coins from a reserve. */ -struct TALER_WithdrawRequest +struct TALER_WithdrawRequestPS { /** - * Purpose must be #TALER_SIGNATURE_WITHDRAW. + * Purpose must be #TALER_SIGNATURE_RESERVE_WITHDRAW_REQUEST. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -132,7 +135,7 @@ struct TALER_WithdrawRequest * Reserve public key (which reserve to withdraw from). This is * the public key which must match the signature. */ - struct TALER_ReservePublicKey reserve_pub; + struct TALER_ReservePublicKeyP reserve_pub; /** * Value of the coin being minted (matching the denomination key) @@ -159,7 +162,7 @@ struct TALER_WithdrawRequest * Format used to generate the signature on a request to deposit * a coin into the account of a merchant. */ -struct TALER_DepositRequest +struct TALER_DepositRequestPS { /** * Purpose must be #TALER_SIGNATURE_WALLET_DEPOSIT @@ -192,7 +195,7 @@ struct TALER_DepositRequest /** * The coin's public key. */ - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; }; @@ -201,10 +204,10 @@ struct TALER_DepositRequest * Format used to generate the signature on a confirmation * from the mint that a deposit request succeeded. */ -struct TALER_DepositConfirmation +struct TALER_DepositConfirmationPS { /** - * Purpose must be #TALER_SIGNATURE_MINT_DEPOSIT + * Purpose must be #TALER_SIGNATURE_COIN_DEPOSIT */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -235,12 +238,12 @@ struct TALER_DepositConfirmation /** * The coin's public key. */ - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; /** * The Merchant's public key. */ - struct TALER_MerchantPublicKey merchant; + struct TALER_MerchantPublicKeyP merchant; }; @@ -249,10 +252,10 @@ struct TALER_DepositConfirmation * Message signed by a coin to indicate that the coin should * be melted. */ -struct RefreshMeltCoinSignature +struct TALER_RefreshMeltCoinAffirmationPS { /** - * Purpose is #TALER_SIGNATURE_REFRESH_MELT_COIN. + * Purpose is #TALER_SIGNATURE_COIN_MELT. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -277,7 +280,7 @@ struct RefreshMeltCoinSignature /** * The coin's public key. */ - struct TALER_CoinSpendPublicKey coin_pub; + union TALER_CoinSpendPublicKeyP coin_pub; }; @@ -287,10 +290,10 @@ struct RefreshMeltCoinSignature * coins were successfully melted. This also commits the mint to a * particular index to not be revealed during the refresh. */ -struct RefreshMeltResponseSignatureBody +struct TALER_RefreshMeltConfirmationPS { /** - * Purpose is #TALER_SIGNATURE_REFRESH_MELT_RESPONSE. + * Purpose is #TALER_SIGNATURE_MINT_MELT_RESPONSE. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -311,15 +314,15 @@ struct RefreshMeltResponseSignatureBody * to sign mint messages other than coins, i.e. to confirm that a * deposit was successful or that a refresh was accepted. */ -struct TALER_MINT_SignKeyIssue +struct TALER_MintSigningKeyValidityPS { /** * Signature over the signing key (by the master key of the mint). */ - struct TALER_MasterSignature signature; + struct TALER_MasterSignatureP signature; /** - * Purpose is #TALER_SIGNATURE_MASTER_SIGNKEY. + * Purpose is #TALER_SIGNATURE_MINT_SIGNING_KEY_VALIDITY. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -327,7 +330,7 @@ struct TALER_MINT_SignKeyIssue * Master public key of the mint corresponding to @e signature. * This is the long-term offline master key of the mint. */ - struct TALER_MasterPublicKey master_pub; + struct TALER_MasterPublicKeyP master_public_key; /** * When does this signing key begin to be valid? @@ -346,7 +349,7 @@ struct TALER_MINT_SignKeyIssue * The public online signing key that the mint will use * between @e start and @e expire. */ - struct TALER_MintPublicKey signkey_pub; + struct TALER_MintPublicKeyP signkey_pub; }; @@ -355,11 +358,11 @@ struct TALER_MINT_SignKeyIssue * to detect cheating mints that give out different sets to * different users. */ -struct TALER_MINT_KeySetSignature +struct TALER_MintKeySetPS { /** - * Purpose is #TALER_SIGNATURE_KEYS_SET + * Purpose is #TALER_SIGNATURE_MINT_KEY_SET */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -379,16 +382,16 @@ struct TALER_MINT_KeySetSignature * Information about a denomination key. Denomination keys * are used to sign coins of a certain value into existence. */ -struct TALER_MINT_DenomKeyIssue +struct TALER_DenominationKeyValidityPS { /** * Signature over this struct to affirm the validity * of the key. */ - struct TALER_MasterSignature signature; + struct TALER_MasterSignatureP signature; /** - * Purpose is #TALER_SIGNATURE_MASTER_DENOM. + * Purpose is #TALER_SIGNATURE_MINT_DENOMINATION_KEY_VALIDITY. */ struct GNUNET_CRYPTO_EccSignaturePurpose purpose; @@ -396,7 +399,7 @@ struct TALER_MINT_DenomKeyIssue * The long-term offline master key of the mint that was * used to create @e signature. */ - struct TALER_MasterPublicKey master; + struct TALER_MasterPublicKeyP master; /** * Start time of the validity period for this key. diff --git a/src/include/taler_util.h b/src/include/taler_util.h index e46583989..b92f22170 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -29,13 +29,13 @@ /* Define logging functions */ -#define LOG_DEBUG(...) \ +#define TALER_LOG_DEBUG(...) \ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) -#define LOG_WARNING(...) \ +#define TALER_LOG_WARNING(...) \ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, __VA_ARGS__) -#define LOG_ERROR(...) \ +#define TALER_LOG_ERROR(...) \ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, __VA_ARGS__) @@ -49,7 +49,7 @@ #define TALER_assert_as(EXP, reason) \ do { \ if (EXP) break; \ - LOG_ERROR("%s at %s:%d\n", reason, __FILE__, __LINE__); \ + TALER_LOG_ERROR("%s at %s:%d\n", reason, __FILE__, __LINE__); \ abort(); \ } while(0) @@ -59,11 +59,11 @@ * a failure of the command 'cmd' with the message given * by gcry_strerror(rc). */ -#define LOG_GCRY_ERROR(cmd, rc) do { LOG_ERROR("`%s' failed at %s:%d with error: %s\n", cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) +#define TALER_LOG_GCRY_ERROR(cmd, rc) do { TALER_LOG_ERROR("`%s' failed at %s:%d with error: %s\n", cmd, __FILE__, __LINE__, gcry_strerror(rc)); } while(0) #define TALER_gcry_ok(cmd) \ - do {int rc; rc = cmd; if (!rc) break; LOG_ERROR("A Gcrypt call failed at %s:%d with error: %s\n", __FILE__, __LINE__, gcry_strerror(rc)); abort(); } while (0) + do {int rc; rc = cmd; if (!rc) break; TALER_LOG_ERROR("A Gcrypt call failed at %s:%d with error: %s\n", __FILE__, __LINE__, gcry_strerror(rc)); abort(); } while (0) /** @@ -108,7 +108,7 @@ TALER_config_get_denom (struct GNUNET_CONFIGURATION_Handle *cfg, * @return a pointer to the dir path (to be freed by the caller) */ char * -TALER_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); +TALER_os_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); #endif |