Oddbean new post about | logout
 I’ve been stuck on implementing NIP-44 for over a day, and stuck on getting the hmac_aad function to work. I’m using the pseudocode from the NIP-44 repo and the Kotlin code as a working base implementation to replicate it for Swift. Inputs are identical but outputs are different. I don’t get it. Cryptography is not my strong suit.

https://i.nostr.build/WGGze.png

https://i.nostr.build/POOYr.png 
 You can also look at the rust code if that helps: https://github.com/mikedilger/nip44

You need libs for base64, chacha20, hkdf, hmac, secp256k1 and sha256.  If you want to compare how the data changes from step to step to see which step is not working I'm happy to help with that. 
 I’m already using the secp256k1 library and the rest come for free from Apple with CryptoKit. I have all the code written and the unit tests pass for most of the base functions. It just doesn’t pass on the encrypt and decrypt tests because of the ciphertext being different in the hmac_aad function. I’ll compare with your Rust implementation and see how far I get. If I’m still stuck, I’ll preemptively commit it to GitHub to get more eyes on it. Thanks, Mike. 🙏🏼 
 I figured it out. Code coming soon. 
 We are about to implement this in Nos, so I have a vested interest in you succeeding haha. Let me know if you would like a second pair of eyes! Happy to hop on a call and be a rubber duck if that’s helpful.