protected void ShareSecret(Zp secret, IList <int> players, DkmsKey key) { var shares = ShamirSharing.Share(secret, players.Count, players.Count - 1); var shareMsgs = new List <ShareMsg <Zp> >(); foreach (var share in shares) { shareMsgs.Add(new ShareMsg <Zp>(new Share <Zp>(share), key)); } Send(players, shareMsgs); }
public override void Run() { Debug.Assert(quorumsMap != null); Debug.Assert(Circuit.InputGates.Count == NumParties * NumSlots); // TODO: input must be encrypted with a random number and the random must be secret shared. // share my input in a random input gate (random slot) and share zero in others var randomSlot = StaticRandom.Next(0, NumSlots); for (int s = 0; s < NumSlots; s++) { // TODO: IMPORTANT: EntityId's are assumed to be continous integers with option base 0. Not other parts of the code have this assumption. var gate = Circuit.InputGates[Party.Id * NumSlots + s]; var quorum = quorumsMap[gate.QuorumIndex]; // in the byzantine case, we have to secret share the input among 'quorum' members but // here in the HBC case, we send the masked input to only one member of 'quorum' and randoms to other players. // These randoms form a global random, which is added to the input to mask it. Zp toSend; if (s == randomSlot) { toSend = Input; } else { toSend = new Zp(Prime); // send a zero } int mask = 0; var minPlayer = quorum.Min(); var stateKey = new DkmsKey(Stage.Input, gate.Id); foreach (var player in quorum) { if (player != minPlayer) { var rand = StaticRandom.Next(0, Prime); mask += rand; Send(Party.Id, player, new InputMsg(new Zp(Prime, rand), stateKey)); } } Send(Party.Id, minPlayer, new InputMsg(Input + mask, stateKey)); } }
public ShareMsg(Share <T> share, DkmsKey key) : base(key) { Share = share; }
public DkmsMsg(DkmsKey key) { StateKey = key; }
public override void Run() { Debug.Assert(quorumsMap != null); Debug.Assert(Circuit.InputGates.Count == NumParties * NumSlots); // TODO: input must be encrypted with a random number and the random must be secret shared. // share my input in a random input gate (random slot) and share zero in others var randomSlot = StaticRandom.Next(0, NumSlots); for (int s = 0; s < NumSlots; s++) { // TODO: IMPORTANT: EntityId's are assumed to be continous integers with option base 0. Not other parts of the code have this assumption. var gate = Circuit.InputGates[Party.Id * NumSlots + s]; var quorum = quorumsMap[gate.QuorumIndex]; // in the byzantine case, we have to secret share the input among 'quorum' members but // here in the HBC case, we send the masked input to only one member of 'quorum' and randoms to other players. // These randoms form a global random, which is added to the input to mask it. Zp toSend; if (s == randomSlot) toSend = Input; else toSend = new Zp(Prime); // send a zero int mask = 0; var minPlayer = quorum.Min(); var stateKey = new DkmsKey(Stage.Input, gate.Id); foreach (var player in quorum) { if (player != minPlayer) { var rand = StaticRandom.Next(0, Prime); mask += rand; Send(Party.Id, player, new InputMsg(new Zp(Prime, rand), stateKey)); } } Send(Party.Id, minPlayer, new InputMsg(Input + mask, stateKey)); } }
protected void ShareSecret(Zp secret, IList<int> players, DkmsKey key) { var shares = ShamirSharing.Share(secret, players.Count, players.Count - 1); var shareMsgs = new List<ShareMsg<Zp>>(); foreach (var share in shares) shareMsgs.Add(new ShareMsg<Zp>(new Share<Zp>(share), key)); Send(players, shareMsgs); }
public InputMsg(Zp data, DkmsKey key) : base(key) { Data = data; }