async def shutdown(self): """Shutdown the MPC runtime. Close all connections, if any. """ m = len(self.parties) if m > 1: # Wait for all parties after a barrier. while asyncoro.pc_level >= len(self._program_counter): await asyncio.sleep(0) await self.output(self.input(sectypes.SecFld(101)(self.pid)), threshold=m-1) # Close connections to all parties. for peer in self.parties: if peer.pid != self.pid: peer.protocol.close_connection() elapsed = time.time() - self.start_time from datetime import timedelta logging.info(f'Stop MPyC runtime -- elapsed time: {timedelta(seconds=elapsed)}')
def test_operatorerrors(self): secfld = sectypes.SecFld() secint = sectypes.SecInt() a = secfld(0) b = secint(1) self.assertRaises(TypeError, operator.add, a, b) self.assertRaises(TypeError, operator.add, a, 3.14) self.assertRaises(TypeError, operator.sub, a, b) self.assertRaises(TypeError, operator.mul, a, b) self.assertRaises(TypeError, operator.mul, 3.14, b) self.assertRaises(TypeError, operator.truediv, a, b) self.assertRaises(TypeError, operator.truediv, a, b) self.assertRaises(TypeError, operator.mod, a, b) self.assertRaises(TypeError, operator.mod, b, a) self.assertRaises(TypeError, operator.floordiv, a, b) self.assertRaises(TypeError, divmod, a, b) self.assertRaises(TypeError, divmod, b, a) self.assertRaises(TypeError, operator.pow, b, 3.14) self.assertRaises(TypeError, operator.lshift, b, 3.14) self.assertRaises(TypeError, operator.lshift, 3.14, b) self.assertRaises(TypeError, operator.rshift, b, 3.14) self.assertRaises(TypeError, operator.rshift, 3.14, b)
def test_bool(self): self.assertRaises(TypeError, bool, sectypes.SecFld()(0)) self.assertRaises(TypeError, bool, sectypes.SecInt()(0)) self.assertRaises(TypeError, bool, sectypes.SecFxp()(0)) self.assertRaises(TypeError, bool, sectypes.SecFlt()(0))