[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 60/70: - started with DID lib create func
From: |
gnunet |
Subject: |
[gnunet] 60/70: - started with DID lib create func |
Date: |
Wed, 31 Aug 2022 18:00:54 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit d3de2f84f551501f70851c8df4fbd8e5779f248e
Author: Tristan Schwieren <tristan.schwieren@tum.de>
AuthorDate: Wed Jun 29 12:48:26 2022 +0200
- started with DID lib create func
---
src/reclaim/did_core.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++-
src/reclaim/did_core.h | 4 +-
2 files changed, 103 insertions(+), 3 deletions(-)
diff --git a/src/reclaim/did_core.c b/src/reclaim/did_core.c
index 5cecc2972..0690a654b 100644
--- a/src/reclaim/did_core.c
+++ b/src/reclaim/did_core.c
@@ -29,13 +29,18 @@
// #define DID_DOCUMENT_LABEL GNUNET_GNS_EMPTY_LABEL_AT
#define DID_DOCUMENT_LABEL "didd"
+#define DID_DOCUMENT_DEFAULT_EXPIRATION_TIME "1d"
static DID_resolve_callback *resolve_cb;
static DID_action_callback *action_cb;
static void *closure;
+// ------------------------------------------------ //
+// -------------------- Resolve ------------------- //
+// ------------------------------------------------ //
+
/**
- * @brief GNS lookup callback. Calls the given callback function
+ * @brief GNS lookup callback. Calls the given callback function
* and gives it the DID Document.
* Fails if there is more than one DID record.
*
@@ -101,4 +106,97 @@ DID_resolve (const char *did,
GNUNET_GNS_LO_DEFAULT, &DID_resolve_gns_lookup_cb, NULL);
return GNUNET_OK;
-}
\ No newline at end of file
+}
+
+// ------------------------------------------------ //
+// -------------------- Create -------------------- //
+// ------------------------------------------------ //
+
+static void
+DID_create_did_store_cb ()
+{
+ return;
+}
+
+/**
+ * @brief Store DID Document in Namestore
+ *
+ * @param didd_str String endoced DID Docuement
+ * @param ego Identity whos DID Document is stored
+ */
+static enum GNUNET_GenericReturnValue
+DID_create_did_store (struct GNUNET_NAMESTORE_Handle *namestore_handle,
+ char *didd_str, struct GNUNET_IDENTITY_Ego *ego)
+{
+
+ struct GNUNET_TIME_Relative expire_time;
+ struct GNUNET_GNSRECORD_Data record_data;
+ const struct GNUNET_IDENTITY_PrivateKey *skey;
+
+ if (GNUNET_STRINGS_fancy_time_to_relative ((GNUNET_OK ==
+
DID_DOCUMENT_DEFAULT_EXPIRATION_TIME),
+ &expire_time))
+ {
+ record_data.data = didd_str;
+ record_data.expiration_time = expire_time.rel_value_us;
+ record_data.data_size = strlen (didd_str) + 1;
+ record_data.record_type = GNUNET_GNSRECORD_typename_to_number ("TXT"),
+ record_data.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
+
+ skey = GNUNET_IDENTITY_ego_get_private_key (ego);
+
+ GNUNET_NAMESTORE_records_store (namestore_handle,
+ skey,
+ GNUNET_GNS_EMPTY_LABEL_AT,
+ 1, // FIXME what if
GNUNET_GNS_EMPTY_LABEL_AT has records
+ &record_data,
+ &DID_create_did_store_cb,
+ NULL);
+ }
+ else {
+ printf ("Failed to read given expiration time\n");
+ return GNUNET_NO;
+ }
+}
+
+// TODO: Expiration time missing
+
+/**
+ * @brief Creates a DID and saves DID Document in Namestore.
+ *
+ * @param ego ego for which the DID should be created.
+ * If ego==NULL a new ego is created
+ * @param did_document did_document that should be saved in namestore.
+ * If ego==NULL did_document can also be NULL.
+ * Default DID document is created.
+ * @param cfg_handle pointer to configuration handle
+ * @param identity_hanlde pointer to identity handle. Can be NULL if ego!=NULL
+ * @param namestore_handle
+ * @param cont callback function
+ * @param cls closure
+ */
+enum GNUNET_GenericReturnValue
+DID_create (const struct GNUNET_IDENTITY_Ego *ego,
+ const char *did_document,
+ struct GNUNET_CONFIGURATION_Handle *cfg_handle,
+ struct GNUNET_IDENTITY_Handle *identity_handle,
+ struct GNUNET_NAMESTORE_Handle *namestore_handle,
+ DID_action_callback *cont,
+ void *cls)
+{
+ struct GNUNET_IDENTITY_PublicKey pkey;
+
+ GNUNET_IDENTITY_ego_get_public_key (ego, &pkey);
+
+ if (did_document != NULL)
+ {
+ printf (
+ "DID Docuement is read from \"did-document\" argument (EXPERIMENTAL)\n");
+ }
+ else
+ {
+ did_document = DID_pkey_to_did_document (&pkey);
+ }
+
+ return GNUNET_OK;
+}
diff --git a/src/reclaim/did_core.h b/src/reclaim/did_core.h
index 21a7cbd89..ba5aaf09c 100644
--- a/src/reclaim/did_core.h
+++ b/src/reclaim/did_core.h
@@ -101,7 +101,8 @@ DID_remove (const struct GNUNET_IDENTITY_Ego *ego,
* If ego==NULL did_document can also be NULL.
* Default DID document is created.
* @param cfg_handle pointer to configuration handle
- * @param identity_hanlde pointer to configuration handle. Can be NULL if
ego!=NULL
+ * @param identity_handle pointer to identity handle. Can be NULL if ego!=NULL
+ * @param namestore_handle
* @param cont callback function
* @param cls closure
*/
@@ -110,6 +111,7 @@ DID_create (const struct GNUNET_IDENTITY_Ego *ego,
const char *did_document,
struct GNUNET_CONFIGURATION_Handle *cfg_handle,
struct GNUNET_IDENTITY_Handle *identity_handle,
+ struct GNUNET_NAMESTORE_Handle *namestore_handle,
DID_action_callback *cont,
void *cls);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 39/70: -did expiration time fix, (continued)
- [gnunet] 39/70: -did expiration time fix, gnunet, 2022/08/31
- [gnunet] 50/70: - not working test, gnunet, 2022/08/31
- [gnunet] 47/70: -move to reclaim, gnunet, 2022/08/31
- [gnunet] 44/70: -add comments, gnunet, 2022/08/31
- [gnunet] 43/70: -mergefix, gnunet, 2022/08/31
- [gnunet] 36/70: -did not working remove abstraction, gnunet, 2022/08/31
- [gnunet] 45/70: fix bugs, gnunet, 2022/08/31
- [gnunet] 66/70: - DID lib; renamed vars and moved a free, gnunet, 2022/08/31
- [gnunet] 63/70: - remove static variable from did_core, gnunet, 2022/08/31
- [gnunet] 55/70: - finished DID helper with tests, gnunet, 2022/08/31
- [gnunet] 60/70: - started with DID lib create func,
gnunet <=
- [gnunet] 54/70: - default did document test without multibase, gnunet, 2022/08/31
- [gnunet] 68/70: - DID lib; simplify closure, gnunet, 2022/08/31
- [gnunet] 30/70: -DID refactor, uncrustify, not working didd create, gnunet, 2022/08/31
- [gnunet] 31/70: - did not working create, gnunet, 2022/08/31
- [gnunet] 46/70: -code review, gnunet, 2022/08/31
- [gnunet] 53/70: - more tests, gnunet, 2022/08/31
- [gnunet] 61/70: - non working DID lib create func, gnunet, 2022/08/31
- [gnunet] 57/70: - changed did_core header, gnunet, 2022/08/31
- [gnunet] 59/70: - DID resolve using DID lib, gnunet, 2022/08/31
- [gnunet] 67/70: - DID lib; formatting, gnunet, 2022/08/31