[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 03/04: worked on secret share
From: |
gnunet |
Subject: |
[taler-anastasis] 03/04: worked on secret share |
Date: |
Thu, 07 May 2020 03:26:56 +0200 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit 9057dde6cfbcefdd6cb7c36f814f73b9174a3a98
Author: Dennis Neufeld <address@hidden>
AuthorDate: Thu May 7 01:16:41 2020 +0000
worked on secret share
---
src/lib/anastasis.c | 125 +++++++++++++++++++++++++++-------------------------
1 file changed, 65 insertions(+), 60 deletions(-)
diff --git a/src/lib/anastasis.c b/src/lib/anastasis.c
index 64a25b1..2ba85e8 100644
--- a/src/lib/anastasis.c
+++ b/src/lib/anastasis.c
@@ -24,6 +24,7 @@
#include <taler/taler_json_lib.h>
#include <gnunet/gnunet_util_lib.h>
+#define SIZE_URL 50
/**
* FIXME: Needed? -> maybe needed in ANASTASIS_secret_share()
@@ -1003,7 +1004,7 @@ struct ANASTASIS_Policy
/**
* array of truths
*/
- struct ANASTASIS_Truth *truths[];
+ struct ANASTASIS_Truth **truths;
};
/**
@@ -1066,7 +1067,7 @@ ANASTASIS_policy_create (struct ANASTASIS_Truth *truths[],
(unsigned long long) sizeof (p->policy_key));
p->uuids = uuids;
p->uuid_length = truths_len;
- *p->truths = truths;
+ p->truths = truths;
GNUNET_assert (NULL != p->uuids);
GNUNET_assert (p->uuid_length == truths_len);
@@ -1304,79 +1305,87 @@ policy_store_cb (void *cls,
/**
+ * Counts the number of different providers
*
- */
-static int
-ANASTASIS_check_array_contains_element (const void **array,
- unsigned int array_len,
- void *element)
-{
- void *arr;
-
- arr = array;
- if (0 == array_len)
- return 0;
-
- for (unsigned int i = 0; i < array_len; i++)
- {
- if (i > 0)
- arr = &array[1];
-
- int ret = GNUNET_memcmp (element, arr);
-
- if (0 == ret)
- {
- return 1;
- }
- }
- return 0;
-}
-
-
-/**
- *
+ * @param policies Array of policies
+ * @param policies_len Length of array
+ * @return number of different providers
*/
static unsigned int
-ANASTASIS_get_uuids_length (const struct ANASTASIS_Policy *policies[],
- unsigned int policies_len)
+ANASTASIS_get_num_urls (const struct ANASTASIS_Policy *policies[],
+ unsigned int policies_len)
{
struct ANASTASIS_Policy *policy;
unsigned int len = 0;
- unsigned int unique_uuids_len = 0;
-
- policy = policies;
+ unsigned int unique_urls_len = 0;
for (unsigned int i = 0; i < policies_len; i++)
{
- if (i > 0)
- policy = &policies[1];
+ policy = policies[i];
len += policy->uuid_length;
}
- {
- uuid_t *uuids[len];
- policy = policies;
+ {
+ char *provider[len];
+ for (unsigned int i = 0; i < len; i++)
+ {
+ // allocate space for each url
+ provider[i] = GNUNET_malloc (SIZE_URL * sizeof (char));
+ }
- for (unsigned int i = 0; i < policies_len; i++)
+ for (unsigned int l = 0; l < policies_len; l++)
{
- if (i > 0)
- policy = &policies[1];
+ policy = policies[l];
+ struct ANASTASIS_Truth *truth;
for (unsigned int j = 0; j < policy->uuid_length; j++)
{
- if (0 == ANASTASIS_check_array_contains_element ((void **) &uuids,
- len,
- (void *)
&policy->uuids
- [j]))
+ truth = policy->truths[0];
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d truth is %s-%llu b\n", __FILE__, __LINE__,
+ TALER_B2S (truth),
+ (unsigned long long) sizeof (struct ANASTASIS_Truth));
+
+ int contains_url = 0;
+ for (unsigned int k = 0; k < len; k++)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d provider url from truth is %s\n", __FILE__,
+ __LINE__,
+ truth->url);
+ if (NULL != provider[k])
+ {
+ if (0 ==
+ strcmp (truth->url, provider[k]))
+ {
+ contains_url = 1;
+ break;
+ }
+ }
+ }
+
+ if (0 == contains_url)
{
- uuids[unique_uuids_len] = policy->uuids[j];
- unique_uuids_len++;
+ provider[unique_urls_len] = truth->url;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d provider url is %s\n", __FILE__, __LINE__,
+ provider[unique_urls_len]);
+ unique_urls_len++;
}
}
}
+ for (unsigned int i = 0; i < len; i++)
+ {
+ // free space for each url
+ GNUNET_free (provider[i]);
+ }
}
- return unique_uuids_len;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "At %s:%d unique_urls_len is %d\n", __FILE__, __LINE__,
+ unique_urls_len);
+ return unique_urls_len;
}
@@ -1410,8 +1419,8 @@ ANASTASIS_secret_share (const json_t *id_data,
struct ANASTASIS_SecretShare *ss;
struct ANASTASIS_Policy *policy;
- unsigned int pss_length = ANASTASIS_get_uuids_length (policies,
- policies_len);
+ unsigned int pss_length = ANASTASIS_get_num_urls (policies,
+ policies_len);
struct PolicyStoreState pss[pss_length];
struct GNUNET_HashCode current_etags[pss_length];
enum TALER_ErrorCode ecs[pss_length];
@@ -1437,11 +1446,9 @@ ANASTASIS_secret_share (const json_t *id_data,
// json array
json_t *esc_methods;
- policy = policies;
for (unsigned int i = 0; i < policies_len; i++)
{
- if (i > 0)
- policy = &policy[1];
+ policy = policies[i];
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"At %s:%d policy is %s-%llu b\n", __FILE__, __LINE__,
TALER_B2S (policy),
@@ -1460,11 +1467,9 @@ ANASTASIS_secret_share (const json_t *id_data,
esc_methods = json_array ();
unsigned int all_uuids_length = 0;
int index_pss = 0;
- policy = policies;
for (unsigned int k = 0; k < policies_len; k++ )
{
- if (k > 0)
- policy = &policy[1];
+ policy = policies[k];
all_uuids_length += policy->uuid_length;
json_t *dec_policy = json_pack ("{s:o," /* encrypted master key */
" s:o," /* policy uuids */
--
To stop receiving notification emails like this one, please contact
address@hidden.