Pārlūkot izejas kodu

test whether or not a prover can get a verifier to accept a false statement

tristangurtler 3 gadi atpakaļ
vecāks
revīzija
b7597a0225
2 mainītis faili ar 17 papildinājumiem un 13 dzēšanām
  1. 1 1
      prsona/src/client.cpp
  2. 16 12
      prsona/src/main.cpp

+ 1 - 1
prsona/src/client.cpp

@@ -154,7 +154,7 @@ std::vector<Proof> PrsonaClient::generate_reputation_proof(
     std::vector<Proof> retval;
 
     // Don't even try if the user asks to make an illegitimate proof
-    if (threshold > currentScore)
+    if (threshold.toInt() > (servers->get_num_clients() * MAX_ALLOWED_VOTE))
         return retval;
 
     // Base case

+ 16 - 12
prsona/src/main.cpp

@@ -179,22 +179,26 @@ void reputation_proof_attempt(default_random_engine& generator, const PrsonaClie
         i++;
 
     uniform_int_distribution<int> thresholdDistribution(0, i);
-    Scalar threshold(thresholdDistribution(generator));
+    Scalar goodThreshold(thresholdDistribution(generator));
+    Scalar badThreshold(aScore + 1);
 
-    cout << "User A's score:            " << aScore << endl;
-    cout << "User A's chosen threshold: " << threshold << endl;
+    cout << "User A's score: " << aScore << endl;
+    cout << "User A's chosen good threshold: " << goodThreshold << endl;
+    cout << "User A's chosen bad threshold: " << badThreshold << endl;
 
     Proof pi;
     Curvepoint shortTermPublicKey = a.get_short_term_public_key(pi);
-    vector<Proof> repProof = a.generate_reputation_proof(threshold);
-    if (b.verify_reputation_proof(repProof, shortTermPublicKey, threshold))
-    {
-        cout << "User A proved their reputation to user B!" << endl;
-    }
-    else
-    {
-        cout << "User A failed to prove their reputation to user B!" << endl;
-    }
+    vector<Proof> goodRepProof = a.generate_reputation_proof(goodThreshold);
+    cout << "TEST VALID PROOF:   "
+        << (b.verify_reputation_proof(goodRepProof, shortTermPublicKey, goodThreshold) ?
+            "PASSED (Proof verified)" : "FAILED (Proof not verified)" )
+        << endl;
+    
+    vector<Proof> badRepProof = a.generate_reputation_proof(badThreshold);
+    cout << "TEST INVALID PROOF: "
+        << (b.verify_reputation_proof(badRepProof, shortTermPublicKey, badThreshold) ?
+            "FAILED (Proof verified)" : "PASSED (Proof not verified)" )
+        << endl;
 }
 
 int main(int argc, char *argv[])