diff --git a/lnbits/extensions/cashu/core/b_dhke.py b/lnbits/extensions/cashu/core/b_dhke.py index 8855481cf..ff0bc5157 100644 --- a/lnbits/extensions/cashu/core/b_dhke.py +++ b/lnbits/extensions/cashu/core/b_dhke.py @@ -30,17 +30,17 @@ import hashlib from secp256k1 import PrivateKey, PublicKey -def hash_to_curve(message: bytes): - """Generates a point 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 - msg_to_hash = message - while point is None: - try: - _hash = hashlib.sha256(msg_to_hash).digest() - point = PublicKey(b"\x02" + _hash, raw=True) - except: - msg_to_hash = _hash +def hash_to_curve(message: bytes): + """Generates a point 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 + msg_to_hash = message + while point is None: + try: + _hash = hashlib.sha256(msg_to_hash).digest() + point = PublicKey(b"\x02" + _hash, raw=True) + except: + msg_to_hash = _hash return point diff --git a/lnbits/extensions/cashu/mint_helper.py b/lnbits/extensions/cashu/mint_helper.py index 4db929463..8e7e22751 100644 --- a/lnbits/extensions/cashu/mint_helper.py +++ b/lnbits/extensions/cashu/mint_helper.py @@ -1,5 +1,5 @@ -import hashlib import base64 +import hashlib from typing import List, Set from .core.b_dhke import verify @@ -41,13 +41,11 @@ async def verify_proof(master_prvkey: str, proofs_used: Set[str], proof: Proof): ] # Get the correct key to check against C = PublicKey(bytes.fromhex(proof.C), raw=True) secret = base64.standard_b64decode(proof.secret) - print('### secret', secret) + print("### secret", secret) validMintSig = verify(secret_key, C, secret) if validMintSig != True: raise Exception(f"tokens not valid. Secret: {proof.secret}") - - def verify_split_amount(amount: int): """Split amount like output amount can't be negative or too big.""" diff --git a/lnbits/extensions/cashu/templates/cashu/wallet.html b/lnbits/extensions/cashu/templates/cashu/wallet.html index af12182b5..f64a19b72 100644 --- a/lnbits/extensions/cashu/templates/cashu/wallet.html +++ b/lnbits/extensions/cashu/templates/cashu/wallet.html @@ -1089,7 +1089,7 @@ page_container %} payload ) - newTokens.promises = data.snd; + newTokens.promises = data.snd // console.log('split data', JSON.stringify(data.snd)) // for (let i =0 ;i < newTokens.length; i++) { // Object.assign(newTokens[i], promises)