示例#1
0
文件: spdz.py 项目: yubo1993/FATE
    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
示例#2
0
    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
示例#3
0
 def generate_key(self, n_length=1024):
     self.public_key, self.privacy_key = \
         PaillierKeypair.generate_keypair(n_length=n_length)
示例#4
0
 def setUp(self):
     self.public_key, self.private_key = PaillierKeypair.generate_keypair()
示例#5
0
 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)