Наследование: StateKey
Пример #1
0
        protected void ShareSecret(Zp secret, IList <int> players, DkmsKey key)
        {
            var shares = ShamirSharing.Share(secret, players.Count, players.Count - 1);

            var shareMsgs = new List <ShareMsg <Zp> >();

            foreach (var share in shares)
            {
                shareMsgs.Add(new ShareMsg <Zp>(new Share <Zp>(share), key));
            }

            Send(players, shareMsgs);
        }
Пример #2
0
        public override void Run()
        {
            Debug.Assert(quorumsMap != null);
            Debug.Assert(Circuit.InputGates.Count == NumParties * NumSlots);

            // TODO: input must be encrypted with a random number and the random must be secret shared.
            // share my input in a random input gate (random slot) and share zero in others
            var randomSlot = StaticRandom.Next(0, NumSlots);

            for (int s = 0; s < NumSlots; s++)
            {
                // TODO: IMPORTANT: EntityId's are assumed to be continous integers with option base 0. Not other parts of the code have this assumption.
                var gate   = Circuit.InputGates[Party.Id * NumSlots + s];
                var quorum = quorumsMap[gate.QuorumIndex];

                // in the byzantine case, we have to secret share the input among 'quorum' members but
                // here in the HBC case, we send the masked input to only one member of 'quorum' and randoms to other players.
                // These randoms form a global random, which is added to the input to mask it.
                Zp toSend;
                if (s == randomSlot)
                {
                    toSend = Input;
                }
                else
                {
                    toSend = new Zp(Prime);                             // send a zero
                }
                int mask      = 0;
                var minPlayer = quorum.Min();
                var stateKey  = new DkmsKey(Stage.Input, gate.Id);

                foreach (var player in quorum)
                {
                    if (player != minPlayer)
                    {
                        var rand = StaticRandom.Next(0, Prime);
                        mask += rand;
                        Send(Party.Id, player, new InputMsg(new Zp(Prime, rand), stateKey));
                    }
                }
                Send(Party.Id, minPlayer, new InputMsg(Input + mask, stateKey));
            }
        }
Пример #3
0
 public ShareMsg(Share <T> share, DkmsKey key)
     : base(key)
 {
     Share = share;
 }
Пример #4
0
 public DkmsMsg(DkmsKey key)
 {
     StateKey = key;
 }
Пример #5
0
        public override void Run()
        {
            Debug.Assert(quorumsMap != null);
            Debug.Assert(Circuit.InputGates.Count == NumParties * NumSlots);

            // TODO: input must be encrypted with a random number and the random must be secret shared.
            // share my input in a random input gate (random slot) and share zero in others
            var randomSlot = StaticRandom.Next(0, NumSlots);

            for (int s = 0; s < NumSlots; s++)
            {
                // TODO: IMPORTANT: EntityId's are assumed to be continous integers with option base 0. Not other parts of the code have this assumption.
                var gate = Circuit.InputGates[Party.Id * NumSlots + s];
                var quorum = quorumsMap[gate.QuorumIndex];

                // in the byzantine case, we have to secret share the input among 'quorum' members but
                // here in the HBC case, we send the masked input to only one member of 'quorum' and randoms to other players.
                // These randoms form a global random, which is added to the input to mask it.
                Zp toSend;
                if (s == randomSlot)
                    toSend = Input;
                else
                    toSend = new Zp(Prime);		// send a zero

                int mask = 0;
                var minPlayer = quorum.Min();
                var stateKey = new DkmsKey(Stage.Input, gate.Id);

                foreach (var player in quorum)
                {
                    if (player != minPlayer)
                    {
                        var rand = StaticRandom.Next(0, Prime);
                        mask += rand;
                        Send(Party.Id, player, new InputMsg(new Zp(Prime, rand), stateKey));
                    }
                }
                Send(Party.Id, minPlayer, new InputMsg(Input + mask, stateKey));
            }
        }
Пример #6
0
        protected void ShareSecret(Zp secret, IList<int> players, DkmsKey key)
        {
            var shares = ShamirSharing.Share(secret, players.Count, players.Count - 1);

            var shareMsgs = new List<ShareMsg<Zp>>();
            foreach (var share in shares)
                shareMsgs.Add(new ShareMsg<Zp>(new Share<Zp>(share), key));

            Send(players, shareMsgs);
        }
Пример #7
0
 public DkmsMsg(DkmsKey key)
 {
     StateKey = key;
 }
Пример #8
0
 public InputMsg(Zp data, DkmsKey key)
     : base(key)
 {
     Data = data;
 }
Пример #9
0
 public InputMsg(Zp data, DkmsKey key)
     : base(key)
 {
     Data = data;
 }