I want to generate a bip32 private root key based on bip39 seed. I found an article with python code, copied it to myself and executed it, getting a valid private root key (checked here). Then I wrote a similar script on golang, inserted the seed from the python example into it, and after executing it, I got the wrong root key. The set of bytes, which is then encoded by base58 to obtain the root key, coincided in both scripts, but the result of base58 encoding was different.

Python example:

root_key = base58.b58encode_check(all_bytes).decode('utf8')

Python output:


Golang example:

rootKey := base58.CheckEncode(buffer.Bytes(), 0)

Golang output:


As you can see, the bytes that are used for encoding are the same here and there, but the result is different. I tried using another golang module to generate a base58 string, but it generates an error for this seed :/ Maybe someone has encountered something similar and knows how to generate the correct base58 strings in golang

1 Answer 1


Your problem might come from the base58.CheckEncode function, try using a different Golang library like this one github.com/btcsuite/btcutil/base58 and below is how to use it in your code

package main

import (


func main() {
    allBytes := []byte{...} // Your bytes here

    rootKey := base58.Encode(allBytes)
  • I tried this module, but the result on a similar set of bytes was quite strange: 9Xoy2u8vevhdokmLKtGXvGcDTHpSQV2DdjbpRe9a7vRGmByeQbE1YvZDpA8ZNfNNdqiyZ3ycaZ8E6pJeseYjvSgvZCMgLRb82bMrmr6G3P
    – Mod diller
    Apr 16, 2023 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.