Accounts and authentication

The same way as other blockchains and the crypto ecosystem overall, and account (or a wallet) in the ICON Blockchain is an instrument that allows users to store, manage and transfer assets on the ICON Network.

An account consists of a private key, a public key and an address.

  • Private keys on the ICON Network, just like in most other blockchain networks are a 32 bytes integer (64 characters long hexadecimal string).
  • Public keys are generated by applying the ECDSA (Elliptic Curve Digital Signature Algorithm) (opens in a new tab) to the private key, this results in a 64 bytes integer (128 characters long hexadecimal string).
  • An address is generated by applying the SHA3-256 hashing algorithm to the public key and taking the last 20 bytes (40 hexadecimal characters) and adding “hx” to the beginning.

Here is an example.

  • Private key => 1111111111111111111111111111111111111111111111111111111111111111
  • Public key => 4f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa385b6b1b8ead809ca67454d9683fcf2ba03456d6fe2c4abe2b07f0fbdbb2f1c1
  • Wallet address => hx396031be52ec56955bd7bf15eacdfa1a1c1fe19e

To showcase in more detail how this process is executed we are going to be creating private keys and generating the respective public keys and addresses using different methods like the goloop CLI, Javascript (nodejs), and the icon-sdk-js.

After creating the private keys we will be describing how to generate a signature for an RPC call and sending the RPC JSON call to a node.

Setting up the project folder.

The following instructions will allow you to setup the working folders depending on which method you will use, one instruction is for the case of using the goloop CLI and the other is for the case of using pure Javascript with nodejs or using the `icon-sdk-js` with nodejs.

Prerequisites when using goloop CLI

ℹ️

Complete the following steps to install the goloop CLI

Prerequisites when using nodejs

To start, let's create a folder called icon-wallet-test inside our home folder.

$ cd ~
$ mkdir icon-wallet-test
$ cd icon-wallet-test

Initialize an NPM project:

~/icon-wallet-test$ npm init -y
Wrote to /home/user/icon-wallet-test/package.json:
 
{
  "name": "icon-wallet-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
       "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

Create a file called main.js.

$ touch main.js

Edit the package.json file and add a command to run the script.

{
  "name": "icon-wallet-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
      "test": "echo \'Error: no test specified\' && exit 1",
      “start”: “node main.js”
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

Install the required nodejs packages to cryptographically generate the keys.

npm install --save-dev secp256k1 js-sha3 icon-sdk-js
CTRL + M