public SharedBitAnd(Party me, Quorum quorum, Share <BigZp> bitA, Share <BigZp> bitB) : base(me, quorum) { BitA = bitA; BitB = bitB; }
public override void HandleMessage(int fromId, Msg msg) { Debug.Assert(msg is SubProtocolCompletedMsg); var completedMsg = msg as SubProtocolCompletedMsg; switch (Stage) { case 0: ShareAMinusB = (Share <BigZp>)completedMsg.SingleResult; ExecuteSubProtocols(new Protocol[] { new LessThanHalfPrime(Me, Quorum, ShareA), new LessThanHalfPrime(Me, Quorum, ShareB), new LessThanHalfPrime(Me, Quorum, ShareAMinusB) }); break; case 1: W = (Share <BigZp>)completedMsg.ResultList[0]; X = (Share <BigZp>)completedMsg.ResultList[1]; Y = (Share <BigZp>)completedMsg.ResultList[2]; ExecuteSubProtocols(new Protocol[] { new ShareMultiplicationProtocol(Me, Quorum, X, Y), new ShareAdditionProtocol(Me, Quorum, X, Y), }); break; case 2: XY = (Share <BigZp>)completedMsg.ResultList[0]; XpY = (Share <BigZp>)completedMsg.ResultList[1]; ExecuteSubProtocol(new ShareMultiplicationProtocol(Me, Quorum, BigZpShareFactory.CreateConstantShare(Prime, 2), XY)); break; case 3: ExecuteSubProtocol(new ShareAdditionProtocol(Me, Quorum, XpY, BigZpShareFactory.ShareAdditiveInverse((Share <BigZp>)completedMsg.SingleResult))); break; case 4: ExecuteSubProtocol(new ShareMultiplicationProtocol(Me, Quorum, W, (Share <BigZp>)completedMsg.SingleResult)); break; case 5: ExecuteSubProtocol(new ShareAdditionProtocol(Me, Quorum, XY, (Share <BigZp>)completedMsg.SingleResult)); break; case 6: ExecuteSubProtocol(new ShareAdditionProtocol(Me, Quorum, BigZpShareFactory.ShareAdditiveInverse(XpY), (Share <BigZp>)completedMsg.SingleResult)); break; case 7: ExecuteSubProtocol(new ShareAdditionProtocol(Me, Quorum, BigZpShareFactory.CreateConstantShare(Prime, 1), (Share <BigZp>)completedMsg.SingleResult)); break; case 8: Result = (Share <BigZp>)completedMsg.SingleResult; IsCompleted = true; break; } Stage++; }
public Protocol <Share <BigZp> > GetBitProtocol(Share <BigZp> bitShareA, Share <BigZp> bitShareB) { return(new SharedBitAnd(Me, Quorum, bitShareA, bitShareB)); }
public ConditionalSwapProtocol(Party me, Quorum quorum, Share <BigZp> shareA, Share <BigZp> shareB, Share <BigZp> swapBit) : base(me, quorum) { Debug.Assert(shareA.Value.Prime == shareB.Value.Prime); ShareA = shareA; ShareB = shareB; SwapBit = swapBit; Prime = ShareA.Value.Prime; }
public LessThanHalfPrime(Party me, Quorum Quorum, Share <BigZp> share) : base(me, Quorum) { Share = share; }
public ShareAdditionProtocol(Party me, Quorum quorum, Share <BigZp> share1, Share <BigZp> share2) : base(me, quorum) { Result = new Share <BigZp>(share1.Value + share2.Value, share1.IsPublic && share2.IsPublic); IsCompleted = true; }
public static Share <BigZp> ShareAdditiveInverse(Share <BigZp> orig) { return(new Share <BigZp>(orig.Value.AdditiveInverse, orig.IsPublic)); }
public ShareMultiplicationProtocol(Party me, Quorum quorum, Share <BigZp> share1, Share <BigZp> share2) : base(me, quorum) { Debug.Assert(share1.Value.Prime == share2.Value.Prime); Prime = share1.Value.Prime; Share1 = share1; Share2 = share2; }
public Protocol <Share <BigZp> > GetBitProtocol(Share <BigZp> bitShareA, Share <BigZp> bitShareB) { return(new ShareMultiplicationProtocol(Me, Quorum, bitShareA, bitShareB)); }
public LeastSignificantBitProtocol(Party me, Quorum quorum, Share <BigZp> share) : base(me, quorum) { Share = share; Prime = Share.Value.Prime; }