aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcmix-common/cmixprotofunctor.hpp7
-rw-r--r--libcmix-protobuf/cmix.proto4
-rw-r--r--node/node.cpp31
3 files changed, 40 insertions, 2 deletions
diff --git a/libcmix-common/cmixprotofunctor.hpp b/libcmix-common/cmixprotofunctor.hpp
index 75944f9..5fd736b 100644
--- a/libcmix-common/cmixprotofunctor.hpp
+++ b/libcmix-common/cmixprotofunctor.hpp
@@ -67,7 +67,12 @@ struct CMixProtoFunctor {
/*!
* #MESSAGE_SETTER_DECL(PrePre, prepre)
*/
- MESSAGE_SETTER_DEF(PrePre, prepre);
+ MESSAGE_SETTER_DEF(PrePre, prepre)
+
+ /*!
+ * #MESSAGE_SETTER_DECL(PreMix, premix)
+ */
+ MESSAGE_SETTER_DEF(PreMix, premix)
#undef MESSAGE_SETTER_DEF
};
diff --git a/libcmix-protobuf/cmix.proto b/libcmix-protobuf/cmix.proto
index 2fe2d83..00ab377 100644
--- a/libcmix-protobuf/cmix.proto
+++ b/libcmix-protobuf/cmix.proto
@@ -35,7 +35,8 @@ message PrePre {
}
message PreMix {
- repeated bytes EPiRS = 1;
+ repeated bytes r_EPiRS = 1;
+ repeated bytes m_EPiRS = 2;
}
message PrePost {
@@ -52,5 +53,6 @@ message CMixMessage {
KeyExchange keyexchange = 6;
NodeReady nodeready = 7;
PrePre prepre = 8;
+ PreMix premix = 9;
}
}
diff --git a/node/node.cpp b/node/node.cpp
index 2e5fd32..02ddb3e 100644
--- a/node/node.cpp
+++ b/node/node.cpp
@@ -128,6 +128,37 @@ void Node::handle_node_secretkey(cmix_proto::SecretKey const& secret)
void Node::handle_node_prepre(cmix_proto::PrePre const& pre) {
if(network_settings.is_first) {
+ cmix_proto::PreMix premix;
+ for(int i = 0; i < pre.m_er_size(); ++i) {
+ GroupElement random_r = api.array_to_element(pre.r_er(i).data(), pre.r_er(i).size(), true);
+ GroupElement message_r = api.array_to_element(pre.m_er(i).data(), pre.m_er(i).size(), true);
+
+ GroupElement random_s;
+ GroupElement message_s;
+
+ api.encrypt(&random_s, &message_s, precomputation_data[precomputation_data[i].new_location].s, network_key);
+
+ GroupElement random_pirs = api.multiply(random_r, random_s, true);
+ GroupElement message_pirs = api.multiply(message_r, message_s, true);
+
+ unsigned char* data;
+ size_t len;
+
+ api.element_to_array(&data, &len, random_pirs);
+ premix.set_r_epirs(precomputation_data[i].new_location, data, len);
+ api.free_buffer(data);
+
+ api.element_to_array(&data, &len, message_pirs);
+ premix.set_m_epirs(precomputation_data[i].new_location, data, len);
+ api.free_buffer(data);
+
+ api.free_group_element(random_r);
+ api.free_group_element(message_r);
+ api.free_group_element(random_s);
+ api.free_group_element(message_s);
+ }
+
+ next_node.async_send(premix);
} else {
std::vector<size_t> permutation(clients.size());