aboutsummaryrefslogtreecommitdiff
path: root/libcmix/cmix.c
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-11-18 14:34:20 +0100
committerDennis Brentjes <d.brentjes@gmail.com>2016-11-18 14:34:20 +0100
commit5a3f32ff25e7672ebc453818e7aa01ae84598ce7 (patch)
tree6279bd29963ed82d4442fd42784b61313dedaea8 /libcmix/cmix.c
parent7f2ae6e37f6e78d7edd561e7c2f91e69e93be85b (diff)
downloadcmix-5a3f32ff25e7672ebc453818e7aa01ae84598ce7.tar.gz
cmix-5a3f32ff25e7672ebc453818e7aa01ae84598ce7.tar.bz2
cmix-5a3f32ff25e7672ebc453818e7aa01ae84598ce7.zip
The Precomputation postprocess step is now done on batch level.
Diffstat (limited to 'libcmix/cmix.c')
-rw-r--r--libcmix/cmix.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/libcmix/cmix.c b/libcmix/cmix.c
index 9c983f0..1430532 100644
--- a/libcmix/cmix.c
+++ b/libcmix/cmix.c
@@ -284,21 +284,23 @@ enum cmix_error key_exchange_initiator(struct CMixContext const* ctx, GroupEleme
return no_error;
}
-enum cmix_error post_process(struct CMixContext* ctx, char* r_out, char* m_out, char const* r_epirs, char const* m_epirs, size_t index) {
- GroupElement x = ctx->api.array_to_element(r_epirs, get_group_element_array_size(ctx), true);
- GroupElement D = ctx->api.get_decryption_share(x, ctx->keypair.sec);
-
- 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);
-
- 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);
+enum cmix_error post_process(struct CMixContext* ctx, char** r_out, char** m_out, const char** r_epirs, const char** m_epirs, size_t nr_elements) {
+ for(size_t i = 0; i < nr_elements; ++i) {
+ GroupElement x = ctx->api.array_to_element(r_epirs[i], get_group_element_array_size(ctx), true);
+ GroupElement D = ctx->api.get_decryption_share(x, ctx->keypair.sec);
+
+ GroupElement msg = ctx->api.array_to_element(m_epirs[i], get_group_element_array_size(ctx), true);
+ GroupElement pirs = ctx->api.multiply(D, msg, true);
+ element_to_buffer(ctx, m_out[i], pirs);
+
+ memcpy(r_out[i], r_epirs[i], get_group_element_array_size(ctx));
+
+ ctx->pirs[i] = 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);
+ }
return no_error;
}