aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-08-17 22:46:55 +0200
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-08-17 22:46:55 +0200
commit9c616547f2e77f01a3a8d1b50a764625e0269104 (patch)
treec71720f4b51bc36a916ee899c8b032ca2a65f960
parent9e3072d8c80e1ccf2efe851acd046782cc574dbd (diff)
downloadgnunet-9c616547f2e77f01a3a8d1b50a764625e0269104.tar.gz
gnunet-9c616547f2e77f01a3a8d1b50a764625e0269104.zip
proving works
-rw-r--r--src/include/gnunet_zklaim_service.h10
-rw-r--r--src/zklaim/Makefile.am1
-rw-r--r--src/zklaim/gnunet-service-zklaim.c98
-rw-r--r--src/zklaim/gnunet-zklaim.c20
-rw-r--r--src/zklaim/zklaim_api.c87
-rw-r--r--src/zklaim/zklaim_functions.c5
6 files changed, 157 insertions, 64 deletions
diff --git a/src/include/gnunet_zklaim_service.h b/src/include/gnunet_zklaim_service.h
index 011f2f9bb..7a46d0242 100644
--- a/src/include/gnunet_zklaim_service.h
+++ b/src/include/gnunet_zklaim_service.h
@@ -196,6 +196,16 @@ GNUNET_ZKLAIM_context_prove (struct GNUNET_ZKLAIM_Context *ctx,
196 GNUNET_ZKLAIM_PredicateIterator iter, 196 GNUNET_ZKLAIM_PredicateIterator iter,
197 void* iter_cls); 197 void* iter_cls);
198 198
199void
200GNUNET_ZKLAIM_context_destroy (struct GNUNET_ZKLAIM_Context *ctx);
201
202int
203GNUNET_ZKLAIM_context_prove_with_keyfile (struct GNUNET_ZKLAIM_Context *ctx,
204 const char* pkey_fn,
205 GNUNET_ZKLAIM_PredicateIterator iter,
206 void* iter_cls);
207
208
199#if 0 /* keep Emacsens' auto-indent happy */ 209#if 0 /* keep Emacsens' auto-indent happy */
200{ 210{
201#endif 211#endif
diff --git a/src/zklaim/Makefile.am b/src/zklaim/Makefile.am
index 22600c882..38c422c0c 100644
--- a/src/zklaim/Makefile.am
+++ b/src/zklaim/Makefile.am
@@ -48,6 +48,7 @@ libgnunetzklaim_la_LDFLAGS = \
48gnunet_service_zklaim_SOURCES = \ 48gnunet_service_zklaim_SOURCES = \
49 gnunet-service-zklaim.c 49 gnunet-service-zklaim.c
50gnunet_service_zklaim_LDADD = \ 50gnunet_service_zklaim_LDADD = \
51 libgnunetzklaim.la \
51 $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ 52 $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
52 $(top_builddir)/src/util/libgnunetutil.la \ 53 $(top_builddir)/src/util/libgnunetutil.la \
53 $(top_builddir)/src/namestore/libgnunetnamestore.la \ 54 $(top_builddir)/src/namestore/libgnunetnamestore.la \
diff --git a/src/zklaim/gnunet-service-zklaim.c b/src/zklaim/gnunet-service-zklaim.c
index baf6b20de..0619432e6 100644
--- a/src/zklaim/gnunet-service-zklaim.c
+++ b/src/zklaim/gnunet-service-zklaim.c
@@ -29,7 +29,9 @@
29#include "gnunet_gns_service.h" 29#include "gnunet_gns_service.h"
30#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"
31#include "gnunet_namestore_service.h" 31#include "gnunet_namestore_service.h"
32#include "gnunet_zklaim_service.h"
32#include "zklaim_api.h" 33#include "zklaim_api.h"
34#include "zklaim_functions.h"
33#include "zklaim/zklaim.h" 35#include "zklaim/zklaim.h"
34 36
35/** 37/**
@@ -53,6 +55,11 @@ static struct GNUNET_STATISTICS_Handle *stats;
53static const struct GNUNET_CONFIGURATION_Handle *cfg; 55static const struct GNUNET_CONFIGURATION_Handle *cfg;
54 56
55/** 57/**
58 * Proving key directory
59 */
60static char *pk_directory;
61
62/**
56 * An idp client 63 * An idp client
57 */ 64 */
58struct ZkClient 65struct ZkClient
@@ -123,16 +130,6 @@ struct CreateContextHandle
123 */ 130 */
124 struct GNUNET_NAMESTORE_QueueEntry *ns_qe; 131 struct GNUNET_NAMESTORE_QueueEntry *ns_qe;
125 132
126 /**
127 * The context name
128 */
129 char *name;
130
131 /**
132 * The attributes to support
133 */
134 char *attrs;
135
136}; 133};
137 134
138struct LookupHandle 135struct LookupHandle
@@ -193,6 +190,8 @@ cleanup()
193 GNUNET_GNS_disconnect (gns_handle); 190 GNUNET_GNS_disconnect (gns_handle);
194 if (NULL != ns_handle) 191 if (NULL != ns_handle)
195 GNUNET_NAMESTORE_disconnect (ns_handle); 192 GNUNET_NAMESTORE_disconnect (ns_handle);
193 GNUNET_free (pk_directory);
194 pk_directory = NULL;
196} 195}
197 196
198/** 197/**
@@ -220,8 +219,6 @@ cleanup_create_handle (struct CreateContextHandle *handle)
220{ 219{
221 if (NULL != handle->ns_qe) 220 if (NULL != handle->ns_qe)
222 GNUNET_NAMESTORE_cancel (handle->ns_qe); 221 GNUNET_NAMESTORE_cancel (handle->ns_qe);
223 GNUNET_free_non_null (handle->name);
224 GNUNET_free_non_null (handle->attrs);
225 GNUNET_free (handle); 222 GNUNET_free (handle);
226} 223}
227 224
@@ -278,6 +275,18 @@ check_create_context_message(void *cls,
278 return GNUNET_OK; 275 return GNUNET_OK;
279} 276}
280 277
278static char*
279get_pk_filename (char *ctx_name)
280{
281 char *filename;
282
283 GNUNET_asprintf (&filename,
284 "%s%s%s",
285 pk_directory,
286 DIR_SEPARATOR_STR,
287 ctx_name);
288 return filename;
289}
281 290
282static void 291static void
283handle_create_context_message (void *cls, 292handle_create_context_message (void *cls,
@@ -286,17 +295,16 @@ handle_create_context_message (void *cls,
286 struct CreateContextHandle *cch; 295 struct CreateContextHandle *cch;
287 struct ZkClient *zkc = cls; 296 struct ZkClient *zkc = cls;
288 struct GNUNET_GNSRECORD_Data ctx_record; 297 struct GNUNET_GNSRECORD_Data ctx_record;
298 struct GNUNET_ZKLAIM_Context *ctx;
289 size_t str_len; 299 size_t str_len;
290 char *tmp; 300 char *tmp;
291 char *pos; 301 char *pos;
292 unsigned char *data;
293 char *rdata; 302 char *rdata;
294 size_t data_len; 303 char *fn;
295 size_t rdata_len; 304 size_t rdata_len;
296 int num_attrs; 305 int num_attrs;
297 int num_pl; 306 int num_pl;
298 int i; 307 int i;
299 zklaim_ctx *ctx;
300 308
301 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 309 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
302 "Received CREATE_REQUEST message\n"); 310 "Received CREATE_REQUEST message\n");
@@ -304,10 +312,11 @@ handle_create_context_message (void *cls,
304 str_len = ntohs (crm->name_len); 312 str_len = ntohs (crm->name_len);
305 313
306 cch = GNUNET_new (struct CreateContextHandle); 314 cch = GNUNET_new (struct CreateContextHandle);
307 cch->name = GNUNET_strndup ((char*)&crm[1], str_len-1); 315 ctx = GNUNET_new (struct GNUNET_ZKLAIM_Context);
316 ctx->name = GNUNET_strndup ((char*)&crm[1], str_len-1);
308 str_len = ntohs(crm->attrs_len); 317 str_len = ntohs(crm->attrs_len);
309 fprintf(stderr, "%s\n", cch->name); 318 fprintf(stderr, "%s\n", ctx->name);
310 cch->attrs = GNUNET_strndup (((char*)&crm[1]) + strlen (cch->name) + 1, 319 ctx->attrs = GNUNET_strndup (((char*)&crm[1]) + strlen (ctx->name) + 1,
311 str_len-1); 320 str_len-1);
312 cch->private_key = crm->private_key; 321 cch->private_key = crm->private_key;
313 GNUNET_CRYPTO_ecdsa_key_get_public (&crm->private_key, 322 GNUNET_CRYPTO_ecdsa_key_get_public (&crm->private_key,
@@ -319,13 +328,14 @@ handle_create_context_message (void *cls,
319 zkc->create_op_tail, 328 zkc->create_op_tail,
320 cch); 329 cch);
321 330
322 tmp = GNUNET_strdup (cch->attrs); 331 tmp = GNUNET_strdup (ctx->attrs);
323 pos = strtok(tmp, ","); 332 pos = strtok(tmp, ",");
324 num_attrs = 0; 333 num_attrs = 0;
325 if (NULL == pos) 334 if (NULL == pos)
326 { 335 {
327 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 336 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
328 "No attributes given.\n"); 337 "No attributes given.\n");
338 GNUNET_ZKLAIM_context_destroy (ctx);
329 send_result(GNUNET_SYSERR, cch); 339 send_result(GNUNET_SYSERR, cch);
330 GNUNET_free (tmp); 340 GNUNET_free (tmp);
331 return; 341 return;
@@ -338,32 +348,34 @@ handle_create_context_message (void *cls,
338 GNUNET_free (tmp); 348 GNUNET_free (tmp);
339 num_pl = (num_attrs / 5) + 1; 349 num_pl = (num_attrs / 5) + 1;
340 zklaim_payload *pl = GNUNET_malloc (num_pl * sizeof (zklaim_payload)); 350 zklaim_payload *pl = GNUNET_malloc (num_pl * sizeof (zklaim_payload));
341 ctx = zklaim_context_new (); 351 ctx->ctx = zklaim_context_new ();
342 for (i = 0; i < num_pl; i++) 352 for (i = 0; i < num_pl; i++)
343 zklaim_add_pl (ctx, pl[i]); 353 zklaim_add_pl (ctx->ctx, pl[i]);
344 zklaim_hash_ctx (ctx); 354 zklaim_hash_ctx (ctx->ctx);
345 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 355 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
346 "Starting trusted setup (%d payloads)... this might take a while...\n", num_pl); 356 "Starting trusted setup (%d payloads)... this might take a while...\n", num_pl);
347 if (0 != zklaim_trusted_setup (ctx)) 357 if (0 != zklaim_trusted_setup (ctx->ctx))
348 { 358 {
349 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 359 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
350 "Trusted Setup failed.\n"); 360 "Trusted Setup failed.\n");
351 send_result (GNUNET_SYSERR, cch); 361 send_result (GNUNET_SYSERR, cch);
352 zklaim_ctx_free (ctx); 362 GNUNET_ZKLAIM_context_destroy (ctx);
353 return; 363 return;
354 } 364 }
355 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 365 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
356 "Finished trusted setup.\n"); 366 "Finished trusted setup. PK size=%lu bytes\n",
357 data_len = zklaim_ctx_serialize (ctx, &data); 367 ctx->ctx->pk_size);
358 rdata_len = data_len + strlen (cch->attrs) + 1; 368 fn = get_pk_filename (ctx->name);
359 zklaim_ctx_free (ctx); 369 (void) GNUNET_DISK_directory_create_for_file (fn);
360 rdata = GNUNET_malloc (rdata_len); 370 if (ctx->ctx->pk_size != GNUNET_DISK_fn_write (fn,
361 memcpy (rdata, 371 ctx->ctx->pk,
362 cch->attrs, 372 ctx->ctx->pk_size,
363 strlen (cch->attrs) + 1); 373 GNUNET_DISK_PERM_USER_READ |
364 memcpy (rdata + strlen (cch->attrs) + 1, 374 GNUNET_DISK_PERM_USER_WRITE))
365 data, 375 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
366 data_len); 376 "write", fn);
377 GNUNET_free (fn);
378 rdata_len = GNUNET_ZKLAIM_context_serialize (ctx, &rdata);
367 ctx_record.data_size = rdata_len; 379 ctx_record.data_size = rdata_len;
368 ctx_record.data = rdata; 380 ctx_record.data = rdata;
369 ctx_record.expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us; //TODO config 381 ctx_record.expiration_time = GNUNET_TIME_UNIT_DAYS.rel_value_us; //TODO config
@@ -371,13 +383,13 @@ handle_create_context_message (void *cls,
371 ctx_record.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 383 ctx_record.flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
372 cch->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle, 384 cch->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle,
373 &cch->private_key, 385 &cch->private_key,
374 cch->name, 386 ctx->name,
375 1, 387 1,
376 &ctx_record, 388 &ctx_record,
377 &context_store_cont, 389 &context_store_cont,
378 cch); 390 cch);
379 GNUNET_free (rdata); 391 GNUNET_free (rdata);
380 GNUNET_free (data); 392 GNUNET_ZKLAIM_context_destroy (ctx);
381} 393}
382 394
383/** 395/**
@@ -409,7 +421,7 @@ send_ctx_result (struct LookupHandle *lh,
409 env = GNUNET_MQ_msg_extra (r_msg, 421 env = GNUNET_MQ_msg_extra (r_msg,
410 len, 422 len,
411 GNUNET_MESSAGE_TYPE_ZKLAIM_RESULT_CTX); 423 GNUNET_MESSAGE_TYPE_ZKLAIM_RESULT_CTX);
412 r_msg->ctx_len = htonl (len); 424 r_msg->ctx_len = htons (len);
413 memcpy ((char*)&r_msg[1], 425 memcpy ((char*)&r_msg[1],
414 ctx, 426 ctx,
415 len); 427 len);
@@ -524,7 +536,15 @@ run (void *cls,
524 { 536 {
525 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to namestore"); 537 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "error connecting to namestore");
526 } 538 }
527 539 if (GNUNET_OK !=
540 GNUNET_CONFIGURATION_get_value_filename (cfg, "zklaim",
541 "PKDIR",
542 &pk_directory))
543 {
544 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "zklaim", "PKDIR");
545 GNUNET_SCHEDULER_shutdown ();
546 return;
547 }
528 gns_handle = GNUNET_GNS_connect (cfg); 548 gns_handle = GNUNET_GNS_connect (cfg);
529 if (NULL == gns_handle) 549 if (NULL == gns_handle)
530 { 550 {
diff --git a/src/zklaim/gnunet-zklaim.c b/src/zklaim/gnunet-zklaim.c
index fb6695574..4146b983e 100644
--- a/src/zklaim/gnunet-zklaim.c
+++ b/src/zklaim/gnunet-zklaim.c
@@ -75,6 +75,11 @@ static char* create_attrs;
75static char* ego_name; 75static char* ego_name;
76 76
77/** 77/**
78 * The proving key
79 */
80static char* pkey_fn;
81
82/**
78 * ZKLAIM handle 83 * ZKLAIM handle
79 */ 84 */
80static struct GNUNET_ZKLAIM_Handle *zklaim_handle; 85static struct GNUNET_ZKLAIM_Handle *zklaim_handle;
@@ -257,7 +262,7 @@ prove_iter (void *cls,
257 op = strtok (NULL, " "); 262 op = strtok (NULL, " ");
258 if (NULL == op) 263 if (NULL == op)
259 break; 264 break;
260 val = strtok (NULL, ";"); 265 val = strtok (NULL, ";");
261 if (NULL == val) 266 if (NULL == val)
262 break; 267 break;
263 if (0 != strcmp (name, attr)) 268 if (0 != strcmp (name, attr))
@@ -320,10 +325,10 @@ handle_arguments ()
320 fprintf (stderr, 325 fprintf (stderr,
321 "%s\n", 326 "%s\n",
322 prove_predicate); 327 prove_predicate);
323 328 ret = GNUNET_ZKLAIM_context_prove_with_keyfile (ctx,
324 ret = GNUNET_ZKLAIM_context_prove (ctx, 329 pkey_fn,
325 &prove_iter, 330 &prove_iter,
326 NULL); 331 NULL);
327 fprintf (stdout, 332 fprintf (stdout,
328 "Prove result: %d\n", ret); 333 "Prove result: %d\n", ret);
329 } 334 }
@@ -429,6 +434,11 @@ main(int argc, char *const argv[])
429 NULL, 434 NULL,
430 gettext_noop ("A credential"), 435 gettext_noop ("A credential"),
431 &credential), 436 &credential),
437 GNUNET_GETOPT_option_filename ('K',
438 "provingkey",
439 NULL,
440 gettext_noop ("The proving key to use"),
441 &pkey_fn),
432 GNUNET_GETOPT_OPTION_END 442 GNUNET_GETOPT_OPTION_END
433 }; 443 };
434 if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "ct", 444 if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "ct",
diff --git a/src/zklaim/zklaim_api.c b/src/zklaim/zklaim_api.c
index 6ca94fda5..fb83cccb6 100644
--- a/src/zklaim/zklaim_api.c
+++ b/src/zklaim/zklaim_api.c
@@ -281,8 +281,8 @@ handle_zklaim_result_ctx (void *cls,
281{ 281{
282 struct GNUNET_ZKLAIM_Handle *h = cls; 282 struct GNUNET_ZKLAIM_Handle *h = cls;
283 struct GNUNET_ZKLAIM_Operation *op; 283 struct GNUNET_ZKLAIM_Operation *op;
284 struct GNUNET_ZKLAIM_Context ctx; 284 struct GNUNET_ZKLAIM_Context *ctx;
285 uint16_t ctx_len = ntohl (cm->ctx_len); 285 uint16_t ctx_len = ntohs (cm->ctx_len);
286 286
287 op = h->op_head; 287 op = h->op_head;
288 if (NULL == op) 288 if (NULL == op)
@@ -294,21 +294,22 @@ handle_zklaim_result_ctx (void *cls,
294 GNUNET_CONTAINER_DLL_remove (h->op_head, 294 GNUNET_CONTAINER_DLL_remove (h->op_head,
295 h->op_tail, 295 h->op_tail,
296 op); 296 op);
297 ctx.attrs = (char*)&cm[1];
298 ctx.ctx = zklaim_context_new ();
299 zklaim_ctx_deserialize (ctx.ctx,
300 (unsigned char *) &cm[1] + strlen (ctx.attrs) + 1,
301 ctx_len - strlen (ctx.attrs) - 1);
302 if (NULL != op->ctx_cont) 297 if (NULL != op->ctx_cont)
303 { 298 {
304 if (0 > ctx_len) 299 fprintf (stderr,
300 "ctx_len %d\n", ctx_len);
301 if (0 < ctx_len)
302 {
303 ctx = GNUNET_ZKLAIM_context_deserialize ((char*)&cm[1],
304 ctx_len);
305 op->ctx_cont (op->cls, 305 op->ctx_cont (op->cls,
306 &ctx); 306 ctx);
307 GNUNET_ZKLAIM_context_destroy (ctx);
308 }
307 else 309 else
308 op->ctx_cont (op->cls, 310 op->ctx_cont (op->cls,
309 &ctx); 311 NULL);
310 } 312 }
311 zklaim_ctx_free (ctx.ctx);
312 GNUNET_free (op); 313 GNUNET_free (op);
313} 314}
314 315
@@ -480,6 +481,15 @@ GNUNET_ZKLAIM_disconnect (struct GNUNET_ZKLAIM_Handle *h)
480 GNUNET_free (h); 481 GNUNET_free (h);
481} 482}
482 483
484void
485GNUNET_ZKLAIM_context_destroy (struct GNUNET_ZKLAIM_Context *ctx)
486{
487 GNUNET_free_non_null (ctx->name);
488 GNUNET_free_non_null (ctx->attrs);
489 zklaim_ctx_free (ctx->ctx);
490 GNUNET_free (ctx);
491}
492
483/** 493/**
484 * Lookup context 494 * Lookup context
485 */ 495 */
@@ -543,18 +553,22 @@ GNUNET_ZKLAIM_context_serialize (const struct GNUNET_ZKLAIM_Context *ctx,
543 char *pos; 553 char *pos;
544 char *tmp; 554 char *tmp;
545 size_t len; 555 size_t len;
546 size_t len_w; 556 uint64_t len_w;
547 size_t ret_len = 0; 557 size_t ret_len = 0;
558 size_t alen = strlen (ctx->attrs) + 1;
559 size_t nlen = strlen (ctx->name) + 1;
548 len = zklaim_ctx_serialize (ctx->ctx, 560 len = zklaim_ctx_serialize (ctx->ctx,
549 (unsigned char**) &tmp); 561 (unsigned char**) &tmp);
550 ret_len += strlen (ctx->attrs) + 1 + sizeof (size_t) + len; 562 ret_len += alen + nlen + sizeof (size_t) + len;
551 *buf = GNUNET_malloc (ret_len); 563 *buf = GNUNET_malloc (ret_len);
552 pos = *buf; 564 pos = *buf;
553 memcpy (pos, ctx->attrs, strlen (ctx->attrs) + 1); 565 memcpy (pos, ctx->attrs, alen);
554 pos += strlen (ctx->attrs) + 1; 566 pos += alen;
555 len_w = htonl (len); 567 memcpy (pos, ctx->name, nlen);
556 memcpy (pos, &len_w, sizeof (size_t)); 568 pos += nlen;
557 pos += sizeof (size_t); 569 len_w = htons (len);
570 memcpy (pos, &len_w, sizeof (uint16_t));
571 pos += sizeof (uint16_t);
558 memcpy (pos, tmp, len); 572 memcpy (pos, tmp, len);
559 GNUNET_free (tmp); 573 GNUNET_free (tmp);
560 return ret_len; 574 return ret_len;
@@ -572,9 +586,11 @@ GNUNET_ZKLAIM_context_deserialize (char *data,
572 ctx = GNUNET_new (struct GNUNET_ZKLAIM_Context); 586 ctx = GNUNET_new (struct GNUNET_ZKLAIM_Context);
573 ctx->attrs = GNUNET_strdup (data); 587 ctx->attrs = GNUNET_strdup (data);
574 pos = data + strlen (ctx->attrs) + 1; 588 pos = data + strlen (ctx->attrs) + 1;
575 len = ntohl (*((size_t*)pos)); 589 ctx->name = GNUNET_strdup (pos);
590 pos += strlen (ctx->name) + 1;
591 len = ntohs (*((uint16_t*)pos));
576 ctx->ctx = zklaim_context_new (); 592 ctx->ctx = zklaim_context_new ();
577 pos += sizeof (size_t); 593 pos += sizeof (uint16_t);
578 if (0 != zklaim_ctx_deserialize (ctx->ctx, 594 if (0 != zklaim_ctx_deserialize (ctx->ctx,
579 (unsigned char*) pos, 595 (unsigned char*) pos,
580 len)) 596 len))
@@ -582,6 +598,37 @@ GNUNET_ZKLAIM_context_deserialize (char *data,
582 return ctx; 598 return ctx;
583} 599}
584 600
601
602int
603GNUNET_ZKLAIM_context_prove_with_keyfile (struct GNUNET_ZKLAIM_Context *ctx,
604 const char* pkey_fn,
605 GNUNET_ZKLAIM_PredicateIterator iter,
606 void* iter_cls)
607{
608 if (GNUNET_SYSERR == GNUNET_DISK_file_size (pkey_fn,
609 &ctx->ctx->pk_size,
610 GNUNET_NO,
611 GNUNET_YES))
612 {
613 return GNUNET_SYSERR;
614 }
615 ctx->ctx->pk = GNUNET_malloc (ctx->ctx->pk_size);
616 if (GNUNET_SYSERR == GNUNET_DISK_fn_read (pkey_fn,
617 ctx->ctx->pk,
618 ctx->ctx->pk_size))
619 {
620 GNUNET_free (ctx->ctx->pk);
621 ctx->ctx->pk = NULL;
622 ctx->ctx->pk_size = 0;
623 return GNUNET_SYSERR;
624 }
625
626 return GNUNET_ZKLAIM_context_prove (ctx,
627 iter,
628 iter_cls);
629}
630
631
585int 632int
586GNUNET_ZKLAIM_context_prove (struct GNUNET_ZKLAIM_Context *ctx, 633GNUNET_ZKLAIM_context_prove (struct GNUNET_ZKLAIM_Context *ctx,
587 GNUNET_ZKLAIM_PredicateIterator iter, 634 GNUNET_ZKLAIM_PredicateIterator iter,
diff --git a/src/zklaim/zklaim_functions.c b/src/zklaim/zklaim_functions.c
index e9e911623..c24549ee4 100644
--- a/src/zklaim/zklaim_functions.c
+++ b/src/zklaim/zklaim_functions.c
@@ -143,6 +143,11 @@ ZKLAIM_context_prove (struct GNUNET_ZKLAIM_Context *ctx,
143 attr_name, 143 attr_name,
144 &plw->pl.data_op[j], 144 &plw->pl.data_op[j],
145 &plw->pl.data_ref[j]); 145 &plw->pl.data_ref[j]);
146 if ((attr_name - tmp) == (strlen (attr_name) + 1))
147 {
148 attr_name = NULL;
149 break;
150 }
146 attr_name = strtok (attr_name + strlen (attr_name) + 1, ","); 151 attr_name = strtok (attr_name + strlen (attr_name) + 1, ",");
147 } 152 }
148 if (NULL == attr_name) 153 if (NULL == attr_name)