[WIP - DOESN'T COMPILE] age_commitment_hash added

This commit is contained in:
Özgür Kesim 2022-01-30 14:18:04 +01:00
parent 0dfd1af8d7
commit 34e71cce0c
Signed by: oec
GPG Key ID: 3D76A56D79EDD9D7
2 changed files with 54 additions and 0 deletions

View File

@ -317,6 +317,30 @@ extern const struct TALER_AgeHash TALER_AgeHash_zeroHash;
&TALER_AgeHash_zeroHash, \
sizeof(struct \
TALER_AgeHash))))
/*
* @brief Representation of an age commitment: one public key per age group.
*
* The number of keys must be be the same as the number of bits set in the
* corresponding age mask.
*/
struct TALER_AgeCommitment
{
struct TALER_AgeMask mask;
struct GNUNET_CRYPTO_EddsaPublicKey *keys;
size_t num_keys;
};
/*
* @brief Generates a hash of the public keys in the age commitment.
* @param commitment the age commitment - one public key per age group
* @param[out] hash resulting hash
*/
void
TALER_age_commitment_hash (
const struct TALER_AgeCommitment *commitment,
struct TALER_AgeHash *hash);
/**
* @brief Type of public keys for Taler coins. The same key material is used

View File

@ -20,6 +20,7 @@
* @author Florian Dold
* @author Benedikt Mueller
* @author Christian Grothoff
* @author Özgür Kesim
*/
#include "platform.h"
#include "taler_util.h"
@ -356,4 +357,33 @@ TALER_coin_pub_hash (const struct TALER_CoinSpendPublicKeyP *coin_pub,
}
void
TALER_age_commitment_hash (
const struct TALER_AgeCommitment *commitment,
struct TALER_AgeHash *ahash)
{
struct GNUNET_HashContext *hash_context;
struct GNUNET_HashCode hash;
GNUNET_assert (NULL != commitment);
GNUNET_assert (__builtin_popcount (commitment->mask.mask) ==
commitment->num_keys);
hash_context = GNUNET_CRYPTO_hash_context_start ();
for (size_t i = 0; i < commitment->num_keys; i++)
{
GNUNET_CRYPTO_hash_context_read (hash_context,
&commitment->keys[i],
sizeof(struct
GNUNET_CRYPTO_EddsaPublicKey));
}
GNUNET_CRYPTO_hash_context_finish (hash_context,
&hash);
GNUNET_memcpy (&ahash->shash.bits,
&hash.bits,
sizeof(ahash->shash.bits));
}
/* end of crypto.c */