Skip to content

Commit

Permalink
SFT-3618: Replace trezorcrypto.secp256k1.publickey.
Browse files Browse the repository at this point in the history
* ports/stm32/boards/Passport/modules/tasks/nostr_key_task.py
(nostr_key_task): Use secp256k1.public_key_schnorr instead of
nostr_pubkey_from_pk.
* ports/stm32/boards/Passport/modules/utils.py
(nostr_pubkey_from_pk): Remove function.
  • Loading branch information
jeandudey committed May 13, 2024
1 parent 8185cb6 commit ca1072e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 3 additions & 2 deletions ports/stm32/boards/Passport/modules/tasks/nostr_key_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

async def nostr_key_task(on_done, index):
import stash
from utils import nostr_pubkey_from_pk, nostr_nip19_from_key
from foundation import secp256k1
from utils import nostr_nip19_from_key

path = "m/44'/1237'/{}'/0/0".format(index)
with stash.SensitiveValues() as sv:
node = sv.derive_path(path)
key = node.private_key()
pub = nostr_pubkey_from_pk(key)
pub = secp256k1.public_key_schnorr(key)
nsec = nostr_nip19_from_key(key, "nsec")
npub = nostr_nip19_from_key(pub, "npub")
await on_done({'priv': nsec, 'npub': npub, 'pk': key, 'pub': pub}, None)
6 changes: 0 additions & 6 deletions ports/stm32/boards/Passport/modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,12 +1360,6 @@ def get_seed_from_words(words):
entropy = entropy[:trim_pos] # Trim off the excess (including checksum bits)
return entropy


def nostr_pubkey_from_pk(pk):
from trezorcrypto import secp256k1
return secp256k1.publickey(pk, True)[1:]


def nostr_nip19_from_key(key, key_type): # generate nsec/npub
import tcc
return tcc.codecs.bech32_plain_encode(key_type, key)
Expand Down

0 comments on commit ca1072e

Please sign in to comment.