Junaidb commited on
Commit
120820f
·
verified ·
1 Parent(s): 2d45c70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -25
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
- proof = base58.b58decode(payload['winternitz_hash'])
73
- anchor = base58.b58decode(payload['anchor']) # Stored in your DB
74
- lap = payload['lap']
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
- # 2. Transaction Execution
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
- partial_signed_bytes = bytes(txn)
91
- encoded_txn = base58.b58encode(partial_signed_bytes).decode("utf-8")
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