What is the difference among so many kinds of addresses?


Freshman here to run full node.

There is one thing I am very confused: what is the difference among so many kinds of addressed?
There are

  • node id like def37d14d8f80dd97dbbbc4ac870cab0f4bd6bca
  • cosmosaddr like cosmosaccaddr1ay37rp2pc3kjarg7a322vu3sa8j9puahqavh2n
  • cosmosaccpub like cosmosaccpub1addwnpepqf69rcy6c4ltc6w49yvr05fhrjwlcmuvsqe57xuls0jrur0mm0dg20sghdm
  • cosmosvalpub like cosmosvalpub1zcjduepqszg0rpcqqn5x0psg5s09tg6euc4nh7anq5whknsmg5kfuzu2w6qqal76vz
  • value field in ~/.gaiad/config/genesis.json like tOEqjO2t51PEgO9Tv0B7qM0yPmy1n5tMa3Beg0tp3ns=
  • the address format in seeds setting in ~/.gaiad/config/config.toml like f00347e8ebddb28e14289a2d2bb42e5b0a78cc76@

There are in different formats. I wonder if they are encoded from just the same binary public key? Why Cosmos specifies some many types of addresses?


@fjchen Here is a document describing the account key format: https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/other/bech32.md

The address format in the seeds setting is <node_id>@<ip>:<port> fo those are the same.

I’m also not seeing a value field in ~/.gaiad/config/config.toml. Are you talking about the value fields in ~/.gaiad/config/priv_validator.json?


Sorry for my mistake. value field is in ~/.gaiad/config/genesis.json, under public_key field. It looks like a kind of expression for binary public key.
And what is the relationship between node id and public key? Go-amino or something?


Just read the spec in https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/other/bech32.md. Why they differentiate cosmosaccaddr and cosmosaccpub for the same account? Is the cosmosaccpub can be decoded into binary public key but cosmosaccaddr can’t?


@jack Is it possible to remove these prefixes or have custom prefixes for our projects when using cosmos-sdk?

Also, can I generate the usual cosmos address with cosmosaccaddr prefix for my wallet and later change the address to my own prefix? Is it just a matter of changing the prefix?


It is not possible at the moment. I just commented here: https://github.com/cosmos/cosmos-sdk/issues/1336 with a proposal for how to go about doing the change, feel free to take a stab at implementation.

You can’t just change the prefix, as the prefix is part of how the rest of it is encoded. Bech32 has error correction, which is a really nice property, and it makes use of the prefix as a part of that.


@valardragon thanks a lot for your response. I will checkout the other link. Is it possible to extract Public Key from just the Bech32 address? I notice a function (GetAccPubKeyBech32) in types/account.go which seems to indicate that it is possible. Just wanted to double check.


Bech32 is just an encoding. If your Bech32 a pubkey, then you can recover the pubkey from it. If you bech32 an address, then you can only recover the address. The name of the prefix is intended to indicate which it is.