Example #1
0
 def client_le(self, *args, **kwargs):
     tensor = self - args[0]
     serialized_tensor = serialize_paillier(to_paillier(tensor, public_key))
     json_obj = MultiDimensionalArrayEncoder().encode(serialized_tensor)
     params = {'obj': json_obj, 'function': '<='}
     r = post(url=url + '/comparetensor', json=params)
     return deserialize(r.content)
Example #2
0
def retrieve_test_result(User, result, public_key):
    random_data = random.randint(100)
    result = result + random_data
    result_obj = serialize_paillier(to_paillier(result, public_key))
    json_obj = MultiDimensionalArrayEncoder().encode(result_obj)
    data = {'buyer': User.address, 'obj': json_obj}
    result_url = User.contract.functions.test_result_link().call()
    response = post(result_url, json=data)
    string_result = response.content
    try:
        print('Result has been received!')
        print('===========================')
        decrypted_result = deserialize(string_result)
        decrypted_result = decrypted_result - random_data
    except:
        decrypted_result = loads(string_result)
    return decrypted_result