Update app.py
Browse files
app.py
CHANGED
|
@@ -69,35 +69,17 @@ def verify_wots(signature, message, public_key):
|
|
| 69 |
@app.post("/relay-txn")
|
| 70 |
async def relay_txn(payload: dict):
|
| 71 |
# 1. Verification Math
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
# Hash the proof 'lap' times to see if it hits the anchor
|
| 77 |
-
check = proof
|
| 78 |
-
for _ in range(lap):
|
| 79 |
-
check = hashlib.sha256(check).digest()
|
| 80 |
-
|
| 81 |
-
if check != anchor:
|
| 82 |
-
raise HTTPException(status_code=403, detail="Quantum Auth Failed")
|
| 83 |
|
| 84 |
-
|
| 85 |
-
# Deserialize the transaction sent from the UI
|
| 86 |
-
raw_tx = base58.b58decode(payload['txn'])
|
| 87 |
-
txn = Transaction.from_bytes(raw_tx)
|
| 88 |
-
txn.partial_sign([SERVER_KEY])
|
| 89 |
|
| 90 |
-
|
| 91 |
-
|
| 92 |
|
|
|
|
| 93 |
|
| 94 |
-
return {
|
| 95 |
-
"success": True,
|
| 96 |
-
"encoded_txn": encoded_txn,
|
| 97 |
-
"status": "Finalized on Solana"
|
| 98 |
-
}
|
| 99 |
-
|
| 100 |
-
|
| 101 |
|
| 102 |
|
| 103 |
|
|
|
|
| 69 |
@app.post("/relay-txn")
|
| 70 |
async def relay_txn(payload: dict):
|
| 71 |
# 1. Verification Math
|
| 72 |
+
message = base58.b58decode(payload["message"])
|
| 73 |
+
signature = payload["signature"] # list[str]
|
| 74 |
+
public_key = payload["anchorB58"] # list[str]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
+
is_valid = verify_wots(signature, message, public_key)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
+
if not is_valid:
|
| 79 |
+
return {"success": False, "error": "Invalid WOTS signature"}
|
| 80 |
|
| 81 |
+
return {"success": True}
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
|
| 85 |
|