aboutsummaryrefslogtreecommitdiff
path: root/libcmix
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-11-16 19:55:11 +0100
committerDennis Brentjes <d.brentjes@gmail.com>2016-11-16 19:55:11 +0100
commit6ae607cc84b671810fca9c24b1c131ca12d922e7 (patch)
treee078e5e30cf2f979a1dbd0baefd18a9f58191f07 /libcmix
parentf93d52bbd0053574fb35d72b85c4b299dc1f3ee5 (diff)
downloadcmix-6ae607cc84b671810fca9c24b1c131ca12d922e7.tar.gz
cmix-6ae607cc84b671810fca9c24b1c131ca12d922e7.tar.bz2
cmix-6ae607cc84b671810fca9c24b1c131ca12d922e7.zip
Working implementation of elgamal in 2048 bit multiplicative group.
Diffstat (limited to 'libcmix')
-rw-r--r--libcmix/cmix.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/libcmix/cmix.c b/libcmix/cmix.c
index 4465011..9db4dbb 100644
--- a/libcmix/cmix.c
+++ b/libcmix/cmix.c
@@ -268,31 +268,38 @@ enum cmix_error post_process(struct CMixContext* ctx, char* r_out, char* m_out,
GroupElement msg = ctx->api.array_to_element(m_epirs, get_group_element_array_size(ctx), true);
GroupElement pirs = ctx->api.multiply(D, msg, true);
element_to_buffer(ctx, m_out, pirs);
- GroupElement new_r = ctx->api.multiply(x, D, true);
- element_to_buffer(ctx, r_out, new_r);
+ //GroupElement new_r = ctx->api.multiply(x, D, true);
+ //element_to_buffer(ctx, r_out, new_r);
+
+ memcpy(r_out, r_epirs, get_group_element_array_size(ctx));
ctx->pirs[index] = pirs; // this is not always usable as only the last node will be able to use this effectively, but we store it anyways.
ctx->api.free_group_element(x);
ctx->api.free_group_element(D);
ctx->api.free_group_element(msg);
- ctx->api.free_group_element(new_r);
+ //ctx->api.free_group_element(new_r);
return no_error;
}
enum cmix_error blind_message(struct CMixContext const* ctx, char* m_out, char const* message, GroupElement const* keys, size_t const nr_nodes) {
- size_t len = get_group_element_array_size(ctx);
+ size_t len = get_group_element_array_size(ctx);
+
+ GroupElement* intermediates = (GroupElement*) calloc(nr_nodes + 1, sizeof(GroupElement));
- GroupElement mes = ctx->api.array_to_element(message, len, true);
+ intermediates[0] = ctx->api.array_to_element(message, len, true);
for(size_t i = 0; i < nr_nodes; ++i) {
- ctx->api.multiply(mes, mes, keys[i]);
+ intermediates[i+1] = ctx->api.multiply(intermediates[i], keys[i], false);
}
- element_to_buffer(ctx, m_out, mes);
+ element_to_buffer(ctx, m_out, intermediates[nr_nodes]);
- ctx->api.free_group_element(mes);
+ for(size_t i = 0; i < nr_nodes + 1; ++i) {
+ ctx->api.free_group_element(intermediates[i]);
+ }
+ free(intermediates);
return no_error;
}