waves_logo Docs
  • Overview
    Overview
  • How-to Guides
    • Reading Blockchain Data
      Reading Blockchain Data
    • Creating & Broadcasting Transactions
      Creating & Broadcasting Transactions
    • Tokenization
      Tokenization
    • Airdrop
      Airdrop
    • Payments
      Payments
    • Exchange Tokens
      Exchange Tokens
    • Simple Voting
      Simple Voting
    • List as argument
      List as argument
    How-to Guides
  • Waves Smart Contracts
    Waves Smart Contracts
  • dApp
    • Creating & Launching dApp
      Creating & Launching dApp
    dApp
  • Smart Account
    • Creating smart account
      Creating smart account
    • Creating and deploying a script manually
      Creating and deploying a script manually
    • Video tutorials
      • Introduction to the Waves blockchain, Waves Smart Accounts and Waves Smart Assets
        Introduction to the Waves blockchain, Waves Smart Accounts and Waves Smart Assets
      • Waves Smart Account with multisignature
        Waves Smart Account with multisignature
      • Waves Smart Account with escrow service
        Waves Smart Account with escrow service
      • Creating multisignature account via Waves IDE tools
        Creating multisignature account via Waves IDE tools
      • Creating multisignature account via Waves Client
        Creating multisignature account via Waves Client
      • Waves console explained
        Waves console explained
      Video tutorials
    Smart Account
  • Smart Asset
    Smart Asset
  • Developer Tools
    • Waves IDE
      Waves IDE
    • Visual Studio Code Extension
      Visual Studio Code Extension
    • Surfboard
      Surfboard
    • Ride REPL
      Ride REPL
    Developer Tools
  • 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
  • Client Libraries
    • Waves C#
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Waves C#
    • Gowaves
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Gowaves
    • WavesJ
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      WavesJ
    • Ts-lib-crypto & waves-transactions
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Ts-lib-crypto & waves-transactions
    • Waves-PHP
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      Waves-PHP
    • PyWaves-CE
      • Install SDK
        Install SDK
      • Run Code Sample
        • Send Transactions
          Send Transactions
        • Use Crypto Utilities
          Use Crypto Utilities
        • Interact With Node
          Interact With Node
        • Set Up Smart Contracts
          Set Up Smart Contracts
        Run Code Sample
      PyWaves-CE
    • Waves-rust
      • Install SDK
        Install SDK
      Waves-rust
    Client Libraries
      • 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

          NOTE: The SDK makes private keys clamped—bit-adjusted to ensure validity and resistance to small subgroup attacks.

          You can create a private key from:

          • Seed phrase.
          • Randomly generated seed phrase.
          • Randomly generated seed phrase with nonce 2.
          • Seed bytes.
          • Randomly generated seed bytes.
          • Bytes.
          • Encoded string.

          # Create Private Key from Seed Phrase

          <?php
          
          require_once __DIR__ . '/vendor/autoload.php';
          
          // Necessary imports.
          use Waves\Account\PrivateKey;
          use Waves\Model\ChainId;
          use Waves\Model\WavesConfig;
          
          // Hide deprecated warnings temporarily.
          error_reporting(E_ALL & ~E_DEPRECATED);
          
          /* 
           * Specify the network chain ID:
           * - Mainnet:  `ChainId::MAINNET()`
           * - Testnet:  `ChainId::TESTNET()`
           * - Stagenet: `ChainId::STAGENET()`
           */
          WavesConfig::chainId(ChainId::TESTNET());
          
          // Specify your seed phrase.
          $seed = 'PASTE YOUR SEED PHRASE';
          
          // Get the private key from the given seed phrase.
          $account = PrivateKey::fromSeed($seed);
          $privateKey = $account->toString();
          
          // Print the results.
          echo "Seed Phrase: $privateKey\n";
          echo "Sender's Private Key: $seed\n";
          

          # Generate Random Seed Phrase and Private Key

          <?php
          
          require_once __DIR__ . '/vendor/autoload.php';
          
          // Necessary imports.
          use Waves\Account\PrivateKey;
          use Waves\Util\Functions;
          use Waves\Model\ChainId;
          use Waves\Model\WavesConfig;
          
          // Hide deprecated warnings temporarily.
          error_reporting(E_ALL & ~E_DEPRECATED);
          
          /* 
           * Specify the network chain ID:
           * - Mainnet:  `ChainId::MAINNET()`
           * - Testnet:  `ChainId::TESTNET()`
           * - Stagenet: `ChainId::STAGENET()`
           */
          WavesConfig::chainId(ChainId::TESTNET());
          
          // Generation of a random seed phrase.
          $seed = Functions::getRandomSeedPhrase();
          
          // Get the private key from the given seed phrase.
          $account = PrivateKey::fromSeed($seed);
          $privateKey = $account->toString();
          
          // Print the results.
          echo "Seed Phrase: $seed\n";
          echo "Sender's Private Key: $privateKey\n";
          

          # Generate Random Seed Phrase with Nonce 2

          <?php
          
          require_once __DIR__ . '/vendor/autoload.php';
          
          // Necessary imports.
          use Waves\Account\PrivateKey;
          use Waves\Util\Functions;
          use Waves\Model\ChainId;
          use Waves\Model\WavesConfig;
          
          // Hide deprecated warnings temporarily.
          error_reporting(E_ALL & ~E_DEPRECATED);
          
          /* 
           * Specify the network chain ID:
           * - Mainnet:  `ChainId::MAINNET()`
           * - Testnet:  `ChainId::TESTNET()`
           * - Stagenet: `ChainId::STAGENET()`
           */
          WavesConfig::chainId(ChainId::TESTNET());
          
          // Generation of a random seed phrase.
          $seed = Functions::getRandomSeedPhrase();
          
          // Get the private key from the given seed phrase, using nonce = 2.
          $account = PrivateKey::fromSeed($seed, 2);
          $privateKey = $account->toString();
          
          // Print the results.
          echo "Seed Phrase: $seed\n";
          echo "Sender's Private Key (nonce 2): $privateKey\n";
          

          # Create Private Key from Seed Bytes

          <?php
          
          require_once __DIR__ . '/vendor/autoload.php';
          
          // Necessary imports.
          use Waves\Account\PrivateKey;
          use Waves\Model\ChainId;
          use Waves\Model\WavesConfig;
          
          // Hide deprecated warnings temporarily.
          error_reporting(E_ALL & ~E_DEPRECATED);
          
          /* 
           * Specify the network chain ID:
           * - Mainnet:  `ChainId::MAINNET()`
           * - Testnet:  `ChainId::TESTNET()`
           * - Stagenet: `ChainId::STAGENET()`
           */
          WavesConfig::chainId(ChainId::TESTNET());
          
          // Creation of a byte array.
          $seedBytes = pack('C*', 1, 2, 3, 4, 5, 6, 7); // Array example.
          
          // Creation of the private key from the seed bytes.
          $account = PrivateKey::fromSeed($seedBytes);
          $privateKey = $account->toString();
          
          // Print the results.
          echo "Sender's Private Key: $privateKey\n";
          

          # Create Private Key from Randomly Generated Seed Bytes

          <?php
          
          require_once __DIR__ . '/vendor/autoload.php';
          
          // Necessary imports.
          use Waves\Account\PrivateKey;
          use Waves\Util\Functions;
          use Waves\Model\ChainId;
          use Waves\Model\WavesConfig;
          
          // Hide deprecated warnings temporarily.
          error_reporting(E_ALL & ~E_DEPRECATED);
          
          /* 
           * Specify the network chain ID:
           * - Mainnet:  `ChainId::MAINNET()`
           * - Testnet:  `ChainId::TESTNET()`
           * - Stagenet: `ChainId::STAGENET()`
           */
          WavesConfig::chainId(ChainId::TESTNET());
          
          // Generation of random seed bytes that are 32 bytes long.
          $randomSeedBytes = random_bytes(32);
          
          // Creation of the private key from the randomly generated seed bytes.
          $account = PrivateKey::fromSeed($randomSeedBytes);
          $privateKey = $account->toString();
          
          // Print the results.
          echo "Sender's Private Key: $privateKey\n";
          

          # Create Private Key from Bytes

          <?php
          
          require_once __DIR__ . '/vendor/autoload.php';
          
          // Necessary imports.
          use Waves\Account\PrivateKey;
          use Waves\Model\ChainId;
          use Waves\Model\WavesConfig;
          
          // Hide deprecated warnings temporarily.
          error_reporting(E_ALL & ~E_DEPRECATED);
          
          /* 
           * Specify the network chain ID:
           * - Mainnet:  `ChainId::MAINNET()`
           * - Testnet:  `ChainId::TESTNET()`
           * - Stagenet: `ChainId::STAGENET()`
           */
          WavesConfig::chainId(ChainId::TESTNET());
          
          // Creation of a byte array.
          $bytes = pack('c*', 56, -3, 37, 64, 2, 38, 78, 37, -98, -45, -23, 117, 14, 88, 20, 42, -9, 21, 55, 87, 117, -8, -81, 77, 77, -99, -87, -23, 7, 116, -99, -20); // Array example.
          
          // Creation of the private key from the byte array.
          $account = PrivateKey::fromSeed($bytes);
          $privateKey = $account->toString();
          
          // Print the results.
          echo "Sender's Private Key: $privateKey\n";
          

          # Create Private Key from an Encoded String

          <?php
          
          require_once __DIR__ . '/vendor/autoload.php';
          
          // Necessary imports.
          use Waves\Account\PrivateKey;
          use Waves\Util\Functions;
          use Waves\Model\ChainId;
          use Waves\Model\WavesConfig;
          
          // Hide deprecated warnings temporarily.
          error_reporting(E_ALL & ~E_DEPRECATED);
          
          /* 
           * Specify the network chain ID:
           * - Mainnet:  `ChainId::MAINNET()`
           * - Testnet:  `ChainId::TESTNET()`
           * - Stagenet: `ChainId::STAGENET()`
           */
          WavesConfig::chainId(ChainId::TESTNET());
          
          // Creation of a Base58 string.
          $base58String = "A5u9Ugt2nG1rWfLkL7pzZrtkP8LgF2rD3g1XBjsF8ZzV"; // Value example.
          
          // Decode the Base58 string to raw bytes.
          $decodedBytes = Functions::base58Decode($base58String);
          
          // Creation of the private key from the decoded bytes.
          $account = PrivateKey::fromSeed($decodedBytes);
          $privateKey = $account->toString();
          
          // Print the output.
          echo "Sender's Private Key: $privateKey\n";
          

          # Public Key

          You can create a public key from a private key:

          1. Generate the private key.
          2. Place the following code after the private key generation:
            // Create the public key from the private key.
            $publicKey = $account->publicKey()->toString();
            
            // Print the results.
            echo "Sender's Public Key:  $publicKey\n";
            

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

            // Create the address from the public key.
            $address = $account->publicKey()->address()->toString();
            
            // Print the results.
            echo "Sender's Address: $address\n";
            
          Send Transactions
          Interact With Node
          Send Transactions
          Interact With Node