aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_revocation_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_revocation_service.h')
-rw-r--r--src/include/gnunet_revocation_service.h73
1 files changed, 40 insertions, 33 deletions
diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h
index 6bd2e88d3..e8824bd8a 100644
--- a/src/include/gnunet_revocation_service.h
+++ b/src/include/gnunet_revocation_service.h
@@ -69,7 +69,7 @@ struct GNUNET_REVOCATION_Pow
69 /** 69 /**
70 * The TTL of this revocation (purely informational) 70 * The TTL of this revocation (purely informational)
71 */ 71 */
72 uint64_t ttl GNUNET_PACKED; 72 struct GNUNET_TIME_RelativeNBO ttl GNUNET_PACKED;
73 73
74 /** 74 /**
75 * The PoWs 75 * The PoWs
@@ -82,6 +82,18 @@ struct GNUNET_REVOCATION_Pow
82 struct GNUNET_CRYPTO_EcdsaSignature signature; 82 struct GNUNET_CRYPTO_EcdsaSignature signature;
83 83
84 /** 84 /**
85 * The revoked public key
86 */
87 struct GNUNET_CRYPTO_EcdsaPublicKey key;
88};
89
90
91/**
92 * The signature object we use for the PoW
93 */
94struct GNUNET_REVOCATION_SignaturePurpose
95{
96 /**
85 * The signature purpose 97 * The signature purpose
86 */ 98 */
87 struct GNUNET_CRYPTO_EccSignaturePurpose purpose; 99 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
@@ -90,11 +102,19 @@ struct GNUNET_REVOCATION_Pow
90 * The revoked public key 102 * The revoked public key
91 */ 103 */
92 struct GNUNET_CRYPTO_EcdsaPublicKey key; 104 struct GNUNET_CRYPTO_EcdsaPublicKey key;
105
106 /**
107 * The timestamp of the revocation
108 */
109 struct GNUNET_TIME_AbsoluteNBO timestamp;
93}; 110};
94 111
95GNUNET_NETWORK_STRUCT_END 112GNUNET_NETWORK_STRUCT_END
96 113
97 114
115/**
116 * Handle to a running proof-of-work calculation.
117 */
98struct GNUNET_REVOCATION_PowCalculationHandle; 118struct GNUNET_REVOCATION_PowCalculationHandle;
99 119
100/** 120/**
@@ -112,7 +132,8 @@ struct GNUNET_REVOCATION_Query;
112 * 132 *
113 */ 133 */
114typedef void (*GNUNET_REVOCATION_Callback) (void *cls, 134typedef void (*GNUNET_REVOCATION_Callback) (void *cls,
115 int is_valid); 135 enum GNUNET_GenericReturnValue
136 is_valid);
116 137
117 138
118/** 139/**
@@ -151,7 +172,7 @@ struct GNUNET_REVOCATION_Handle;
151 * @param cfg the configuration to use 172 * @param cfg the configuration to use
152 * @param pow proof of work to use (should have been created by 173 * @param pow proof of work to use (should have been created by
153 * iteratively calling #GNUNET_REVOCATION_pow_round) 174 * iteratively calling #GNUNET_REVOCATION_pow_round)
154 * @param func funtion to call with the result of the check 175 * @param func function to call with the result of the check
155 * (called with `is_valid` being #GNUNET_NO if 176 * (called with `is_valid` being #GNUNET_NO if
156 * the revocation worked). 177 * the revocation worked).
157 * @param func_cls closure to pass to @a func 178 * @param func_cls closure to pass to @a func
@@ -177,40 +198,37 @@ GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h);
177 * 198 *
178 * @param pow proof of work 199 * @param pow proof of work
179 * @param matching_bits how many bits must match (configuration) 200 * @param matching_bits how many bits must match (configuration)
180 * @param epoch_length length of single epoch in configuration 201 * @param epoch_duration length of single epoch in configuration
181 * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not 202 * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
182 */ 203 */
183int 204enum GNUNET_GenericReturnValue
184GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow, 205GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow,
185 unsigned int matching_bits, 206 unsigned int matching_bits,
186 struct GNUNET_TIME_Relative epoch_length); 207 struct GNUNET_TIME_Relative epoch_duration);
187
188 208
189 209
190/** 210/**
191 * Initializes a fresh PoW computation 211 * Initializes a fresh PoW computation.
192 * 212 *
193 * @param key the key to calculate the PoW for. 213 * @param key the key to calculate the PoW for.
194 * @param epochs the number of epochs for which the PoW must be valid. 214 * @param pow the pow object to work with in the calculation.
195 * @param difficulty the base difficulty of the PoW
196 * @return a handle for use in PoW rounds
197 */ 215 */
198struct GNUNET_REVOCATION_PowCalculationHandle* 216void
199GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, 217GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
200 int epochs, 218 struct GNUNET_REVOCATION_Pow *pow);
201 unsigned int difficulty);
202 219
203 220
204/** 221/**
205 * Initializes PoW computation based on an existing PoW. 222 * Starts a proof-of-work calculation given the pow object as well as
223 * target epochs and difficulty.
206 * 224 *
207 * @param pow the PoW to continue the calculations from. 225 * @param pow the PoW to based calculations on.
208 * @param epochs the number of epochs for which the PoW must be valid. 226 * @param epochs the number of epochs for which the PoW must be valid.
209 * @param difficulty the base difficulty of the PoW 227 * @param difficulty the base difficulty of the PoW.
210 * @return a handle for use in PoW rounds 228 * @return a handle for use in PoW rounds
211 */ 229 */
212struct GNUNET_REVOCATION_PowCalculationHandle* 230struct GNUNET_REVOCATION_PowCalculationHandle*
213GNUNET_REVOCATION_pow_init2 (const struct GNUNET_REVOCATION_Pow *pow, 231GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_Pow *pow,
214 int epochs, 232 int epochs,
215 unsigned int difficulty); 233 unsigned int difficulty);
216 234
@@ -221,29 +239,18 @@ GNUNET_REVOCATION_pow_init2 (const struct GNUNET_REVOCATION_Pow *pow,
221 * @param pc handle to the PoW, initially called with NULL. 239 * @param pc handle to the PoW, initially called with NULL.
222 * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not 240 * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not
223 */ 241 */
224int 242enum GNUNET_GenericReturnValue
225GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc); 243GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
226 244
227 245
228/** 246/**
229 * Return the current PoW state from the calculation
230 *
231 * @param pc the calculation to get it from
232 * @return a pointer to the PoW
233 */
234const struct GNUNET_REVOCATION_Pow*
235GNUNET_REVOCATION_pow_get (const struct
236 GNUNET_REVOCATION_PowCalculationHandle *pc);
237
238
239/**
240 * Cleanup a PoW calculation 247 * Cleanup a PoW calculation
241 * 248 *
242 * @param pc the calculation to clean up 249 * @param pc the calculation to clean up
243 */ 250 */
244void 251void
245GNUNET_REVOCATION_pow_cleanup (struct 252GNUNET_REVOCATION_pow_cleanup (
246 GNUNET_REVOCATION_PowCalculationHandle *pc); 253 struct GNUNET_REVOCATION_PowCalculationHandle *pc);
247 254
248#if 0 /* keep Emacsens' auto-indent happy */ 255#if 0 /* keep Emacsens' auto-indent happy */
249{ 256{