[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[freehaven-cvs] Partial mixnet observation



Update of /home/freehaven/cvsroot/doc/e2e-traffic/src
In directory moria.mit.edu:/tmp/cvs-serv4280

Modified Files:
	sim.cpp sim.h simmain.cpp trials.cpp trials.h 
Log Message:
Partial mixnet observation

Index: sim.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/sim.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sim.cpp	23 Aug 2003 19:04:29 -0000	1.3
+++ sim.cpp	23 Aug 2003 21:30:38 -0000	1.4
@@ -266,7 +266,7 @@
 }
 
 //XXXX make this configurable.  Low values really seem to hurt.
-#define BG_THRESHOLD 0.8
+#define BG_THRESHOLD 1
 void 
 DelayMixAttacker::addRound(int nAlice, int nOther, 
                            const vec<int> &r)
@@ -305,4 +305,31 @@
   res -= u;
   res /= nObservedAlice;
   return true;
+}
+
+// ======================================================================
+
+void
+POAttacker::addRound(int nAlice, int nOther, const vec<int> &rcvd)
+{
+  int nA = 0, nO = 0;
+  int nR = rcvd.size();
+  vec<int> r(nR, 0);
+  for (int i = 0; i < nAlice; ++i) {
+    if (rng() < pObserve) ++nA;
+  }
+  for (int i = 0; i < nOther; ++i) {
+    if (rng() < pObserve) ++nO;
+  }
+  for (int i = 0; i < nR; ++i) {
+    for (int j = 0; j < rcvd[i]; ++j) {
+      if (rng() < pObserve) ++r[i];
+    }
+  }
+  /*
+  std::cout << nAlice << " -> " << nA << ", "
+            << nOther << " -> " << nO << ", "
+            << rcvd << " -> " << r << std::endl;
+  */
+  base->addRound(nA, nO, r);
 }

Index: sim.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/sim.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- sim.h	23 Aug 2003 19:04:29 -0000	1.3
+++ sim.h	23 Aug 2003 21:30:38 -0000	1.4
@@ -28,6 +28,9 @@
   virtual void addRound(int nSentAlice, int nSentOther, 
                         const vec<int> &nReceived) = 0;
   virtual bool guessAlice(vec<double> &recipients) = 0;
+  void getRoundCounts(int &nObs, int &nAlice) { 
+    nObs = nAlice = 0;
+  }
 
   virtual ~FwdAttacker() {}
 };
@@ -207,6 +210,20 @@
 };
 
 
+// Partially observant attacker.
+class POAttacker : public FwdAttacker
+{
+ private:
+  FwdAttacker *base;
+  double pObserve;
+ public:
+  POAttacker(FwdAttacker *baseA, double p) : base(baseA), pObserve(p) {}
+  void reset() { base->reset(); }
+  void addRound(int nAlice, int nOther, const vec<int> &rcvd);
+  bool guessAlice(vec<double> &guess) { return base->guessAlice(guess); }
+  void getRoundCounts(int &r, int &ra) { base->getRoundCounts(r, ra); }
+  ~POAttacker() {}
+};
 
 
 #endif /* _SIM_H */

Index: simmain.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/simmain.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- simmain.cpp	23 Aug 2003 19:04:29 -0000	1.2
+++ simmain.cpp	23 Aug 2003 21:30:38 -0000	1.3
@@ -54,7 +54,8 @@
   // SDTrial trial(10000, 10, 3000);
   // XTrial trial;
   // UnkBGBatchTrial trial(100, 5, 30, false, 0.5, 0.0, 10);
-  MixTrial trial(100, 5, 3, 0.5, true, 0.6, 0.2, 30, 3, 0, 5);
+  // MixTrial trial(100, 5, 3, 0.5, true, 0.6, 0.2, 30, 3, 0, 5);
+  MixTrial trial(100, 5, 3, 0.5, true, 0.6, 0.2, 30, 3, 0, 20, true, 0.4);
   percentiles p;
   getPercentile(trial, 5, p);
   cout << "======" 

Index: trials.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- trials.cpp	23 Aug 2003 19:04:29 -0000	1.1
+++ trials.cpp	23 Aug 2003 21:30:38 -0000	1.2
@@ -214,7 +214,7 @@
 MixTrial::MixTrial(int nR, int nAR, int pathLen, double pDelay,
                    bool expAlice, double pMessage, double pDummy,
                    double bgVolMean, double bgVolDev, int padding,
-                   int g)
+                   int g, bool partial, double pObserve)
   : NonbatchTrial(nR, g)
 {
   assert(pathLen > 0);
@@ -232,6 +232,8 @@
   
   mixnet = new DelayMix(nR, maxDelay, delayDist);
   attacker = new DelayMixAttacker(nR, maxDelay, delayDist);
+  if (partial)
+    attacker = new POAttacker(attacker, pObserve);
   
   delete delayDist;
 
@@ -268,7 +270,8 @@
 MixTrial::attempt()
 {
   TrialResult res = NonbatchTrial::attempt();
-  dynamic_cast<DelayMixAttacker*>(attacker)->getRoundCounts(
-                          res.nRoundsObserved, res.nRoundsMaybeAlice);
+  attacker->getRoundCounts(res.nRoundsObserved, res.nRoundsMaybeAlice);
   return res;
 }
+
+// ======================================================================

Index: trials.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- trials.h	23 Aug 2003 19:04:29 -0000	1.1
+++ trials.h	23 Aug 2003 21:30:38 -0000	1.2
@@ -120,11 +120,14 @@
            double bgVolMean, // \ Taken together, these two decide how many
            double bgVolDev,  // / messages the background sends in a round.
            int padding=0,
-           int granularity=5
+           int granularity=5,
+           bool partial=false,
+           double pObserve=1.0
            );
   TrialResult attempt();
   ~MixTrial() {}
 };
+
 
 
 #endif

***********************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe freehaven-cvs       in the body. http://freehaven.net/