aboutsummaryrefslogtreecommitdiff
path: root/libcmix/cmix.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix/cmix.c')
-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;
}