title: How to generate hd wallet keys & addresses given seed phrase with cosmos sdk?
body: <p>I am trying to generate hd wallet private keys , public keys and addresess using cosmos sdk. Below is the equivalent implementation in python which generates the keys , address as expected but when trying to generated in <code>golang</code> using cosmos sdk it won't generate same keys. Any inputs for equivalent golang version of the python implementation is much appreciated. Thank you.</p>
  <blockquote>
  <p>Python</p>
  </blockquote>
  <pre><code>seed = Mnemonic.to_seed(&quot;blast about old claw current first paste risk involve victory edit current&quot;, passphrase=&quot;&quot;)
  print(&quot;Seed: &quot;, seed.hex())
  purpose = 44
  coinType = 118
  account = 0
  change = 0
  
  hdwallet = HDWallet()
  hdwallet.from_seed(seed=seed.hex())
  
  for addressIndex in range(1):
      hdwallet.clean_derivation()
      hdwallet.from_index(purpose, hardened=True)
      hdwallet.from_index(coinType, hardened=True)
      hdwallet.from_index(account, hardened=True)
      hdwallet.from_index(change)
      hdwallet.from_index(addressIndex, hardened=True)
  
      print(&quot;---&quot;)
      print(&quot;Derivation Path: &quot;, hdwallet.path())
      print(&quot;Private Key: &quot;, hdwallet.private_key())
      print(&quot;Public Key: &quot;, hdwallet.public_key())
  
      readdr_bytes = b&quot;\x04&quot; + bytearray.fromhex(hdwallet.public_key())
      readdr_bytes5 = bech32.convertbits(readdr_bytes, 8, 5)
      wallet_addr = bech32.bech32_encode(&quot;atom&quot;, readdr_bytes5)
      print(&quot;Wallet Address: &quot;, wallet_addr)
  </code></pre>
  <blockquote>
  <h1>OUTPUT</h1>
  <p>Derivation Path:  m/44'/118'/0'/0/0'
  Private Key:  69668f2378b43009b16b5c6eb5e405d9224ca2a326a65a17919e567105fa4e5a
  Public Key:  03de79435cbc8a799efc24cdce7d3b180fb014d5f19949fb8d61de3f21b9f6c1f8
  Wallet Address:  atom1qspau72rtj7g57v7lsjvmnna8vvqlvq56hcejj0m34sau0eph8mvr7qgl9avu</p>
  </blockquote>
  <blockquote>
  <p>GoLang ( Gernerating differnt keys )</p>
  </blockquote>
  <pre><code>import (
      &quot;github.com/tendermint/tendermint/crypto/secp256k1&quot;
      &quot;github.com/cosmos/cosmos-sdk/crypto/hd&quot;
      &quot;github.com/cosmos/go-bip39&quot;
      &quot;github.com/decred/dcrd/bech32&quot;
   )
  
  path := hd.BIP44Params{
      Purpose:      44,
      CoinType:     118,
      Account:      0,
      Change:       false,
      AddressIndex: 0,
  }
  
  seed := bip39.NewSeed(&quot;blast about old claw current first paste risk involve victory edit current&quot;,&quot;&quot;)
  
  master, ch := hd.ComputeMastersFromSeed(seed)
  priv, err := hd.DerivePrivateKeyForPath(master, ch, path.String())
  if err != nil {
      log.Fatal(err)
  }
  var privKey = secp256k1.GenPrivKeySecp256k1(priv)
  pubKey := privKey.PubKey()
  fmt.Println(hex.EncodeToString(pubKey.Bytes()))
  
  decodeString, _ := hex.DecodeString(fmt.Sprintf(&quot;04%x&quot;, pubKey.Bytes()))
  
  // Convert test data to base32:
  conv, err := bech32.ConvertBits(decodeString, 8, 5, true)
  if err != nil {
      fmt.Println(&quot;Error:&quot;, err)
  }
  encoded, err := bech32.Encode(&quot;atom&quot;, conv)
  if err != nil {
      fmt.Println(&quot;Error:&quot;, err)
  }
  
  // Show the encoded data.
  fmt.Println(&quot;Atom address:&quot;, encoded)
  </code></pre>
  <blockquote>
  <h1>OUTPUT</h1>
  <hr />
  <p>Derivation Path:  m/44'/1022'/0'/0/0'
  Private Key:  84925813eac8c1dc39f170e93b3bebe0bf961ac9c46507e858ce178a1a715c26
  Public Key:  0204a0bad86cafed2daf1b4080a3e908afcf524e2a9c24e20817920c478d537cc1
  Wallet Address:  atom1qsp3yaurlt463pl6pekgae4yudlcwk2dhxt93cxz5d5ymw3j8xmngaqef5j7p</p>
  </blockquote>