# Use Crypto Utilities
You can work with the Private Key, Public Key, and Address methods.
# Private Key
You can create a private key from:
# Create Private Key from Seed Phrase
# Necessary import.
import pywaves as pw
# Specify your account's seed phrase.
seed_phrase = "PASTE YOUR SEED PHRASE"
# Creation of the private key from the seed phrase.
address = pw.Address(seed=seed_phrase)
privateKey = address.privateKey
# Print the output.
print("Sender's Private Key:", privateKey)
# Create Private Key from Seed Bytes
# Necessary imports.
import pywaves as pw
import base58
# Creation of a byte array.
seed_bytes = bytes([1, 2, 3, 4, 5, 6, 7]) # Byte array example.
# Encoding bytes to a Base58 string to use as a seed.
seed_phrase = base58.b58encode(seed_bytes).decode()
# Creation of the private key from the seed bytes.
address = pw.Address(seed=seed_phrase)
privateKey = address.privateKey
# Print the output.
print("Sender's Private Key:", privateKey)
# Create Private Key from Randomly Generated Seed Bytes
# Necessary imports.
import pywaves as pw
import os
import base58
# Generation of random seed bytes.
random_seed_bytes = os.urandom(32)
# Encoding to Base58 to use as a seed.
seed_phrase = base58.b58encode(random_seed_bytes).decode()
# Creation of the private key from the randomly generated seed bytes.
address = pw.Address(seed=seed_phrase)
privateKey = address.privateKey
# Print the output.
print("Sender's Private Key:", privateKey)
# Create Private Key from Bytes
# Necessary imports.
import pywaves as pw
import base58
# Creation of a byte array.
bytes_array = bytes([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]) # Bytes example.
# Encoding bytes to Base58 string to use as a seed.
seed_phrase = base58.b58encode(bytes_array).decode()
# Creation of the private key from the bytes.
address = pw.Address(seed=seed_phrase)
privateKey = address.privateKey
# Print the output.
print("Sender's Private Key:", privateKey)
# Create Private Key from an Encoded String
# Necessary import.
import pywaves as pw
# Creation of a Base58 string.
base58_string = "A5u9Ugt2nG1rWfLkL7pzZrtkP8LgF2rD3g1XBjsF8ZzV" # Base58 string example.
# Creation of the private key from the Base58 string seed.
address = pw.Address(seed=seed_phrase)
privateKey = address.privateKey
# Print the output.
print("Sender's Private Key:", privateKey)
# Public Key
You can create a public key from an address. Place the following code after the address generation:
# Creation of the public key.
publicKey = address.publicKey
# Print the output.
print("Sender's Public Key:", address.publicKey)
# Address
You can create an address from the private key. Place the following code after the private key generation:
# Set the node link and chain ID.
pw.setNode(
# Specify the link for the network:
# - Mainnet: 'https://nodes.wavesnodes.com/'
# - Testnet: 'https://nodes-testnet.wavesnodes.com/'
# - Stagenet: 'https://nodes-stagenet.wavesnodes.com/'
node='https://nodes-testnet.wavesnodes.com',
# Specify the network chain ID:
# - Mainnet: 'M'
# - Testnet: 'T'
# - Stagenet: 'S'
chain='T'
)
# Print the output.
print("Sender's Address:", address)