To generate a non-public key from one other personal key or derivation path, you should use a course of referred to as “key derivation”. Key derivation is a option to create a brand new personal key from an present personal key through the use of a mathematical perform.
To derive a non-public key from one other personal key, you should use a key derivation perform (KDF) similar to PBKDF2 (Password-Based mostly Key Derivation Perform 2) or BIP32 (Bitcoin Enchancment Proposal 32). These capabilities use the prevailing personal key and a derivation path (a collection of numbers and letters that specify how the brand new personal key ought to be derived) as enter, and produce a brand new personal key as output.
Right here is an instance of the way you would possibly use BIP32 to derive a brand new personal key from an present personal key:
# Import the BIP32 library
import BIP32
# Create a BIP32 occasion
bip32 = BIP32.new()
# Set the prevailing personal key
bip32.set_private_key(existing_private_key)
# Derive the brand new personal key utilizing the desired derivation path
new_private_key = bip32.derive_path(derivation_path)
Observe that the precise steps for producing a non-public key from one other personal key will differ relying on the particular KDF and programming language you might be utilizing. It is usually vital to maintain your personal keys secure and safe, as they can be utilized to entry and spend your Bitcoin.
