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
      • Install SDK
        Install SDK
      Ts-lib-crypto
    • Waves-PHP
      • Install SDK
        Install SDK
      Waves-PHP
    • PyWaves-CE
      • Install SDK
        Install SDK
      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, or Address methods.

          # Private Key

          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

          package com.example;
          
          // Necessary import.
          import com.wavesplatform.transactions.account.PrivateKey;
          
          public class CreatePrivateKeyFromSeedPhrase {
              public static void main(String[] args) {
          		// Specify your account's seed phrase.
                  String seedPhrase = "PASTE A SEED PHRASE";
          
          		// Creation of the private key from the seed phrase.
                  PrivateKey accountPrivateKey = PrivateKey.fromSeed(seedPhrase);
          
          		// Print the output.
                  System.out.println("Sender's Private Key: " + accountPrivateKey);
              }
          }
          

          # Generate Random Seed Phrase and Private Key

          package com.example;
          
          // Necessary imports.
          import com.wavesplatform.crypto.Crypto;
          import com.wavesplatform.transactions.account.PrivateKey;
          
          public class GenerateRandomPrivateKey {
              public static void main(String[] args) {
          		// Generaton of a random seed phrase.
                  String seed = Crypto.getRandomSeedPhrase();
          
          		// Creation of the private key from the seed phrase.
                  PrivateKey senderPrivateKey = PrivateKey.fromSeed(seed);
          
          		// Print the output.
                  System.out.println("Seed Phrase: " + seed);
                  System.out.println("Sender's Private Key: " + senderPrivateKey);
              }
          }
          

          # Generate Random Seed Phrase with Nonce 2

          package com.example;
          
          // Necessary imports.
          import com.wavesplatform.crypto.Crypto;
          import com.wavesplatform.transactions.account.PrivateKey;
          
          public class GeneratePrivateKeyWithNonce2 {
              public static void main(String[] args) {
          		// Generaton of a random seed phrase.
                  String seed = Crypto.getRandomSeedPhrase();
          
          		// Creation of the private key from the seed phrase, with the nonce equal to 2.
                  PrivateKey senderPrivateKey = PrivateKey.fromSeed(seed, 2);
          
          		// Print the output.
                  System.out.println("Seed Phrase: " + seed);
                  System.out.println("Sender's Private Key: " + senderPrivateKey);
              }
          }
          

          # Create Private Key from Seed Bytes

          package com.example;
          
          // Necessary import.
          import com.wavesplatform.transactions.account.PrivateKey;
          
          public class CreatePrivateKeyFromSeedBytes {
              public static void main(String[] args) {
          		// Creation of a byte array.
                  byte[] seed = new byte[] { 1, 2, 3, 4, 5, 6, 7 }; // Byte array example.
          
          		// Creation of the private key from the seed bytes.
                  PrivateKey privateKeyFromBytes = PrivateKey.fromSeed(seed);
          
          		// Print the output.
                  System.out.println("Sender's Private Key: " + privateKeyFromBytes);
              }
          }
          

          # Create Private Key from Randomly Generated Seed Bytes

          package com.example;
          
          // Necessary imports.
          import com.wavesplatform.crypto.Crypto;
          import com.wavesplatform.transactions.account.PrivateKey;
          
          public class CreatePrivateKeyFromRandomSeedBytes {
              public static void main(String[] args) {
          		// Generation of random seed bytes.
                  byte[] randomSeedBytes = Crypto.getRandomSeedBytes();
          
          		// Creation of the private key from the randomly generated seed bytes.
                  PrivateKey senderPrivateKey = PrivateKey.fromSeed(randomSeedBytes);
          
          		// Print the output.
                  System.out.println("Sender's Private Key: " + senderPrivateKey);
              }
          }
          

          # Create Private Key from Bytes

          package com.example;
          
          // Necessary import.
          import com.wavesplatform.transactions.account.PrivateKey;
          
          public class CreatePrivateKeyFromBytes {
              public static void main(String[] args) {
          		// Creation of a byte array.
                  byte[] bytes = {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}; // Bytes example.
          
          		// Creation of the private key from the bytes.
                  PrivateKey senderPrivateKey = PrivateKey.as(bytes);
          
          		// Print the output.
                  System.out.println("Sender's Private Key: " + senderPrivateKey);
              }
          }
          

          # Create Private Key from an Encoded String

          package com.example;
          
          // Necessary import.
          import com.wavesplatform.transactions.account.PrivateKey;
          
          public class CreatePrivateKeyFromEncodedString {
              public static void main(String[] args) {
          		// Creation of a Base58 string.
                  String base58String = "A5u9Ugt2nG1rWfLkL7pzZrtkP8LgF2rD3g1XBjsF8ZzV"; // Base58 string example.
          
          		// Creation of the private key from the encoded string.
                  PrivateKey senderPrivateKey = PrivateKey.as(base58String);
          
          		// Print the output.
                  System.out.println("Sender's Private Key: " + senderPrivateKey);
              }
          }
          

          # 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 publicKey = privateKey.publicKey();
            
            // Print the pubic key.
            System.out.println("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 com.wavesplatform.transactions.common.ChainId; import com.wavesplatform.transactions.account.Address;

            /* 
             * Define the network of your wallet:
             * - Use `ChainId.MAINNET` for Mainnet.
             * - Use `ChainId.TESTNET` for Testnet.
             * - Use `ChainId.STAGENET` for StageNet.
             */
            
            Address senderAddress = Address.from(ChainId.TESTNET, senderPublicKey);
            
            System.out.println("Sender's Address: " + senderAddress);
            
          Send Transactions
          Interact With Node
          Send Transactions
          Interact With Node