Replying to Avatar hodlbod

Ok I need some more help, nostr:nprofile1qy2hwumn8ghj7un9d3shjtnyv9kh2uewd9hj7qghwaehxw309aex2mrp0yh8qunfd4skctnwv46z7qgewaehxw309aex2mrp0yh8xmn0wf6zuum0vd5kzmp0qqsdr8lv2sp86ztsv4yz9q9wz7ng6zk40u84cta8fcj08kamrek9f9gsq8th3 nostr:nprofile1qyvhwumn8ghj7un9d3shjtndd3jkkafwdahxc6twv5hszyrhwden5te0vyhxummn9ekx7mp0qythwumn8ghj7ct5d3shxtnwdaehgu3wd3skuep0qqsyeqqz27jc32pgf8gynqtu90d2mxztykj94k0kmttxu37nk3lrktctmwr4h nostr:nprofile1qyd8wumn8ghj7urewfsk66ty9enxjct5dfskvtnrdakj7qgmwaehxw309aex2mrp0yh8wetnw3jhymnzw33jucm0d5hsqgpm7rrrljungc6q0tuh5hj7ue863q73qlheu4vywtzwhx42a7j9n5zr9h9m

I'm trying to decrypt an event using nip44, but I'm getting an "invalid hmac" warning on a valid payload (at least, according to the javascript implementation). Any hints? Code below.

func getNip44ConversationKey(sk string, pk string) []byte {

sk_bytes, _ := hex.DecodeString("02" + sk)

sk_obj := secp256k1.PrivKeyFromBytes(sk_bytes)

pk_bytes, _ := hex.DecodeString("02" + pk)

pk_obj, _ := secp256k1.ParsePubKey(pk_bytes)

return nip44.GenerateConversationKey(sk_obj, pk_obj)

}

func getNip44Rumor(sk string, wrap *nostr.Event) (*nostr.Event, error) {

wrap_key := getNip44ConversationKey(sk, wrap.PubKey)

nip44.Decrypt(wrap_key, wrap.Content) // invalid hmac

...

}

have you tried assigning and checking any of the error values that are being ignored in the above code snippet yet? they might give you a hint where the code is failing.

Reply to this note

Please Login to reply.

Discussion

haha... this is the reference impl for #golang of NIP-44

it is clearly doing something different to the javascript version, the HMAC comes out wrong , and when i make it skip the HMAC check it then says the padding is wrong, which is presumably the two parts of the function that are wrong (decrypt)

i'm literally going to have to look at another language version of this crazy scheme

honestly, i've never seen such a crappy piece of code, nor such an unclear specification as i have here... i suppose it's written in python too, fuck you all