Skip to content
Cosmopediaby Unity Nodes
DiscussionsCosmos-SDKWhat is the difference among so many kinds of addresses?Forum ↗

What is the difference among so many kinds of addresses?

Cosmos-SDK8 posts2,866 views2 likesLast activity Oct 2018
FJ
fjchenOP
Jul 2018 2

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 [email protected]:26656

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?

JA
jack
Jul 2018

@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?

FJ
fjchen
Jul 2018

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?

FJ
fjchen
Jul 2018

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?

SV
svaishnavy
Oct 2018

@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?

VA
valardragon
Oct 2018

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.

SV
svaishnavy
Oct 2018

@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.

VA
valardragon
Oct 2018

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.

← Back to Discussions