forked from sangge/tpre-python
		
	feat: add send_messages debug info
This commit is contained in:
		| @@ -134,7 +134,6 @@ async def receive_messages(message: C): | |||||||
|     # Serialization |     # Serialization | ||||||
|     bin_C_capsule = pickle.dumps(C_capsule) |     bin_C_capsule = pickle.dumps(C_capsule) | ||||||
|  |  | ||||||
|  |  | ||||||
|     # insert record into database |     # insert record into database | ||||||
|     with sqlite3.connect("client.db") as db: |     with sqlite3.connect("client.db") as db: | ||||||
|         try: |         try: | ||||||
| @@ -235,11 +234,13 @@ async def send_messages( | |||||||
|         for i in range(4): |         for i in range(4): | ||||||
|             id += int(ip_parts[i]) << (24 - (8 * i)) |             id += int(ip_parts[i]) << (24 - (8 * i)) | ||||||
|         id_list.append(id) |         id_list.append(id) | ||||||
|  |     print(f"Calculated IDs: {id_list}") | ||||||
|     # generate rk |     # generate rk | ||||||
|     rk_list = GenerateReKey(sk, pk_B, len(node_ips), shreshold, tuple(id_list))  # type: ignore |     rk_list = GenerateReKey(sk, pk_B, len(node_ips), shreshold, tuple(id_list))  # type: ignore | ||||||
|  |     print(f"Generated ReKey list: {rk_list}") | ||||||
|     capsule, ct = Encrypt(pk, message)  # type: ignore |     capsule, ct = Encrypt(pk, message)  # type: ignore | ||||||
|     # capsule_ct = (capsule, int.from_bytes(ct)) |     # capsule_ct = (capsule, int.from_bytes(ct)) | ||||||
|  |     print(f"Encrypted message to capsule={capsule}, ct={ct}") | ||||||
|  |  | ||||||
|     for i in range(len(node_ips)): |     for i in range(len(node_ips)): | ||||||
|         url = "http://" + node_ips[i][0] + ":8001" + "/user_src" |         url = "http://" + node_ips[i][0] + ":8001" + "/user_src" | ||||||
| @@ -250,11 +251,15 @@ async def send_messages( | |||||||
|             "ct": int.from_bytes(ct), |             "ct": int.from_bytes(ct), | ||||||
|             "rk": rk_list[i], |             "rk": rk_list[i], | ||||||
|         } |         } | ||||||
|         print(json.dumps(payload)) |         print(f"Sending payload to {url}: {json.dumps(payload)}") | ||||||
|         response = requests.post(url, json=payload) |         response = requests.post(url, json=payload) | ||||||
|  |  | ||||||
|         if response.status_code == 200: |         if response.status_code == 200: | ||||||
|             print(f"send to {node_ips[i]} successful") |             print(f"send to {node_ips[i]} successful") | ||||||
|  |         else: | ||||||
|  |             print( | ||||||
|  |                 f"Failed to send to {node_ips[i]}. Response code: {response.status_code}, Response text: {response.text}" | ||||||
|  |             ) | ||||||
|     return 0 |     return 0 | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user