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

[freehaven-cvs] Implement basic pseudonymous email example (full lin...



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

Modified Files:
	netparams.cpp netparams.h sim.cpp simmain.cpp trials.cpp 
	trials.h 
Added Files:
	NYMPLAN 
Log Message:
Implement basic pseudonymous email example (full linkability).  [This will probably get used in the pynchon-gate paper.]

--- NEW FILE: NYMPLAN ---

Test: Mixnet.  Alice has one pseudonym.  All recipients receive
    messages with equal probability and distribution.

  bgVolMean = 1/(1-pMsgAlice)

Variables: pathLen, pDelay, nRecipients, pMsgAlice

  N : 1024, 4096, 16384, 65536
  pL: 1, 4
  pD: .1, .6, .9
  pA: .1, .5, .9

  3*3*2*4 = 7200

Too big.  Start with:

  n1: pA==.1,.5, pD==.1,.6, pL=1, N=1024...65536
   [2*2*4 == 1600]

Index: netparams.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/netparams.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- netparams.cpp	11 Apr 2004 05:02:56 -0000	1.8
+++ netparams.cpp	12 Sep 2004 02:39:32 -0000	1.9
@@ -133,31 +133,12 @@
 void
 getNymStats(InvDist<int> *&aliceNymDist,
 	    InvDist<int> *&backgroundNymDist,
-	    std::vector<int> *&aliceNyms,
-	    int nAliceNyms,
-	    int nNyms,
-	    bool smallworld)
+	    int nNyms)
 {
-  assert(nAliceNyms<nNyms);
-  int nBGNyms = nNyms-nAliceNyms;
   std::vector<int> a(nNyms,0);
-  aliceNyms = new std::vector<int>(nAliceNyms);
-  for (int i=0; i<nAliceNyms; ++i) {
-    a[nBGNyms+i]=1;
-    (*aliceNyms)[i]=nBGNyms+i;
-  }
+  std::vector<int> b(nNyms,1);
+  a[0] = 1;
+  b[0] = 0;
   aliceNymDist = new OCumulativeDist(a);
-  if (!smallworld) {
-    std::vector<int> b(nNyms,0);
-    for (int i=0; i < (nNyms-nAliceNyms); ++i) {
-      b[i]=1;
-    }
-    backgroundNymDist = new OCumulativeDist(b);
-  } else {
-    InvDist<int> *ad, *bd;
-    std::vector<int> *ar;
-    getCommunicationLinks(ad,bd,ar,1,nNyms-nAliceNyms,false,false);
-    delete ar, ad;
-    backgroundNymDist = bd;
-  }
+  backgroundNymDist = new OCumulativeDist(b);
 }

Index: netparams.h
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/netparams.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- netparams.h	11 Apr 2004 05:02:56 -0000	1.4
+++ netparams.h	12 Sep 2004 02:39:32 -0000	1.5
@@ -56,9 +56,6 @@
 void
 getNymStats(InvDist<int> *&aliceNymDist,
 	    InvDist<int> *&backgroundNymDist,
-	    std::vector<int> *&aliceNyms,
-	    int nAliceNyms,
-	    int nNyms,
-	    bool smallworld);
+	    int nNyms);
 
 #endif // _NETPARAMS_H

Index: sim.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/sim.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- sim.cpp	27 Apr 2004 19:44:39 -0000	1.15
+++ sim.cpp	12 Sep 2004 02:39:32 -0000	1.16
@@ -43,10 +43,12 @@
   } else if (nDummyDist) {
     n_out += nDummyDist->get();
   }
+  /*
 #ifndef QUIET
   std::cout << "Alice sends " << n_out << "; " << nPending << " pending."
 	    << std::endl;
 #endif
+  */
 }
 
 void

Index: simmain.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/simmain.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- simmain.cpp	2 May 2004 23:54:18 -0000	1.41
+++ simmain.cpp	12 Sep 2004 02:39:32 -0000	1.42
@@ -1513,6 +1513,43 @@
   trial7a_base(.9,4);
 }
 
+void trialnym_base(int nR, int pL, double pD, double pA)
+{
+  NymTrialSpec s;
+  double bgvol = 1.0/(1.0-pA);
+  s.setNRecipients(nR).setPathLen(pL).setPDelay(pD)
+    .setPartial(false).setPObserve(1.0)
+    .setPMsgAlice(pA).setBGVolMean(bgvol).setBGVolDev(bgvol/10.0);
+
+  s.setGranularity(1);
+  s.setCutoff(1000000);
+  int nBad = 0;
+  int nGood = 0;
+  for (int i = 1; i <= 100; ++i) {
+    s.write(std::cout);
+    std::cout << "\"" << i << "/" << 100 << "\"" << std::endl;
+    NymTrial trial(s);
+    TrialResult res = trial.attempt();
+    std::cout << res << std::endl << std::endl;
+    if (res.failed)
+      ++nBad;
+    else
+      ++nGood;
+    if (nBad >= 5 && nGood < nBad/2) {
+      break;
+    }
+  }
+}
+
+void trialnym_1()
+{
+  for (int n = 1024; n <= 65536; n *= 4) {
+    trialnym_base(n, 1, .1, .5);
+    trialnym_base(n, 1, .6, .5);
+    trialnym_base(n, 1, .1, .1);
+    trialnym_base(n, 1, .6, .1);
+  }
+}
 
 typedef void (*trialfunc)(void);
 
@@ -1644,6 +1681,8 @@
   { "7a.5", trial7a_5 },
   { "7a.6", trial7a_6 },
 
+  { "nym.1", trialnym_1 },
+
   { 0, 0 }
 };
 

Index: trials.cpp
===================================================================
RCS file: /home/freehaven/cvsroot/doc/e2e-traffic/src/trials.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- trials.cpp	27 Apr 2004 19:44:39 -0000	1.19
+++ trials.cpp	12 Sep 2004 02:39:32 -0000	1.20
@@ -71,7 +71,7 @@
       }
       if (!attacker->guessAlice(recips)) continue;
 #ifndef QUIET
-      std::cout << n << " " << recips << std::endl;
+      std::cout << "!!!!!!!" << n << " " << recips << std::endl;
       std::cout << n << " ------ " << std::endl;
       pvec(std::cout, truth);
       pvec(std::cout, recips.topN(truth.size()));
@@ -264,7 +264,7 @@
       }
       if (!attacker->guessAlice(recips)) continue;
 #ifndef QUIET
-      std::cout << n << " ------ " << std::endl;
+      std::cout << "########" << n << " ------ " << std::endl;
       pvec(std::cout, truth);
       pvec(std::cout, recips.topN(truth.size()));
       std::cout << n << " ------ " << std::endl;
@@ -314,6 +314,24 @@
   return new MixTrial(*this);
 }
 
+void
+NymTrialSpec::write(std::ostream &o) const {
+  o << "NymTrial(N=" << nRecipients
+    << ",pA=" << pMsgAlice
+    << ",pD=" << pDelay
+    << ",l=" << pathLen
+    << ",bgVol=" << bgVolMean
+    << ",bgDev=" << bgVolDev
+    << ",pObs=" << pObserve
+    << ")" << std::endl;
+}
+
+Trial *
+NymTrialSpec::create() const
+{
+  return new NymTrial(*this);
+}
+
 #define DELAY_SLOP 0.0001
 
 void
@@ -325,6 +343,7 @@
 	       bool knownBackground, bool pseudonyms)
 {
   assert(pathLen > 0);
+  assert(!pseudonyms);
 
   ////
   // Set up mixnet and attacker.
@@ -363,14 +382,10 @@
   InvDist<int> *aliceRecipDist = 0;
   InvDist<int> *backgroundTrafficDist = 0;
   std::vector<int> *aliceRecipients = 0;
-  if (!pseudonyms) {
-    getCommunicationLinks(aliceRecipDist, backgroundTrafficDist,
-			  aliceRecipients,
-			  nAR, nR, false, true);
-  } else {
-    getNymStats(aliceRecipDist, backgroundTrafficDist,
-		aliceRecipients, nAR, nR, false);
-  }
+  assert(!pseudonyms);
+  getCommunicationLinks(aliceRecipDist, backgroundTrafficDist,
+                        aliceRecipients,
+                        nAR, nR, false, true);
 
   //// Set up attacker and mixnet
   mixnet = new DelayMix(nR, maxDelay, delayDist);
@@ -426,3 +441,62 @@
 }
 
 // ======================================================================
+
+void
+NymTrial::init(const NymTrialSpec &s)
+{
+  // Set up mixnet and attacker
+  InvDist<int> *delayDist;
+  if (s.pathLen == 1) {
+    delayDist = getSingleMixDelays(s.pDelay);
+  } else {
+    int md;
+    if (s.pDelay < 0.00001)
+      md = s.pathLen + 1;
+    else
+      md = (int)( (std::log(DELAY_SLOP) / std::log(s.pDelay))+1)*s.pathLen;
+    delayDist = getMixNetDelays(ConstDist<int>(s.pathLen), s.pathLen+1,
+                                s.pDelay, md);
+  }
+  double totalPDelay = 0.0;
+  int maxDelay = 0;
+  while (totalPDelay < 1.0-DELAY_SLOP) {
+    totalPDelay += delayDist->getP(maxDelay++);
+  }
+
+  //// Set up alice's pseudonym and the other pseudonyms.
+  InvDist<int> *alicePseudDist = 0;
+  InvDist<int> *backgroundPseudDist = 0;
+  getNymStats(alicePseudDist, backgroundPseudDist, s.nRecipients);
+
+  //// Finish attacker and mixnet
+  mixnet = new DelayMix(s.nRecipients, maxDelay, delayDist);
+  attacker = new DelayMixAttacker(s.nRecipients, maxDelay, delayDist);
+
+  if (s.partial)
+    attacker = new POAttacker(attacker, s.pObserve);
+
+  delete delayDist;
+
+  //// Configure alize
+  GeometricDist aMsgs(1.0-s.pMsgAlice);
+  BinaryDist<int> aDummies(0.0, 0, 0);
+  truth = std::vector<int>(1, 0);
+  alice = new DistAlice(alicePseudDist, &aMsgs, &aDummies, 0, 1.0, false);
+
+  //// Configure background
+  background = new DistBackground(*backgroundPseudDist,
+                                  IntNormalDist(s.bgVolMean, s.bgVolDev, true));
+  cutoff = s.cutoff;
+
+  delete alicePseudDist;
+  delete backgroundPseudDist;
+}
+
+TrialResult
+NymTrial::attempt()
+{
+  TrialResult res = NonbatchTrial::attempt();
+  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.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- trials.h	11 Apr 2004 05:02:56 -0000	1.12
+++ trials.h	12 Sep 2004 02:39:32 -0000	1.13
@@ -299,4 +299,61 @@
   ~MixTrial() {}
 };
 
+
+// ======================================================================
+class NymTrialSpec : public TrialSpec {
+  friend class NymTrial;
+ protected:
+  int nRecipients, pathLen;
+  int granularity, cutoff;
+  double pDelay, pMsgAlice, bgVolMean, bgVolDev, pObserve;
+  bool partial;
+  bool partialSet;
+ public:
+  NymTrialSpec() {
+    nRecipients = pathLen = 0;
+    pDelay = pMsgAlice = bgVolMean = bgVolDev = 0.0;
+    granularity = 5;
+    cutoff = 10000000;
+    pObserve = 1.0;
+    partialSet = false;
+  }
+
+  NymTrialSpec &setNRecipients(int i) { nRecipients = i; return *this; }
+  NymTrialSpec &setPathLen(int i) { pathLen = i; return *this; }
+  NymTrialSpec &setCutoff(int n) { cutoff = n; return *this; }
+  NymTrialSpec &setGranularity(int n) { granularity = n; return *this; }
+
+  NymTrialSpec &setPDelay(double d) { pDelay = d; return *this; }
+  NymTrialSpec &setPMsgAlice(double d) { pMsgAlice = d; return *this; }
+  NymTrialSpec &setBGVolMean(double d) { bgVolMean = d; return *this; }
+  NymTrialSpec &setBGVolDev(double d) { bgVolDev = d; return *this; }
+  NymTrialSpec &setPObserve(double d) { pObserve = d; return *this; }
+
+  NymTrialSpec &setPartial(bool b) { partial = b; partialSet=true; return *this; }
+  void assertFilled() const {
+    assert(nRecipients > 0);
+    assert(pathLen > 0);
+    assert(pDelay > 0.0);
+    assert(pMsgAlice > 0.0);
+    assert(bgVolMean > 0.0);
+    assert(bgVolDev > 0.0);
+    assert(partialSet);
+  }
+  void write(std::ostream &o) const;
+  Trial *create() const;
+};
+
+class NymTrial : public NonbatchTrial {
+ private:
+  void init(const NymTrialSpec &s);
+ public:
+  NymTrial(const NymTrialSpec &s) : NonbatchTrial(s.nRecipients,
+                                                  s.granularity)
+    { s.assertFilled();
+      init(s); }
+  TrialResult attempt();
+  ~NymTrial() {}
+};
+
 #endif

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