-fixed tests for age restriction, now using correct seed
This commit is contained in:
parent
eea35ffb01
commit
31c545b9e8
@ -88,17 +88,19 @@ TALER_age_restriction_commit (
|
|||||||
const struct GNUNET_HashCode *seed,
|
const struct GNUNET_HashCode *seed,
|
||||||
struct TALER_AgeCommitmentProof *new)
|
struct TALER_AgeCommitmentProof *new)
|
||||||
{
|
{
|
||||||
struct GNUNET_HashCode seed_i = *seed;
|
struct GNUNET_HashCode seed_i;
|
||||||
uint8_t num_pub = __builtin_popcount (mask->bits) - 1;
|
uint8_t num_pub = __builtin_popcount (mask->bits) - 1;
|
||||||
uint8_t num_priv = get_age_group (mask, age);
|
uint8_t num_priv = get_age_group (mask, age);
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
GNUNET_assert (NULL != seed);
|
||||||
GNUNET_assert (NULL != new);
|
GNUNET_assert (NULL != new);
|
||||||
GNUNET_assert (mask->bits & 1); /* fist bit must have been set */
|
GNUNET_assert (mask->bits & 1); /* fist bit must have been set */
|
||||||
GNUNET_assert (0 <= num_priv);
|
GNUNET_assert (0 <= num_priv);
|
||||||
GNUNET_assert (31 > num_priv);
|
GNUNET_assert (31 > num_priv);
|
||||||
GNUNET_assert (num_priv <= num_pub);
|
GNUNET_assert (num_priv <= num_pub);
|
||||||
|
|
||||||
|
seed_i = *seed;
|
||||||
new->commitment.mask.bits = mask->bits;
|
new->commitment.mask.bits = mask->bits;
|
||||||
new->commitment.num = num_pub;
|
new->commitment.num = num_pub;
|
||||||
new->proof.num = num_priv;
|
new->proof.num = num_priv;
|
||||||
|
@ -148,12 +148,16 @@ test_attestation (void)
|
|||||||
struct TALER_AgeCommitmentProof acp[3] = {0};
|
struct TALER_AgeCommitmentProof acp[3] = {0};
|
||||||
struct TALER_AgeAttestation at = {0};
|
struct TALER_AgeAttestation at = {0};
|
||||||
uint8_t age_group = get_age_group (&age_mask, age);
|
uint8_t age_group = get_age_group (&age_mask, age);
|
||||||
uint64_t salt = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
|
struct GNUNET_HashCode seed;
|
||||||
UINT64_MAX);
|
|
||||||
|
|
||||||
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
|
&seed,
|
||||||
|
sizeof(seed));
|
||||||
|
|
||||||
ret = TALER_age_restriction_commit (&age_mask,
|
ret = TALER_age_restriction_commit (&age_mask,
|
||||||
age,
|
age,
|
||||||
salt,
|
&seed,
|
||||||
&acp[0]);
|
&acp[0]);
|
||||||
|
|
||||||
printf (
|
printf (
|
||||||
@ -166,8 +170,8 @@ test_attestation (void)
|
|||||||
/* Also derive two more commitments right away */
|
/* Also derive two more commitments right away */
|
||||||
for (uint8_t i = 0; i<2; i++)
|
for (uint8_t i = 0; i<2; i++)
|
||||||
{
|
{
|
||||||
salt = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
|
uint64_t salt = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
UINT64_MAX);
|
UINT64_MAX);
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_age_commitment_derive (&acp[i],
|
TALER_age_commitment_derive (&acp[i],
|
||||||
salt,
|
salt,
|
||||||
|
@ -131,13 +131,16 @@ test_planchets_rsa (uint8_t age)
|
|||||||
{
|
{
|
||||||
struct TALER_AgeCommitmentProof acp;
|
struct TALER_AgeCommitmentProof acp;
|
||||||
struct TALER_AgeCommitmentHash ah = {0};
|
struct TALER_AgeCommitmentHash ah = {0};
|
||||||
uint64_t salt = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
|
struct GNUNET_HashCode seed;
|
||||||
UINT64_MAX);
|
|
||||||
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
|
&seed,
|
||||||
|
sizeof(seed));
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_age_restriction_commit (&age_mask,
|
TALER_age_restriction_commit (&age_mask,
|
||||||
age,
|
age,
|
||||||
salt,
|
&seed,
|
||||||
&acp));
|
&acp));
|
||||||
TALER_age_commitment_hash (&acp.commitment,
|
TALER_age_commitment_hash (&acp.commitment,
|
||||||
&ah);
|
&ah);
|
||||||
@ -260,13 +263,16 @@ test_planchets_cs (uint8_t age)
|
|||||||
{
|
{
|
||||||
struct TALER_AgeCommitmentHash ah = {0};
|
struct TALER_AgeCommitmentHash ah = {0};
|
||||||
struct TALER_AgeCommitmentProof acp;
|
struct TALER_AgeCommitmentProof acp;
|
||||||
uint64_t salt = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
|
struct GNUNET_HashCode seed;
|
||||||
UINT64_MAX);
|
|
||||||
|
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||||
|
&seed,
|
||||||
|
sizeof(seed));
|
||||||
|
|
||||||
GNUNET_assert (GNUNET_OK ==
|
GNUNET_assert (GNUNET_OK ==
|
||||||
TALER_age_restriction_commit (&age_mask,
|
TALER_age_restriction_commit (&age_mask,
|
||||||
age,
|
age,
|
||||||
salt,
|
&seed,
|
||||||
&acp));
|
&acp));
|
||||||
TALER_age_commitment_hash (&acp.commitment,
|
TALER_age_commitment_hash (&acp.commitment,
|
||||||
&ah);
|
&ah);
|
||||||
|
Loading…
Reference in New Issue
Block a user