lnurl-auth: hashing_key -> linking_key.

This commit is contained in:
fiatjaf
2020-11-11 22:37:55 -03:00
parent 805000cd06
commit b794f8302d
3 changed files with 13 additions and 6 deletions
+6 -3
View File
@@ -1,4 +1,5 @@
import json
import hmac
import hashlib
from ecdsa import SECP256k1, SigningKey # type: ignore
from typing import List, NamedTuple, Optional, Dict
@@ -35,10 +36,12 @@ class Wallet(NamedTuple):
def balance(self) -> int:
return self.balance_msat // 1000
@property
def lnurlauth_key(self) -> SigningKey:
def lnurlauth_key(self, domain: str) -> SigningKey:
hashing_key = hashlib.sha256(self.id.encode("utf-8")).digest()
linking_key = hmac.digest(hashing_key, domain.encode("utf-8"), "sha256")
return SigningKey.from_string(
hashlib.sha256(self.id.encode("utf-8")).digest(),
linking_key,
curve=SECP256k1,
hashfunc=hashlib.sha256,
)