From e4cf0d04c4afff98603df440d12a4a19b3717a34 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Fri, 18 Nov 2016 15:04:56 +0100 Subject: The Realtime precomputation step is now done on batch level. --- libcmix/cmix.c | 26 ++++++++++++++------------ libcmix/cmix.h | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'libcmix') diff --git a/libcmix/cmix.c b/libcmix/cmix.c index 1430532..d21dab5 100644 --- a/libcmix/cmix.c +++ b/libcmix/cmix.c @@ -326,20 +326,22 @@ enum cmix_error blind_message(struct CMixContext const* ctx, char* m_out, char c return no_error; } -enum cmix_error swap_k_for_r(struct CMixContext const* ctx, char* out_buffer, char const* message, GroupElement const key, size_t index) { +enum cmix_error swap_k_for_r(struct CMixContext const* ctx, char** out_buffer, const char** message, const GroupElement* key, size_t nr_elements) { size_t len = get_group_element_array_size(ctx); - GroupElement mes = ctx->api.array_to_element(message, len, false); - GroupElement inv_key = ctx->api.invert(key); - - GroupElement unblinded = ctx->api.multiply(mes, inv_key, false); - GroupElement blinded = ctx->api.multiply(unblinded, ctx->r[index], false); - - element_to_buffer(ctx, out_buffer, blinded); - ctx->api.free_group_element(mes); - ctx->api.free_group_element(inv_key); - ctx->api.free_group_element(unblinded); - ctx->api.free_group_element(blinded); + for(size_t i = 0; i < nr_elements; ++i) { + GroupElement mes = ctx->api.array_to_element(message[i], len, false); + GroupElement inv_key = ctx->api.invert(key[i]); + + GroupElement unblinded = ctx->api.multiply(mes, inv_key, false); + GroupElement blinded = ctx->api.multiply(unblinded, ctx->r[i], false); + + element_to_buffer(ctx, out_buffer[i], blinded); + ctx->api.free_group_element(mes); + ctx->api.free_group_element(inv_key); + ctx->api.free_group_element(unblinded); + ctx->api.free_group_element(blinded); + } return no_error; } diff --git a/libcmix/cmix.h b/libcmix/cmix.h index 390b28f..057fd60 100644 --- a/libcmix/cmix.h +++ b/libcmix/cmix.h @@ -105,7 +105,7 @@ enum cmix_error enqueue_message(struct CMixContext* ctx, char const* message, si enum cmix_error enqueue_random_message(struct CMixContext* ctx, size_t index); -enum cmix_error swap_k_for_r(struct CMixContext const* ctx, char* out_buffer, char const* message, GroupElement const key, size_t index); +enum cmix_error swap_k_for_r(struct CMixContext const* ctx, char** out_buffer, char const** message, GroupElement const* key, size_t nr_elements); enum cmix_error remove_r_and_s(struct CMixContext const* ctx, char* out_buffer, char const* message, size_t index); -- cgit v1.2.3-70-g09d2