Build a 3-party secure-sum calculator in Python or Rust. Each party holds a secret integer; no party learns any other party's value, but all parties learn the sum. Use additive sharing from Task 4 and simulate the three parties either as separate processes communicating over localhost sockets, or as three threads with an explicit message-passing abstraction. Semi-honest threat model is fine for this project — name it explicitly in your README.
A simple socket-based scaffold — fill in the crypto:
# party.py
import socket, json, sys
from secrets import randbelow
P = 2**127 - 1
def run(party_id: int, my_input: int, peers: list[tuple[str, int]]):
# 1. Create additive shares of my_input.
# 2. Send one share to each peer, keep one for myself.
# 3. Receive one share from each peer.
# 4. Locally sum: my_share_of_sum = sum(my_received_shares + my_retained_share).
# 5. Broadcast my_share_of_sum.
# 6. Reconstruct: sum = sum(broadcast_shares) mod P.
...
if __name__ == "__main__":
party_id = int(sys.argv[1])
my_input = int(sys.argv[2])
peers = [("127.0.0.1", 9000), ("127.0.0.1", 9001), ("127.0.0.1", 9002)]
print("sum =", run(party_id, my_input, peers))$ python party.py 0 42 &
$ python party.py 1 17 &
$ python party.py 2 99 &
sum = 158
sum = 158
sum = 158
All three parties print the same sum. None of them see each other's contribution.