[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 09/31: no diplicate nonces
From: |
gnunet |
Subject: |
[gnunet] 09/31: no diplicate nonces |
Date: |
Wed, 22 Apr 2020 21:53:00 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 814b19c0b7621e7fb32446fa2996f838f56e45f8
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Sun Apr 19 20:25:17 2020 +0200
no diplicate nonces
---
src/revocation/revocation_api.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c
index 6510f9583..c817e612a 100644
--- a/src/revocation/revocation_api.c
+++ b/src/revocation/revocation_api.c
@@ -27,8 +27,7 @@
#include "gnunet_signatures.h"
#include "gnunet_protocols.h"
#include "revocation.h"
-#include <gcrypt.h>
-
+#include <inttypes.h>
/**
* Handle for the key revocation query.
@@ -389,6 +388,16 @@ GNUNET_REVOCATION_check_pow (const struct
GNUNET_REVOCATION_Pow *pow,
unsigned int epochs;
uint64_t pow_val;
+ /**
+ * First, check if any duplicates are in the PoW set
+ */
+ for (unsigned int i = 0; i < POW_COUNT; i++)
+ {
+ for (unsigned int j = i+1; j < POW_COUNT; j++) {
+ if (pow->pow[i] == pow->pow[j])
+ return GNUNET_NO;
+ }
+ }
GNUNET_memcpy (&buf[sizeof(uint64_t)],
&pow->timestamp,
sizeof (uint64_t));
@@ -405,8 +414,8 @@ GNUNET_REVOCATION_check_pow (const struct
GNUNET_REVOCATION_Pow *pow,
&result);
tmp_score = count_leading_zeroes (&result);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Score %u (#%u)\n",
- tmp_score, i);
+ "Score %u with %"PRIu64" (#%u)\n",
+ tmp_score, pow_val, i);
score += tmp_score;
}
@@ -460,6 +469,13 @@ GNUNET_REVOCATION_pow_round (struct
GNUNET_REVOCATION_PowCalculationHandle *pc)
pc->current_pow++;
+ /**
+ * Do not try duplicates
+ */
+ for (unsigned int i = 0; i < POW_COUNT; i++)
+ if (pc->current_pow == pc->best[i].pow)
+ return GNUNET_NO;
+
GNUNET_memcpy (buf, &pc->current_pow, sizeof(uint64_t));
GNUNET_memcpy (&buf[sizeof(uint64_t)],
&pc->pow.timestamp,
@@ -480,8 +496,8 @@ GNUNET_REVOCATION_pow_round (struct
GNUNET_REVOCATION_PowCalculationHandle *pc)
pc->best[i].pow = pc->current_pow;
pc->pow.pow[i] = GNUNET_htonll (pc->current_pow);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "New best score %u (#%u)\n",
- zeros, i);
+ "New best score %u with %"PRIu64" (#%u)\n",
+ zeros, pc->current_pow, i);
break;
}
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnunet] branch master updated (bf99d2243 -> f225e5688), gnunet, 2020/04/22
- [gnunet] 04/31: merge, gnunet, 2020/04/22
- [gnunet] 01/31: add argon2 for LSD0001, gnunet, 2020/04/22
- [gnunet] 03/31: update params, gnunet, 2020/04/22
- [gnunet] 02/31: add argon2 for LSD0001, gnunet, 2020/04/22
- [gnunet] 07/31: towards more expirations, gnunet, 2020/04/22
- [gnunet] 05/31: revert, gnunet, 2020/04/22
- [gnunet] 06/31: simplify pow even more; add timestamp to revocation pow, gnunet, 2020/04/22
- [gnunet] 09/31: no diplicate nonces,
gnunet <=
- [gnunet] 11/31: uncrustify, gnunet, 2020/04/22
- [gnunet] 12/31: those are actually debug messages, gnunet, 2020/04/22
- [gnunet] 13/31: more comments, allow to pick up pow later, gnunet, 2020/04/22
- [gnunet] 18/31: fix, gnunet, 2020/04/22
- [gnunet] 10/31: some comments, gnunet, 2020/04/22
- [gnunet] 25/31: packed makes no sense there, gnunet, 2020/04/22
- [gnunet] 19/31: check signature in check_pow, gnunet, 2020/04/22
- [gnunet] 14/31: evaluate epochs, gnunet, 2020/04/22
- [gnunet] 24/31: remove pow_get, gnunet, 2020/04/22
- [gnunet] 21/31: predate validity time on creation; extent ttl on validation, gnunet, 2020/04/22