forked from sangge/tpre-python
main #22
@ -16,13 +16,31 @@ jobs:
|
|||||||
|
|
||||||
|
|
||||||
- name: copy file via ssh password
|
- name: copy file via ssh password
|
||||||
uses: appleboy/scp-action@v0.1.4
|
uses: cross-the-world/scp-pipeline@master
|
||||||
with:
|
with:
|
||||||
host: "110.41.155.96,110.41.130.197,110.41.21.35"
|
host: "110.41.155.96"
|
||||||
username: ${{ secrets.USERNAME }}
|
user: ${{ secrets.USERNAME }}
|
||||||
password: ${{ secrets.PASSWORD }}
|
pass: ${{ secrets.PASSWORD }}
|
||||||
source: "src/server.py,src/client.py,src/node.py"
|
local: "src/*"
|
||||||
target: "/root/mimajingsai/src/"
|
remote: /root/mimajingsai/src/
|
||||||
|
|
||||||
|
- name: copy file via ssh password
|
||||||
|
uses: cross-the-world/scp-pipeline@master
|
||||||
|
with:
|
||||||
|
host: "110.41.130.197"
|
||||||
|
user: ${{ secrets.USERNAME }}
|
||||||
|
pass: ${{ secrets.PASSWORD }}
|
||||||
|
local: "src/*"
|
||||||
|
remote: /root/mimajingsai/src/
|
||||||
|
|
||||||
|
- name: copy file via ssh password
|
||||||
|
uses: cross-the-world/scp-pipeline@master
|
||||||
|
with:
|
||||||
|
host: "110.41.21.35"
|
||||||
|
user: ${{ secrets.USERNAME }}
|
||||||
|
pass: ${{ secrets.PASSWORD }}
|
||||||
|
local: "src/*"
|
||||||
|
remote: /root/mimajingsai/src/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,4 +15,6 @@ tpre3: docker run -it -p 8000:8000 -p 8001:8001 -p 8002:8002 -v ~/mimajingsai:/a
|
|||||||
|
|
||||||
110.41.155.96 tpre1
|
110.41.155.96 tpre1
|
||||||
110.41.130.197 tpre2
|
110.41.130.197 tpre2
|
||||||
110.41.21.35 tpre3
|
110.41.21.35 tpre3
|
||||||
|
|
||||||
|
python client_cli.py 110.41.21.35 aaa
|
@ -114,19 +114,22 @@ async def receive_messages(message: C):
|
|||||||
return:
|
return:
|
||||||
status_code
|
status_code
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not message.Tuple or not message.ip:
|
if not message.Tuple or not message.ip:
|
||||||
raise HTTPException(status_code=400, detail="Invalid input data")
|
raise HTTPException(status_code=400, detail="Invalid input data")
|
||||||
|
|
||||||
C_capsule, C_ct = message.Tuple
|
C_capsule, C_ct = message.Tuple
|
||||||
ip = message.ip
|
ip = message.ip
|
||||||
|
|
||||||
# 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:
|
||||||
|
print("bin:", bin_C_capsule)
|
||||||
|
print("ct:", C_ct)
|
||||||
|
print("ip:", ip)
|
||||||
db.execute(
|
db.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO message
|
INSERT INTO message
|
||||||
@ -134,7 +137,7 @@ async def receive_messages(message: C):
|
|||||||
VALUES
|
VALUES
|
||||||
(?, ?, ?)
|
(?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(bin_C_capsule, C_ct, ip),
|
(bin_C_capsule, str(C_ct), ip),
|
||||||
)
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
await check_merge(C_ct, ip)
|
await check_merge(C_ct, ip)
|
||||||
@ -149,6 +152,8 @@ async def receive_messages(message: C):
|
|||||||
async def check_merge(ct: int, ip: str):
|
async def check_merge(ct: int, ip: str):
|
||||||
global sk, pk, node_response, message
|
global sk, pk, node_response, message
|
||||||
with sqlite3.connect("client.db") as db:
|
with sqlite3.connect("client.db") as db:
|
||||||
|
print("str(ct):", str(ct))
|
||||||
|
print("ip:", ip)
|
||||||
# Check if the combination of ct_column and ip_column appears more than once.
|
# Check if the combination of ct_column and ip_column appears more than once.
|
||||||
cursor = db.execute(
|
cursor = db.execute(
|
||||||
"""
|
"""
|
||||||
@ -156,21 +161,23 @@ async def check_merge(ct: int, ip: str):
|
|||||||
FROM message
|
FROM message
|
||||||
WHERE ct = ? AND senderip = ?
|
WHERE ct = ? AND senderip = ?
|
||||||
""",
|
""",
|
||||||
(ct, ip),
|
(str(ct), ip),
|
||||||
)
|
)
|
||||||
# [(capsule, ct), ...]
|
# [(capsule, ct), ...]
|
||||||
cfrag_cts = cursor.fetchall()
|
cfrag_cts = cursor.fetchall()
|
||||||
|
|
||||||
|
print("ip", type(ip))
|
||||||
# get T
|
# get T
|
||||||
cursor = db.execute(
|
cursor = db.execute(
|
||||||
"""
|
"""
|
||||||
SELECT publickey, threshold
|
SELECT publickey, threshold
|
||||||
FROM senderinfo
|
FROM senderinfo
|
||||||
WHERE senderip = ?
|
WHERE ip = ?
|
||||||
""",
|
""",
|
||||||
(ip),
|
(ip),
|
||||||
)
|
)
|
||||||
result = cursor.fetchall()
|
result = cursor.fetchall()
|
||||||
|
print("maybe error here?")
|
||||||
pk_sender, T = result[0] # result[0] = (pk, threshold)
|
pk_sender, T = result[0] # result[0] = (pk, threshold)
|
||||||
|
|
||||||
if len(cfrag_cts) >= T:
|
if len(cfrag_cts) >= T:
|
||||||
@ -178,8 +185,8 @@ async def check_merge(ct: int, ip: str):
|
|||||||
temp_cfrag_cts = []
|
temp_cfrag_cts = []
|
||||||
for i in cfrag_cts:
|
for i in cfrag_cts:
|
||||||
capsule = pickle.loads(i[0])
|
capsule = pickle.loads(i[0])
|
||||||
temp_cfrag_cts.append((capsule, i[1]))
|
temp_cfrag_cts.append((capsule, int(i[1])))
|
||||||
|
|
||||||
cfrags = mergecfrag(temp_cfrag_cts)
|
cfrags = mergecfrag(temp_cfrag_cts)
|
||||||
message = DecryptFrags(sk, pk, pk_sender, cfrags) # type: ignore
|
message = DecryptFrags(sk, pk, pk_sender, cfrags) # type: ignore
|
||||||
node_response = True
|
node_response = True
|
||||||
@ -258,20 +265,6 @@ async def request_message(i_m: Request_Message):
|
|||||||
except:
|
except:
|
||||||
print("can't post")
|
print("can't post")
|
||||||
return {"message": "can't post"}
|
return {"message": "can't post"}
|
||||||
if response.status_code == 200:
|
|
||||||
data = response.json()
|
|
||||||
public_key = int(data["public_key"])
|
|
||||||
threshold = int(data["threshold"])
|
|
||||||
with sqlite3.connect("client.db") as db:
|
|
||||||
db.execute(
|
|
||||||
"""
|
|
||||||
INSERT INTO senderinfo
|
|
||||||
(public_key, threshold)
|
|
||||||
VALUES
|
|
||||||
(?, ?)
|
|
||||||
""",
|
|
||||||
(public_key, threshold),
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
@ -283,11 +276,11 @@ async def request_message(i_m: Request_Message):
|
|||||||
db.execute(
|
db.execute(
|
||||||
"""
|
"""
|
||||||
INSERT INTO senderinfo
|
INSERT INTO senderinfo
|
||||||
(public_key, threshold)
|
(ip, public_key, threshold)
|
||||||
VALUES
|
VALUES
|
||||||
(?, ?)
|
(?, ?, ?)
|
||||||
""",
|
""",
|
||||||
(public_key, threshold),
|
(str(dest_ip), public_key, threshold),
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
print("Database error")
|
print("Database error")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user