implemented planchet_prepare for CS
This commit is contained in:
parent
a02ab8f81b
commit
f1ec1e70a0
@ -1061,7 +1061,8 @@ TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
|
|||||||
const struct TALER_AgeHash *age_commitment_hash,
|
const struct TALER_AgeHash *age_commitment_hash,
|
||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
struct TALER_CoinPubHash *c_hash,
|
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,
|
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
||||||
const struct TALER_PlanchetSecretsP *ps,
|
const struct TALER_PlanchetSecretsP *ps,
|
||||||
struct TALER_CoinPubHash *c_hash,
|
struct TALER_CoinPubHash *c_hash,
|
||||||
struct TALER_PlanchetDetail *pd);
|
struct TALER_PlanchetDetail *pd,
|
||||||
|
...);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,23 +280,61 @@ enum GNUNET_GenericReturnValue
|
|||||||
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
TALER_planchet_prepare (const struct TALER_DenominationPublicKey *dk,
|
||||||
const struct TALER_PlanchetSecretsP *ps,
|
const struct TALER_PlanchetSecretsP *ps,
|
||||||
struct TALER_CoinPubHash *c_hash,
|
struct TALER_CoinPubHash *c_hash,
|
||||||
struct TALER_PlanchetDetail *pd)
|
struct TALER_PlanchetDetail *pd,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
struct TALER_CoinSpendPublicKeyP coin_pub;
|
struct TALER_CoinSpendPublicKeyP coin_pub;
|
||||||
|
|
||||||
GNUNET_CRYPTO_eddsa_key_get_public (&ps->coin_priv.eddsa_priv,
|
GNUNET_CRYPTO_eddsa_key_get_public (&ps->coin_priv.eddsa_priv,
|
||||||
&coin_pub.eddsa_pub);
|
&coin_pub.eddsa_pub);
|
||||||
if (GNUNET_OK !=
|
|
||||||
TALER_denom_blind (dk,
|
switch (dk->cipher)
|
||||||
&ps->blinding_key,
|
|
||||||
NULL, /* FIXME-Oec */
|
|
||||||
&coin_pub,
|
|
||||||
c_hash,
|
|
||||||
&pd->blinded_planchet))
|
|
||||||
{
|
{
|
||||||
|
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);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
TALER_denom_pub_hash (dk,
|
TALER_denom_pub_hash (dk,
|
||||||
&pd->denom_pub_hash);
|
&pd->denom_pub_hash);
|
||||||
return GNUNET_OK;
|
return GNUNET_OK;
|
||||||
|
@ -244,6 +244,7 @@ TALER_denom_pub_hash (const struct TALER_DenominationPublicKey *denom_pub,
|
|||||||
GNUNET_CRYPTO_hash_context_read (hc,
|
GNUNET_CRYPTO_hash_context_read (hc,
|
||||||
&denom_pub->details.cs_public_key,
|
&denom_pub->details.cs_public_key,
|
||||||
sizeof(denom_pub->details.cs_public_key));
|
sizeof(denom_pub->details.cs_public_key));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
GNUNET_assert (0);
|
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_AgeHash *age_commitment_hash,
|
||||||
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
const struct TALER_CoinSpendPublicKeyP *coin_pub,
|
||||||
struct TALER_CoinPubHash *c_hash,
|
struct TALER_CoinPubHash *c_hash,
|
||||||
struct TALER_BlindedPlanchet *blinded_planchet)
|
struct TALER_BlindedPlanchet *blinded_planchet,
|
||||||
|
...)
|
||||||
{
|
{
|
||||||
blinded_planchet->cipher = dk->cipher;
|
blinded_planchet->cipher = dk->cipher;
|
||||||
TALER_coin_pub_hash (coin_pub,
|
TALER_coin_pub_hash (coin_pub,
|
||||||
@ -301,7 +303,34 @@ TALER_denom_blind (const struct TALER_DenominationPublicKey *dk,
|
|||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
return GNUNET_OK;
|
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:
|
default:
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
|
@ -148,10 +148,9 @@ test_planchets_cs (void)
|
|||||||
struct TALER_CoinPubHash c_hash;
|
struct TALER_CoinPubHash c_hash;
|
||||||
struct TALER_WithdrawNonce nonce;
|
struct TALER_WithdrawNonce nonce;
|
||||||
struct TALER_DenominationCsPublicR r_pub;
|
struct TALER_DenominationCsPublicR r_pub;
|
||||||
// struct TALER_DenominationCsPrivateR priv_r;
|
struct TALER_DenominationCsPrivateR priv_r;
|
||||||
// struct TALER_BlindedDenominationSignature blind_sig;
|
// struct TALER_BlindedDenominationSignature blind_sig;
|
||||||
// struct TALER_FreshCoin coin;
|
// struct TALER_FreshCoin coin;
|
||||||
// struct TALER_PlanchetDeriveCsBlindingSecrets seed;
|
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_denom_priv_create (&dk_priv,
|
TALER_denom_priv_create (&dk_priv,
|
||||||
@ -169,15 +168,17 @@ test_planchets_cs (void)
|
|||||||
&ps.coin_priv,
|
&ps.coin_priv,
|
||||||
&r_pub);
|
&r_pub);
|
||||||
|
|
||||||
// NEXT:
|
GNUNET_assert (GNUNET_OK ==
|
||||||
// Implement to genrate b-seed from it and calculate c then§
|
TALER_planchet_prepare (&dk_pub,
|
||||||
|
&ps,
|
||||||
// GNUNET_assert (GNUNET_OK ==
|
&c_hash,
|
||||||
// TALER_planchet_prepare (&dk_pub,
|
&pd,
|
||||||
// &ps,
|
&nonce,
|
||||||
// &c_hash,
|
&r_pub));
|
||||||
// &pd));
|
GNUNET_assert (GNUNET_OK ==
|
||||||
|
TALER_denom_cs_derive_r_secret (&nonce,
|
||||||
|
&dk_priv,
|
||||||
|
&priv_r));
|
||||||
|
|
||||||
// TALER_blinded_denom_sig_free (&blind_sig);
|
// TALER_blinded_denom_sig_free (&blind_sig);
|
||||||
// TALER_denom_sig_free (&coin.sig);
|
// TALER_denom_sig_free (&coin.sig);
|
||||||
|
Loading…
Reference in New Issue
Block a user