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
      WavesJ
    • Ts-lib-crypto
      • Install SDK
        Install SDK
      Ts-lib-crypto
    • Waves-PHP
      • Install SDK
        Install SDK
      Waves-PHP
    • Waves-python
      • Install SDK
        Install SDK
      Waves-python
    • 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 bytes.
          • Bytes.

          # Create Private Key from Seed Phrase

          package main
          
          // Required imports.
          import (
          	"bytes"
          	"encoding/binary"
          	"fmt"
          
          	"github.com/wavesplatform/gowaves/pkg/crypto"
          )
          
          func main() {
          	// Paste your seed phrase.
          	seedPhrase := "PASTE YOUR SEED PHRASE"
          	accountNumber := uint32(0)
          
          	// Concatenate your account number and seed phrase.
          	accountNumConcatSeedPhrase := bytes.Join([][]byte{
          		binary.BigEndian.AppendUint32(nil, accountNumber),
          		[]byte(seedPhrase),
          	}, nil)
          
          	// Securely hash the seed.
          	accountSeed, err := crypto.SecureHash(accountNumConcatSeedPhrase)
          	if err != nil {
          		panic(err)
          	}
          
          	// Generate the private key the hashed seed.
          	senderPrivateKey, _, err := crypto.GenerateKeyPair(accountSeed.Bytes())
          	if err != nil {
          		panic(err)
          	}
          
          	// Print only the private key
          	fmt.Println("Sender's Private Key:", senderPrivateKey.String())
          }
          

          # Create Private Key from Randomly Generated Seed Bytes

          package main
          
          // Required imports.
          import (
          	"fmt"
          
          	"github.com/tyler-smith/go-bip39"
          	"github.com/wavesplatform/gowaves/pkg/crypto"
          )
          
          func main() {
              // Create random entropy bytes.
              entropy, err := bip39.NewEntropy(160)
              if err != nil {
                  panic(err)
              }
          
              // Generate the seed phrase from the bytes.
              seedPhrase, err := bip39.NewMnemonic(entropy)
              if err != nil {
                  panic(err)
              }
          
              // Create the private key from the seed.
              senderPrivateKey := crypto.GenerateSecretKey([]byte(seedPhrase))
          
          	// Print the private key.
          	fmt.Println("Sender's Private Key:", senderPrivateKey.String())
          }
          

          # Create Private Key from Bytes

          package main
          
          // Required imports.
          import (
          	"fmt"
          
          	"github.com/tyler-smith/go-bip39"
          	"github.com/wavesplatform/gowaves/pkg/crypto"
          )
          
          func main() {
              // Create an array of bytes.
          	seedBytes := []byte{
          		0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF,
          		0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
          		0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
          		0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00,
          	}
          	
              // Generate the seed phrase from the bytes.
              seedPhrase, err := bip39.NewMnemonic(seedBytes)
              if err != nil {
                  panic(err)
              }
          
              // Create the private key from the seed.
              senderPrivateKey := crypto.GenerateSecretKey([]byte(seedPhrase))
          
          	// Print the private key.
          	fmt.Println("Sender's Private Key:", senderPrivateKey.String())
          }
          

          # 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.
            senderPublicKey := crypto.GeneratePublicKey(senderPrivateKey)
            
            // Print the pubic key.
            fmt.Println("Sender's Public Key:", senderPublicKey.String())
            

          # 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 "github.com/wavesplatform/gowaves/pkg/proto" dependency in the import {} block.

            /* Define the network of your wallet:
            - Use `proto.MainNetScheme` for Mainnet.
            - Use `proto.TestNetScheme` for Testnet.
            - Use `proto.StageNetScheme` for StageNet.
            */
            const = {
            	network = proto.MainNetScheme
            }
            
            // Derive the account address from the public key.
            senderAddress, err := proto.NewAddressFromPublicKey(network, senderPublicKey)
            if err != nil {
            	log.Fatalf(err)
            }
            
            // Print the sender address.
            fmt.Println("Sender's address:", senderAddress.String())
          Send Transactions
          Interact With Node
          Send Transactions
          Interact With Node