def _generate_triple_candidates(self, n): """Generates triple candidates for use in the BeDOZa protocol. Returns a deferred that will eventually yield a list of 3n shares of type viff.bedoza.shares.BeDOZaShare corresponding to n multiplicative tuples. The first n are the a's, then comes n b's followed by n c's. The triples are only candidates because consistency of the triples is only half-way guaranteed in the precense of active adversaries. More concretely, the triples returned by this method are guaranteed - even in the precense of an active adversary - to be of the right size. But they may not satisfy the equation c = a * b. """ self.runtime.increment_pc() gen = PartialShareGenerator(self.Zp, self.runtime, self.random, self.paillier) partial_shares = [] for _ in xrange(2 * n): partial_shares.append( gen.generate_share(self.random.randint(0, self.Zp.modulus - 1))) partial_shares_c = self._full_mul(partial_shares[0:n], partial_shares[n:2 * n]) full_shares = add_macs(self.runtime, self.Zp, self.u_bound, self.alpha, self.random, self.paillier, partial_shares + partial_shares_c) return full_shares
def _generate_triple_candidates(self, n): """Generates triple candidates for use in the BeDOZa protocol. Returns a deferred that will eventually yield a list of 3n shares of type viff.bedoza.shares.BeDOZaShare corresponding to n multiplicative tuples. The first n are the a's, then comes n b's followed by n c's. The triples are only candidates because consistency of the triples is only half-way guaranteed in the precense of active adversaries. More concretely, the triples returned by this method are guaranteed - even in the precense of an active adversary - to be of the right size. But they may not satisfy the equation c = a * b. """ self.runtime.increment_pc() gen = PartialShareGenerator(self.Zp, self.runtime, self.random, self.paillier) partial_shares = [] for _ in xrange(2 * n): partial_shares.append( gen.generate_share( self.random.randint(0, self.Zp.modulus - 1))) partial_shares_c = self._full_mul(partial_shares[0: n], partial_shares[n: 2 * n]) full_shares = add_macs(self.runtime, self.Zp, self.u_bound, self.alpha, self.random, self.paillier, partial_shares + partial_shares_c) return full_shares
def partial_share(random, runtime, Zp, val, paillier=None): if not paillier: paillier_random = Random(random.getrandbits(128)) paillier = ModifiedPaillier(runtime, paillier_random) share_random = Random(random.getrandbits(128)) gen = PartialShareGenerator(Zp, runtime, share_random, paillier) return gen.generate_share(Zp(val))