aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-08-19 20:32:27 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-08-19 20:32:27 +0000
commit491e6b15d64983d8885067d3ef7bcb354d9555c6 (patch)
tree968109b149ea6cccb8d3c4123bc59d1aad9e1ec4 /src/include
parent41b260fd0f3db3daf54c5e03ccb07af4b1fc5859 (diff)
downloadgnunet-491e6b15d64983d8885067d3ef7bcb354d9555c6.tar.gz
gnunet-491e6b15d64983d8885067d3ef7bcb354d9555c6.zip
sensor: test case for proof-of-work + fixes
Diffstat (limited to 'src/include')
-rw-r--r--src/include/gnunet_sensor_util_lib.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/include/gnunet_sensor_util_lib.h b/src/include/gnunet_sensor_util_lib.h
index d1b1a925e..55cfc9002 100644
--- a/src/include/gnunet_sensor_util_lib.h
+++ b/src/include/gnunet_sensor_util_lib.h
@@ -415,10 +415,26 @@ struct GNUNET_SENSOR_crypto_pow_block
415 struct GNUNET_CRYPTO_EddsaSignature signature; 415 struct GNUNET_CRYPTO_EddsaSignature signature;
416 416
417 /** 417 /**
418 * Purpose of signing, data is allocated after this. 418 * Size of the msg component (allocated after this struct)
419 */
420 size_t msg_size;
421
422 /**
423 * Purpose of signing.
424 * Data is allocated after this (timestamp, public_key, msg).
419 */ 425 */
420 struct GNUNET_CRYPTO_EccSignaturePurpose purpose; 426 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
421 427
428 /**
429 * First part of data - timestamp
430 */
431 struct GNUNET_TIME_Absolute timestamp;
432
433 /**
434 * Second part of data - Public key
435 */
436 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
437
422}; 438};
423 439
424 440
@@ -468,6 +484,29 @@ GNUNET_SENSOR_crypto_pow_sign (void *msg, size_t msg_size,
468 GNUNET_SENSOR_UTIL_pow_callback callback, 484 GNUNET_SENSOR_UTIL_pow_callback callback,
469 void *callback_cls); 485 void *callback_cls);
470 486
487
488/**
489 * Verify that proof-of-work and signature in the given block are valid.
490 * If all valid, a pointer to the payload within the block is set and the size
491 * of the payload is returned.
492 *
493 * **VERY IMPORTANT** : You will still need to verify the timestamp yourself.
494 *
495 * @param block The block received and needs to be verified
496 * @param matching_bits Number of leading zeros in the hash used to verify pow
497 * @param public_key Public key of the peer that sent this block
498 * @param purpose Expected signing purpose
499 * @param payload Where to store the pointer to the payload
500 * @return Size of the payload
501 */
502size_t
503GNUNET_SENSOR_crypto_verify_pow_sign (struct GNUNET_SENSOR_crypto_pow_block *
504 block, int matching_bits,
505 struct GNUNET_CRYPTO_EddsaPublicKey *
506 public_key, uint32_t purpose,
507 void **payload);
508
509
471#if 0 /* keep Emacsens' auto-indent happy */ 510#if 0 /* keep Emacsens' auto-indent happy */
472{ 511{
473#endif 512#endif