예제 #1
0
        private void SetupResultBroadcast()
        {
            // we need to broadcast each result to every other quorum
            List <Protocol> resultProtocols = new List <Protocol>();

            for (int i = 0; i < PartyIds.Count; i++)
            {
                Quorum evalQuorum = GateQuorumMapping[SortNetwork.LastGateForWire[i].Gate];
                if (Result[i] == null)
                {
                    // setup a receive for this result
                    resultProtocols.Add(new MajorityFilteringProtocol <BigZp>(Me, PartyIds, evalQuorum.Members,
                                                                              ProtocolIdGenerator.ResultBroadcastIdentifier(i)));
                }
                else
                {
                    // setup a broadcast for this result
                    ISet <int> others = new SortedSet <int>(PartyIds);
                    foreach (var qid in evalQuorum.Members)
                    {
                        others.Remove(qid);
                    }

                    resultProtocols.Add(new MajorityFilteringProtocol <BigZp>(Me, PartyIds, others, Result[i],
                                                                              ProtocolIdGenerator.ResultBroadcastIdentifier(i)));
                }
            }

            ExecuteSubProtocols(resultProtocols);
        }
예제 #2
0
        private void CollectResults(IDictionary <ulong, object> rawResults)
        {
            var allResults = rawResults.ToDictionary(k => k.Key, v => (BigZp)v.Value);

            for (int i = 0; i < PartyIds.Count; i++)
            {
                if (Result[i] == null)
                {
                    Result[i] = allResults[ProtocolIdGenerator.ResultBroadcastIdentifier(i)];
                }
            }
        }