def __init__(self, name="ss", q_field=None, local_party=None, all_parties=None, use_mix_rand=False, n_length=1024): self.name_service = naming.NamingService(name) self._prev_name_service = None self._pre_instance = None self.communicator = Communicator(local_party, all_parties) self.party_idx = self.communicator.party_idx self.other_parties = self.communicator.other_parties if len(self.other_parties) > 1: raise EnvironmentError("support 2-party secret share only") self.public_key, self.private_key = PaillierKeypair.generate_keypair( n_length=n_length) if q_field is None: q_field = self.public_key.n self.q_field = self._align_q_field(q_field) self.use_mix_rand = use_mix_rand
def __init__(self, name="ss", q_field=2 << 60, local_party=None, all_parties=None): self.name_service = naming.NamingService(name) self._prev_name_service = None self._pre_instance = None self.communicator = Communicator(local_party, all_parties) self.party_idx = self.communicator.party_idx self.other_parties = self.communicator.other_parties if len(self.other_parties) > 1: raise EnvironmentError("support 2-party secret share only") self.public_key, self.private_key = PaillierKeypair.generate_keypair(1024) self.q_field = q_field
def generate_key(self, n_length=1024): self.public_key, self.privacy_key = \ PaillierKeypair.generate_keypair(n_length=n_length)
def setUp(self): self.public_key, self.private_key = PaillierKeypair.generate_keypair()
def test_generate_keypair(self): public_key, private_key = PaillierKeypair.generate_keypair() self.assertTrue(isinstance(public_key, PaillierPublicKey)) self.assertTrue(isinstance(private_key, PaillierPrivateKey)) self.assertEqual(private_key.public_key, public_key)