public bool equals(
            Object other)
        {
            if (other is BarnettSmartVTMF_dlog)
            {
                BarnettSmartVTMF_dlog typed_other = (BarnettSmartVTMF_dlog)other;
                if (x_i != typed_other.x_i)
                {
                    return(false);
                }
                if (h_i != typed_other.h_i)
                {
                    return(false);
                }
                if (d != typed_other.d)
                {
                    return(false);
                }
                if (h_i_fp != typed_other.h_i_fp)
                {
                    return(false);
                }
                if (h_j != typed_other.h_j)
                {
                    return(false);
                }
                if (F_size != typed_other.F_size)
                {
                    return(false);
                }
                if (G_size != typed_other.G_size)
                {
                    return(false);
                }
                if (p != typed_other.p)
                {
                    return(false);
                }

                if (q != typed_other.q)
                {
                    return(false);
                }

                if (g != typed_other.g)
                {
                    return(false);
                }

                if (k != typed_other.k)
                {
                    return(false);
                }
                if (h != typed_other.h)
                {
                    return(false);
                }
            }
            return(false);
        }
Esempio n. 2
0
        // private final IChannel d_channal;

        public PokerPlayer(
            int player_id,
            IChannel[] player_channals,
            BarnettSmartVTMF_dlog vmtf)
        {
            d_player_id       = player_id;
            d_player_channals = player_channals;
            d_vmtf            = vmtf;
        }
Esempio n. 3
0
        public void MentalPokerTest()
        {
            // create and check VTMF instance
            System.Diagnostics.Debug.WriteLine("BarnettSmartVTMF_dlog()");
            BarnettSmartVTMF_dlog vtmf = new BarnettSmartVTMF_dlog();

            System.Diagnostics.Debug.WriteLine("vtmf.CheckGroup()");

            Assert.IsTrue(vtmf.CheckGroup());             // TODO random fail??

            // publish VTMF instance as string stream
            System.Diagnostics.Debug.WriteLine("vtmf.PublishGroup(vtmf_str)");
            //vtmf.PublishGroup(d_channal);
            int player_count = PokerPlayer.PLAYER_COUNT;

            // open channel
            IChannel [][] channals = new IChannel[player_count][];
            for (int index_player = 0; index_player < PokerPlayer.PLAYER_COUNT; index_player++)
            {
                channals[index_player] = new IChannel[player_count];
            }

            for (int index_send = 0; index_send < PokerPlayer.PLAYER_COUNT; index_send++)
            {
                for (int index_recieve = index_send + 1; index_recieve < PokerPlayer.PLAYER_COUNT; index_recieve++)
                {
                    ChannelTwoWayBigInteger channel = new ChannelTwoWayBigInteger();
                    channals[index_send][index_recieve] = channel.Channel0;
                    channals[index_recieve][index_send] = channel.Channel1;
                }
            }
            System.Diagnostics.Debug.WriteLine("starting " + PokerPlayer.PLAYER_COUNT + " players");
            // start poker childs

            Thread [] player_treads = new Thread [PokerPlayer.PLAYER_COUNT];
            for (int i = 0; i < PokerPlayer.PLAYER_COUNT; i++)
            {
                PokerPlayer poker_player = new PokerPlayer(i, channals[i], new BarnettSmartVTMF_dlog(vtmf));
                player_treads[i] = new Thread(poker_player.Run);
                player_treads[i].Start();
            }

            for (int i = 0; i < PokerPlayer.PLAYER_COUNT; i++)
            {
                player_treads[i].Join();
            }
        }
        public BarnettSmartVTMF_dlog(
            BarnettSmartVTMF_dlog other)
        {
            x_i    = other.x_i;
            h_i    = other.h_i;
            d      = other.d;
            h_i_fp = other.h_i_fp;
            h_j    = new Dictionary <String, BigInteger>(other.h_j);

            F_size = other.F_size;
            G_size = other.G_size;

            p = other.p;
            q = other.q;
            g = other.g;
            k = other.k;
            h = other.h;
        }
Esempio n. 5
0
        public void Run()
        {
            // create TMCG and VTMF instances
            BarnettSmartVTMF_dlog vtmf = d_vmtf;

            if (!vtmf.CheckGroup())
            {
                throw new Exception("P_" + d_player_id + ": Group G was not correctly generated!");
            }
            System.Diagnostics.Debug.WriteLine("P_" + d_player_id + " done generating keys");

            // create and exchange VTMF keys
            vtmf.KeyGenerationProtocol_GenerateKey();
            for (int i = 0; i < PLAYER_COUNT; i++)
            {
                if (i != d_player_id)
                {
                    vtmf.KeyGenerationProtocol_PublishKey(d_player_channals[i]);
                }
            }
            for (int i = 0; i < PLAYER_COUNT; i++)
            {
                if (i != d_player_id)
                {
                    if (!vtmf.KeyGenerationProtocol_UpdateKey(d_player_channals[i]))
                    {
                        throw new Exception("P_" + d_player_id + ": Public key of P_" + i + " was not correctly generated!");
                    }
                }
            }
            //vtmf.KeyGenerationProtocol_Finalize();
            System.Diagnostics.Debug.WriteLine("P_" + d_player_id + " done create and exchange VTMF keys");

            // VSSHE
            GrothVSSHE vsshe;

            if (d_player_id == 0)
            {
                // create and publish VSSHE instance as leader
                vsshe = new GrothVSSHE(DECKSIZE, vtmf.p, vtmf.q, vtmf.k, vtmf.g, vtmf.h);
                System.Diagnostics.Debug.WriteLine("P_" + d_player_id + " done GrothVSSHE");
                if (!vsshe.CheckGroup())
                {
                    throw new Exception("P_" + d_player_id + ": VSSHE instance was not correctly generated!");
                }
                System.Diagnostics.Debug.WriteLine("P_" + d_player_id + " done CheckGroup");
                for (int i = 1; i < PLAYER_COUNT; i++)
                {
                    vsshe.PublishGroup(d_player_channals[i]); // TODO not also publish to self!
                }

                System.Diagnostics.Debug.WriteLine("P_" + d_player_id + " done VSSHE");
            }
            else
            {
                // receive and create VSSHE instance as non-leader
                vsshe = new GrothVSSHE(DECKSIZE, d_player_channals[0]);
                System.Diagnostics.Debug.WriteLine("P_" + d_player_id + " done GrothVSSHE");
                if (!vsshe.CheckGroup())
                {
                    throw new Exception("P_" + d_player_id + ": VSSHE instance was not correctly generated!");
                }
                if (vtmf.h != vsshe.com.h)
                {
                    throw new Exception("P_" + d_player_id + ": VSSHE: Common public key does not match! " + vtmf.h.BitLength() + " " + vsshe.com.h.BitLength());
                }
                if (vtmf.q != vsshe.com.q)
                {
                    throw new Exception("P_" + d_player_id + ": VSSHE: VSSHE: Subgroup order does not match!");
                }
                if (vtmf.p != vsshe.p || vtmf.q != vsshe.q || vtmf.g != vsshe.g || vtmf.h != vsshe.h)
                {
                    throw new Exception("P_" + d_player_id + ": VSSHE: Encryption scheme does not match!");
                }

                System.Diagnostics.Debug.WriteLine("P_" + d_player_id + " done VSSHE");
            }
        }