Nibiru Chain: The breakthrough smart contract platform ushering in the next era of money. Nibiru powers an ecosystem of dApps including perps, RWAs, and more.
OUTPUT:
Address (expected): nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl
Address from the public key (wrong): nibi1nphvjvd47w2re37radm4d67vjg094jjrnrhwdl
Problem
While playing with the above I found a problem with GoSDK. Correct me if I'm wrong.` This private key has nothing to do with the address:
https://github.com/NibiruChain/nibiru/blob/main/gosdk/keys.go#L54
The actual private/public keys and address are produced within
GenerateSaveCoinKey()
Test script:
OUTPUT: Address (expected): nibi1zaavvzxez0elundtn32qnk9lkm8kmcsz44g7xl Address from the public key (wrong): nibi1nphvjvd47w2re37radm4d67vjg094jjrnrhwdl
keys.go privKey := secp256k1.GenPrivKeyFromSecret([]byte(secret))
Solution
Read the internals of the
GenerateSaveCoinKey
function and use that logic inside "nibiru/gosdk".