Esempio n. 1
0
def get_arit_circuit(circuit_id):
    if circuit_id == 1:
        return ArithmeticCircuits().add_1_mult_2_3()
    elif circuit_id == 2:
        return ArithmeticCircuits(
        ).mult_add_5_people_where_one_person_has_multiple_inputs()
    elif circuit_id == 3:
        return ArithmeticCircuits(
        ).add_mult_scalarmult_where_some_player_has_no_input()
    elif circuit_id == 4:
        return ArithmeticCircuits().add_mult_scalarmult_with_multiple_outputs()
Esempio n. 2
0
    def start_test_server(self, player_count):
        # choose circuit for the party that we test on
        circuit = ArithmeticCircuits().add_1_mult_2_3()
        # read config parameters
        test_setup = TestSetupLocalProcess(host='127.0.0.1',
                                           port='5001',
                                           id='1',
                                           player_count=player_count)

        # create shares memory (a list) between test tread and server tread for getting the result of the computaiton.
        multiprocessing_manager = Manager()
        self.result_arr = multiprocessing_manager.list()

        # choose strategies and start the server
        s = Server(setup=test_setup)
        client = Client()
        sharingStrategy = ArithmeticSharingStrategy()
        evaluationStrategy = ArithmeticEvaluationStrategy(client)
        config.ceps_speed = Ceps_Speed(circuit, sharingStrategy,
                                       evaluationStrategy)
        config.ceps = Ceps(Client().create_circuit(0), ShareByWireId())

        # start the server in a thread
        self.process = Process(target=s.start, args=[self.result_arr])
        self.process.start()
Esempio n. 3
0
 def boolean_circuit_setup(self):
     # choose circuit for the party that we test on
     circuit = ArithmeticCircuits().add_1_mult_2_3()
     # choose strategies
     sharingStrategy = BooleanSharingStrategy()
     evaluationStrategy = BooleanEvaluationStrategy(Client())
     config.ceps_speed = Ceps_Speed(circuit, sharingStrategy,
                                    evaluationStrategy)
     config.ceps = Ceps(Client().create_circuit(0), ShareByWireId())
Esempio n. 4
0
 def setup(self):
     player_count, my_player_id, players, all = self.create_player_dict()
     config.players = players
     config.host = "0.0.0.0"
     config.port = "80"
     config.id = my_player_id
     config.player_count = player_count
     config.all_players = all
     circuit = ArithmeticCircuits().add_1_mult_2_3()
     config.ceps_speed = Ceps_Speed(
         circuit=circuit,
         sharingStrategy=BooleanLayerSharingStrategy(),
         evaluationStrategy=BooleanLayerEvaluationStrategy(Client()))
     config.ceps = Ceps(circuit=Client().create_circuit(0),
                        sharingStrategy=ShareByWirePlayerId())
Esempio n. 5
0
 def setup(self):
     host, port, id, _ = self.get_host_info()
     player_count, players, all = self.create_player_dict(id)
     config.players = players
     config.host = host
     config.port = port
     config.id = id
     config.player_count = int(player_count)
     config.all_players = all
     circuit = ArithmeticCircuits().add_1_mult_2_3()
     config.ceps_speed = Ceps_Speed(
         circuit=circuit,
         sharingStrategy=BooleanLayerSharingStrategyByPlayerId(),
         evaluationStrategy=BooleanLayerEvaluationStrategy(Client()))
     config.ceps = Ceps(circuit=Client().create_circuit(0),
                        sharingStrategy=ShareWire())