def dot(self, other: 'FixedPointTensor', target_name=None): spdz = self.get_spdz() if target_name is None: target_name = NamingService.get_instance().next() a, b, c = beaver_triplets(a_tensor=self.value, b_tensor=other.value, dot=table_dot, q_field=self.q_field, he_key_pair=(spdz.public_key, spdz.private_key), communicator=spdz.communicator, name=target_name) x_add_a = (self + a).rescontruct(f"{target_name}_confuse_x") y_add_b = (other + b).rescontruct(f"{target_name}_confuse_y") cross = c - table_dot_mod(a, y_add_b, self.q_field) - table_dot_mod( x_add_a, b, self.q_field) if spdz.party_idx == 0: cross += table_dot_mod(x_add_a, y_add_b, self.q_field) cross = cross % self.q_field cross = self.endec.truncate(cross, self.get_spdz().party_idx) share = fixedpoint_numpy.FixedPointTensor(cross, self.q_field, self.endec, target_name) return share
def __init__(self, value, q_field, endec, tensor_name: str = None): super().__init__(q_field, tensor_name) self.value = value self.endec = endec self.tensor_name = NamingService.get_instance().next( ) if tensor_name is None else tensor_name
def __init__(self, q_field, tensor_name: str = None): self.q_field = q_field self.tensor_name = NamingService.get_instance().next( ) if tensor_name is None else tensor_name