diff options
author | Tristan Schwieren <tristan.schwieren@tum.de> | 2022-05-18 17:52:21 +0200 |
---|---|---|
committer | Tristan Schwieren <tristan.schwieren@tum.de> | 2022-05-18 17:52:21 +0200 |
commit | 87e8f46b7d2eefe77c5ee43e554184b1c57a36e6 (patch) | |
tree | 2ffbcb798835b712d218649925e99da7c3227953 /src | |
parent | df8660ffec05d108d59de191ddc5114c4678a362 (diff) | |
download | gnunet-87e8f46b7d2eefe77c5ee43e554184b1c57a36e6.tar.gz gnunet-87e8f46b7d2eefe77c5ee43e554184b1c57a36e6.zip |
- started DID refactor
Diffstat (limited to 'src')
-rw-r--r-- | src/reclaim/Makefile.am | 4 | ||||
-rw-r--r-- | src/reclaim/did_helper.c | 188 | ||||
-rw-r--r-- | src/reclaim/did_helper.h | 78 | ||||
-rw-r--r-- | src/reclaim/gnunet-did.c | 170 |
4 files changed, 279 insertions, 161 deletions
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am index 6b5934a2f..7b73f35f2 100644 --- a/src/reclaim/Makefile.am +++ b/src/reclaim/Makefile.am | |||
@@ -189,7 +189,9 @@ test_reclaim_attribute_LDADD = \ | |||
189 | $(GN_LIBINTL) | 189 | $(GN_LIBINTL) |
190 | 190 | ||
191 | gnunet_did_SOURCES = \ | 191 | gnunet_did_SOURCES = \ |
192 | gnunet-did.c | 192 | gnunet-did.c \ |
193 | did_helper.h \ | ||
194 | did_helper.c | ||
193 | gnunet_did_LDADD = \ | 195 | gnunet_did_LDADD = \ |
194 | $(top_builddir)/src/util/libgnunetutil.la \ | 196 | $(top_builddir)/src/util/libgnunetutil.la \ |
195 | $(top_builddir)/src/gns/libgnunetgns.la \ | 197 | $(top_builddir)/src/gns/libgnunetgns.la \ |
diff --git a/src/reclaim/did_helper.c b/src/reclaim/did_helper.c new file mode 100644 index 000000000..ad02d96b5 --- /dev/null +++ b/src/reclaim/did_helper.c | |||
@@ -0,0 +1,188 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file reclaim/oidc_helper.h | ||
23 | * @brief helper library for DID related functions | ||
24 | * @author Tristan Schwieren | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_namestore_service.h" | ||
29 | #include "gnunet_gns_service.h" | ||
30 | #include "gnunet_gnsrecord_lib.h" | ||
31 | #include "did_helper.h" | ||
32 | #include "jansson.h" | ||
33 | |||
34 | |||
35 | /** | ||
36 | * @brief Generate a DID for a given GNUNET public key | ||
37 | * | ||
38 | * @param pkey | ||
39 | * @return char* Returns the DID. Caller must free | ||
40 | * TODO: Check if EdDSA | ||
41 | */ | ||
42 | char* | ||
43 | GNUNET_DID_pkey_to_did (struct GNUNET_IDENTITY_PublicKey *pkey) | ||
44 | { | ||
45 | char *pkey_str; | ||
46 | char *did_str; | ||
47 | |||
48 | pkey_str = GNUNET_IDENTITY_public_key_to_string (pkey); | ||
49 | GNUNET_asprintf (&did_str, "%s%s", | ||
50 | GNUNET_DID_METHOD_PREFIX, | ||
51 | pkey_str); | ||
52 | |||
53 | GNUNET_free (pkey_str); | ||
54 | return did_str; | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * @brief Generate a DID for a given gnunet EGO | ||
59 | * | ||
60 | * @param ego | ||
61 | * @return char* Returns the DID. Caller must free | ||
62 | */ | ||
63 | char* | ||
64 | GNUNET_DID_identity_to_did (struct GNUNET_IDENTITY_Ego *ego) | ||
65 | { | ||
66 | struct GNUNET_IDENTITY_PublicKey pkey; | ||
67 | |||
68 | GNUNET_IDENTITY_ego_get_public_key (ego, &pkey); | ||
69 | return GNUNET_DID_pkey_to_did (&pkey); | ||
70 | } | ||
71 | |||
72 | /** | ||
73 | * @brief Return the public key of a DID | ||
74 | */ | ||
75 | struct GNUNET_IDENTITY_PublicKey * | ||
76 | GNUNET_DID_did_to_pkey (char *did) | ||
77 | { | ||
78 | return NULL; | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * @brief Return the GNUNET EGO of a DID | ||
83 | */ | ||
84 | struct GNUNET_IDENTITY_Ego * | ||
85 | GNUNET_DID_did_to_identity (char *did) | ||
86 | { | ||
87 | return NULL; | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * @brief Convert a base 64 encoded public key to a GNUNET key | ||
92 | */ | ||
93 | struct GNUNET_IDENTITY_PublicKey * | ||
94 | GNUNET_DID_key_covert_multibase_base64_to_gnunet (char *pkey_str) | ||
95 | { | ||
96 | return NULL; | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * @brief Convert GNUNET key to a base 64 encoded public key | ||
101 | */ | ||
102 | char * | ||
103 | GNUNET_DID_key_covert_gnunet_multibase_to_base64 (struct | ||
104 | GNUNET_IDENTITY_PublicKey * | ||
105 | pkey) | ||
106 | { | ||
107 | return NULL; | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * @brief Create a did generate did object | ||
112 | * | ||
113 | * @param pkey | ||
114 | * @return void* Return pointer to the DID Document | ||
115 | */ | ||
116 | char * | ||
117 | GNUNET_DID_pkey_to_did_document (struct GNUNET_IDENTITY_PublicKey *pkey) | ||
118 | { | ||
119 | char *did_str; | ||
120 | char *didd_str; | ||
121 | char *verify_id_str; | ||
122 | char *pkey_multibase_str; | ||
123 | |||
124 | /* FIXME-MSC: This screams for a GNUNET_DID_identity_key_to_string() */ | ||
125 | char *b64; | ||
126 | char pkx[34]; | ||
127 | pkx[0] = 0xed; | ||
128 | pkx[1] = 0x01; | ||
129 | memcpy (pkx + 2, &(pkey->eddsa_key), sizeof(pkey->eddsa_key)); | ||
130 | GNUNET_STRINGS_base64_encode (pkx, sizeof(pkx), &b64); | ||
131 | |||
132 | GNUNET_asprintf (&pkey_multibase_str, "u%s", b64); | ||
133 | |||
134 | json_t *didd_json; | ||
135 | |||
136 | did_str = GNUNET_DID_pkey_to_did (pkey); | ||
137 | GNUNET_asprintf (&verify_id_str, "%s#key-1", did_str); | ||
138 | |||
139 | // sprintf(pkey_multibase_str, "V%s", pkey_str); // Convert the public key to MultiBase data format | ||
140 | |||
141 | /* FIXME-MSC: This is effectively creating a DID Document default template for | ||
142 | * the initial document. | ||
143 | * Maybe this can be refactored to generate such a template for an identity? | ||
144 | * Even if higher layers add/modify it, there should probably still be a | ||
145 | * GNUNET_DID_document_template_from_identity() | ||
146 | */ | ||
147 | |||
148 | // Add a relative DID URL to reference a verifiation method | ||
149 | // https://www.w3.org/TR/did-core/#relative-did-urls` | ||
150 | |||
151 | didd_json = json_pack ("{s:[ss], s:s, s:[{ssss}], s:[s], s:[s]", | ||
152 | "@context", | ||
153 | "https://www.w3.org/ns/did/v1", | ||
154 | "https://w3id.org/security/suites/ed25519-2020/v1", | ||
155 | "id", | ||
156 | did_str, | ||
157 | "verificationMethod", | ||
158 | verify_id_str, | ||
159 | "Ed25519VerificationKey2020", | ||
160 | did_str, | ||
161 | pkey_multibase_str, | ||
162 | "authentication", | ||
163 | "#key-1", | ||
164 | "assertionMethod", | ||
165 | "#key-1"); | ||
166 | |||
167 | // Encode DID Document as JSON string | ||
168 | didd_str = json_dumps (didd_json, JSON_INDENT (2)); | ||
169 | |||
170 | // Free | ||
171 | GNUNET_free (pkey_multibase_str); | ||
172 | GNUNET_free (b64); | ||
173 | json_decref (didd_json); | ||
174 | |||
175 | return didd_str; | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * @brief Generate the default DID document for a GNUNET ego | ||
180 | */ | ||
181 | char * | ||
182 | GNUNET_DID_identity_to_did_document (struct GNUNET_IDENTITY_Ego *ego) | ||
183 | { | ||
184 | struct GNUNET_IDENTITY_PublicKey pkey; | ||
185 | |||
186 | GNUNET_IDENTITY_ego_get_public_key (ego, &pkey); | ||
187 | return GNUNET_DID_pkey_to_did (&pkey); | ||
188 | } \ No newline at end of file | ||
diff --git a/src/reclaim/did_helper.h b/src/reclaim/did_helper.h new file mode 100644 index 000000000..bc4db239e --- /dev/null +++ b/src/reclaim/did_helper.h | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | SPDX-License-Identifier: AGPL3.0-or-later | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file reclaim/oidc_helper.h | ||
23 | * @brief helper library for DID related functions | ||
24 | * @author Tristan Schwieren | ||
25 | */ | ||
26 | |||
27 | #define GNUNET_DID_METHOD_PREFIX "did:reclaim:" | ||
28 | |||
29 | /** | ||
30 | * @brief Return a DID for a given GNUNET public key | ||
31 | */ | ||
32 | char * | ||
33 | GNUNET_DID_pkey_to_did(struct GNUNET_IDENTITY_PublicKey *pkey); | ||
34 | |||
35 | /** | ||
36 | * @brief Generate a DID for a given gnunet EGO | ||
37 | * | ||
38 | * @param ego | ||
39 | * @return char * Returns the DID. Caller must free | ||
40 | */ | ||
41 | char * | ||
42 | GNUNET_DID_identity_to_did(struct GNUNET_IDENTITY_Ego *ego); | ||
43 | |||
44 | /** | ||
45 | * @brief Return the public key of a DID | ||
46 | */ | ||
47 | struct GNUNET_IDENTITY_PublicKey * | ||
48 | GNUNET_DID_did_to_pkey(char *did); | ||
49 | |||
50 | /** | ||
51 | * @brief Return the GNUNET EGO of a DID | ||
52 | */ | ||
53 | struct GNUNET_IDENTITY_Ego * | ||
54 | GNUNET_DID_did_to_identity(char *did); | ||
55 | |||
56 | /** | ||
57 | * @brief Convert a base 64 encoded public key to a GNUNET key | ||
58 | */ | ||
59 | struct GNUNET_IDENTITY_PublicKey * | ||
60 | GNUNET_DID_key_covert_multibase_base64_to_gnunet(char *); | ||
61 | |||
62 | /** | ||
63 | * @brief Convert GNUNET key to a base 64 encoded public key | ||
64 | */ | ||
65 | char * | ||
66 | GNUNET_DID_key_covert_gnunet_multibase_to_base64(struct GNUNET_IDENTITY_PublicKey *); | ||
67 | |||
68 | /** | ||
69 | * @brief Generate the default DID document for a GNUNET public key | ||
70 | */ | ||
71 | char * | ||
72 | GNUNET_DID_pkey_to_did_document (struct GNUNET_IDENTITY_PublicKey *pkey); | ||
73 | |||
74 | /** | ||
75 | * @brief Generate the default DID document for a GNUNET ego | ||
76 | */ | ||
77 | char * | ||
78 | GNUNET_DID_identity_to_did_document(struct GNUNET_IDENTITY_Ego *ego); \ No newline at end of file | ||
diff --git a/src/reclaim/gnunet-did.c b/src/reclaim/gnunet-did.c index 2ebef7601..637b403a9 100644 --- a/src/reclaim/gnunet-did.c +++ b/src/reclaim/gnunet-did.c | |||
@@ -38,9 +38,9 @@ | |||
38 | #include "gnunet_namestore_service.h" | 38 | #include "gnunet_namestore_service.h" |
39 | #include "gnunet_gns_service.h" | 39 | #include "gnunet_gns_service.h" |
40 | #include "gnunet_gnsrecord_lib.h" | 40 | #include "gnunet_gnsrecord_lib.h" |
41 | #include "did_helper.h" | ||
41 | #include "jansson.h" | 42 | #include "jansson.h" |
42 | 43 | ||
43 | #define GNUNET_DID_METHOD_RECLAIM_PREFIX "did:reclaim:" | ||
44 | #define GNUNET_DID_DEFAULT_DID_DOCUMENT_EXPIRATION_TIME "1d" | 44 | #define GNUNET_DID_DEFAULT_DID_DOCUMENT_EXPIRATION_TIME "1d" |
45 | 45 | ||
46 | /** | 46 | /** |
@@ -146,24 +146,6 @@ cleanup (void *cls) | |||
146 | GNUNET_SCHEDULER_shutdown (); | 146 | GNUNET_SCHEDULER_shutdown (); |
147 | } | 147 | } |
148 | 148 | ||
149 | char* | ||
150 | ego_to_did (struct GNUNET_IDENTITY_Ego *ego) | ||
151 | { | ||
152 | struct GNUNET_IDENTITY_PublicKey pkey; // Get Public key | ||
153 | char *pkey_str; | ||
154 | char *did_str; | ||
155 | size_t pkey_len; | ||
156 | |||
157 | GNUNET_IDENTITY_ego_get_public_key (ego, &pkey); | ||
158 | |||
159 | pkey_str = GNUNET_IDENTITY_public_key_to_string (&pkey); | ||
160 | GNUNET_asprintf (&did_str, "%s%s", | ||
161 | GNUNET_DID_METHOD_RECLAIM_PREFIX, | ||
162 | pkey_str); | ||
163 | |||
164 | free (pkey_str); | ||
165 | return did_str; | ||
166 | } | ||
167 | 149 | ||
168 | /** | 150 | /** |
169 | * @brief Callback for ego loockup of get_did_for_ego() | 151 | * @brief Callback for ego loockup of get_did_for_ego() |
@@ -183,7 +165,7 @@ get_did_for_ego_lookup_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
183 | ret = 1; | 165 | ret = 1; |
184 | return; | 166 | return; |
185 | } | 167 | } |
186 | did_str = ego_to_did (ego); | 168 | did_str = GNUNET_DID_identity_to_did (ego); |
187 | 169 | ||
188 | printf ("%s\n", did_str); | 170 | printf ("%s\n", did_str); |
189 | 171 | ||
@@ -229,7 +211,7 @@ get_pkey_from_attr_did (struct GNUNET_IDENTITY_PublicKey *pkey) | |||
229 | */ | 211 | */ |
230 | char pkey_str[59]; | 212 | char pkey_str[59]; |
231 | 213 | ||
232 | if ((1 != (sscanf (did, GNUNET_DID_METHOD_RECLAIM_PREFIX"%58s", pkey_str))) || | 214 | if ((1 != (sscanf (did, GNUNET_DID_METHOD_PREFIX"%58s", pkey_str))) || |
233 | (GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (pkey_str, pkey))) | 215 | (GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (pkey_str, pkey))) |
234 | { | 216 | { |
235 | fprintf (stderr, _("Invalid DID `%s'\n"), pkey_str); | 217 | fprintf (stderr, _("Invalid DID `%s'\n"), pkey_str); |
@@ -410,140 +392,6 @@ remove_did_document (remove_did_document_callback cont, void *cls) | |||
410 | 392 | ||
411 | 393 | ||
412 | /** | 394 | /** |
413 | * @brief Create a did generate did object | ||
414 | * | ||
415 | * @param pkey | ||
416 | * @return void* Return pointer to the DID Document | ||
417 | */ | ||
418 | char * | ||
419 | create_did_generate (struct GNUNET_IDENTITY_PublicKey pkey) | ||
420 | { | ||
421 | /* FIXME-MSC: I would prefer constants instead of magic numbers */ | ||
422 | char *pkey_str; // Convert public key to string | ||
423 | char did_str[71]; // 58 + 12 + 1 = 71 | ||
424 | char *didd_str; | ||
425 | char verify_id_str[77]; // did_str len + "#key-1" = 71 + 6 = 77 | ||
426 | char *pkey_multibase_str; | ||
427 | |||
428 | /* FIXME-MSC: This screams for a GNUNET_DID_identity_key_to_string() */ | ||
429 | char *b64; | ||
430 | char pkx[34]; | ||
431 | pkx[0] = 0xed; | ||
432 | pkx[1] = 0x01; | ||
433 | memcpy (pkx + 2, &(pkey.eddsa_key), sizeof(pkey.eddsa_key)); | ||
434 | GNUNET_STRINGS_base64_encode (pkx, sizeof(pkx), &b64); | ||
435 | |||
436 | GNUNET_asprintf (&pkey_multibase_str, "u%s", b64); | ||
437 | |||
438 | json_t *didd; | ||
439 | json_t *did_json; | ||
440 | json_t *pkey_multibase_json; | ||
441 | json_t *context_json; | ||
442 | json_t *context_1_json; | ||
443 | json_t *context_2_json; | ||
444 | json_t *verify_json; | ||
445 | json_t *verify_1_json; | ||
446 | json_t *verify_1_type_json; | ||
447 | json_t *verify_1_id_json; | ||
448 | json_t *verify_relative_ref_json; | ||
449 | json_t *auth_json; | ||
450 | json_t *assert_json; | ||
451 | |||
452 | /* FIXME-MSC: This screams for GNUNET_DID_identity_to_did() */ | ||
453 | pkey_str = GNUNET_IDENTITY_public_key_to_string (&pkey); // Convert public key to string | ||
454 | sprintf (did_str, "did:reclaim:%s", pkey_str); // Convert the public key to a DID str | ||
455 | sprintf (verify_id_str, "did:reclaim:%s#key-1", pkey_str); // Convert the public key to a DID str | ||
456 | |||
457 | // sprintf(pkey_multibase_str, "V%s", pkey_str); // Convert the public key to MultiBase data format | ||
458 | |||
459 | /* FIXME-MSC: This is effectively creating a DID Document default template for | ||
460 | * the initial document. | ||
461 | * Maybe this can be refactored to generate such a template for an identity? | ||
462 | * Even if higher layers add/modify it, there should probably still be a | ||
463 | * GNUNET_DID_document_template_from_identity() | ||
464 | */ | ||
465 | // Create Json Strings | ||
466 | did_json = json_string (did_str); | ||
467 | pkey_multibase_json = json_string (pkey_multibase_str); | ||
468 | |||
469 | context_1_json = json_string ("https://www.w3.org/ns/did/v1"); | ||
470 | context_2_json = json_string ( | ||
471 | "https://w3id.org/security/suites/ed25519-2020/v1"); | ||
472 | verify_1_id_json = json_string (verify_id_str); | ||
473 | verify_1_type_json = json_string ("Ed25519VerificationKey2020"); | ||
474 | |||
475 | // Add a relative DID URL to reference a verifiation method | ||
476 | // https://www.w3.org/TR/did-core/#relative-did-urls` | ||
477 | verify_relative_ref_json = json_string ("#key-1"); | ||
478 | |||
479 | // Create DID Document | ||
480 | didd = json_object (); | ||
481 | |||
482 | // Add context | ||
483 | context_json = json_array (); | ||
484 | json_array_append (context_json, context_1_json); | ||
485 | json_array_append (context_json, context_2_json); | ||
486 | json_object_set (didd, "@context", context_json); | ||
487 | |||
488 | // Add id | ||
489 | json_object_set (didd, "id", did_json); | ||
490 | |||
491 | // Add verification method | ||
492 | verify_json = json_array (); | ||
493 | verify_1_json = json_object (); | ||
494 | json_object_set (verify_1_json, "id", verify_1_id_json); | ||
495 | json_object_set (verify_1_json, "type", verify_1_type_json); | ||
496 | json_object_set (verify_1_json, "controller", did_json); | ||
497 | json_object_set (verify_1_json, "publicKeyMultiBase", pkey_multibase_json); | ||
498 | json_array_append (verify_json, verify_1_json); | ||
499 | json_object_set (didd, "verificationMethod", verify_json); | ||
500 | |||
501 | // Add authentication method | ||
502 | auth_json = json_array (); | ||
503 | json_array_append (auth_json, verify_relative_ref_json); | ||
504 | json_object_set (didd, "authentication", auth_json); | ||
505 | |||
506 | // Add assertion method to issue a Verifiable Credential | ||
507 | assert_json = json_array (); | ||
508 | json_array_append (assert_json, verify_relative_ref_json); | ||
509 | json_object_set (didd, "assertionMethod", assert_json); | ||
510 | |||
511 | // Encode DID Document as JSON string | ||
512 | didd_str = json_dumps (didd, JSON_INDENT (2)); | ||
513 | if (didd_str == NULL) | ||
514 | { | ||
515 | printf ("DID Document could not be encoded"); | ||
516 | GNUNET_SCHEDULER_add_now (&cleanup, NULL); | ||
517 | ret = 1; | ||
518 | return NULL; | ||
519 | } | ||
520 | |||
521 | // TODO: MORE FREEEEEEEE | ||
522 | /* FIXME-MSC: json_t's are free'd using "json_decref". Also json_t usually | ||
523 | * keeps a reference counter. Check jansson docs for how to use it. | ||
524 | * Also: Use valgrind to find leaks. | ||
525 | */ | ||
526 | free (pkey_multibase_str); | ||
527 | free (b64); | ||
528 | |||
529 | free (didd); | ||
530 | free (did_json); | ||
531 | free (pkey_multibase_json); | ||
532 | free (context_json); | ||
533 | free (context_1_json); | ||
534 | free (context_2_json); | ||
535 | free (verify_json); | ||
536 | free (verify_1_json); | ||
537 | free (verify_1_type_json); | ||
538 | free (verify_1_id_json); | ||
539 | free (auth_json); | ||
540 | free (assert_json); | ||
541 | free (verify_relative_ref_json); | ||
542 | |||
543 | return didd_str; | ||
544 | } | ||
545 | |||
546 | /** | ||
547 | * @brief Create a DID. Store DID in Namestore cb | 395 | * @brief Create a DID. Store DID in Namestore cb |
548 | * | 396 | * |
549 | */ | 397 | */ |
@@ -636,7 +484,7 @@ create_did_ego_lockup_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego) | |||
636 | } | 484 | } |
637 | else { | 485 | else { |
638 | // Generate DID Docuement from public key | 486 | // Generate DID Docuement from public key |
639 | didd_str = create_did_generate (pkey); | 487 | didd_str = GNUNET_DID_pkey_to_did_document (&pkey); |
640 | } | 488 | } |
641 | 489 | ||
642 | // Print DID Document to stdout | 490 | // Print DID Document to stdout |
@@ -681,6 +529,8 @@ create_did_document () | |||
681 | { | 529 | { |
682 | if ((egoname != NULL) && (expire != NULL)) | 530 | if ((egoname != NULL) && (expire != NULL)) |
683 | { | 531 | { |
532 | // TODO: Check if ego already has a DID document | ||
533 | |||
684 | GNUNET_IDENTITY_create (identity_handle, | 534 | GNUNET_IDENTITY_create (identity_handle, |
685 | egoname, | 535 | egoname, |
686 | NULL, | 536 | NULL, |
@@ -798,7 +648,7 @@ process_dids (void *cls, struct GNUNET_IDENTITY_Ego *ego, | |||
798 | } | 648 | } |
799 | if (1 == show_all) | 649 | if (1 == show_all) |
800 | { | 650 | { |
801 | did_str = ego_to_did (ego); | 651 | did_str = GNUNET_DID_identity_to_did (ego); |
802 | printf ("%s\n", did_str); | 652 | printf ("%s\n", did_str); |
803 | GNUNET_free (did_str); | 653 | GNUNET_free (did_str); |
804 | return; | 654 | return; |
@@ -807,7 +657,7 @@ process_dids (void *cls, struct GNUNET_IDENTITY_Ego *ego, | |||
807 | { | 657 | { |
808 | if (0 == strncmp (name, egoname, strlen (egoname))) | 658 | if (0 == strncmp (name, egoname, strlen (egoname))) |
809 | { | 659 | { |
810 | did_str = ego_to_did (ego); | 660 | did_str = GNUNET_DID_identity_to_did (ego); |
811 | printf ("%s\n", did_str); | 661 | printf ("%s\n", did_str); |
812 | GNUNET_free (did_str); | 662 | GNUNET_free (did_str); |
813 | return; | 663 | return; |
@@ -879,7 +729,7 @@ main (int argc, char *const argv[]) | |||
879 | gettext_noop ("Replace the DID Document."), | 729 | gettext_noop ("Replace the DID Document."), |
880 | &replace), | 730 | &replace), |
881 | GNUNET_GETOPT_option_flag ('A', | 731 | GNUNET_GETOPT_option_flag ('A', |
882 | "--show-all", | 732 | "show-all", |
883 | gettext_noop ("Replace the DID Document."), | 733 | gettext_noop ("Replace the DID Document."), |
884 | &show_all), | 734 | &show_all), |
885 | GNUNET_GETOPT_option_string ('d', | 735 | GNUNET_GETOPT_option_string ('d', |
@@ -889,7 +739,7 @@ main (int argc, char *const argv[]) | |||
889 | "The Decentralized Identity (DID)"), | 739 | "The Decentralized Identity (DID)"), |
890 | &did), | 740 | &did), |
891 | GNUNET_GETOPT_option_string ('D', | 741 | GNUNET_GETOPT_option_string ('D', |
892 | "--did-document", | 742 | "did-document", |
893 | "JSON", | 743 | "JSON", |
894 | gettext_noop ( | 744 | gettext_noop ( |
895 | "The DID Document to store in GNUNET"), | 745 | "The DID Document to store in GNUNET"), |