def set_task(self): client = self.client print(f"[+] {self.user_id} registering function") function_id = client.register_function( name="builtin-password-check", description="Check whether a password is exposed.", executor_type="builtin", arguments=[], inputs=[ FunctionInput("password", "Client 0 data."), FunctionInput("exposed_passwords", "Client 1 data.") ], outputs=[]) print(f"[+] {self.user_id} creating task") task_id = client.create_task( function_id=function_id, function_arguments={}, executor="builtin", inputs_ownership=[ OwnerList("password", [USER_DATA_0.user_id]), OwnerList("exposed_passwords", [USER_DATA_1.user_id]) ], ) return task_id
def set_single_party_task(self, functionname, payloadpath, args={}, inlabels=["input_data_0"], outlabels=["result_data_0"], ex=Executor.builtin): client = self.client print(f"[+] {self.user_id} registering function") p_str = "" if payloadpath != "": print(f"[+] {self.user_id} reading payload file") with open(payloadpath, "rb") as f: p_str = f.read() function_id = client.register_function( name=functionname, description="worker: %s" % functionname, executor_type=ex.name, arguments=list(args.keys()), payload=list(p_str), inputs=[ FunctionInput(label, "user input data fileļ¼ %s" % label) for label in inlabels ], outputs=[ FunctionOutput(label, "user output file: %s" % label) for label in outlabels ]) print(f"[+] {self.user_id} creating task") task_id = client.create_task(function_id=function_id, executor=ex.value, function_arguments=(args), inputs_ownership=[ OwnerList(label, [self.user_id]) for label in inlabels ], outputs_ownership=[ OwnerList(label, [self.user_id]) for label in outlabels ]) return task_id
def create_task(client, function_id, input_file_user): task_id = client.create_task( function_id=function_id, executor="builtin", function_arguments=({ "data": "test data", }), inputs_ownership=[OwnerList("rsa_key", [input_file_user])]) return task_id
def set_task(self): client = self.client print(f"[+] {self.user_id} registering function") function_id = client.register_function( name="builtin-ordered-set-intersect", description="Native Private Set Intersection", executor_type="builtin", arguments=["order"], inputs=[ FunctionInput("input_data1", "Client 0 data."), FunctionInput("input_data2", "Client 1 data.") ], outputs=[ FunctionOutput("output_result1", "Output data."), FunctionOutput("output_result2", "Output data.") ]) print(f"[+] {self.user_id} creating task") task_id = client.create_task( function_id=function_id, function_arguments=({ "order": "ascending", # Order can be ascending or desending }), executor="builtin", inputs_ownership=[ OwnerList("input_data1", [USER_DATA_0.user_id]), OwnerList("input_data2", [USER_DATA_1.user_id]) ], outputs_ownership=[ OwnerList("output_result1", [USER_DATA_0.user_id]), OwnerList("output_result2", [USER_DATA_1.user_id]) ]) return task_id
def set_task(self): client = self.client print(f"[+] {self.user_id} registering function") function_id = client.register_function( name="builtin-private-join-and-compute", description="Native Private Join And Compute", executor_type="builtin", arguments=["num_user"], inputs=[ FunctionInput("input_data0", "Bank A data file."), FunctionInput("input_data1", "Bank B data file."), FunctionInput("input_data2", "Bank C data file.") ], outputs=[ FunctionOutput("output_data0", "Output data."), FunctionOutput("output_data1", "Output data."), FunctionOutput("output_data2", "Output date.") ]) print(f"[+] {self.user_id} creating task") task_id = client.create_task(function_id=function_id, function_arguments=({ "num_user": 3, }), executor="builtin", inputs_ownership=[ OwnerList("input_data0", [USER_DATA_0.user_id]), OwnerList("input_data1", [USER_DATA_1.user_id]), OwnerList("input_data2", [USER_DATA_2.user_id]) ], outputs_ownership=[ OwnerList("output_data0", [USER_DATA_0.user_id]), OwnerList("output_data1", [USER_DATA_1.user_id]), OwnerList("output_data2", [USER_DATA_2.user_id]) ]) return task_id
def gbdt(self): client = AuthenticationService( AUTHENTICATION_SERVICE_ADDRESS, AS_ROOT_CA_CERT_PATH, ENCLAVE_INFO_PATH).connect().get_client() print("[+] registering user") client.user_register(self.user_id, self.user_password) print("[+] login") token = client.user_login(self.user_id, self.user_password) client = FrontendService(FRONTEND_SERVICE_ADDRESS, AS_ROOT_CA_CERT_PATH, ENCLAVE_INFO_PATH).connect().get_client() metadata = {"id": self.user_id, "token": token} client.metadata = metadata print("[+] registering function") function_id = client.register_function( name="builtin-gbdt-train", description="Native Gbdt Training Function", executor_type="builtin", arguments=[ "feature_size", "max_depth", "iterations", "shrinkage", "feature_sample_ratio", "data_sample_ratio", "min_leaf_size", "loss", "training_optimization_level" ], inputs=[ FunctionInput("training_data", "Input traning data file.") ], outputs=[FunctionOutput("trained_model", "Output trained model.")]) print("[+] registering input file") url = "http://localhost:6789/fixtures/functions/gbdt_training/train.enc" cmac = "881adca6b0524472da0a9d0bb02b9af9" schema = "teaclave-file-128" key = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] iv = [] training_data_id = client.register_input_file(url, schema, key, iv, cmac) print("[+] registering output file") url = "http://localhost:6789/fixtures/functions/gbdt_training/e2e_output_model.enc" schema = "teaclave-file-128" key = [ 63, 195, 250, 208, 252, 127, 203, 27, 247, 168, 71, 77, 27, 47, 254, 240 ] iv = [] output_model_id = client.register_output_file(url, schema, key, iv) print("[+] creating task") task_id = client.create_task( function_id=function_id, function_arguments=({ "feature_size": 4, "max_depth": 4, "iterations": 100, "shrinkage": 0.1, "feature_sample_ratio": 1.0, "data_sample_ratio": 1.0, "min_leaf_size": 1, "loss": "LAD", "training_optimization_level": 2 }), executor="builtin", inputs_ownership=[OwnerList("training_data", [self.user_id])], outputs_ownership=[OwnerList("trained_model", [self.user_id])]) print("[+] assigning data to task") client.assign_data_to_task( task_id, [DataMap("training_data", training_data_id)], [DataMap("trained_model", output_model_id)]) print("[+] approving task") client.approve_task(task_id) print("[+] invoking task") client.invoke_task(task_id) print("[+] getting result") result = client.get_task_result(task_id) print("[+] done") return bytes(result)