Public-Private key pairs and how they work in the blockchain realm


If you are new to crypto, you must be wondering about what are public and private keys.

NEAR protocol, as well as all other major cryptocurrencies, is built upon public-key cryptography, a cryptographic system that uses pairs of keys: public keys and private keys to authenticate transactions on the blockchain — send or receive funds.

Public keys can be described as an email address. You openly share your email address so that your friends or families can send you emails (or messages). Similarly, public keys can be shared with everyone. So to send a transaction (or fund), one first should know the public key of the other user.

Each public key comes paired with a unique private key. The private key gives the user a ‘write-access’ — meaning ownership of the funds on a given address and must remain known only to the user (or owner). The private key is akin to the password of your email account, that only you have a copy (or knowledge). Anyone who learns the associated password has access to the account and may misuse it. Therefore, this information should not be shared with anyone and stored secretly.

Use of Public-Private keys:

As explained above, the most common use of these key-pairs is to securely send or receive funds. Other than that, it allows users access to decentralized applications. Like in real-world applications (web2), we use Gmail to auto-login to Web2 applications, similarly, these key pairs help to interact with smart contracts of decentralized applications.

Other advance use of Public-Private keys:

  • For data encryption purposes. Using these keys users can share cryptographic messages with each other. Let’s say, Bob wants to send Alice an encrypted email. To do this, Bob encrypts his message with Alice’s public key. Then, when Alice receives the message, she takes the private key that is known only to her to decrypt the message from Bob.
  • Use as a digital signature to bind a person to the digital data. i.e. provide verification that the message was created by a known person and the message was intact and not altered in transit. In the NEAR protocol, validators sign with their key to show authenticity or their agreements on the block produced.

Customizable experience in NEAR wallets:

The public and private keys consist of a string of random numbers. It looks something like this: ed255192o4A5yaoxg1zvpGCrh9LaEUFVTZCht1PsXNacyMbot7i.

Not as easy as remembering your Gmail account ID and security password. Given the complexity to remember crypto key-pairs, users need to store it somewhere safe. If a user loses them, especially private-key, they lose access to funds in the account. This can be a barrier to user adoption, especially for non-tech-savvy individuals.

NEAR wallet allows users to create a customizable experience. When creating an account through the NEAR Wallet, users can define the account name like creating an email account. These human-readable accounts end in ‘.near’. For e.g. ashkharoo.near

To make private keys user-friendly, similar to other blockchains, the NEAR protocol uses mnemonic keys. Mnemonic keys are a human-readable version of the private keys.

Mnemonic is a way to reproduce something hard to remember. To a series of data like private keys, random words are associated so as users can remember the original form. Remember the phrase — ‘Some People Have Curly Brown Hair Turn Permanently Black’ from your school days. It’s a mnemonic form to remember Sin, Cos, and Tan trigonometric formulas.

NEAR wallets use 12-word mnemonic seeds that are tied to a given private key. This conversion is done through the method called BIP 39. BIP 39 is an English wordlist that contains 2048 words.

Closing thoughts:

The onboarding process is a user’s first impression of the application. If users don’t understand your app, they won’t use it. Studies show that 60% of users say they have chosen not to use the app after discovering how much information the app asked for. Blockchain apps have a complex onboarding process. One has to make an effort to know the wallet, public/ private key, etc.

With the NEAR wallet, users login to NEAR-based decentralized applications seamlessly. The customizable experience from NEAR wallets increases the chances of apps usability and the likelihood of successful user adoption.

Also, Read

Public-Private key pairs and how they work in the blockchain realm was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.