1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-12 17:38:13 +00:00

feat(contacts): new contact UI using nostr event

This commit is contained in:
obrusvit 2024-12-11 16:26:27 +01:00
parent bfc444f083
commit 6151524393

View File

@ -15,6 +15,7 @@ async def sign_event(msg: NostrSignEvent, keychain: Keychain) -> NostrEventSigna
from trezor.crypto.curve import secp256k1
from trezor.crypto.hashlib import sha256
from trezor.messages import NostrEventSignature
from trezor.ui.layouts import confirm_action, confirm_new_contact
address_n = msg.address_n
created_at = msg.created_at
@ -22,6 +23,22 @@ async def sign_event(msg: NostrSignEvent, keychain: Keychain) -> NostrEventSigna
tags = msg.tags
content = msg.content
if content and kind == 27922:
if "/" not in content:
raise ValueError("Invalid content")
# message will have format <label>/<npub>
# hackathon simplification
label, contact_id = content.split("/")
await confirm_new_contact(
label=label,
contact_id=contact_id,
chunkify=True,
)
else:
await confirm_action(
"nostr_sign_event", "Nostr event", action="Sign nostr event", description=""
)
node = keychain.derive(address_n)
pk = node.public_key()[-32:]
sk = node.private_key()