What is Nostr?
npub1t39…0fey
2024-04-15 15:10:47

npub1t3…j0fey on Nostr: doing something dumb... Anyone any clue why the following python code isn't coming ...

doing something dumb... Anyone any clue why the following python code isn't coming out to match the keys as NIP44 at https://github.com/paulmillr/nip44/blob/main/nip44.vectors.json

from cryptography.hazmat.primitives.hashes import SHA256
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
import secp256k1


def get_conversion_key(priv_k:str, pub_k:str):

the_priv: secp256k1.PrivateKey = secp256k1.PrivateKey(privkey=bytes.fromhex(priv_k))
print(f'using priv: {the_priv.private_key.hex()}')

the_pub: secp256k1.PublicKey = secp256k1.PublicKey(pubkey=bytes.fromhex('02'+pub_k), raw=True)
print(f'using pub_k: {the_pub.serialize().hex()}')

tweaked_key: secp256k1.PublicKey = the_pub.tweak_mul(the_priv.private_key)

print(f'tweaked {tweaked_key.serialize().hex()}')

h = HKDF(algorithm=SHA256(),
length=32,
salt=b'nip44-v2',
info=None)

con_key = h.derive(key_material=tweaked_key.serialize()[1:])
print(f'conversion k: {con_key.hex()}')

get_conversion_key(priv_k='315e59ff51cb9209768cf7da80791ddcaae56ac9775eb25b6dee1234bc5d2268',
pub_k='c2f9d9948dc8c7c38321e4b85c8558872eafa0641cd269db76848a6073e69133')
Author Public Key
npub1t39l8e2gdq7kr7mjhe053skl7r84ryqmnhvca6xmz780u53wxf0swj0fey