Browse Source

make sure the orchestrator and everything else can handle lambda (as well as moving things towards being able to run multiple tests with different configs simultaneously)

tristangurtler 3 years ago
parent
commit
15d3c66001

+ 5 - 0
prsona/cfg/default/clientIPs.cfg

@@ -0,0 +1,5 @@
+127.0.0.1:8082
+127.0.0.1:8083
+127.0.0.1:8084
+127.0.0.1:8085
+127.0.0.1:8086

+ 19 - 0
prsona/cfg/default/commands.cfg

@@ -0,0 +1,19 @@
+V 127.0.0.1:8082
+V 127.0.0.1:8083
+V 127.0.0.1:8084
+V 127.0.0.1:8085
+V 127.0.0.1:8086
+E
+V 127.0.0.1:8082
+V 127.0.0.1:8083
+V 127.0.0.1:8084
+V 127.0.0.1:8085
+V 127.0.0.1:8086
+E
+V 127.0.0.1:8082
+V 127.0.0.1:8083
+V 127.0.0.1:8084
+V 127.0.0.1:8085
+V 127.0.0.1:8086
+E
+R 127.0.0.1:8083 127.0.0.1:8082

+ 1 - 0
prsona/cfg/default/dealerIP.cfg

@@ -0,0 +1 @@
+127.0.0.1:8080

+ 1 - 0
prsona/cfg/default/selfIP-c0.cfg

@@ -0,0 +1 @@
+127.0.0.1:8082

+ 1 - 0
prsona/cfg/default/selfIP-c1.cfg

@@ -0,0 +1 @@
+127.0.0.1:8083

+ 1 - 0
prsona/cfg/default/selfIP-c2.cfg

@@ -0,0 +1 @@
+127.0.0.1:8084

+ 1 - 0
prsona/cfg/default/selfIP-c3.cfg

@@ -0,0 +1 @@
+127.0.0.1:8085

+ 1 - 0
prsona/cfg/default/selfIP-c4.cfg

@@ -0,0 +1 @@
+127.0.0.1:8086

+ 1 - 0
prsona/cfg/default/selfIP-d.cfg

@@ -0,0 +1 @@
+127.0.0.1:8080

+ 1 - 0
prsona/cfg/default/selfIP-s1.cfg

@@ -0,0 +1 @@
+127.0.0.1:8081

+ 2 - 0
prsona/cfg/default/serverIPs.cfg

@@ -0,0 +1,2 @@
+127.0.0.1:8080
+127.0.0.1:8081

+ 0 - 0
prsona/cfg/clientIPs.cfg → prsona/cfg/multidefault/clientIPs.cfg


+ 0 - 0
prsona/cfg/commands.cfg → prsona/cfg/multidefault/commands.cfg


+ 0 - 0
prsona/cfg/dealerIP.cfg → prsona/cfg/multidefault/dealerIP.cfg


+ 0 - 0
prsona/cfg/selfIP-c0.cfg → prsona/cfg/multidefault/selfIP-c0.cfg


+ 0 - 0
prsona/cfg/selfIP-c1.cfg → prsona/cfg/multidefault/selfIP-c1.cfg


+ 0 - 0
prsona/cfg/selfIP-c2.cfg → prsona/cfg/multidefault/selfIP-c2.cfg


+ 0 - 0
prsona/cfg/selfIP-c3.cfg → prsona/cfg/multidefault/selfIP-c3.cfg


+ 0 - 0
prsona/cfg/selfIP-c4.cfg → prsona/cfg/multidefault/selfIP-c4.cfg


+ 0 - 0
prsona/cfg/selfIP-d.cfg → prsona/cfg/multidefault/selfIP-d.cfg


+ 0 - 0
prsona/cfg/selfIP-s1.cfg → prsona/cfg/multidefault/selfIP-s1.cfg


+ 0 - 0
prsona/cfg/serverIPs.cfg → prsona/cfg/multidefault/serverIPs.cfg


+ 21 - 8
prsona/src/clientMain.cpp

@@ -21,6 +21,8 @@ using namespace std;
  *      its IP address and port
  * <output> - a string that will name the file in which outputs for this run of
  *      the program will be written (that is, timings and traffic data)
+ * <lambda> - a positive integer that determines the absolute soundness parameter
+ *      for batched proofs
  * <servers_are_malicious> - a bool (given as T/t or F/f)
  *      which is true when servers are in malicious security
  *      and false when they are in HBC security
@@ -57,13 +59,18 @@ int main(int argc, char *argv[])
     mutex repVerifyOutputMtx;
     string repVerifyOutputFilename = outputDir + "/repVerifier.out";
 
+    // Default to not doing proof batching if not specified
+    size_t lambda = 0;
+    if (argc > 3)
+        lambda = atoi(argv[3]);
+
+    if (lambda > 0)
+        PrsonaBase::set_lambda(lambda);
+
     // Default to malicious security if not specified
     bool maliciousServers = true;
-    if (argc > 3)
-    {
-        bool setting = argv[3][0] == 't' || argv[3][0] == 'T';
-        maliciousServers = setting;
-    }
+    if (argc > 4)
+        maliciousServers = argv[4][0] == 't' || argv[4][0] == 'T';
 
     // Set malicious flags where necessary
     if (maliciousServers)
@@ -76,6 +83,7 @@ int main(int argc, char *argv[])
     else
     {
         seedStr = id;
+        seedStr += "-" + output;
         seedStr += "-client";
     }
     seed_seq seed(seedStr.begin(), seedStr.end());
@@ -86,14 +94,16 @@ int main(int argc, char *argv[])
     string selfIP, selfPortStr;
     int selfPort = 0;
 
+    string configDir = "cfg/" + output;
+
     // Read in from config files the server locations
-    load_multiple_instances_config(serverIPs, serverPorts, "cfg/serverIPs.cfg");
+    load_multiple_instances_config(serverIPs, serverPorts, configDir + "/serverIPs.cfg");
 
     // And now the client locations
-    load_multiple_instances_config(clientIPs, clientPorts, "cfg/clientIPs.cfg");
+    load_multiple_instances_config(clientIPs, clientPorts, configDir + "/clientIPs.cfg");
 
     // Finally, read in the ip/port corresponding to the id that this instance was given
-    string selfConfigFilename = "cfg/selfIP";
+    string selfConfigFilename = configDir + "/selfIP";
     if (!id.empty())
     {
         selfConfigFilename += "-";
@@ -115,6 +125,9 @@ int main(int argc, char *argv[])
     cout << "[" << seedStr << "] Establishing PRSONA client with the following parameters: " << endl;
     cout << "[" << seedStr << "] " << numServers << " PRSONA servers" << endl;
     cout << "[" << seedStr << "] " << numClients << " PRSONA clients" << endl;
+    cout << "[" << seedStr << "] " << "Proof batching " << (lambda > 0 ? "IS" : "is NOT") << " in use." << endl;
+    if (lambda > 0)
+        cout << "[" << seedStr << "] Batch parameter: " << lambda << endl;
     cout << "[" << seedStr << "] Servers are set to " << (maliciousServers ? "MALICIOUS" : "HBC") << " security" << endl;
     cout << "[" << seedStr << "] This client is at IP address: " << selfIP << ":" << selfPort << endl;
     cout << endl;

+ 9 - 13
prsona/src/localMain.cpp

@@ -181,12 +181,14 @@ void test_reputation_proof(
     const PrsonaClient& b)
 {
     bool flag;
+
     mpz_class aScore = a.get_score().toInt();
-    int i = 0;
-    while (i < aScore)
-        i++;
+    size_t intScore = 0;
+    while (intScore < aScore)
+        intScore++;
+    intScore = (intScore == 0 ? 1 : intScore);
 
-    uniform_int_distribution<int> thresholdDistribution(0, i);
+    uniform_int_distribution<size_t> thresholdDistribution(0, intScore-1);
     Scalar goodThreshold(thresholdDistribution(generator));
     Scalar badThreshold(aScore + 1);
 
@@ -210,7 +212,7 @@ void test_reputation_proof(
     fullProof.push_back(baseProof);
     servers.get_other_user_tally_commitments(fullProof, shortTermPublicKey);
 
-    flag = b.verify_reputation_proof(badRepProof, shortTermPublicKey, goodThreshold, fullProof, currEncryptedScore);
+    flag = b.verify_reputation_proof(badRepProof, shortTermPublicKey, badThreshold, fullProof, currEncryptedScore);
     cout << "TEST INVALID REPUTATION PROOF:   " << (flag ? "FAILED (Proof verified)" : "PASSED (Proof not verified)" ) << endl << endl;
 }
 
@@ -386,15 +388,9 @@ int main(int argc, char *argv[])
     if (argc > 5)
         lambda = atoi(argv[5]);
     if (argc > 6)
-    {
-        bool setting = argv[6][0] == 't' || argv[6][0] == 'T';
-        maliciousServers = setting;
-    }
+        maliciousServers = argv[6][0] == 't' || argv[6][0] == 'T';
     if (argc > 7)
-    {
-        bool setting = argv[7][0] == 't' || argv[7][0] == 'T';
-        maliciousClients = setting;
-    }
+        maliciousClients = argv[7][0] == 't' || argv[7][0] == 'T';
     if (argc > 8)
         seedStr = argv[8];
 

+ 3 - 2
prsona/src/networkOrchestrator.cpp

@@ -21,15 +21,16 @@ int start_remote_actor(
     bool server,
     const std::string& id,
     const std::string& output,
+    size_t lambda,
     bool maliciousServers)
 {
     std::stringstream buffer;
     std::string command;
 
     if (target != "tick0" && !target.empty())
-        buffer << "ssh -n " << target << " \"~/prsona/prsona/scripts/startup.sh " << (server ? "server " : "client ") << id << " " << output << (maliciousServers ? " T\" &" : " F\" &");
+        buffer << "ssh -n " << target << " \"~/prsona/prsona/scripts/startup.sh " << (server ? "server " : "client ") << id << " " << output << " " << lambda << (maliciousServers ? " T\" &" : " F\" &");
     else
-        buffer << "bin/" << (server ? "server " : "client ") << id << " " << output << (maliciousServers ? " T &" : " F &");
+        buffer << "bin/" << (server ? "server " : "client ") << id << " " << output << " " << lambda << (maliciousServers ? " T &" : " F &");
     command = buffer.str();
 
     return system(command.c_str());

+ 16 - 11
prsona/src/orchestratorMain.cpp

@@ -20,6 +20,8 @@ using namespace std;
  *
  * <output> - a string that will name the files in which outputs for this run of
  *      the experiment will be written (that is, timings and traffic data)
+ * <lambda> - a positive integer that determines the absolute soundness parameter
+ *      for batched proofs
  * <servers_are_malicious> - a bool (given as T/t or F/f)
  *      which is true when servers are in malicious security
  *      and false when they are in HBC security
@@ -40,13 +42,14 @@ int main(int argc, char* argv[])
     if (argc > 1)
         output = argv[1];
 
+    size_t lambda = 0;
+    if (argc > 2)
+        lambda = atoi(argv[2]);
+
     // Default to malicious security if not specified
     bool maliciousServers = true;
-    if (argc > 2)
-    {
-        bool setting = argv[2][0] == 't' || argv[2][0] == 'T';
-        maliciousServers = setting;
-    }
+    if (argc > 3)
+        maliciousServers = argv[3][0] == 't' || argv[3][0] == 'T';
 
     vector<string> serverIPs, clientIPs;
     vector<int> serverPorts, clientPorts;
@@ -57,14 +60,16 @@ int main(int argc, char* argv[])
     targeter["129.97.119.208"] = "tick0";
     targeter["129.97.119.209"] = "tick1";
 
+    string configDir = "cfg/" + output;
+
     // Read in from config files the server locations
-    load_multiple_instances_config(serverIPs, serverPorts, "cfg/serverIPs.cfg");
+    load_multiple_instances_config(serverIPs, serverPorts, configDir + "/serverIPs.cfg");
 
     // And now the client locations
-    load_multiple_instances_config(clientIPs, clientPorts, "cfg/clientIPs.cfg");
+    load_multiple_instances_config(clientIPs, clientPorts, configDir + "/clientIPs.cfg");
 
     // And finally the dealer location
-    load_single_instance_config(dealerIP, dealerPortStr, dealerPort, "cfg/dealerIP.cfg");
+    load_single_instance_config(dealerIP, dealerPortStr, dealerPort, configDir + "/dealerIP.cfg");
 
     size_t numServers = serverIPs.size();
     size_t numClients = clientIPs.size();
@@ -80,7 +85,7 @@ int main(int argc, char* argv[])
     cout << "[ORC] Starting BGN dealer server." << endl;
 
     vector<thread> serverStartup, clientStartup;
-    serverStartup.push_back(thread(start_remote_actor, targeter[dealerIP], true, "d", output, maliciousServers));
+    serverStartup.push_back(thread(start_remote_actor, targeter[dealerIP], true, "d", output, lambda, maliciousServers));
     this_thread::sleep_for(ONE_SECOND);
 
     cout << "[ORC] Starting other servers." << endl;
@@ -90,7 +95,7 @@ int main(int argc, char* argv[])
         if (serverIPs[i] == dealerIP && serverPorts[i] == dealerPort)
             continue;
 
-        serverStartup.push_back(thread(start_remote_actor, targeter[serverIPs[i]], true, "s" + to_string(i), output, maliciousServers));
+        serverStartup.push_back(thread(start_remote_actor, targeter[serverIPs[i]], true, "s" + to_string(i), output, lambda, maliciousServers));
     }
 
     cout << "[ORC] Waiting for confirmation that servers are ready to continue." << endl;
@@ -104,7 +109,7 @@ int main(int argc, char* argv[])
 
     for (size_t i = 0; i < numClients; i++)
     {
-        clientStartup.push_back(thread(start_remote_actor, targeter[clientIPs[i]], false, "c" + to_string(i), output, maliciousServers));
+        clientStartup.push_back(thread(start_remote_actor, targeter[clientIPs[i]], false, "c" + to_string(i), output, lambda, maliciousServers));
         this_thread::sleep_for(ONE_SECOND);
     }
 

+ 22 - 8
prsona/src/serverMain.cpp

@@ -21,6 +21,8 @@ using namespace std;
  *      its IP address and port
  * <output> - a string that will name the file in which outputs for this run of
  *      the program will be written (that is, timings and traffic data)
+ * <lambda> - a positive integer that determines the absolute soundness parameter
+ *      for batched proofs
  * <servers_are_malicious> - a bool (given as T/t or F/f)
  *      which is true when servers are in malicious security
  *      and false when they are in HBC security
@@ -61,13 +63,19 @@ int main(int argc, char *argv[])
     mutex fullEpochOutputMtx;
     string fullEpochOutputFilename = outputDir + "/overallEpoch.out";
 
+    // Default to no proof batching if not specified
+    size_t lambda = 0;
+    if (argc > 3)
+        lambda = atoi(argv[3]);
+
+    // Set lambda where necessary
+    if (lambda > 0)
+        PrsonaBase::set_lambda(lambda);
+
     // Default to malicious security if not specified
     bool maliciousServers = true;
-    if (argc > 3)
-    {
-        bool setting = argv[3][0] == 't' || argv[3][0] == 'T';
-        maliciousServers = setting;
-    }
+    if (argc > 4)
+        maliciousServers = argv[4][0] == 't' || argv[4][0] == 'T';
 
     // Set malicious flags where necessary
     if (maliciousServers)
@@ -80,6 +88,7 @@ int main(int argc, char *argv[])
     else
     {
         seedStr = id;
+        seedStr += "-" + output;
         seedStr += "-server";
     }
     seed_seq seed(seedStr.begin(), seedStr.end());
@@ -90,11 +99,13 @@ int main(int argc, char *argv[])
     string selfIP, selfPortStr, dealerIP, dealerPortStr;
     int selfPort = 0, dealerPort = 0;
 
+    string configDir = "cfg/" + output;
+
     // Read in from config files the server locations
-    load_multiple_instances_config(serverIPs, serverPorts, "cfg/serverIPs.cfg");
+    load_multiple_instances_config(serverIPs, serverPorts, configDir + "/serverIPs.cfg");
 
     // Read in the ip/port corresponding to the id that this instance was given
-    string selfConfigFilename = "cfg/selfIP";
+    string selfConfigFilename = configDir + "/selfIP";
     if (!id.empty())
     {
         selfConfigFilename += "-";
@@ -104,7 +115,7 @@ int main(int argc, char *argv[])
     load_single_instance_config(selfIP, selfPortStr, selfPort, selfConfigFilename.c_str());
 
     // And finally the dealer location
-    load_single_instance_config(dealerIP, dealerPortStr, dealerPort, "cfg/dealerIP.cfg");
+    load_single_instance_config(dealerIP, dealerPortStr, dealerPort, configDir + "/dealerIP.cfg");
 
     size_t numServers = serverIPs.size();
     bool bgnDealer = selfIP == dealerIP && selfPort == dealerPort;
@@ -122,6 +133,9 @@ int main(int argc, char *argv[])
     cout << "[" << seedStr << "] Establishing PRSONA server with the following parameters: " << endl;
     cout << "[" << seedStr << "] " << numServers << " PRSONA servers" << endl;
     cout << "[" << seedStr << "] This server " << (bgnDealer ? "IS" : "is NOT") << " the trusted BGN dealer" << endl;
+    cout << "[" << seedStr << "] " << "Proof batching " << (lambda > 0 ? "IS" : "is NOT") << " in use." << endl;
+    if (lambda > 0)
+        cout << "[" << seedStr << "] Batch parameter: " << lambda << endl;
     cout << "[" << seedStr << "] Servers are set to " << (maliciousServers ? "MALICIOUS" : "HBC") << " security" << endl;
     cout << "[" << seedStr << "] This server is at IP address: " << selfIP << ":" << selfPort << endl;
     cout << "[" << seedStr << "] The BGN dealer is at IP address: " << dealerIP << ":" << dealerPort << endl;