fix burn -a and hash_to_curve is now hash_to_point

This commit is contained in:
callebtc
2022-09-23 23:03:46 +03:00
parent 1a96423a47
commit a76f2ba698
3 changed files with 10 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ Alice:
A = a*G A = a*G
return A return A
Bob: Bob:
Y = hash_to_curve(secret_message) Y = hash_to_point(secret_message)
r = random blinding factor r = random blinding factor
B'= Y + r*G B'= Y + r*G
return B' return B'
@@ -20,7 +20,7 @@ C = C' - r*A
(= a*Y) (= a*Y)
return C, secret_message return C, secret_message
Alice: Alice:
Y = hash_to_curve(secret_message) Y = hash_to_point(secret_message)
C == a*Y C == a*Y
If true, C must have originated from Alice If true, C must have originated from Alice
""" """
@@ -30,7 +30,7 @@ import hashlib
from secp256k1 import PrivateKey, PublicKey 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. """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.""" If it does not, it tries computing again a new x coordinate from the hash of the coordinate."""
point = None point = None
@@ -51,7 +51,7 @@ def hash_to_curve(secret_msg):
def step1_alice(secret_msg): def step1_alice(secret_msg):
secret_msg = secret_msg.encode("utf-8") secret_msg = secret_msg.encode("utf-8")
Y = hash_to_curve(secret_msg) Y = hash_to_point(secret_msg)
r = PrivateKey() r = PrivateKey()
B_ = Y + r.pubkey B_ = Y + r.pubkey
return B_, r return B_, r
@@ -68,7 +68,7 @@ def step3_alice(C_, r, A):
def verify(a, C, secret_msg): 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) return C == Y.mult(a)

View File

@@ -139,7 +139,7 @@ async def burn(ctx, token: str, all: bool, force: bool):
if all: if all:
# check only those who are flagged as reserved # check only those who are flagged as reserved
proofs = await get_reserved_proofs(wallet.db) proofs = await get_reserved_proofs(wallet.db)
if force: elif force:
# check all proofs in db # check all proofs in db
proofs = wallet.proofs proofs = wallet.proofs
else: else:

View File

@@ -80,14 +80,14 @@ class LedgerAPI:
amount=amount, B_=B_.serialize().hex() amount=amount, B_=B_.serialize().hex()
) )
payloads.blinded_messages.append(payload) payloads.blinded_messages.append(payload)
promises_dict = requests.post( promises_list = requests.post(
self.url + "/mint", self.url + "/mint",
json=payloads.dict(), json=payloads.dict(),
params={"payment_hash": payment_hash}, params={"payment_hash": payment_hash},
).json() ).json()
if "error" in promises_dict: if "error" in promises_list:
raise Exception("Error: {}".format(promises_dict["error"])) raise Exception("Error: {}".format(promises_list["error"]))
promises = [BlindedSignature.from_dict(p) for p in promises_dict] promises = [BlindedSignature.from_dict(p) for p in promises_list]
return self._construct_proofs(promises, [(r, s) for r, s in zip(rs, secrets)]) return self._construct_proofs(promises, [(r, s) for r, s in zip(rs, secrets)])
def split(self, proofs, amount): def split(self, proofs, amount):