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.h142
1 files changed, 119 insertions, 23 deletions
diff --git a/src/include/gnunet_revocation_service.h b/src/include/gnunet_revocation_service.h
index 7222cedc1..9a8918b43 100644
--- a/src/include/gnunet_revocation_service.h
+++ b/src/include/gnunet_revocation_service.h
@@ -51,6 +51,73 @@ extern "C"
51#define GNUNET_REVOCATION_VERSION 0x00000000 51#define GNUNET_REVOCATION_VERSION 0x00000000
52 52
53/** 53/**
54 * The proof-of-work narrowing factor.
55 * The number of PoWs that are calculates as part of revocation.
56 */
57#define POW_COUNT 32
58
59
60GNUNET_NETWORK_STRUCT_BEGIN
61
62struct GNUNET_REVOCATION_Pow
63{
64 /**
65 * The timestamp of the revocation
66 */
67 struct GNUNET_TIME_AbsoluteNBO timestamp;
68
69 /**
70 * The TTL of this revocation (purely informational)
71 */
72 struct GNUNET_TIME_RelativeNBO ttl;
73
74 /**
75 * The PoWs
76 */
77 uint64_t pow[POW_COUNT] GNUNET_PACKED;
78
79 /**
80 * The signature
81 */
82 struct GNUNET_CRYPTO_EcdsaSignature signature;
83
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 /**
97 * The signature purpose
98 */
99 struct GNUNET_CRYPTO_EccSignaturePurpose purpose;
100
101 /**
102 * The revoked public key
103 */
104 struct GNUNET_CRYPTO_EcdsaPublicKey key;
105
106 /**
107 * The timestamp of the revocation
108 */
109 struct GNUNET_TIME_AbsoluteNBO timestamp;
110};
111
112GNUNET_NETWORK_STRUCT_END
113
114
115/**
116 * Handle to a running proof-of-work calculation.
117 */
118struct GNUNET_REVOCATION_PowCalculationHandle;
119
120/**
54 * Handle for the key revocation query. 121 * Handle for the key revocation query.
55 */ 122 */
56struct GNUNET_REVOCATION_Query; 123struct GNUNET_REVOCATION_Query;
@@ -65,7 +132,8 @@ struct GNUNET_REVOCATION_Query;
65 * 132 *
66 */ 133 */
67typedef void (*GNUNET_REVOCATION_Callback) (void *cls, 134typedef void (*GNUNET_REVOCATION_Callback) (void *cls,
68 int is_valid); 135 enum GNUNET_GenericReturnValue
136 is_valid);
69 137
70 138
71/** 139/**
@@ -102,12 +170,9 @@ struct GNUNET_REVOCATION_Handle;
102 * Perform key revocation. 170 * Perform key revocation.
103 * 171 *
104 * @param cfg the configuration to use 172 * @param cfg the configuration to use
105 * @param key public key of the key to revoke
106 * @param sig signature to use on the revocation (should have been
107 * created using #GNUNET_REVOCATION_sign_revocation).
108 * @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
109 * iteratively calling #GNUNET_REVOCATION_check_pow) 174 * iteratively calling #GNUNET_REVOCATION_pow_round)
110 * @param func funtion to call with the result of the check 175 * @param func function to call with the result of the check
111 * (called with `is_valid` being #GNUNET_NO if 176 * (called with `is_valid` being #GNUNET_NO if
112 * the revocation worked). 177 * the revocation worked).
113 * @param func_cls closure to pass to @a func 178 * @param func_cls closure to pass to @a func
@@ -115,9 +180,7 @@ struct GNUNET_REVOCATION_Handle;
115 */ 180 */
116struct GNUNET_REVOCATION_Handle * 181struct GNUNET_REVOCATION_Handle *
117GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg, 182GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
118 const struct GNUNET_CRYPTO_EcdsaPublicKey *key, 183 const struct GNUNET_REVOCATION_Pow *pow,
119 const struct GNUNET_CRYPTO_EcdsaSignature *sig,
120 uint64_t pow,
121 GNUNET_REVOCATION_Callback func, void *func_cls); 184 GNUNET_REVOCATION_Callback func, void *func_cls);
122 185
123 186
@@ -131,31 +194,64 @@ GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h);
131 194
132 195
133/** 196/**
134 * Check if the given proof-of-work value 197 * Check if the given proof-of-work is valid.
135 * would be acceptable for revoking the given key.
136 * 198 *
137 * @param key key to check for 199 * @param pow proof of work
138 * @param pow proof of work value
139 * @param matching_bits how many bits must match (configuration) 200 * @param matching_bits how many bits must match (configuration)
201 * @param epoch_duration length of single epoch in configuration
140 * @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
141 */ 203 */
142int 204enum GNUNET_GenericReturnValue
143GNUNET_REVOCATION_check_pow (const struct GNUNET_CRYPTO_EcdsaPublicKey *key, 205GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_Pow *pow,
144 uint64_t pow, 206 unsigned int matching_bits,
145 unsigned int matching_bits); 207 struct GNUNET_TIME_Relative epoch_duration);
146 208
147 209
148/** 210/**
149 * Create a revocation signature. 211 * Initializes a fresh PoW computation.
150 * 212 *
151 * @param key private key of the key to revoke 213 * @param key the key to calculate the PoW for.
152 * @param sig where to write the revocation signature 214 * @param pow the pow object to work with in the calculation.
153 */ 215 */
154void 216void
155GNUNET_REVOCATION_sign_revocation (const struct 217GNUNET_REVOCATION_pow_init (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
156 GNUNET_CRYPTO_EcdsaPrivateKey *key, 218 struct GNUNET_REVOCATION_Pow *pow);
157 struct GNUNET_CRYPTO_EcdsaSignature *sig); 219
220
221/**
222 * Starts a proof-of-work calculation given the pow object as well as
223 * target epochs and difficulty.
224 *
225 * @param pow the PoW to based calculations on.
226 * @param epochs the number of epochs for which the PoW must be valid.
227 * @param difficulty the base difficulty of the PoW.
228 * @return a handle for use in PoW rounds
229 */
230struct GNUNET_REVOCATION_PowCalculationHandle*
231GNUNET_REVOCATION_pow_start (struct GNUNET_REVOCATION_Pow *pow,
232 int epochs,
233 unsigned int difficulty);
234
158 235
236/**
237 * Calculate a single round in the key revocation PoW.
238 *
239 * @param pc handle to the PoW, initially called with NULL.
240 * @return GNUNET_YES if the @a pow is acceptable, GNUNET_NO if not
241 */
242enum GNUNET_GenericReturnValue
243GNUNET_REVOCATION_pow_round (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
244
245
246/**
247 * Stop a PoW calculation
248 *
249 * @param pc the calculation to clean up
250 * @return #GNUNET_YES if pow valid, #GNUNET_NO if pow was set but is not
251 * valid
252 */
253void
254GNUNET_REVOCATION_pow_stop (struct GNUNET_REVOCATION_PowCalculationHandle *pc);
159 255
160#if 0 /* keep Emacsens' auto-indent happy */ 256#if 0 /* keep Emacsens' auto-indent happy */
161{ 257{