I will be that you want to get the closed key from the breast phrases, the use of Python and Litecoin.
Do we need a line key?
———————
A partial key is required for transaction transaction in the blockchain network. When you prove a new cottage record or send cryptocurrency, the key to your face (unattractive advertising) is hindered on the dwarf.
How to get the present key from the mamonic phrase:
—————————————- —— — – – –
You can use Python “cryptographies” and library to reach this. Here is the primer how to generate the face with a melodic phrase:
Install libraries that are not in progress
`Bash
PIP has set cryptography
Primer code
`Python
This is cryptography.Fernet import fernet
Import Base64
Json Import
This is cryptography.hazmat.primitive serialization of importance
This is cryptography.hazmat.primitive.ding import import
This is cryptography.hazmat.backes import default_backend
Import hashlib
Def Load_private_key_from_mnemonic (mnemonic, password = none):
"" ""
Download the line key from the Mint phrase.
Args:
Mogonik (Str): breast phrase.
Password (Str, Inmorable): Password for Koshka. If I have been presented,
Only this password is used to generate a closed key. In anti -server,
A partial key is not generated.
Returns:
Bytes: A partial key like Stack Json.
"" ""
Create the object of the fungus
f = papron ()
Download mamonic phrase from file or database (inappropriate)
In accomplishment, you should hunt the breast phrase.
with open ("mnemonic_phrase.txt", "rb") as f:
mnemonic_bytes = f.read ()
Password = ""
inappropriate
If not the password:
#The firmly sprinkle with new front key
Private_key = fernet.Generate_private_ke (
Coding = "utf-8",
Backend = default_back (),
US_KEYGEN = TRUE,
)
Print (F "The spoiled closed key: {private_key.private_bytes (
Codification = serialization.encoding.pem,
Format = serialization.privateFormat.Tradialopensl,
Encryption_algorithm = serialization.noencry ()
)} ")
Shifile mammonic frame with replicated class
Incrypted_mnemonic = fernet.encrypt (
Mnemonic.encode ("UTF-8"),
Padding.oaep (
mgf = padding.mgf1 (algorithm = hashlib.sha256 ())
Algorithm = hashlib.sha256 (),
Mark = no,
)
)
Download closed key from JSON file
with open ("private_key.json", "rb") as f:
Private_key_bytes = F.Rad ()
#Bound to make the mamonic phrase mutilated in byte
Incrypted_mnemonic_bytes = base64.b64decode (crypto_mnemonic)
Returns Private_Key_bytes, incrypted_Mnemonic_bytes
#Prier using
mnemonic_phrase = "your_mnemonic_phrase_here"
Password = ""
inappropriate
Private_Key_bytes, incrypted_Mnemonic_bytes = Load_private_key_from_mnemonic (mnemonic_phrase, password)
Print (“Private Key (JSON):“)
Package (Private_Key_bytes)
Print ("\ ncrypted mnemonic frame:")
Print (crypto_mnemonic_bytes.hex ())
How to use this code:
1 .. immobility of the mother’s phrase in the file or database.
- Install the password, if Predatroena is for the neighborhood.
- Pass the mamonic phrase killed in the qualities of the argument on call
LOAD_PRIVATE_KE_FROM_MNEMONIC
.
- The private key is generated and appears as JSON.
Obraty Unimania that this achievement pretends to use the algorithm for the Papron currency with Heshon Sha-256. You can adjust these settings on your concrete treatments.