Exemplo n.º 1
0
        public static void SetupBitwiseAndProtocol(Quorum quorum)
        {
            int n = quorum.Size;

            var polyDeg = (int)Math.Ceiling(n / 3.0) - 1;

            var sharesA = BigShamirSharing.Share(new BigZp(prime, 0), n, polyDeg);
            var sharesB = BigShamirSharing.Share(new BigZp(prime, 1), n, polyDeg);
            var sharesC = BigShamirSharing.Share(new BigZp(prime, 0), n, polyDeg);

            var sharesD = BigShamirSharing.Share(new BigZp(prime, 0), n, polyDeg);
            var sharesE = BigShamirSharing.Share(new BigZp(prime, 1), n, polyDeg);
            var sharesF = BigShamirSharing.Share(new BigZp(prime, 1), n, polyDeg);


            for (int i = 0; i < n; i++)
            {
                Quorum q = quorum.Clone() as Quorum;
                TestParty <List <Share <BigZp> > > party = new TestParty <List <Share <BigZp> > >();
                party.UnderTest = new BitwiseOperationProtocol(party, q,
                                                               MakeList(sharesA[i], sharesB[i], sharesC[i]),
                                                               MakeList(sharesD[i], sharesE[i], sharesF[i]),
                                                               new SharedBitAnd.ProtocolFactory(party, q));
                NetSimulator.RegisterParty(party);
            }
        }
Exemplo n.º 2
0
        public static void SetupRandomBitGenProtocol(Quorum quorum)
        {
            int n = quorum.Size;

            for (int i = 0; i < n; i++)
            {
                TestParty <Share <BigZp> > party = new TestParty <Share <BigZp> >();
                party.UnderTest = new RandomBitGenProtocol(party, quorum.Clone() as Quorum, prime);
                NetSimulator.RegisterParty(party);
            }
        }
Exemplo n.º 3
0
        public static void SetupCompareAndSwap(Quorum quorum)
        {
            int n       = quorum.Size;
            var polyDeg = (int)Math.Ceiling(n / 3.0) - 1;

            var sharesA = BigShamirSharing.Share(new BigZp(prime, 440), n, polyDeg);
            var sharesB = BigShamirSharing.Share(new BigZp(prime, 450), n, polyDeg);

            for (int i = 0; i < n; i++)
            {
                TestParty <Share <BigZp>[]> party = new TestParty <Share <BigZp>[]>();
                party.UnderTest = new CompareAndSwapProtocol(party, quorum.Clone() as Quorum, new Share <BigZp>(sharesA[i]), new Share <BigZp>(sharesB[i]));
                NetSimulator.RegisterParty(party);
            }
        }