aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Schwieren <tristan.schwieren@tum.de>2022-01-09 22:53:26 +0100
committerTristan Schwieren <tristan.schwieren@tum.de>2022-01-09 22:53:26 +0100
commita3579be4e2a4193e4ba5df5bac71a1f88fef9219 (patch)
treecf163b0838b41cbaf69a18e6934423d6682c91b1
parent4da81265a258c1eee35697e7517103c8056ed377 (diff)
downloadgnunet-a3579be4e2a4193e4ba5df5bac71a1f88fef9219.tar.gz
gnunet-a3579be4e2a4193e4ba5df5bac71a1f88fef9219.zip
-w3cvc Presentation generation & getter
-rw-r--r--src/reclaim/gnunet-reclaim.c2
-rw-r--r--src/reclaim/plugin_reclaim_credential_vc.c286
-rwxr-xr-xsrc/reclaim/test_reclaim_vc.sh15
3 files changed, 214 insertions, 89 deletions
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c
index 409ef78bd..6c0996783 100644
--- a/src/reclaim/gnunet-reclaim.c
+++ b/src/reclaim/gnunet-reclaim.c
@@ -317,7 +317,7 @@ process_attrs (void *cls,
317 317
318 // FIXME: This is not right. Use the to_string function of the presentation 318 // FIXME: This is not right. Use the to_string function of the presentation
319 fprintf (stdout, 319 fprintf (stdout,
320 "Presentation: %s\n", 320 "Presentation:\n%s\n",
321 (char *) presentation->data 321 (char *) presentation->data
322 ); 322 );
323 323
diff --git a/src/reclaim/plugin_reclaim_credential_vc.c b/src/reclaim/plugin_reclaim_credential_vc.c
index b58af5595..3c85a9498 100644
--- a/src/reclaim/plugin_reclaim_credential_vc.c
+++ b/src/reclaim/plugin_reclaim_credential_vc.c
@@ -41,7 +41,7 @@
41 * @return NULL on error, otherwise human-readable representation of the value 41 * @return NULL on error, otherwise human-readable representation of the value
42 */ 42 */
43static char * 43static char *
44vc_value_to_string (void *cls, 44value_to_string (void *cls,
45 uint32_t type, 45 uint32_t type,
46 const void *data, 46 const void *data,
47 size_t data_size) 47 size_t data_size)
@@ -69,7 +69,7 @@ vc_value_to_string (void *cls,
69 * @return #GNUNET_OK on success 69 * @return #GNUNET_OK on success
70 */ 70 */
71static int 71static int
72vc_string_to_value (void *cls, 72string_to_value (void *cls,
73 uint32_t type, 73 uint32_t type,
74 const char *s, 74 const char *s,
75 void **data, 75 void **data,
@@ -142,34 +142,57 @@ vc_number_to_typename (void *cls, uint32_t type)
142 return vc_cred_name_map[i].name; 142 return vc_cred_name_map[i].name;
143} 143}
144 144
145/**
146 *
147 * @return
148 */
149json_t *
150get_json_vc_from_json_vp(json_t * cred)
151{
152 json_t * vc_array;
153 json_t * vc;
154
155 vc_array = json_object_get(cred, "verifiableCredential");
156
157 if(vc_array == NULL){
158 printf("The Verifiable Presentation has to contain an Array with Key \"verifiableCredential\"\n");
159 return NULL;
160 }
161
162 vc = json_array_get(vc_array, 0);
163
164 if(vc == NULL){
165 printf("The \"verifiableCredential\" array in the Verifiable Presentation can not be empty\n");
166 return NULL;
167 }
168
169 free(vc_array);
170
171 return vc;
172}
173
145 174
146/** 175/**
147 * Parse a W3C Verifiable Credential and return the respective claim value as Attribute 176 * @brief Parse a json decoded verifiable credential and return the respective claim value as Attribute
148 * Only Works for single subject verifiable credentials 177 * @param cred a json decoded verifiable credential
149 * 178 * @return a list of Attributes in the verifiable credential
150 * @param cls the plugin 179 *
151 * @param cred the W3C Verifiable credential
152 * @return a GNUNET_RECLAIM_Attribute, containing the new value
153 */ 180 */
154struct GNUNET_RECLAIM_AttributeList * 181struct GNUNET_RECLAIM_AttributeList *
155vc_parse_attributes (void *cls, 182parse_attributes_from_json_vc(json_t * cred)
156 const char *cred,
157 size_t data_size)
158{ 183{
159 struct GNUNET_RECLAIM_AttributeList *attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 184 struct GNUNET_RECLAIM_AttributeList *attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
160 185
161 json_t * root;
162 json_t * subject; 186 json_t * subject;
163 const char * key; 187 const char * key;
164 json_t * value; 188 json_t * value;
165 const char * value_str; 189 const char * value_str;
166 190
167 root = json_loads(cred, JSON_DECODE_ANY, NULL); 191 subject = json_object_get(cred, "credentialSubject");
168 subject = json_object_get(root, "credentialSubject");
169 192
170 if(subject == NULL) 193 if(subject == NULL)
171 { 194 {
172 printf("The verifiable credential has to contain a Subject\n"); 195 printf("The verifiable credential has to contain a subject\n");
173 return NULL; 196 return NULL;
174 } 197 }
175 198
@@ -192,24 +215,34 @@ vc_parse_attributes (void *cls,
192 215
193 216
194/** 217/**
195 * Parse a W3C verifiable credential and return the respective claim value as Attribute 218 * Parse a verifiable credential and return the respective claim value as Attribute
196 * 219 *
197 * @param cls the plugin 220 * @param cls the plugin
198 * @param cred the w3cvc credential 221 * @param cred the w3cvc credential
199 * @return a GNUNET_RECLAIM_Attribute, containing the new value 222 * @return a GNUNET_RECLAIM_Attribute, containing the new value
200 */ 223 */
201struct GNUNET_RECLAIM_AttributeList * 224struct GNUNET_RECLAIM_AttributeList *
202vc_parse_attributes_c (void *cls, 225parse_attributes_c (void *cls,
203 const struct GNUNET_RECLAIM_Credential *cred) 226 const struct GNUNET_RECLAIM_Credential *cred)
204{ 227{
205 if (cred->type != GNUNET_RECLAIM_CREDENTIAL_TYPE_VC) 228 if (cred->type != GNUNET_RECLAIM_CREDENTIAL_TYPE_VC)
206 return NULL; 229 return NULL;
207 return vc_parse_attributes (cls, cred->data, cred->data_size); 230 else
231 {
232 struct GNUNET_RECLAIM_AttributeList *attrs;
233
234 json_t * root;
235 root = json_loads(cred->data, JSON_DECODE_ANY, NULL);
236 attrs = parse_attributes_from_json_vc(root);
237
238 free(root);
239 return attrs;
240 }
208} 241}
209 242
210 243
211/** 244/**
212 * Parse a W3C verifiable presentation and return the respective claim value as Attribute 245 * Parse a verifiable presentation and return the respective claim value as Attribute
213 * 246 *
214 * @param cls the plugin 247 * @param cls the plugin
215 * @param cred the w3cvc credential 248 * @param cred the w3cvc credential
@@ -217,34 +250,54 @@ vc_parse_attributes_c (void *cls,
217 */ 250 */
218struct GNUNET_RECLAIM_AttributeList * 251struct GNUNET_RECLAIM_AttributeList *
219vc_parse_attributes_p (void *cls, 252vc_parse_attributes_p (void *cls,
220 const struct GNUNET_RECLAIM_Presentation *cred) 253 const struct GNUNET_RECLAIM_Presentation *pres)
221{ 254{
222 if (cred->type != GNUNET_RECLAIM_CREDENTIAL_TYPE_VC) 255 if (pres->type != GNUNET_RECLAIM_CREDENTIAL_TYPE_VC)
223 return NULL; 256 return NULL;
224 return vc_parse_attributes (cls, cred->data, cred->data_size); 257 else
258 {
259 struct GNUNET_RECLAIM_AttributeList *attrs;
260
261 json_t * root;
262 json_t * cred;
263 json_error_t * error;
264 char * cred_str;
265
266 root = json_loads(pres->data, JSON_DECODE_ANY, error);
267
268 if(root == NULL)
269 {
270 printf("Could not decode the verifiable presentation\n");
271 return NULL;
272 }
273
274 cred = get_json_vc_from_json_vp(root);
275
276 cred_str = json_dumps(cred, JSON_INDENT(2));
277
278 attrs = parse_attributes_from_json_vc(cred);
279
280 free(root);
281 free(cred);
282 return attrs;
283 }
225} 284}
226 285
227 286
228/** 287/**
229 * Parse a VC and return the issuer 288 * @brief Return the issuer of the credential
230 * Does not work for URI Issuer. https://www.w3.org/TR/vc-data-model/#issuer 289 * @param vc decoded json containing a verifiable credential
231 * 290 * @return a string containg the issuer
232 * @param cls the plugin 291 *
233 * @param cred the verifiable credential
234 * @return a string, containing the isser
235 */ 292 */
236char * 293char *
237vc_get_issuer (void *cls, 294get_issuer_from_json_vc(json_t * vc)
238 const char *cred,
239 size_t data_size)
240{ 295{
241 json_t * root;
242 json_t * issuer; 296 json_t * issuer;
243 json_t * issuer_id; 297 json_t * issuer_id;
244 char * issuer_id_str; 298 const char * issuer_id_str;
245 299
246 root = json_loads(cred, JSON_DECODE_ANY, NULL); 300 issuer = json_object_get(vc, "issuer");
247 issuer = json_object_get(root, "credentialSubject");
248 301
249 if(issuer == NULL) 302 if(issuer == NULL)
250 { 303 {
@@ -260,24 +313,38 @@ vc_get_issuer (void *cls,
260 } 313 }
261 314
262 issuer_id_str = json_string_value(issuer_id); 315 issuer_id_str = json_string_value(issuer_id);
316
317 free(issuer);
318 free(issuer_id);
319
263 return GNUNET_strndup(issuer_id_str, strlen(issuer_id_str)); 320 return GNUNET_strndup(issuer_id_str, strlen(issuer_id_str));
264} 321}
265 322
266 323
267/** 324/**
268 * Parse a Verifiable Credential and return the issuer 325 * Parse a Verifiable Credential and return the issuer
326 * Does not work for URI Issuer. https://www.w3.org/TR/vc-data-model/#issuer
269 * 327 *
270 * @param cls the plugin 328 * @param cls the plugin
271 * @param cred the verifiable credential 329 * @param cred the verifiable credential
272 * @return a string, containing the isser 330 * @return a string, containing the isser
273 */ 331 */
274char * 332char *
275vc_get_issuer_c (void *cls, 333get_issuer_c (void *cls,
276 const struct GNUNET_RECLAIM_Credential *cred) 334 const struct GNUNET_RECLAIM_Credential *cred)
277{ 335{
278 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != cred->type) 336 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != cred->type)
279 return NULL; 337 return NULL;
280 return vc_get_issuer (cls, cred->data, cred->data_size); 338 else
339 {
340 json_t * root;
341 char * issuer_id_str;
342
343 root = json_loads(cred->data, JSON_DECODE_ANY, NULL);
344 issuer_id_str = get_issuer_from_json_vc(root);
345 free(root);
346 return issuer_id_str;
347 }
281} 348}
282 349
283 350
@@ -289,45 +356,42 @@ vc_get_issuer_c (void *cls,
289 * @return a string, containing the isser 356 * @return a string, containing the isser
290 */ 357 */
291char * 358char *
292vc_get_issuer_p (void *cls, 359get_issuer_p (void *cls,
293 const struct GNUNET_RECLAIM_Presentation *cred) 360 const struct GNUNET_RECLAIM_Presentation *pres)
294{ 361{
295 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != cred->type) 362 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != pres->type)
296 return NULL; 363 return NULL;
297 return vc_get_issuer (cls, cred->data, cred->data_size); 364 else
365 {
366 json_t * root;
367 json_t * cred;
368 char * issuer_id_str;
369
370 root = json_loads(pres->data, JSON_DECODE_ANY, NULL);
371 cred = get_json_vc_from_json_vp(root);
372 issuer_id_str = get_issuer_from_json_vc(cred);
373 free(root);
374 free(cred);
375 return issuer_id_str;
376 }
298} 377}
299 378
300
301/**
302 * Parse a Verifiable Credential and return the expiration
303 *
304 * @param cls the plugin
305 * @param cred the w3cvc credential
306 * @return a string, containing the expiration
307 */
308enum GNUNET_GenericReturnValue 379enum GNUNET_GenericReturnValue
309vc_get_expiration (void *cls, 380get_expiration_from_json_vc(json_t * cred,
310 const char *cred, 381 struct GNUNET_TIME_Absolute * exp)
311 size_t data_size,
312 struct GNUNET_TIME_Absolute *exp)
313{ 382{
314 json_t * root;
315 json_t * expiration_date_json; 383 json_t * expiration_date_json;
316 char * expiration_date_str; 384 const char * expiration_date_str;
317 385
318 root = json_loads(cred, JSON_DECODE_ANY, NULL); 386 expiration_date_json = json_object_get(cred, "issuanceDate");
319 expiration_date_json = json_object_get(root, "issuanceDate");
320 387
321 if(expiration_date_json == NULL) 388 if(expiration_date_json == NULL)
322 { 389 {
323 return GNUNET_NO; 390 return GNUNET_NO;
324 } 391 }
325 392
326 // TODO: Cacluate GNUNET_TIME based on W3C datetime 393 expiration_date_str = json_string_value(expiration_date_json);
327 // expiration_date_str = json_string_value(expiration_date_json); 394 GNUNET_STRINGS_rfc3339_time_to_absolute(expiration_date_str, exp);
328 // return GNUNET_strndup(expiration_date_str, strlen(expiration_date_str));
329
330 exp->abs_value_us = UINT64_MAX;
331 return GNUNET_OK; 395 return GNUNET_OK;
332} 396}
333 397
@@ -345,8 +409,14 @@ vc_get_expiration_c (void *cls,
345 struct GNUNET_TIME_Absolute *exp) 409 struct GNUNET_TIME_Absolute *exp)
346{ 410{
347 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != cred->type) 411 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != cred->type)
348 return GNUNET_NO; 412 return GNUNET_SYSERR;
349 return vc_get_expiration (cls, cred->data, cred->data_size, exp); 413 else
414 {
415 json_t * root;
416
417 root = json_loads(cred->data, JSON_DECODE_ANY, NULL);
418 return get_expiration_from_json_vc(root, exp);
419 }
350} 420}
351 421
352 422
@@ -359,12 +429,21 @@ vc_get_expiration_c (void *cls,
359 */ 429 */
360enum GNUNET_GenericReturnValue 430enum GNUNET_GenericReturnValue
361vc_get_expiration_p (void *cls, 431vc_get_expiration_p (void *cls,
362 const struct GNUNET_RECLAIM_Presentation *cred, 432 const struct GNUNET_RECLAIM_Presentation *pres,
363 struct GNUNET_TIME_Absolute *exp) 433 struct GNUNET_TIME_Absolute *exp)
364{ 434{
365 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != cred->type) 435 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != pres->type)
366 return GNUNET_NO; 436 return GNUNET_SYSERR;
367 return vc_get_expiration (cls, cred->data, cred->data_size, exp); 437 else
438 {
439 json_t * root;
440 json_t * cred;
441 char * issuer_id_str;
442
443 root = json_loads(pres->data, JSON_DECODE_ANY, NULL);
444 cred = get_json_vc_from_json_vp(root);
445 return get_expiration_from_json_vc(cred, exp);
446 }
368} 447}
369 448
370 449
@@ -374,12 +453,51 @@ vc_create_presentation (void *cls,
374 const struct GNUNET_RECLAIM_AttributeList *attrs, 453 const struct GNUNET_RECLAIM_AttributeList *attrs,
375 struct GNUNET_RECLAIM_Presentation **presentation) 454 struct GNUNET_RECLAIM_Presentation **presentation)
376{ 455{
456 // Check if Ego has a DID Docuement
457 // Get date string for now
458 json_t * root;
459 json_t * context_array;
460 json_t * credential_array;
461 json_t * credential;
462 json_t * proof;
463
464 char * presentation_str;
465 const char * now;
466
377 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != cred->type) 467 if (GNUNET_RECLAIM_CREDENTIAL_TYPE_VC != cred->type)
378 return GNUNET_NO; 468 return GNUNET_NO;
469
470 now = GNUNET_STRINGS_absolute_time_to_rfc3339(GNUNET_TIME_absolute_get());
471
472 root = json_object();
473
474 context_array = json_array();
475 json_array_append(context_array, json_string("https://www.w3.org/2018/credentials/v1"));
476 json_object_set(root, "@context", context_array);
477
478 json_object_set(root, "type", json_string("VerifiablePresentation"));
479
480 credential_array = json_array();
481 credential = json_loads(cred->data, JSON_DECODE_ANY, NULL);
482 json_array_append(credential_array, credential);
483 json_object_set(root, "verifiableCredential", credential_array);
484
485 proof = json_object();
486 json_object_set(proof, "type", json_string("EDdSASignature2021"));
487 json_object_set(proof, "created", json_string(now));
488 json_object_set(proof, "proofPurpose", json_string("assertionMethod"));
489 json_object_set(proof, "verificationMethod", json_string("did:reclaim:1234key-1"));
490 // FIXME: # inside the verificationMethod value makes the encoded json not decodeable by jannson
491 // json_object_set(proof, "verificationMethod", json_string("did:reclaim:1234#key-1"));
492 json_object_set(proof, "signature", json_string("abc"));
493 json_object_set(root, "proof", proof);
494
495 presentation_str = json_dumps(root, JSON_INDENT(2));
496
379 *presentation = GNUNET_RECLAIM_presentation_new ( 497 *presentation = GNUNET_RECLAIM_presentation_new (
380 GNUNET_RECLAIM_CREDENTIAL_TYPE_VC, 498 GNUNET_RECLAIM_CREDENTIAL_TYPE_VC,
381 cred->data, 499 (void *) presentation_str,
382 cred->data_size); 500 strlen(presentation_str));
383 return GNUNET_OK; 501 return GNUNET_OK;
384} 502}
385 503
@@ -396,19 +514,19 @@ libgnunet_plugin_reclaim_credential_vc_init (void *cls)
396 struct GNUNET_RECLAIM_CredentialPluginFunctions *api; 514 struct GNUNET_RECLAIM_CredentialPluginFunctions *api;
397 515
398 api = GNUNET_new (struct GNUNET_RECLAIM_CredentialPluginFunctions); 516 api = GNUNET_new (struct GNUNET_RECLAIM_CredentialPluginFunctions);
399 api->value_to_string = &vc_value_to_string; 517 api->value_to_string = &value_to_string;
400 api->string_to_value = &vc_string_to_value; 518 api->string_to_value = &string_to_value;
401 api->typename_to_number = &vc_typename_to_number; // done 519 api->typename_to_number = &vc_typename_to_number;
402 api->number_to_typename = &vc_number_to_typename; // done 520 api->number_to_typename = &vc_number_to_typename;
403 api->get_attributes = &vc_parse_attributes_c; 521 api->get_attributes = &parse_attributes_c;
404 api->get_issuer = &vc_get_issuer_c; 522 api->get_issuer = &get_issuer_c;
405 api->get_expiration = &vc_get_expiration_c; // not needed 523 api->get_expiration = &vc_get_expiration_c;
406 api->value_to_string_p = &vc_value_to_string; 524 api->value_to_string_p = &value_to_string;
407 api->string_to_value_p = &vc_string_to_value; 525 api->string_to_value_p = &string_to_value;
408 api->typename_to_number_p = &vc_typename_to_number; // done 526 api->typename_to_number_p = &vc_typename_to_number;
409 api->number_to_typename_p = &vc_number_to_typename; // done 527 api->number_to_typename_p = &vc_number_to_typename;
410 api->get_attributes_p = &vc_parse_attributes_p; 528 api->get_attributes_p = &vc_parse_attributes_p;
411 api->get_issuer_p = &vc_get_issuer_p; 529 api->get_issuer_p = &get_issuer_p;
412 api->get_expiration_p = &vc_get_expiration_p; 530 api->get_expiration_p = &vc_get_expiration_p;
413 api->create_presentation = &vc_create_presentation; 531 api->create_presentation = &vc_create_presentation;
414 return api; 532 return api;
@@ -431,4 +549,4 @@ libgnunet_plugin_reclaim_credential_vc_done (void *cls)
431} 549}
432 550
433 551
434/* end of plugin_reclaim_w3c_verifiable_credential_type.c */ 552/* end of plugin_reclaim_credential_vc.c */
diff --git a/src/reclaim/test_reclaim_vc.sh b/src/reclaim/test_reclaim_vc.sh
index 82789691e..3412fa5c6 100755
--- a/src/reclaim/test_reclaim_vc.sh
+++ b/src/reclaim/test_reclaim_vc.sh
@@ -3,22 +3,28 @@ ego1="ego1_$(tr -dc a-z </dev/urandom | head -c 8 ; echo '')"
3ego2="ego2_$(tr -dc a-z </dev/urandom | head -c 8 ; echo '')" 3ego2="ego2_$(tr -dc a-z </dev/urandom | head -c 8 ; echo '')"
4test_vc='{"@context":["https://www.w3.org/2018/credentials/v1"],"type":["VerifiableCredential"],"issuer":"did:reclaim:1234","issuanceDate":"2018-02-24T05:28:04Z","expirationDate":"2025-02-24T00:00:00Z","credentialSubject":{"id":"did:example:abcdef1234567","name":"Tristan"},"proof":{"type":"RsaSignature2018","created":"2017-06-18T21:19:10Z","proofPurpose":"assertionMethod","verificationMethod":"did:reclaim:1234#key-1","proof":"abc"}}' 4test_vc='{"@context":["https://www.w3.org/2018/credentials/v1"],"type":["VerifiableCredential"],"issuer":"did:reclaim:1234","issuanceDate":"2018-02-24T05:28:04Z","expirationDate":"2025-02-24T00:00:00Z","credentialSubject":{"id":"did:example:abcdef1234567","name":"Tristan"},"proof":{"type":"RsaSignature2018","created":"2017-06-18T21:19:10Z","proofPurpose":"assertionMethod","verificationMethod":"did:reclaim:1234#key-1","proof":"abc"}}'
5 5
6# Create Identities
6gnunet-identity -C $ego1 7gnunet-identity -C $ego1
7gnunet-identity -C $ego2 8gnunet-identity -C $ego2
8 9
9ego1_id=$(gnunet-identity -d | grep $ego1 | sed 's/.*- \(.*\) -.*/\1/') 10ego1_id=$(gnunet-identity -d | grep $ego1 | sed 's/.*- \(.*\) -.*/\1/')
10ego2_id=$(gnunet-identity -d | grep $ego2 | sed 's/.*- \(.*\) -.*/\1/') 11ego2_id=$(gnunet-identity -d | grep $ego2 | sed 's/.*- \(.*\) -.*/\1/')
11 12
13# Import Credential
12gnunet-reclaim -e $ego1 -N cred1 -u VC -V $test_vc 14gnunet-reclaim -e $ego1 -N cred1 -u VC -V $test_vc
13cred1_id=$(gnunet-reclaim -e $ego1 -A | grep cred1 | sed 's/.*ID: \(.*\)/\1/') 15cred1_id=$(gnunet-reclaim -e $ego1 -A | grep cred1 | sed 's/.*ID: \(.*\)/\1/')
14 16
17# Create Attribute based on Credential
15gnunet-reclaim -e $ego1 --add=cred1 --value=name --credential-id=$cred1_id 18gnunet-reclaim -e $ego1 --add=cred1 --value=name --credential-id=$cred1_id
16att1_id=$(gnunet-reclaim -e $ego1 -D | sed 's/.*ID: \(.*\)/\1/') 19att1_id=$(gnunet-reclaim -e $ego1 -D | sed 's/.*ID: \(.*\)/\1/')
17 20
21# Issue a ticket for the attribute
18gnunet-reclaim -e $ego1 -i cred1 -r $ego2_id &> /dev/null 22gnunet-reclaim -e $ego1 -i cred1 -r $ego2_id &> /dev/null
19ticket=$(gnunet-reclaim -e $ego1 -T | sed 's/.*Ticket: \(.*\) | ID:.*/\1/') 23ticket=$(gnunet-reclaim -e $ego1 -T | sed 's/.*Ticket: \(.*\) | ID:.*/\1/')
20gnunet-reclaim -e $ego2 -C $ticket | grep Presentation | sed 's/Presentation: \(.*\)/\1/' | jq 24
21proof=$(gnunet-reclaim -e $ego2 -C $ticket | grep Presentation | sed 's/.*"proof":"\(.*\)"}}/\1/') 25# Consume Ticket
26proof=$(gnunet-reclaim -e $ego2 -C $ticket | grep signature | sed 's/.*": "\(.*\)"/\1/')
27gnunet-reclaim -e $ego2 -C $ticket | tail -n +3 | jq
22 28
23if [ "$proof" != "abc" ]; then 29if [ "$proof" != "abc" ]; then
24 echo "Failed." 30 echo "Failed."
@@ -28,7 +34,8 @@ else
28 return=0 34 return=0
29fi 35fi
30 36
31gnunet-identity -D $ego1 37# Delete Identities
32gnunet-identity -D $ego2 38# gnunet-identity -D $ego1
39# gnunet-identity -D $ego2
33 40
34exit $return 41exit $return