implemented planchet_prepare for CS

This commit is contained in:
Gian Demarmels 2021-12-22 16:55:34 +01:00
parent a02ab8f81b
commit f1ec1e70a0
No known key found for this signature in database
GPG Key ID: 030CEDDCCC92D778
4 changed files with 93 additions and 23 deletions

View File

@ -1061,7 +1061,8 @@ TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
const struct TALER_AgeHash *age_commitment_hash,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct TALER_CoinPubHash *c_hash,
struct TALER_BlindedPlanchet *blinded_planchet);
struct TALER_BlindedPlanchet *blinded_planchet,
...);
/**
@ -1469,7 +1470,8 @@ enum GNUNET_GenericReturnValue
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
const struct TALER_PlanchetSecretsP *ps,
struct TALER_CoinPubHash *c_hash,
struct TALER_PlanchetDetail *pd);
struct TALER_PlanchetDetail *pd,
...);
/**

View File

@ -280,23 +280,61 @@ enum GNUNET_GenericReturnValue
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
const struct TALER_PlanchetSecretsP *ps,
struct TALER_CoinPubHash *c_hash,
struct TALER_PlanchetDetail *pd)
struct TALER_PlanchetDetail *pd,
...)
{
struct TALER_CoinSpendPublicKeyP coin_pub;
GNUNET_CRYPTO_eddsa_key_get_public (&ps->coin_priv.eddsa_priv,
&coin_pub.eddsa_pub);
if (GNUNET_OK !=
TALER_denom_blind (dk,
&ps->blinding_key,
NULL, /* FIXME-Oec */
&coin_pub,
c_hash,
&pd->blinded_planchet))
switch (dk->cipher)
{
case TALER_DENOMINATION_RSA:
if (GNUNET_OK !=
TALER_denom_blind (dk,
&ps->blinding_key,
NULL, /* FIXME-Oec */
&coin_pub,
c_hash,
&pd->blinded_planchet))
{
GNUNET_break (0);
return GNUNET_SYSERR;
}
break;
case TALER_DENOMINATION_CS:
{
va_list ap;
va_start (ap, pd);
struct TALER_WithdrawNonce *nonce;
struct TALER_DenominationCsPublicR *r_pub;
nonce = va_arg (ap, struct TALER_WithdrawNonce *);
r_pub = va_arg (ap, struct TALER_DenominationCsPublicR *);
if (GNUNET_OK !=
TALER_denom_blind (dk,
&ps->blinding_key,
NULL, /* FIXME-Oec */
&coin_pub,
c_hash,
&pd->blinded_planchet,
nonce,
r_pub))
{
va_end (ap);
GNUNET_break (0);
return GNUNET_SYSERR;
}
va_end (ap);
break;
}
default:
GNUNET_break (0);
return GNUNET_SYSERR;
}
TALER_denom_pub_hash (dk,
&pd->denom_pub_hash);
return GNUNET_OK;

View File

@ -244,6 +244,7 @@ TALER_denom_pub_hash (const struct TALER_DenominationPublicKey *denom_pub,
GNUNET_CRYPTO_hash_context_read (hc,
&denom_pub->details.cs_public_key,
sizeof(denom_pub->details.cs_public_key));
break;
default:
GNUNET_assert (0);
}
@ -279,7 +280,8 @@ TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
const struct TALER_AgeHash *age_commitment_hash,
const struct TALER_CoinSpendPublicKeyP *coin_pub,
struct TALER_CoinPubHash *c_hash,
struct TALER_BlindedPlanchet *blinded_planchet)
struct TALER_BlindedPlanchet *blinded_planchet,
...)
{
blinded_planchet->cipher = dk->cipher;
TALER_coin_pub_hash (coin_pub,
@ -301,7 +303,34 @@ TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
return GNUNET_SYSERR;
}
return GNUNET_OK;
// TODO: add case for Clause-Schnorr
case TALER_DENOMINATION_CS:
{
// TODO: Where to store the blinded rpub? currently ignored
struct GNUNET_CRYPTO_CsRPublic blinded_r_pub[2];
va_list ap;
va_start (ap, blinded_planchet);
struct TALER_WithdrawNonce *nonce;
struct TALER_DenominationCsPublicR *r_pub;
nonce = va_arg (ap, struct TALER_WithdrawNonce *);
r_pub = va_arg (ap, struct TALER_DenominationCsPublicR *);
struct GNUNET_CRYPTO_CsBlindingSecret bs[2];
GNUNET_CRYPTO_cs_blinding_secrets_derive (&nonce->nonce, bs);
GNUNET_CRYPTO_cs_calc_blinded_c (bs,
r_pub->r_pub,
&dk->details.cs_public_key,
&c_hash->hash,
sizeof(struct GNUNET_HashCode),
blinded_planchet->details.
cs_blinded_planchet.c,
blinded_r_pub);
va_end (ap);
return GNUNET_OK;
}
default:
GNUNET_break (0);
return GNUNET_SYSERR;

View File

@ -148,10 +148,9 @@ test_planchets_cs (void)
struct TALER_CoinPubHash c_hash;
struct TALER_WithdrawNonce nonce;
struct TALER_DenominationCsPublicR r_pub;
// struct TALER_DenominationCsPrivateR priv_r;
struct TALER_DenominationCsPrivateR priv_r;
// struct TALER_BlindedDenominationSignature blind_sig;
// struct TALER_FreshCoin coin;
// struct TALER_PlanchetDeriveCsBlindingSecrets seed;
GNUNET_assert (GNUNET_OK ==
TALER_denom_priv_create (&dk_priv,
@ -169,15 +168,17 @@ test_planchets_cs (void)
&ps.coin_priv,
&r_pub);
// NEXT:
// Implement to genrate b-seed from it and calculate c then§
// GNUNET_assert (GNUNET_OK ==
// TALER_planchet_prepare (&dk_pub,
// &ps,
// &c_hash,
// &pd));
GNUNET_assert (GNUNET_OK ==
TALER_planchet_prepare (&dk_pub,
&ps,
&c_hash,
&pd,
&nonce,
&r_pub));
GNUNET_assert (GNUNET_OK ==
TALER_denom_cs_derive_r_secret (&nonce,
&dk_priv,
&priv_r));
// TALER_blinded_denom_sig_free (&blind_sig);
// TALER_denom_sig_free (&coin.sig);