LogoLogo
WalletsEcosystemStart BuildingJoin the Community
  • Welcome to IoTeX 2.0
    • 💡Why IoTeX
    • 🪙Tokenomics
      • IOTX Utility in IoTeX 2.0
      • IOTX Emission, Deflation, and Re-Staking
    • 📖Whitepaper
    • ⚡Get Started
  • DePIN Infra Modules (DIM)
    • DIMs Overview
    • [IoTeX L1] DePIN Blockchain
      • Core Concepts
        • Consensus Mechanism
        • Voters and Delegates
        • Ethereum Virtual Machine
        • Accounts & Identities
        • Blockchain Actions
        • ERC20 and NFT Tokens
        • Smart Contracts
        • Interoperability
        • Governance
      • The IOTX Token
        • IOTX Token Exchange Support
        • Different Formats of the IOTX Token
        • IOTX Token Contracts
      • Wallets
        • Supported Wallet Apps
          • ioPay Mobile
          • IoTeX Web Wallet
          • OKX Wallet
          • Rabby Wallet
          • Metamask Desktop
          • Ledger Nano S & X
            • Use Ledger with Metamask
            • Use Ledger with Rabby Walet
            • Use Ledger with IoTeX Hub Portal
            • Migrate to the Ethereum Ledger App
          • IoTeX Desktop Wallet
          • 👩‍💻IoTeX HD Derivation Path
        • Buy IOTX Tokens
        • Execute Transactions
          • Transfer IOTX Tokens
          • Transfer ERC20 Tokens
          • Interact with Dapps
          • Explore transactions
        • Migrate Assets to a different wallet
      • Staking & Governance
        • About IoTeX Staking
        • IoTeX Staking Guide
          • Native staking
          • Staking as NFT
        • Join the Governance
          • Marshall DAO
          • Improvement Proposals
      • Exchange Integration
      • 👨‍💻Deploy Dapps on IoTeX
    • [ioID] DePIN Identities
      • ioID Specification
      • Overview of ioID
      • Registering Identities
      • 👩‍💻Integration Guide
        • Register a DePIN Project
        • Bind your Device NFT
        • Reserve Device ioIDs
        • Query Project Status
        • Register a Device
        • ioID Smart contracts quick reference
    • [W3bstream] DePIN Verification
      • Overview of W3bstream
      • Multi-Prover Architecture
      • 👨‍💻Build with W3bstream
        • Get Started
          • Sequencer Options
        • Build the Prover Code
          • Risc Zero
          • Halo2
          • zkWASM
        • Deploy to W3bstream
          • Create the Project File
          • W3bstream Outputs
          • Deploying Projects
          • Interacting with Projects
        • On-chain integration
          • Verify Risc0 Proofs
          • Verify Halo2 Proofs
          • Verify zkWASM profs
        • Sending Messages
      • 👩‍💻Node Operators
        • Configure a ZK Prover Node
        • Register your Node
    • [ioID-SDK] Hardware SDK
      • ioID-SDK Overview
      • Layered Architecture
      • Compatibility
      • Current Development Status
    • [MSP] Modular Security Pool
    • Third-Party DIMs
      • Data Sequencer Infras
      • Data Availability Infras
      • 👨‍💻W3bstream Tasks
  • Ecosystem
    • Assets on IoTeX
      • Mainstream Assets
      • IOTX and Derivatives
      • DePIN Tokens
      • MEME Coins
    • iotube Bridge
    • iotexscan Explorer
    • Ecosystem Apps
      • DePINScan
      • mimo DEX
      • ecosystem.iotex.io
    • "Powered by IoTeX" Devices
      • Pebble Tracker
        • Quick Start
        • Device Registration
        • Online Firmware Update
        • USB Firmware Update
        • Migrating to Pebble v2.0
          • 1.0 Device Registration
        • Tech Specs
        • Network Selection
        • Pebble Configuration
        • Query Pebble Data
        • Troubleshooting
        • Firmware Development
          • Hardware Setup
          • Build the Firmware
          • Flash the firmware
      • SenseCAP Indicator
      • UCam Home Camera
  • Builders
    • IoTeX Developer Portal
    • Dev Chat on Discord
    • Web3 Development
      • RPC Endpoints
      • Set up your Environment
      • Get Testnet IOTX Tokens
      • ioctl CLI
        • Installation
        • Create Accounts
        • Blockchain interaction
          • ioctl command reference
      • Chain Indexing
        • The Graph
        • SubQuery
        • IoTeX Analytics API
      • IoTeXscan API
      • Deterministic Deployment
      • Account Abstraction
        • Components of AA
        • 👩‍💻Creating new Accounts
        • 👨‍💻P256Account Example
      • Blob Transactions (EIP-4844)
      • Multicall3
      • EVM Precompiled Contracts
    • Building DePINs
      • ioID Step by Step Tutorial
        • Integrate ioID in the Device Firmware
        • Integrate ioID in your cloud
      • Decentralized WiFi Connectivity (DeWi)
        • Project Specification
        • The choice of Hardware
        • The Data API Service
        • DePIN Incentives Contract
    • Building DeFi
      • Deploy Tokens
        • Deploy an ERC20 Token
        • Deploy an NFT Token
      • Price Oracles
        • Chainlink Relayer
        • SupraOracles
      • Integrate IoTeX Staking
      • Liquid staking Dapps
    • Launch Dapps on IoTeX
      • Submit Tokens to the IoTeX Ecosystem
      • Submit tokens to the iotube bridge
      • Verify Smart Contracts
      • Audit your Contracts
      • Submit your Dapp to Portals
      • Useful tools
    • Node Operators
      • Fastblocks (Node as a Service)
      • Setup an IoTeX RPC Node
      • Run a Delegate Node
      • Rosetta API
    • Reference Docs
      • ioctl client
        • Accounts
        • HD Wallets
        • Aliases
        • Actions
        • Queries
        • Smart Contracts
        • Staking & Voting
        • Tokens
        • ioID Identities
        • W3bstream
        • Decentralized Identifiers (DID)
        • JWT Auth Tokens
      • Native IoTeX Development
        • IoTeX gRPC API
        • Account Cryptography
        • Address Conversion
        • Create Accounts
        • Estimate Gas Price
        • Make IOTX Transfers
        • Manage ERC20 Tokens
        • Smart Contract Interactions
        • ioPay Desktop
        • DID JWT Tokens
        • Calling any RPC method
      • Embedded Blockchain Clients
        • Arduino IDE
        • Linux Systems
        • PlatformIO
        • Examples
        • Tutorials
  • Participate
    • Crypto's Got Talent (CGT)
      • IoTeX x Polygon DePIN Grant
    • Governance
      • IoTeX Improvement Proposals
      • The Marshall DAO
    • Join the Community
    • Get in Touch
Powered by GitBook
LogoLogo

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.

  • .

2025 | IoTeX

On this page
  • Overview
  • Private Key
  • Native Address Construction
  • Address Conversion Examples
  • Convert from io1 to 0x format
  • Convert from 0x to io1 format

Was this helpful?

Export as PDF
  1. Builders
  2. Reference Docs
  3. Native IoTeX Development

Account Cryptography

PreviousIoTeX gRPC APINextAddress Conversion

Last updated 6 months ago

Was this helpful?

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.

Overview

Here are the key components of IoTeX's account cryptography:

  1. 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...").

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

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

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

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

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

  7. Secure Key Storage:

    • Hardware wallets and other secure storage solutions use additional cryptographic techniques to protect private keys from being compromised.

Private Key

In IoTeX, the account Private Key is generated as 64 random hex characters, e.g.:

90bf89cd944df5c6d8281b132783277c1760537809c534fc54dda34c4edfb4f4

and the corresponding Public Key is derived from the private key using ECDSA with the secp256k1 curve, which is the same as Ethereum.

Native Address Construction

An IoTeX native representation of an account address looks like:

io1nyjs526mnqcsx4twa7nptkg08eclsw5c2dywp4

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

privKey =
0700898c9dcae0279c88318003ee210e1ee2514121d292d2f03739498ce95f4e

2. Calculate the corresponding public key using secp256k1 elliptic curve

pubKey := keccak256k1(privKey) = 046748ee7f4b573f1fb17517005499003385da75788b2052b18bbb05fd0dcf50597ffc54a22a02ca7343ed2654212022c1f4a0c3755dbdb81a2e70c7c0805520dc

3. Apply keccak256 hash function to the public key, excluding the first byte:

hash := keccak256(pubKey[1:]) = 42a1c0796606183ccdb3d935147e805c858840099190e208d7a04a74f2a0aac8

4. Take the last 20 bytes of the hash

payload := hash[12:] = 147e805c858840099190e208d7a04a74f2a0aac8

which is the "byte representation" of the address

5. Convert the byte representation to 5-bit encoding (base32):

2, 17, 31, 8, 0, 23, 4, 5, 17, 1, 0, 0, 19, 4, 12, 16, 28, 8, 4, 13, 15, 8, 2, 10, 14, 19, 25, 10, 1, 10, 22, 8
address := io1bc1qz3lgqhy93pqqnyvsugyd0gz2wne2p2kght0g4r

Address Conversion Examples

Convert from io1 to 0x format

const { bech32 } = require('bech32');

// Function to decode IoTeX address to Ethereum address
const ioToEthAddress = (ioAddress) => {
  // Step 1: Decode the Bech32 IoTeX address
  const decoded = bech32.decode(ioAddress);
  
  // Step 2: Convert 5-bit words back to bytes
  const words = bech32.fromWords(decoded.words);

  // Step 3: Slice the last 20 bytes (Ethereum address is 20 bytes)
  const ethAddressBytes = Buffer.from(words).slice(-20);

  // Step 4: Convert to Ethereum-style hex address
  const ethAddress = ethAddressBytes.toString('hex');
  return `0x${ethAddress}`;
};

// Test the function
const ioAddress = 'io12etkzmykk4mnavvqjgcrprnzhq8zxahqr698nl'; // Replace with IoTeX address
console.log(`Ethereum Address: ${ioToEthAddress(ioAddress)}`);

Convert from 0x to io1 format

const { bech32 } = require('bech32');

// Function to convert Ethereum address to IoTeX address
const ethToIoAddress = (ethAddress) => {
  // Step 1: Remove the '0x' prefix and convert the hex string to a byte array
  const ethAddressBytes = Buffer.from(ethAddress.slice(2), 'hex');

  // Step 2: Convert the byte array into 5-bit words for Bech32 encoding
  const words = bech32.toWords(ethAddressBytes);

  // Step 3: Encode the words into a Bech32 IoTeX address with the 'io' prefix
  const ioAddress = bech32.encode('io', words);
  return ioAddress;
};

// Test the function
const ethAddress = '0x5657616c96b5773eb1809230308e62b80e2376e0'; // Replace with your Ethereum address
console.log(`IoTeX Address: ${ethToIoAddress(ethAddress)}`);

Given 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:

Ecrecover
solidity
5-bit conversion
nodejs
bech32
bech32 encoding
nodejs
Go
Typescript
Java
-> Learn here how to construct the IoTeX address in native format