Represents an abstract message sent/received to/from network parties.
Наследование: ISizable
Пример #1
0
 //public override int SenderId
 //{
 //    set
 //    {
 //        base.SenderId = value;
 //        if (InnerMessage != null)
 //            InnerMessage.SenderId = (ToGateId << 16) + value;		// TODO: HWSMPC VIRTUAL ADDRESS
 //    }
 //}
 public MpcMsg(int toGateId, int anchorId, Msg innerMessage)
     : base(new MpcKey(toGateId, anchorId))
 {
     ToGateId = toGateId;
     AnchorId = anchorId;
     InnerMessage = innerMessage;
 }
Пример #2
0
 public override void HandleMessage(int fromId, Msg msg)
 {
     NopCount--;
     if (NopCount <= 0)
         IsCompleted = true;
     else
         Send(Me.Id, new Msg(MsgType.NextRound));
 }
Пример #3
0
        public override void HandleMessage(int fromId, Msg msg)
        {
            if (msg is SubProtocolCompletedMsg)
            {
                // my subprotocols completed. broadcast that information
                Multicast(new Msg(MsgType.NextRound), PartyIds);
                RawResult = msg;
            } else
            {
                Debug.Assert(msg.Type == MsgType.NextRound);

                PeersCompleted.Add(fromId);
                if (PeersCompleted.Count == PartyIds.Count)
                    IsCompleted = true;
            }
        }
Пример #4
0
 public override void HandleMessage(int fromId, Msg msg)
 {
 }
Пример #5
0
 public void Send(int toId, Msg msg, int delay = 0)
 {
     Me.Send(this, toId, msg, delay);
 }
Пример #6
0
 public void Multicast(Msg msg, IEnumerable<int> toIds, int delay = 0)
 {
     Me.Multicast(this, msg, toIds, delay);
 }
Пример #7
0
 public abstract void HandleMessage(int fromId, Msg msg);
Пример #8
0
 public void Broadcast(Msg msg, int delay = 0)
 {
     Me.Broadcast(this, msg, delay);
 }
Пример #9
0
 public static void Loopback(int id, ulong protocolId, Msg msg)
 {
     des.Loopback(id, parties[id].Receive, id, protocolId, msg);
 }
Пример #10
0
 public void Broadcast(Protocol protocol, Msg msg, int delay = 0)
 {
     NetSimulator.Broadcast(Id, protocol.ProtocolId, msg, delay);
 }
Пример #11
0
 public void Send(Protocol protocol, int toId, Msg msg, int delay = 0)
 {
     NetSimulator.Send(Id, toId, protocol.ProtocolId, msg, delay);
 }
Пример #12
0
        public virtual void Receive(int fromId, ulong protocolId, Msg msg)
        {
            // Console.WriteLine("Receive msg " + Id + " " + protocolId);
            Debug.Assert(RegisteredProtocols.ContainsKey(protocolId));

            Protocol protocol = RegisteredProtocols[protocolId];
            protocol.HandleMessage(fromId, msg);
            CheckCompleted(protocol);
        }
Пример #13
0
 public static void Broadcast(int fromId, ulong protocolId, Msg msg, int delay = 0)
 {
     Multicast(fromId, protocolId, PartyIds, msg, delay);
 }
Пример #14
0
        public static void Send(int fromId, int toId, ulong protocolId, Msg msg, int delay = 0)
        {
            //  Console.WriteLine("Adding send from " + fromId + " at " + des.Clock);

            SentMessageCount++;
            SentByteCount += msg.Size;
            des.Schedule(toId, parties[toId].Receive, delay + 1, fromId, protocolId, msg);

            if (MessageSent != null)
                MessageSent(fromId, toId, msg.Size);
        }
Пример #15
0
        public static void Multicast(int fromId, ulong protocolId, IEnumerable<int> toIds, Msg msg, int delay = 0)
        {
            // Console.WriteLine("Adding multicast from " + fromId + " at " + des.Clock);
            foreach (var toId in toIds)
            {
                des.Schedule(toId, parties[toId].Receive, delay + 1, fromId, protocolId, msg);

                if (MessageSent != null)
                    MessageSent(fromId, toId, msg.Size);
            }

            // Add actual number of message sent in the reliable broadcast protocol based on CKS '2000
            // The party first sends msg to every other party and then parties run the Byzantine agreement
            // protocol of CKS '2000 to ensure consistency.
            // CKS sends a total of 4*n^2 messages so the total number of messages sent is n + 4n^2.
            // Note: we do not add the term n here as we have already sent the message to each party (see above).
            // See OKS'10 for CKS'00 simulation results
            var nSquared = (int)Math.Pow(toIds.Count(), 2);
            SentMessageCount += 4 * nSquared;

            // For 80 bit security (i.e., RSA 1024), CKS sends 4*n^2 messages, where each message is of at most
            // two RSA signatures (i.e., 2048 bit messages). So, the total number of bits sent is 8192*n^2 (or 1024*n^2 bytes).
            SentByteCount += 1024 * nSquared;
        }
Пример #16
0
        protected void OnMpcSend(int fromId, int toId, Msg msg/*, StateKey stateKey*/)
        {
            // wrap the smpc message in a scalable smpc message
            //var key = stateKey as MpcKey;			// TODO: Can we make SendHandler generic in order to avoid these costy castings?
            // MAHDI 11/4/2013: Extract the key from msg.

            var origFromId = fromId & 65535;
            var fromGateId = fromId >> 16;

            var origToId = toId & 65535;
            var toGateId = toId >> 16;

            msg.SenderId = fromId;		// put virtual id in the embedded message
            //var wrappedMsg = new MpcMsg(toGateId, key.AnchorId, msg);
            //Send(origFromId, origToId, wrappedMsg);
        }
Пример #17
0
 public void Multicast(Protocol protocol, Msg msg, IEnumerable<int> toIds, int delay = 0)
 {
     NetSimulator.Multicast(Id, protocol.ProtocolId, toIds, msg, delay);
 }