예제 #1
0
        /*
         *  prime = prime20;
         *  Main(32);
         *  NetSimulator.Reset();
         *
         *  prime = prime30;
         *  Main(32);
         *  NetSimulator.Reset();
         *
         *  prime = prime40;
         *  Main(32);
         *  NetSimulator.Reset();
         *
         *  prime = prime50;
         *  Main(32);
         *  NetSimulator.Reset();
         */

        public static void Main(int n)                                   // number of parties
        {
            Debug.Assert(NumTheoryUtils.MillerRabin(prime, 5) == false); // must be a prime

            // Create an MPC network, add parties, and init them with random inputs
            NetSimulator.Init(seed);     //seed
            StaticRandom.Init(seed + 1); //seed + 1

            Quorum q = new Quorum(0, 0, n);

            SetupMps(n);

            //SetupMultiQuorumCircuitEvaluation(q);

            Console.WriteLine(n + " parties initialized. Running simulation...\n");
            // run the simulator
            var elapsedTime = Timex.Run(() => NetSimulator.Run());

            // CheckMps(n);
            //ReconstructDictionary(q, network.LastGateForWire, 4);

            Console.WriteLine("Simulation finished.  Checking results...\n");

            Console.WriteLine("# parties    = " + n);
            Console.WriteLine("# msgs sent  = " + NetSimulator.SentMessageCount.ToString("0.##E+00"));
            Console.WriteLine("# bits sent  = " + (NetSimulator.SentByteCount * 8).ToString("0.##E+00"));
            Console.WriteLine("Rounds       = " + NetSimulator.RoundCount + "\n");
            Console.WriteLine("Key size     = " + NumTheoryUtils.GetBitLength2(prime) + " bits");
            Console.WriteLine("Seed         = " + seed + "\n");
            Console.WriteLine("Elapsed time = " + elapsedTime.ToString("hh':'mm':'ss'.'fff") + "\n");
        }
예제 #2
0
        public RandomBitwiseGenProtocol(Party me, Quorum quorum, BigInteger prime, BigInteger max)
            : base(me, quorum)
        {
            Max   = max;
            Prime = prime;

            BitsNeeded = NumTheoryUtils.GetBitLength2(Max);
            if (Max.IsPowerOfTwo)
            {
                BitsNeeded--;
            }

            Result = new List <Share <BigZp> >();
        }