* @param ts revocation timestamp
* @param pow proof of work value
* @param matching_bits how many bits must match (configuration)
- * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
+ * @return number of epochs valid if the @a pow is acceptable, -1 if not
*/
int
GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow,
*/
static unsigned long long matching_bits;
+/**
+ * Epoch length
+ */
+static struct GNUNET_TIME_Relative epoch_length;
+
/**
* Task used for proof-of-work calculation.
*/
struct GNUNET_REVOCATION_Pow *pow;
struct GNUNET_CRYPTO_EcdsaPublicKey key;
struct GNUNET_REVOCATION_PowCalculationHandle *ph = NULL;
+ int epochs;
el = NULL;
if (NULL == ego)
GNUNET_free (pow);
return;
}
- if (GNUNET_YES ==
+ if (0 < (epochs =
GNUNET_REVOCATION_check_pow (pow,
- (unsigned int) matching_bits))
+ (unsigned int) matching_bits)))
{
+ struct GNUNET_TIME_Absolute ts;
+ struct GNUNET_TIME_Relative ttl;
+ ts = GNUNET_TIME_absolute_ntoh (pow->timestamp);
+ ttl = GNUNET_TIME_relative_multiply (epoch_length,
+ epochs);
fprintf (stderr, "%s", _ ("Revocation certificate ready\n"));
+ fprintf (stderr, "%s %s for %s\n", _ ("Valid from"),
+ GNUNET_STRINGS_absolute_time_to_string (ts),
+ GNUNET_STRINGS_relative_time_to_string (ttl, GNUNET_NO));
if (perform)
perform_revocation (pow);
else
"WORKBITS");
return;
}
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg,
+ "REVOCATION",
+ "EPOCH_LENGTH",
+ &epoch_length))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "REVOCATION",
+ "EPOCH_LENGTH");
+ return;
+ }
+
if (NULL != revoke_ego)
{
if (! perform && (NULL == filename))
return;
}
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
- if (GNUNET_YES !=
+ if (0 >=
GNUNET_REVOCATION_check_pow (&pow,
(unsigned int) matching_bits))
{
static int
verify_revoke_message (const struct RevokeMessage *rm)
{
- if (GNUNET_YES !=
- GNUNET_REVOCATION_check_pow (&rm->proof_of_work,
+ if (0 >= GNUNET_REVOCATION_check_pow (&rm->proof_of_work,
(unsigned int) revocation_work_required))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_break_op (0);
return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
}
- if (GNUNET_YES !=
+ if (0 >=
GNUNET_REVOCATION_check_pow (&rm->proof_of_work,
ic->matching_bits))
{
"REVOCATION",
"WORKBITS",
&matching_bits)) &&
- (GNUNET_YES !=
- GNUNET_REVOCATION_check_pow (pow,
- (unsigned int) matching_bits)))
+ (0 >= GNUNET_REVOCATION_check_pow (pow, (unsigned int) matching_bits)))
{
GNUNET_break (0);
GNUNET_free (h);
* @param ts revocation timestamp
* @param pow proof of work value
* @param matching_bits how many bits must match (configuration)
- * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
+ * @return number of epochs valid if the @a pow is acceptable, -1 if not
*/
int
GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow,
for (unsigned int j = i + 1; j < POW_COUNT; j++)
{
if (pow->pow[i] == pow->pow[j])
- return GNUNET_NO;
+ return -1;
}
}
GNUNET_memcpy (&buf[sizeof(uint64_t)],
score = score / POW_COUNT;
if (score < difficulty)
return GNUNET_NO;
- // TODO verfiy signature?
- epochs = score - difficulty + 1;
- // TODO verify expiration
- return GNUNET_YES;
+ epochs = score - difficulty;
+ return epochs;
}