aboutsummaryrefslogtreecommitdiff
path: root/libcmix/cmix.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix/cmix.c')
-rw-r--r--libcmix/cmix.c26
1 files changed, 14 insertions, 12 deletions
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;
}