diff options
author | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2018-08-17 15:04:19 +0200 |
---|---|---|
committer | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2018-08-17 15:04:19 +0200 |
commit | 9dfd05ddd6933e9e46804d7db47cea149f24d8d4 (patch) | |
tree | ecbc0b1e52ea72cfadb4cbcaa226da7db1d1376a /src/zklaim/zklaim_functions.c | |
parent | 8cd6146318d890c5cb18a2edb72090feee9729b2 (diff) | |
download | gnunet-9dfd05ddd6933e9e46804d7db47cea149f24d8d4.tar.gz gnunet-9dfd05ddd6933e9e46804d7db47cea149f24d8d4.zip |
towards zklaim prove
Diffstat (limited to 'src/zklaim/zklaim_functions.c')
-rw-r--r-- | src/zklaim/zklaim_functions.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/zklaim/zklaim_functions.c b/src/zklaim/zklaim_functions.c new file mode 100644 index 000000000..1c66b421c --- /dev/null +++ b/src/zklaim/zklaim_functions.c | |||
@@ -0,0 +1,75 @@ | |||
1 | #include "platform.h" | ||
2 | #include "zklaim/zklaim.h" | ||
3 | #include "gcrypt.h" | ||
4 | #include "gnunet_zklaim_service.h" | ||
5 | #include "zklaim_functions.h" | ||
6 | |||
7 | int | ||
8 | ZKLAIM_context_sign (struct GNUNET_ZKLAIM_Context *ctx, | ||
9 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key) | ||
10 | { | ||
11 | int rc; | ||
12 | gcry_sexp_t priv; | ||
13 | |||
14 | //TODO how to ensure not hashed?? | ||
15 | zklaim_hash_ctx (ctx->ctx); | ||
16 | rc = gcry_sexp_build (&priv, NULL, | ||
17 | "(private-key(ecc(curve \"Ed25519\")" | ||
18 | "(d %b)))", | ||
19 | (int) sizeof (key->d), key->d); | ||
20 | if (0 != rc) | ||
21 | { | ||
22 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
23 | "GCRY error...\n"); | ||
24 | //send_issue_response (ih, NULL, 0); | ||
25 | return GNUNET_SYSERR; | ||
26 | } | ||
27 | return zklaim_ctx_sign (ctx->ctx, priv); | ||
28 | } | ||
29 | |||
30 | void | ||
31 | ZKLAIM_context_attributes_iterate (const struct GNUNET_ZKLAIM_Context *ctx, | ||
32 | GNUNET_ZKLAIM_PayloadIterator iter, | ||
33 | void *iter_cls) | ||
34 | { | ||
35 | int i; | ||
36 | int j; | ||
37 | uint64_t data; | ||
38 | char *attr_name; | ||
39 | char *tmp; | ||
40 | zklaim_wrap_payload_ctx *plw; | ||
41 | |||
42 | tmp = GNUNET_strdup (ctx->attrs); | ||
43 | attr_name = strtok (tmp, ","); | ||
44 | plw = ctx->ctx->pl_ctx_head; | ||
45 | |||
46 | for (i = 0; i < ctx->ctx->num_of_payloads; i++) | ||
47 | { | ||
48 | for (j = 0; j < ZKLAIM_MAX_PAYLOAD_ATTRIBUTES; j++) | ||
49 | { | ||
50 | GNUNET_assert (NULL != attr_name); | ||
51 | iter (iter_cls, attr_name, &data); | ||
52 | zklaim_set_attr (&plw->pl, | ||
53 | data, | ||
54 | j); | ||
55 | attr_name = strtok (NULL, ","); | ||
56 | } | ||
57 | plw = plw->next; | ||
58 | GNUNET_assert (NULL != plw); | ||
59 | } | ||
60 | GNUNET_free (tmp); | ||
61 | |||
62 | } | ||
63 | |||
64 | void | ||
65 | ZKLAIM_context_issue (struct GNUNET_ZKLAIM_Context *ctx, | ||
66 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | ||
67 | GNUNET_ZKLAIM_PayloadIterator iter, | ||
68 | void *iter_cls) | ||
69 | { | ||
70 | ZKLAIM_context_attributes_iterate (ctx, | ||
71 | iter, | ||
72 | iter_cls); | ||
73 | ZKLAIM_context_sign (ctx, | ||
74 | key); | ||
75 | } | ||