Account Cryptography
Last updated
Last updated
This documentation portal is currently undergoing updates to align with the IoTeX 2.0 Whitepaper release. Information provided here may be incomplete, or out-of-date. Please use this portal for preliminary reference only, and check out the official IoTeX 2.0 Whitepaper for updated information.
.2024 | IoTeX
IoTeX uses cryptographic techniques to secure its accounts and ensure the integrity and authenticity of transactions. Specifically, IoTeX account generation and digital signature are based on the same cryptographic schemes as Ethereum.
Here are the key components of IoTeX's account cryptography:
Elliptic Curve Digital Signature Algorithm (ECDSA):
Private Key: IoTeX accounts are secured using private keys, which are 256-bit random numbers. The private key is known only to the account owner and is used to sign transactions.
Public Key: The public key is derived from the private key using the secp256k1 elliptic curve. The public key is then used to generate the IoTeX address, which can be both in the format of an Ethereum address (starting with "0x...") or a native IoTeX address (starting with "io1...").
IoTeX Address:
The IoTeX address can be generated like an Ethereum address, derived from the public key by taking the last 20 bytes of the Keccak-256 hash of the public key. This address is a unique identifier for the account on the IoTeX network.
Keccak-256 Hash Function:
IoTeX uses the Keccak-256 cryptographic hash function (often referred to as SHA-3) for various purposes, including generating addresses from public keys and ensuring data integrity.
Digital Signatures:
Transactions in IoTeX are signed with the account's private key using ECDSA. The digital signature ensures that the transaction was created by the account owner and has not been altered. Nodes in the network can verify the signature using the corresponding public key.
Nonce:
Each account has a nonce, which is a counter that keeps track of the number of transactions sent from the account. The nonce prevents replay attacks by ensuring that each transaction can only be processed once.
Account Encryption:
While not a part of the core protocol, encryption is often used to protect private keys. Wallets and other storage solutions typically encrypt private keys to prevent unauthorized access.
Secure Key Storage:
Hardware wallets and other secure storage solutions use additional cryptographic techniques to protect private keys from being compromised.
In IoTeX, the account Private Key is generated as 64 random hex characters, e.g.:
and the corresponding Public Key is derived from the private key using ECDSA with the secp256k1 curve, which is the same as Ethereum.
An IoTeX native representation of an account address looks like:
and it can be constructed starting from the private key using the following steps:
1. Generate a random private key as 64 random hex characters
2. Calculate the corresponding public key using secp256k1 elliptic curve
3. Apply keccak256
hash function to the public key, excluding the first byte:
4. Take the last 20 bytes of the hash
which is the "byte representation" of the address
5. Convert the byte representation to 5-bit encoding (base32):
io1
to 0x
format0x
to io1
formatGiven a signed message, you can recover the public key of the signing account using , also defined in for signature verification in smart contracts.
See a go lang implementation for the implementation or a package (use toWords()
to convert a bytes array into 5-bit words).
6. Apply the encoding on the 5-bit payload with the io
prefix to obtain the address:
See a go lang implementation for the implementation or a package (use encode
to encode 5-bit words with a prefix).
Developers can refer to the iotex-address library ( | | ) to learn how IoTeX native addresses are created and converted between 0x and io1 formats. Below, you will also find two brief examples: