aboutsummaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
Diffstat (limited to 'node')
-rw-r--r--node/main.cpp4
-rw-r--r--node/node.cpp6
-rw-r--r--node/node.hpp2
-rw-r--r--node/node_client.cpp2
-rw-r--r--node/node_node.cpp15
5 files changed, 26 insertions, 3 deletions
diff --git a/node/main.cpp b/node/main.cpp
index 0c81312..28ef60c 100644
--- a/node/main.cpp
+++ b/node/main.cpp
@@ -21,6 +21,7 @@ int main(int argc, char* argv[]) {
("interface6,6", po::value<std::string>()->default_value("::"), "Set the ipv6 address to listen on.")
("next_node,n", po::value<std::string>(), "The address of the next node in the network.")
("first,f", "This is the first node and will be the communication point for the clients.")
+ ("last,f", "this is the last node and will be able to send the original message out of the network.")
("cert,c", po::value<std::string>(), "The cert file to use (in pem format).")
("key,k", po::value<std::string>(), "The key file (in pem format).")
("dhparam,d", po::value<std::string>(), "The dhparam file.")
@@ -92,6 +93,7 @@ int main(int argc, char* argv[]) {
BOOST_LOG_TRIVIAL(info) << "Started node";
bool is_first = bool(vm.count("first"));
+ bool is_last = bool(vm.count("last"));
std::string next_node;
if(vm.count("next_node")) {
next_node = vm["next_node"].as<std::string>();
@@ -112,7 +114,7 @@ int main(int argc, char* argv[]) {
Uri uri = parse_uri(next_node);
- NodeNetworkSettings nsettings{is_first, uri.host, uri.port, certdir};
+ NodeNetworkSettings nsettings{is_first, is_last, uri.host, uri.port, certdir};
Node node(lsettings, nsettings);
node.run();
diff --git a/node/node.cpp b/node/node.cpp
index fa9a721..b5c8506 100644
--- a/node/node.cpp
+++ b/node/node.cpp
@@ -135,6 +135,12 @@ void Node::start_precomputation() {
exit(-1);
}
+ int i = 0;
+ for(auto&& pair : clients) {
+ index_map[pair.first] = i++;
+ generate_random_message(&cmix_ctx, i);
+ }
+
if(initialize_mix_randomness(&cmix_ctx) != no_error) {
exit(-1);
}
diff --git a/node/node.hpp b/node/node.hpp
index ea73121..a4c7992 100644
--- a/node/node.hpp
+++ b/node/node.hpp
@@ -24,6 +24,7 @@
*/
struct NodeNetworkSettings {
bool is_first; ///< Are we the first node in the network.
+ bool is_last; ///< Are we the last node in the network.
std::string next_host; ///< Next nodes host.
std::string next_port; ///< Next nodes port.
std::string certdir; ///< Directory containing trusted certificate authorities.
@@ -71,6 +72,7 @@ class Node
CMixContext cmix_ctx;
std::vector<MixData> precomputation_data;
+ std::map<std::string, int> index_map;
bool shutting_down;
diff --git a/node/node_client.cpp b/node/node_client.cpp
index fef1937..f60c48d 100644
--- a/node/node_client.cpp
+++ b/node/node_client.cpp
@@ -10,7 +10,7 @@ void Node::handle_client_keyexchange(ClientConnections::key_type handle, cmix_pr
nke.mutable_public_key()->resize(len);
nke.mutable_value()->resize(len);
- key_exchange(&cmix_ctx, &d.shared_value.shared, &(*nke.mutable_public_key())[0], &(*nke.mutable_value())[0], ke.public_key().data(), ke.value().data());
+ key_exchange_responder(&cmix_ctx, &d.shared_value.shared, &(*nke.mutable_public_key())[0], &(*nke.mutable_value())[0], ke.public_key().data(), ke.value().data());
data[handle] = d;
diff --git a/node/node_node.cpp b/node/node_node.cpp
index fecc4ad..eea9eb0 100644
--- a/node/node_node.cpp
+++ b/node/node_node.cpp
@@ -60,7 +60,20 @@ cmix_proto::PrePost fill_precomputation_post_message(CMixContext& ctx, T const&
cmix_proto::PrePost prepost;
for(size_t i = 0; i < ctx.nr_participants; ++i) {
- post_process(&ctx, rs.Get(i).data(), ms.Get(i).data(), i);
+ size_t el_len = get_group_element_array_size(&ctx);
+
+ prepost.mutable_r_epirs(i)->resize(el_len);
+ prepost.mutable_m_epirs(i)->resize(el_len);
+
+ post_process(
+ &ctx,
+ &(*prepost.mutable_r_epirs(i))[0],
+ &(*prepost.mutable_m_epirs(i))[0],
+ rs.Get(i).data(),
+ ms.Get(i).data(),
+ i
+ );
+
*prepost.mutable_r_epirs(i) = rs.Get(i);
*prepost.mutable_m_epirs(i) = ms.Get(i);
}