public override void HandleMessage(int fromId, Msg msg) { Debug.Assert(msg.Type == MsgType.SubProtocolCompleted); var completedMsg = (SubProtocolCompletedMsg)msg; switch (Stage) { case 0: // reconstruct the rand we just created ExecuteSubProtocol(new ReconstructionProtocol(Me, RandGenQuorum, (Share <BigZp>)completedMsg.SingleResult)); break; case 1: ProtocolRandom = (BigZp)completedMsg.SingleResult; ExecuteSubProtocol(new MajorityFilteringProtocol <BigZp>(Me, PartyIds, PartyIds.Skip(TRUSTED_PARTY_COUNT).ToArray(), ProtocolRandom, ProtocolIdGenerator.GenericIdentifier(1))); break; case 2: if (!RandGenQuorum.HasMember(Me.Id)) { ProtocolRandom = (BigZp)completedMsg.SingleResult; } GenerateQuorums(); GenerateGateQuorumAssignment(); SetupInputDistribution(); break; case 3: UnpackCircuitInputs(completedMsg.Result); SetupQuorumExecutions(); break; case 4: UnpackCircuitResults((completedMsg.SingleResult as SubProtocolCompletedMsg).Result); SetupReconstruction(); break; case 5: UnpackReconstruction(completedMsg.Result); SetupResultBroadcast(); break; case 6: CollectResults(completedMsg.Result); IsCompleted = true; break; } Stage++; }
private static SortedSet <int> QuorumPlusParty(Quorum q, int p) { if (q.HasMember(p)) { return(q.Members); } var newSet = new SortedSet <int>(q.Members); newSet.Add(p); return(newSet); }
public override void Start() { if (Me.Id == SrcParty) { Debug.Assert(Secret != null); Share(Secret); } if (!DstQuorum.HasMember(Me.Id)) { IsCompleted = true; Result = null; } }
public void SetupRandGenStep() { Debug.Assert(PartyIds.Count > TRUSTED_PARTY_COUNT); RandGenQuorum = new Quorum(NextQuorumNumber++, PartyIds.Take(5).ToArray()); if (RandGenQuorum.HasMember(Me.Id)) { BigZp myRandom = new BigZp(Prime, Me.SafeRandGen.Next(Prime)); ExecuteSubProtocol(new RandomGenProtocol(Me, RandGenQuorum, myRandom, Prime)); } else { // receive the rand broadcast ExecuteSubProtocol(new MajorityFilteringProtocol <BigZp>(Me, PartyIds, RandGenQuorum.Members.ToList(), ProtocolIdGenerator.GenericIdentifier(1))); Stage = 2; } }