diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-04-20 07:48:19 +0200 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-04-20 07:48:19 +0200 |
commit | 196a465c2254c224055b71a5bdb3697e7a468801 (patch) | |
tree | e6ab30ab3458ceb77bca7a54f995a604de540f7c /src/include | |
parent | 2408dd18af486517a484544ebf468e5790e7ce05 (diff) | |
download | gnunet-196a465c2254c224055b71a5bdb3697e7a468801.tar.gz gnunet-196a465c2254c224055b71a5bdb3697e7a468801.zip |
more comments, allow to pick up pow later
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_revocation_service.h | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h index 775da01ac..a5a014708 100644 --- a/src/include/gnunet_revocation_service.h +++ b/src/include/gnunet_revocation_service.h | |||
@@ -56,6 +56,9 @@ extern "C" | |||
56 | */ | 56 | */ |
57 | #define POW_COUNT 32 | 57 | #define POW_COUNT 32 |
58 | 58 | ||
59 | |||
60 | GNUNET_NETWORK_STRUCT_BEGIN | ||
61 | |||
59 | struct GNUNET_REVOCATION_Pow | 62 | struct GNUNET_REVOCATION_Pow |
60 | { | 63 | { |
61 | /** | 64 | /** |
@@ -66,12 +69,12 @@ struct GNUNET_REVOCATION_Pow | |||
66 | /** | 69 | /** |
67 | * The TTL of this revocation (purely informational) | 70 | * The TTL of this revocation (purely informational) |
68 | */ | 71 | */ |
69 | uint64_t ttl; | 72 | uint64_t ttl GNUNET_PACKED; |
70 | 73 | ||
71 | /** | 74 | /** |
72 | * The PoWs | 75 | * The PoWs |
73 | */ | 76 | */ |
74 | uint64_t pow[POW_COUNT]; | 77 | uint64_t pow[POW_COUNT] GNUNET_PACKED; |
75 | 78 | ||
76 | /** | 79 | /** |
77 | * The signature | 80 | * The signature |
@@ -89,6 +92,9 @@ struct GNUNET_REVOCATION_Pow | |||
89 | struct GNUNET_CRYPTO_EcdsaPublicKey key; | 92 | struct GNUNET_CRYPTO_EcdsaPublicKey key; |
90 | }; | 93 | }; |
91 | 94 | ||
95 | GNUNET_NETWORK_STRUCT_END | ||
96 | |||
97 | |||
92 | struct GNUNET_REVOCATION_PowCalculationHandle; | 98 | struct GNUNET_REVOCATION_PowCalculationHandle; |
93 | 99 | ||
94 | /** | 100 | /** |
@@ -185,6 +191,15 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow, | |||
185 | unsigned int matching_bits); | 191 | unsigned int matching_bits); |
186 | 192 | ||
187 | 193 | ||
194 | |||
195 | /** | ||
196 | * Initializes a fresh PoW computation | ||
197 | * | ||
198 | * @param key the key to calculate the PoW for. | ||
199 | * @param epochs the number of epochs for which the PoW must be valid. | ||
200 | * @param difficulty the base difficulty of the PoW | ||
201 | * @return a handle for use in PoW rounds | ||
202 | */ | ||
188 | struct GNUNET_REVOCATION_PowCalculationHandle* | 203 | struct GNUNET_REVOCATION_PowCalculationHandle* |
189 | GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_EcdsaPublicKey *key, | 204 | GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_EcdsaPublicKey *key, |
190 | int epochs, | 205 | int epochs, |
@@ -192,6 +207,20 @@ GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_EcdsaPublicKey *key, | |||
192 | 207 | ||
193 | 208 | ||
194 | /** | 209 | /** |
210 | * Initializes PoW computation based on an existing PoW. | ||
211 | * | ||
212 | * @param pow the PoW to continue the calculations from. | ||
213 | * @param epochs the number of epochs for which the PoW must be valid. | ||
214 | * @param difficulty the base difficulty of the PoW | ||
215 | * @return a handle for use in PoW rounds | ||
216 | */ | ||
217 | struct GNUNET_REVOCATION_PowCalculationHandle* | ||
218 | GNUNET_REVOCATION_pow_init2 (const struct GNUNET_REVOCATION_Pow *pow, | ||
219 | int epochs, | ||
220 | unsigned int difficulty); | ||
221 | |||
222 | |||
223 | /** | ||
195 | * Calculate a key revocation valid for broadcasting for a number | 224 | * Calculate a key revocation valid for broadcasting for a number |
196 | * of epochs. | 225 | * of epochs. |
197 | * | 226 | * |
@@ -205,11 +234,22 @@ int | |||
205 | GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc); | 234 | GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc); |
206 | 235 | ||
207 | 236 | ||
237 | /** | ||
238 | * Return the curren PoW state from the calculation | ||
239 | * | ||
240 | * @param pc the calculation to get it from | ||
241 | * @return a pointer to the PoW | ||
242 | */ | ||
208 | const struct GNUNET_REVOCATION_Pow* | 243 | const struct GNUNET_REVOCATION_Pow* |
209 | GNUNET_REVOCATION_pow_get (const struct | 244 | GNUNET_REVOCATION_pow_get (const struct |
210 | GNUNET_REVOCATION_PowCalculationHandle *pc); | 245 | GNUNET_REVOCATION_PowCalculationHandle *pc); |
211 | 246 | ||
212 | 247 | ||
248 | /** | ||
249 | * Cleanup a PoW calculation | ||
250 | * | ||
251 | * @param pc the calculation to clean up | ||
252 | */ | ||
213 | void | 253 | void |
214 | GNUNET_REVOCATION_pow_cleanup (struct | 254 | GNUNET_REVOCATION_pow_cleanup (struct |
215 | GNUNET_REVOCATION_PowCalculationHandle *pc); | 255 | GNUNET_REVOCATION_PowCalculationHandle *pc); |