waves_logo Docs
  • Обзор
    Обзор
  • Практические руководства
    • Получение данных из блокчейна
      Получение данных из блокчейна
    • Создание и отправка транзакций
      Создание и отправка транзакций
    • Токенизация
      Токенизация
    • Распространение токена (airdrop)
      Распространение токена (airdrop)
    • Прием платежей
      Прием платежей
    • Обмен токенов
      Обмен токенов
    • Простое голосование
      Простое голосование
    • Список как аргумент
      Список как аргумент
    Практические руководства
  • Смарт-контракты Waves
    Смарт-контракты Waves
  • dApp
    • Создание и запуск dApp
      Создание и запуск dApp
    dApp
  • Cмарт-аккаунт
    • Создание смарт-аккаунта
      Создание смарт-аккаунта
    • [en] Creating and deploying a script manually
      [en] Creating and deploying a script manually
    • [en] Video tutorials
      [en] Video tutorials
    Cмарт-аккаунт
  • Cмарт-ассет
    Cмарт-ассет
  • Инструменты разработчика
    • Waves IDE
      Waves IDE
    • Расширение для VS Code
      Расширение для VS Code
    • Surfboard
      Surfboard
    • Ride REPL
      Ride REPL
    Инструменты разработчика
  • Signer ◆
    Signer ◆
  • Waves API
    • Data Service API
      Data Service API
    • Node REST API 🡥
      Node REST API 🡥
    • Node gRPC Server 🡥
      Node gRPC Server 🡥
    • Blockchain Updates 🡥
      Blockchain Updates 🡥
    Waves API
  • Клиентские библиотеки
    • Waves C#
      • Установка SDK
        Установка SDK
      • Запуск кода
        • Отправка транзакций
          Отправка транзакций
        • Использование криптографических утилит
          Использование криптографических утилит
        • Взаимодействие с нодой
          Взаимодействие с нодой
        • Развертывание смарт-контрактов
          Развертывание смарт-контрактов
        Запуск кода
      Waves C#
    • Gowaves
      • Установка SDK
        Установка SDK
      • Запуск кода
        • Отправка транзакций
          Отправка транзакций
        • Использование криптографических утилит
          Использование криптографических утилит
        • Взаимодействие с нодой
          Взаимодействие с нодой
        • Развертывание смарт-контрактов
          Развертывание смарт-контрактов
        Запуск кода
      Gowaves
    • WavesJ
      • Установка SDK
        Установка SDK
      • Запуск кода
        • Отправка транзакций
          Отправка транзакций
        • Использование криптографических утилит
          Использование криптографических утилит
        • Взаимодействие с нодой
          Взаимодействие с нодой
        • Развертывание смарт-контрактов
          Развертывание смарт-контрактов
        Запуск кода
      WavesJ
    • Ts-lib-crypto & waves-transactions
      • Установка SDK
        Установка SDK
      • Запуск кода
        • Отправка транзакций
          Отправка транзакций
        • Использование криптографических утилит
          Использование криптографических утилит
        • Взаимодействие с нодой
          Взаимодействие с нодой
        • Развертывание смарт-контрактов
          Развертывание смарт-контрактов
        Запуск кода
      Ts-lib-crypto & waves-transactions
    • Waves-PHP
      • Установка SDK
        Установка SDK
      Waves-PHP
    • PyWaves-CE
      • Установка SDK
        Установка SDK
      • Запуск кода
        • Отправка транзакций
          Отправка транзакций
        • Использование криптографических утилит
          Использование криптографических утилит
        • Взаимодействие с нодой
          Взаимодействие с нодой
        • Развертывание смарт-контрактов
          Развертывание смарт-контрактов
        Запуск кода
      PyWaves-CE
    • Waves-rust
      • Установка SDK
        Установка SDK
      Waves-rust
    Клиентские библиотеки
      • English
      • Русский
      On this page
        • Private Key
        • Public Key
        • Address
      waves_logo Docs

          # Use Crypto Utilities

          You can work with the Private Key, Public Key, and Address methods.

          # Private Key

          You can create a private key from:

          • Seed phrase.
          • Randomly generated seed phrase.
          • Seed bytes.
          • Randomly generated seed bytes.
          • Bytes.
          • Encoded string.

          # Create Private Key from Seed Phrase

          // Necessary import.
          import { keyPair } from '@waves/ts-lib-crypto';
          
          // Specify your account's seed phrase.
          const seedPhrase: string = 'PASTE A SEED PHRASE';
          
          // Create the key pair, including the private and public keys.
          const accountKeyPair = keyPair(seedPhrase);
          
          // Print the private key.
          console.log("Sender's Private Key:", accountKeyPair.privateKey);
          

          # Generate Random Seed Phrase and Private Key

          // Necessary import.
          import { keyPair, randomSeed } from '@waves/ts-lib-crypto';
          
          // Generate a random seed phrase.
          const seedPhrase: string = randomSeed();
          
          // Create the key pair, including the private and public keys.
          const accountKeyPair = keyPair(seedPhrase);
          
          // Print the private key.
          console.log("Seed Phrase:", seedPhrase);
          console.log("Sender's Private Key:", accountKeyPair.privateKey);
          

          # Create Private Key from Seed Bytes

          // Necessary import.
          import { keyPair } from '@waves/ts-lib-crypto';
          
          // Create a byte array.
          const seedBytes: Uint8Array = Uint8Array.from(
            [1, 2, 3, 4, 5, 6, 7] // Array example.
          );
          
          // Convert the byte array to a string seed.
          const seedString: string = new TextDecoder().decode(seedBytes);
          
          // Create the key pair, including the private and public keys.
          const accountKeyPair = keyPair(seedString);
          
          // Print the private key.
          console.log("Sender's Private Key:", accountKeyPair.privateKey);
          

          # Create Private Key from Randomly Generated Seed Bytes

          // Necessary import.
          import { randomBytes, blake2b, keyPair } from '@waves/ts-lib-crypto';
          
          // Generate random seed bytes. 32 bytes by default.
          const randomSeedBytes: Uint8Array = randomBytes(32);
          
          // Derive the private key from the random seed bytes.
          const hashedSeed: Uint8Array = blake2b(randomSeedBytes);
          
          // Create the key pair from the hashed seed.
          const accountKeyPair = keyPair(hashedSeed);
          
          // Print the private key.
          console.log("Sender's Private Key:", accountKeyPair.privateKey);
          

          # Create Private Key from Bytes

          // Necessary import.
          import { keyPair } from '@waves/ts-lib-crypto';
          
          // Define the private key bytes.
          const privateKeyBytes: Uint8Array = Uint8Array.from([
            56, 253, 37, 64, 2, 38, 78, 37, 158, 211, 233, 117, 14, 88, 20, 42,
            247, 21, 55, 87, 117, 248, 175, 77, 77, 157, 169, 233, 7, 116, 157, 236
          ]); // Array example.
          
          // Create the key pair, including the private and public keys.
          const accountKeyPair = keyPair(privateKeyBytes);
          
          // Print the private key.
          console.log("Sender's Private Key:", accountKeyPair.privateKey);
          

          # Create Private Key from an Encoded String

          // Necessary import.
          import { base58Decode, keyPair } from '@waves/ts-lib-crypto';
          
          // Define the Base58-encoded private key string.
          const base58String: string = 'A5u9Ugt2nG1rWfLkL7pzZrtkP8LgF2rD3g1XBjsF8ZfV'; // Value example.
          
          // Decode the Base58 string to raw bytes.
          const privateKeyBytes: Uint8Array = base58Decode(base58String);
          
          // Create the key pair, including the private and public keys.
          const accountKeyPair = keyPair(privateKeyBytes);
          
          // Print the private key.
          console.log("Sender's Private Key:", accountKeyPair.privateKey);
          

          # Public Key

          You can create a public key from the seed's key pair:

          1. Generate the private key.
          2. Place the following code after the private key generation:
            // Generate the public key from the existing key pair.
            const publicKey: string = accountKeyPair.publicKey;
            
            // Print the public key.
            console.log("Sender's Public Key:", publicKey);
            

          # Address

          You can create an address from a public key:

          1. Generate the public key.

          2. Place the following code after the public key generation:

            NOTE: Ensure importing the following dependencies: import { address } from '@waves/ts-lib-crypto';

            // Necessary import.
            import { address } from '@waves/ts-lib-crypto';
            
            /*
             * Specify the network chain ID:
             * - 'W' for Mainnet.
             * - 'T' for Testnet.
             */
            const chainId: string = 'T'
            
            // Generate the address from the given public key and chain ID.
            const senderAddress = address(publicKey, chainId);
            
            // Print the address.
            console.log("Sender's Address:", senderAddress);
            
          Отправка транзакций
          Взаимодействие с нодой
          Отправка транзакций
          Взаимодействие с нодой