aboutsummaryrefslogtreecommitdiff
path: root/libcmix/cmix.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcmix/cmix.c')
-rw-r--r--libcmix/cmix.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/libcmix/cmix.c b/libcmix/cmix.c
index 582fe70..a47a9fa 100644
--- a/libcmix/cmix.c
+++ b/libcmix/cmix.c
@@ -216,6 +216,8 @@ enum cmix_error key_exchange_init(struct CMixContext const* ctx, char* pubkey_bu
get_public_key(ctx, pubkey_buffer);
element_to_buffer(ctx, value_buffer, value);
+
+ ctx->api.free_group_element(value);
return no_error;
}
@@ -235,10 +237,13 @@ enum cmix_error key_exchange_responder(struct CMixContext const* ctx, GroupEleme
return no_error;
}
-enum cmix_error key_exchange_initiator(struct CMixContext const* ctx, GroupElement* shared_key, char const* pubkey, char const* value, GroupElement priv_el) {
+enum cmix_error key_exchange_initiator(struct CMixContext const* ctx, GroupElement* shared_key, char const* pubkey, char const* value, GroupElement* priv_el) {
size_t el_len = get_group_element_array_size(ctx);
*shared_key = ctx->api.derive_shared_key(ctx->keypair, (unsigned char*)pubkey, el_len, (unsigned char*)value, el_len, priv_el, false);
+ ctx->api.free_group_element(*priv_el);
+ *priv_el = NULL;
+
return no_error;
}
@@ -251,7 +256,7 @@ enum cmix_error post_process(struct CMixContext* ctx, char* r_out, char* m_out,
GroupElement pirs = ctx->api.multiply(D, msg, true);
element_to_buffer(ctx, m_out, pirs);
- ctx->pirs = pirs; // this is not always usable as only the last node will be able to use this effectively, but we store it anyways.
+ 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);
@@ -259,3 +264,19 @@ enum cmix_error post_process(struct CMixContext* ctx, char* r_out, char* m_out,
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);
+
+ GroupElement mes = ctx->api.array_to_element(message, len, true);
+
+ for(size_t i = 0; i < nr_nodes; ++i) {
+ ctx->api.multiply(mes, mes, keys[i]);
+ }
+
+ element_to_buffer(ctx, m_out, mes);
+
+ ctx->api.free_group_element(mes);
+
+ return no_error;
+}