feat: NWC use coincurve instead of secp (#3455)
This commit is contained in:
+13
-13
@@ -6,8 +6,8 @@ from uuid import uuid4
|
||||
|
||||
import jwt
|
||||
import pytest
|
||||
import secp256k1
|
||||
import shortuuid
|
||||
from coincurve import PrivateKey
|
||||
from httpx import AsyncClient
|
||||
|
||||
from lnbits.core.crud.users import (
|
||||
@@ -42,11 +42,11 @@ nostr_event = {
|
||||
"sig": "fb7eb47fa8355747f6837e55620103d73ba47b2c3164ab8319d2f164022a9f25"
|
||||
"6e00ecda7d3c8945f07b7d6ecc18cfff34c07bc99677309e2b9310d9fc1bb138",
|
||||
}
|
||||
private_key = secp256k1.PrivateKey(
|
||||
private_key = PrivateKey(
|
||||
bytes.fromhex("6e00ecda7d3c8945f07b7d6ecc18cfff34c07bc99677309e2b9310d9fc1bb138")
|
||||
)
|
||||
assert private_key.pubkey, "Pubkey not created."
|
||||
pubkey_hex = private_key.pubkey.serialize().hex()[2:]
|
||||
assert private_key.public_key, "Pubkey not created."
|
||||
pubkey_hex = private_key.public_key.format().hex()[2:]
|
||||
|
||||
|
||||
################################ LOGIN ################################
|
||||
@@ -552,9 +552,9 @@ async def test_register_nostr_ok(http_client: AsyncClient, settings: Settings):
|
||||
event = {**nostr_event}
|
||||
event["created_at"] = int(time.time())
|
||||
|
||||
private_key = secp256k1.PrivateKey(bytes.fromhex(os.urandom(32).hex()))
|
||||
assert private_key.pubkey, "Pubkey not created."
|
||||
pubkey_hex = private_key.pubkey.serialize().hex()[2:]
|
||||
private_key = PrivateKey(bytes.fromhex(os.urandom(32).hex()))
|
||||
assert private_key.public_key, "Pubkey not created."
|
||||
pubkey_hex = private_key.public_key.format().hex()[2:]
|
||||
event_signed = sign_event(event, pubkey_hex, private_key)
|
||||
base64_event = base64.b64encode(json.dumps(event_signed).encode()).decode("ascii")
|
||||
response = await http_client.post(
|
||||
@@ -759,9 +759,9 @@ async def test_change_pubkey_npub_ok(http_client: AsyncClient, settings: Setting
|
||||
payload: dict = jwt.decode(access_token, settings.auth_secret_key, ["HS256"])
|
||||
access_token_payload = AccessTokenPayload(**payload)
|
||||
|
||||
private_key = secp256k1.PrivateKey(bytes.fromhex(os.urandom(32).hex()))
|
||||
assert private_key.pubkey, "Pubkey not created."
|
||||
pubkey_hex = private_key.pubkey.serialize().hex()[2:]
|
||||
private_key = PrivateKey(bytes.fromhex(os.urandom(32).hex()))
|
||||
assert private_key.public_key, "Pubkey not created."
|
||||
pubkey_hex = private_key.public_key.format().hex()[2:]
|
||||
npub = hex_to_npub(pubkey_hex)
|
||||
|
||||
response = await http_client.put(
|
||||
@@ -802,9 +802,9 @@ async def test_change_pubkey_ok(
|
||||
payload: dict = jwt.decode(access_token, settings.auth_secret_key, ["HS256"])
|
||||
access_token_payload = AccessTokenPayload(**payload)
|
||||
|
||||
private_key = secp256k1.PrivateKey(bytes.fromhex(os.urandom(32).hex()))
|
||||
assert private_key.pubkey, "Pubkey not created."
|
||||
pubkey_hex = private_key.pubkey.serialize().hex()[2:]
|
||||
private_key = PrivateKey(bytes.fromhex(os.urandom(32).hex()))
|
||||
assert private_key.public_key, "Pubkey not created."
|
||||
pubkey_hex = private_key.public_key.format().hex()[2:]
|
||||
|
||||
response = await http_client.put(
|
||||
"/api/v1/auth/pubkey",
|
||||
|
||||
Reference in New Issue
Block a user