DEV Community

Cover image for Exploring The Main Concepts in the Cosmos SDK, Part 1 Accounts.
Mitchyugan
Mitchyugan

Posted on • Updated on

Exploring The Main Concepts in the Cosmos SDK, Part 1 Accounts.

Develop an understanding of the main concepts of the Cosmos SDK, from account to modules, keepers, queries, and protobuf in the interchain. Today we will be learning about accounts. Stay tuned for other concepts.

Accounts

An account is a pair of keys:

  • PubKey: a public key
  • PrivKey: a private key

A public key is a unique identifier for a user or entity that is safe to disclose. Private keys are sensitive information that users are required to manage confidentially. Private keys are used to sign information in a way that proves to others that a message was signed by someone using the private key corresponding to a given public key. This is done without revealing the private key itself.

Public key cryptography

Public key cryptography is also known as asymmetric cryptography and is a cryptographic system that employs pairs of keys. Every pair consists of a public and a private key. The security of the system is not endangered as long as the private key is not disclosed. Asymmetric cryptography do not require users to use a secure channel to exchange the keys for encryption and decryption, unlike symmetric cryptography.

Asymmetric cryptographic keys are usually very long. And this is good because: the longer the key, the more difficult it is to crack the code. To Break an asymmetric key an attacker would need to try every possible key to find a match.

Asymmetric keys always come in pairs and offer their owner various capabilities based on cryptographic mathematics. The public key is meant to be distributed to whoever is relevant, while the private key is to remain a secret. This is similar to your bank account number, but keeping the pin safe with you.

Asymmetric cryptography has two main implementations

  • Authentication: The public key serves as a verification tool for the private key pair.
  • Encryption: Only a private key can decrypt the information locked by the corresponding public key.

Sign and verify

Lets see an example of using private and public key to sign and verify.

Bob and Alice are having a conversation, Alice made a public announcement and Bob wants to verify it's indeed from Alice:

  • Alice gives Bob her public key.
  • Alice signs the announcement with her private key.
  • Bob receives the announcement sent by Alice along with it's signature.
  • Bob verifies the announcement using Alice public key.

Bob used Alice public key to verify if the private key used to sign that signature corresponds to Alice public key.

Private keys are used to prove that messages originate from the owners of accounts known by their public keys: the signatures prove that messages were signed by someone that knows the private key that corresponds to a given public key. This is the basis of user authentication in a blockchain, and why private keys are strictly guarded secrets.

Conclusion

Here is a wrap we've been able to go through Accounts, one main concepts of the cosmos SDK. Stay tuned for other Concepts coming shortly

Happy Learning!

Top comments (0)