From 495fab44f1d7673077503625ce8f64fe1c59121a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 8 Aug 2015 16:09:25 +0200 Subject: [PATCH] complete implementation of TALER_MINT_refresh_prepare --- src/mint-lib/mint_api_refresh.c | 109 ++++++++++++++++++++++++-------- 1 file changed, 82 insertions(+), 27 deletions(-) diff --git a/src/mint-lib/mint_api_refresh.c b/src/mint-lib/mint_api_refresh.c index d9591a514..5c58679ed 100644 --- a/src/mint-lib/mint_api_refresh.c +++ b/src/mint-lib/mint_api_refresh.c @@ -97,12 +97,6 @@ struct FreshCoinP */ struct TALER_CoinSpendPrivateKeyP coin_priv; - /** - * Link secret used to encrypt the @a coin_priv and the blinding - * key in the linkage data. - */ - struct TALER_LinkSecretP link_secret; - /** * Size of the encoded blinding key that follows. */ @@ -128,9 +122,10 @@ struct MeltDataP struct GNUNET_HashCode melt_session_hash; /** - * Transfer secrets for each cut-and-choose dimension. + * Link secret used to encrypt the @a coin_priv and the blinding + * key in the linkage data for the respective cut-and-choose dimension. */ - struct TALER_TransferSecretP transfer_secrets[TALER_CNC_KAPPA]; + struct TALER_LinkSecretP link_secrets[TALER_CNC_KAPPA]; /** * Number of coins we are melting, in NBO @@ -209,12 +204,6 @@ struct FreshCoin */ struct TALER_CoinSpendPrivateKeyP coin_priv; - /** - * Link secret used to encrypt the @a coin_priv and the blinding - * key in the linkage data. - */ - struct TALER_LinkSecretP link_secret; - /** * Blinding key used for blinding during blind signing. */ @@ -235,9 +224,9 @@ struct MeltData struct GNUNET_HashCode melt_session_hash; /** - * Transfer secrets for each cut-and-choose dimension. + * Link secrets for each cut-and-choose dimension. */ - struct TALER_TransferSecretP transfer_secrets[TALER_CNC_KAPPA]; + struct TALER_LinkSecretP link_secrets[TALER_CNC_KAPPA]; /** * Number of coins we are melting @@ -595,7 +584,6 @@ serialize_fresh_coin (const struct FreshCoin *fc, return sizeof (struct FreshCoinP) + bbuf_size; } fcp.coin_priv = fc->coin_priv; - fcp.link_secret = fc->link_secret; fcp.bbuf_size = htonl ((uint32_t) bbuf_size); memcpy (&buf[off], &fcp, @@ -652,7 +640,6 @@ deserialize_fresh_coin (struct FreshCoin *fc, return 0; } fc->coin_priv = fcp.coin_priv; - fc->link_secret = fcp.link_secret; return sizeof (struct FreshCoinP) + bbuf_size; } @@ -693,7 +680,7 @@ serialize_melt_data (const struct MeltData *md, mdp = (struct MeltDataP *) buf; mdp->melt_session_hash = md->melt_session_hash; for (i=0;itransfer_secrets[i] = md->transfer_secrets[i]; + mdp->link_secrets[i] = md->link_secrets[i]; mdp->num_melted_coins = htons (md->num_melted_coins); mdp->num_fresh_coins = htons (md->num_fresh_coins); } @@ -743,7 +730,7 @@ deserialize_melt_data (const char *buf, md = GNUNET_new (struct MeltData); md->melt_session_hash = mdp.melt_session_hash; for (i=0;itransfer_secrets[i] = mdp.transfer_secrets[i]; + md->link_secrets[i] = mdp.link_secrets[i]; md->num_melted_coins = ntohs (mdp.num_melted_coins); md->num_fresh_coins = ntohs (mdp.num_fresh_coins); md->melted_coins = GNUNET_new_array (md->num_melted_coins, @@ -803,9 +790,6 @@ setup_fresh_coin (struct FreshCoin *fc, epk = GNUNET_CRYPTO_eddsa_key_create (); fc->coin_priv.eddsa_priv = *epk; GNUNET_free (epk); - GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_STRONG, - &fc->link_secret, - sizeof (struct TALER_LinkSecretP)); len = GNUNET_CRYPTO_rsa_public_key_len (pk->key.rsa_public_key); fc->blinding_key.rsa_blinding_key = GNUNET_CRYPTO_rsa_blinding_key_create (len); @@ -869,11 +853,12 @@ TALER_MINT_refresh_prepare (unsigned int num_melts, char *buf; unsigned int i; unsigned int j; + struct GNUNET_HashContext *hash_context; for (i=0;icoin_priv.eddsa_priv, + &coin_pub.eddsa_pub); + GNUNET_CRYPTO_hash (&coin_pub.eddsa_pub, + sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey), + &coin_hash); + coin_ev_size = GNUNET_CRYPTO_rsa_blind (&coin_hash, + fc->blinding_key.rsa_blinding_key, + md.fresh_pks[j].rsa_public_key, + &coin_ev); + GNUNET_CRYPTO_hash_context_read (hash_context, + coin_ev, + coin_ev_size); + GNUNET_free (coin_ev); + + rld.coin_priv = fc->coin_priv; + rld.blinding_key = fc->blinding_key; + rle = TALER_refresh_encrypt (&rld, + &md.link_secrets[i]); + link_enc = TALER_refresh_link_encrypted_encode (rle, + &link_enc_size); + + GNUNET_CRYPTO_hash_context_read (hash_context, + link_enc, + link_enc_size); + GNUNET_free (link_enc); + } + } buf = serialize_melt_data (&md, res_size); free_melt_data (&md);