From: Schanzenbach, Martin Date: Fri, 17 Aug 2018 13:18:39 +0000 (+0200) Subject: add prove and issue X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a6581f9ede6cae352c71a4a632513d74bb45695a;p=oweals%2Fgnunet.git add prove and issue --- diff --git a/src/include/gnunet_zklaim_service.h b/src/include/gnunet_zklaim_service.h index 6654555ab..0a551e703 100644 --- a/src/include/gnunet_zklaim_service.h +++ b/src/include/gnunet_zklaim_service.h @@ -37,6 +37,7 @@ extern "C" #endif #include "gnunet_util_lib.h" +#include "zklaim/zklaim.h" /** * Version number of GNUnet Identity Provider API. @@ -80,6 +81,19 @@ typedef void uint64_t *data); +/** + * Iterator called for each attribute to set a predicate in proof generation. + * + * @param cls closure + * @param name name of attribute + * @param data attribute data (can be modified) + */ +typedef void +(*GNUNET_ZKLAIM_PredicateIterator) (void *cls, + const char* name, + enum zklaim_op *op, + uint64_t *ref); + /** * Continuation called to notify client about result of the diff --git a/src/zklaim/zklaim_functions.c b/src/zklaim/zklaim_functions.c index 268056698..3c968cfea 100644 --- a/src/zklaim/zklaim_functions.c +++ b/src/zklaim/zklaim_functions.c @@ -98,3 +98,44 @@ ZKLAIM_context_issue (struct GNUNET_ZKLAIM_Context *ctx, ZKLAIM_context_sign (ctx, key); } + +void +ZKLAIM_context_prove (struct GNUNET_ZKLAIM_Context *ctx, + GNUNET_ZKLAIM_PredicateIterator iter, + void *iter_cls) +{ + int i; + int j; + char *attr_name; + char *tmp; + zklaim_wrap_payload_ctx *plw; + + tmp = GNUNET_strdup (ctx->attrs); + attr_name = strtok (tmp, ","); + plw = ctx->ctx->pl_ctx_head; + + for (i = 0; i < ctx->ctx->num_of_payloads; i++) + { + for (j = 0; j < ZKLAIM_MAX_PAYLOAD_ATTRIBUTES; j++) + { + GNUNET_assert (NULL != attr_name); + iter (iter_cls, + attr_name, + &plw->pl.data_op[i], + &plw->pl.data_ref[i]); + attr_name = strtok (NULL, ","); + } + plw = plw->next; + GNUNET_assert (NULL != plw); + } + GNUNET_free (tmp); + +} + +int +ZKLAIM_context_verify (struct GNUNET_ZKLAIM_Context *ctx, + const struct GNUNET_CRYPTO_EcdsaPublicKey *ttp) +{ + //TODO check ttp pubkey against pubkey in ctx + return zklaim_ctx_verify (ctx->ctx); +}