Beispiel #1
0
        public void SetupInputDistribution()
        {
            int         myPosition      = Quorum.GetPositionOf(PartyIds, Me.Id);
            GateAddress myInputGateAddr = SortNetwork.FirstGateForWire[myPosition];
            Quorum      myInputQuorum   = GateQuorumMapping[myInputGateAddr.Gate];

            Protocol sortValueDistribution = new SharingProtocol(Me, Me.Id, myInputQuorum, SortValue, Prime,
                                                                 ProtocolIdGenerator.GateInputSharingIdentifier(myInputGateAddr.Gate.TopologicalRank, 2 * myInputGateAddr.Port));

            Protocol secretDistribution = new SharingProtocol(Me, Me.Id, myInputQuorum, Secret, Prime,
                                                              ProtocolIdGenerator.GateInputSharingIdentifier(myInputGateAddr.Gate.TopologicalRank, 2 * myInputGateAddr.Port + 1));

            List <Protocol> inputProtocols = new List <Protocol>();

            inputProtocols.Add(sortValueDistribution);
            inputProtocols.Add(secretDistribution);

            InputProtocolMapping = new Dictionary <InputGateAddress, Tuple <ulong, ulong> >();

            for (int i = 0; i < PartyIds.Count; i++)
            {
                var gateAddr = SortNetwork.FirstGateForWire[i];
                foreach (Quorum q in MyQuorums)
                {
                    if (GateQuorumMapping[gateAddr.Gate] == q)
                    {
                        if (i == myPosition)
                        {
                            InputProtocolMapping[gateAddr] = new Tuple <ulong, ulong>(sortValueDistribution.ProtocolId, secretDistribution.ProtocolId);
                        }
                        else
                        {
                            ulong sortRecvId  = ProtocolIdGenerator.GateInputSharingIdentifier(gateAddr.Gate.TopologicalRank, 2 * gateAddr.Port);
                            ulong shareRecvId = ProtocolIdGenerator.GateInputSharingIdentifier(gateAddr.Gate.TopologicalRank, 2 * gateAddr.Port + 1);
                            InputProtocolMapping[gateAddr] = new Tuple <ulong, ulong>(sortRecvId, shareRecvId);
                            // I need to receive for this gate
                            inputProtocols.Add(new SharingProtocol(Me, PartyIds.ElementAt(i), q, null, Prime, sortRecvId));
                            inputProtocols.Add(new SharingProtocol(Me, PartyIds.ElementAt(i), q, null, Prime, shareRecvId));
                        }
                    }
                }
            }

            ExecuteSubProtocols(inputProtocols);
        }
Beispiel #2
0
 public MultiQuorumProtocol <Tuple <Share <BigZp>, Share <BigZp> > > GetResharingProtocol(Party me, Quorum fromQuorum, Quorum toQuorum, Tuple <Share <BigZp>, Share <BigZp> > value, int gateNumber, int portNumber)
 {
     return(new QuorumTaggedShareRenewalProtocol(me, fromQuorum, toQuorum, value, Prime, ProtocolIdGenerator.GateInputSharingIdentifier(gateNumber, portNumber * 3)));
 }