public static void ReconstructDictionary(Quorum q, OutputGateAddress[] ordering, int qSize) { List <BigZp> result = new List <BigZp>(); foreach (OutputGateAddress outAddr in ordering) { if (outAddr == null) { continue; } BigZp[] shares = new BigZp[qSize]; int j = 0; foreach (var id in q.Members) { Protocol <IDictionary <OutputGateAddress, Share <BigZp> > > p = (NetSimulator.GetParty(id) as TestParty <IDictionary <OutputGateAddress, Share <BigZp> > >).UnderTest; if (p.Result.ContainsKey(outAddr)) { shares[j++] = p.Result[outAddr].Value; } } result.Add(BigShamirSharing.Recombine(new List <BigZp>(shares), (int)Math.Ceiling(qSize / 3.0) - 1, prime)); } Console.WriteLine("Result: " + string.Join(" ", result)); }
public static void CheckMps(int n) { for (int i = 0; i < n; i++) { MpsParty party = (MpsParty)NetSimulator.GetParty(i); Console.WriteLine("Party " + i + ": " + string.Join(" ", party.Results)); } }
public static void Reconstruct(Quorum q) { BigZp[] shares = new BigZp[q.Size]; int i = 0; foreach (var id in q.Members) { shares[i++] = (NetSimulator.GetParty(id) as TestParty <Share <BigZp> >).UnderTest.Result.Value; } var val = BigShamirSharing.Recombine(new List <BigZp>(shares), (int)Math.Ceiling(q.Size / 3.0) - 1, prime); Console.WriteLine("Output: " + val); }
public static void ReconstructTuple(Quorum q) { BigZp[] shares1 = new BigZp[q.Size]; BigZp[] shares2 = new BigZp[q.Size]; int i = 0; foreach (var id in q.Members) { var result = (NetSimulator.GetParty(id) as TestParty <Tuple <Share <BigZp>, Share <BigZp> > >).UnderTest.Result; shares1[i] = result.Item1.Value; shares2[i] = result.Item2.Value; i++; } var val1 = BigShamirSharing.Recombine(new List <BigZp>(shares1), (int)Math.Ceiling(q.Size / 3.0) - 1, prime); var val2 = BigShamirSharing.Recombine(new List <BigZp>(shares2), (int)Math.Ceiling(q.Size / 3.0) - 1, prime); Console.WriteLine(val1 + " " + val2); }
public static void ReconstructBitwise(Quorum q, int bitCount) { List <BigZp> result = new List <BigZp>(); for (int i = bitCount - 1; i >= 0; i--) { BigZp[] shares = new BigZp[q.Size]; int j = 0; foreach (var id in q.Members) { shares[j++] = (NetSimulator.GetParty(id) as TestParty <List <Share <BigZp> > >).UnderTest.Result[i].Value; } result.Add(BigShamirSharing.Recombine(new List <BigZp>(shares), (int)Math.Ceiling(q.Size / 3.0) - 1, prime)); } foreach (var bit in result) { Console.Write(bit); } Console.WriteLine(); }