예제 #1
0
 def broadcast_reconstruct_share(self, tensor_name=None):
     from federatedml.secureprotol.spdz import SPDZ
     spdz = SPDZ.get_instance()
     share_val = self.value.copy()
     name = tensor_name or self.tensor_name
     if name is None:
         raise ValueError("name not specified")
     # remote share to other parties
     spdz.communicator.broadcast_rescontruct_share(share_val, name)
     return share_val
예제 #2
0
    def rescontruct(self, tensor_name=None):
        from federatedml.secureprotol.spdz import SPDZ
        spdz = SPDZ.get_instance()
        share_val = self.value
        name = tensor_name or self.tensor_name

        if name is None:
            raise ValueError("name not specified")

        # remote share to other parties
        spdz.communicator.broadcast_rescontruct_share(share_val, name)

        # get shares from other parties
        for other_share in spdz.communicator.get_rescontruct_shares(name):
            share_val = _table_binary_op(share_val, other_share, self.q_field, operator.add)
        return share_val
예제 #3
0
    def reconstruct(self, tensor_name=None, broadcast=True):
        from federatedml.secureprotol.spdz import SPDZ
        spdz = SPDZ.get_instance()
        share_val = self.value.copy()
        LOGGER.debug(f"share_val: {share_val}")

        name = tensor_name or self.tensor_name

        if name is None:
            raise ValueError("name not specified")

        # remote share to other parties
        if broadcast:
            spdz.communicator.broadcast_rescontruct_share(share_val, name)

        # get shares from other parties
        for other_share in spdz.communicator.get_rescontruct_shares(name):
            # LOGGER.debug(f"share_val: {share_val}, other_share: {other_share}")
            share_val += other_share
            try:
                share_val %= self.q_field
                return share_val
            except BaseException:
                return share_val
예제 #4
0
 def get_spdz(cls):
     from federatedml.secureprotol.spdz import SPDZ
     return SPDZ.get_instance()