mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-22 19:34:18 +01:00
fix burn -a and hash_to_curve is now hash_to_point
This commit is contained in:
@@ -6,7 +6,7 @@ Alice:
|
||||
A = a*G
|
||||
return A
|
||||
Bob:
|
||||
Y = hash_to_curve(secret_message)
|
||||
Y = hash_to_point(secret_message)
|
||||
r = random blinding factor
|
||||
B'= Y + r*G
|
||||
return B'
|
||||
@@ -20,7 +20,7 @@ C = C' - r*A
|
||||
(= a*Y)
|
||||
return C, secret_message
|
||||
Alice:
|
||||
Y = hash_to_curve(secret_message)
|
||||
Y = hash_to_point(secret_message)
|
||||
C == a*Y
|
||||
If true, C must have originated from Alice
|
||||
"""
|
||||
@@ -30,7 +30,7 @@ import hashlib
|
||||
from secp256k1 import PrivateKey, PublicKey
|
||||
|
||||
|
||||
def hash_to_curve(secret_msg):
|
||||
def hash_to_point(secret_msg):
|
||||
"""Generates x coordinate from the message hash and checks if the point lies on the curve.
|
||||
If it does not, it tries computing again a new x coordinate from the hash of the coordinate."""
|
||||
point = None
|
||||
@@ -51,7 +51,7 @@ def hash_to_curve(secret_msg):
|
||||
|
||||
def step1_alice(secret_msg):
|
||||
secret_msg = secret_msg.encode("utf-8")
|
||||
Y = hash_to_curve(secret_msg)
|
||||
Y = hash_to_point(secret_msg)
|
||||
r = PrivateKey()
|
||||
B_ = Y + r.pubkey
|
||||
return B_, r
|
||||
@@ -68,7 +68,7 @@ def step3_alice(C_, r, A):
|
||||
|
||||
|
||||
def verify(a, C, secret_msg):
|
||||
Y = hash_to_curve(secret_msg.encode("utf-8"))
|
||||
Y = hash_to_point(secret_msg.encode("utf-8"))
|
||||
return C == Y.mult(a)
|
||||
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ async def burn(ctx, token: str, all: bool, force: bool):
|
||||
if all:
|
||||
# check only those who are flagged as reserved
|
||||
proofs = await get_reserved_proofs(wallet.db)
|
||||
if force:
|
||||
elif force:
|
||||
# check all proofs in db
|
||||
proofs = wallet.proofs
|
||||
else:
|
||||
|
||||
@@ -80,14 +80,14 @@ class LedgerAPI:
|
||||
amount=amount, B_=B_.serialize().hex()
|
||||
)
|
||||
payloads.blinded_messages.append(payload)
|
||||
promises_dict = requests.post(
|
||||
promises_list = requests.post(
|
||||
self.url + "/mint",
|
||||
json=payloads.dict(),
|
||||
params={"payment_hash": payment_hash},
|
||||
).json()
|
||||
if "error" in promises_dict:
|
||||
raise Exception("Error: {}".format(promises_dict["error"]))
|
||||
promises = [BlindedSignature.from_dict(p) for p in promises_dict]
|
||||
if "error" in promises_list:
|
||||
raise Exception("Error: {}".format(promises_list["error"]))
|
||||
promises = [BlindedSignature.from_dict(p) for p in promises_list]
|
||||
return self._construct_proofs(promises, [(r, s) for r, s in zip(rs, secrets)])
|
||||
|
||||
def split(self, proofs, amount):
|
||||
|
||||
Reference in New Issue
Block a user