Removed qr-code generation from btc wallet script. Saved Chatgtp plan about creating general purpose btc application for ondemand key generation and signing.

This commit is contained in:
kalzu 2023-05-23 10:49:19 +03:00
parent 5361afec07
commit b866ac06b4
2 changed files with 63 additions and 28 deletions

View File

@ -9,43 +9,26 @@ of the seed phrase. The database file is password protected to ensure the securi
Usage: ./generate_btc_wallet.py
"""
import base64
import gc
from getpass import getpass
import qrcode
from mnemonic import Mnemonic
from bitcoinlib.keys import HDKey
from pykeepass import create_database
MNEMONIC_STRENGTH=256
SUBKEY_PATH="m/0/0"
# Generate a BIP-0039 mnemonic seed phrase
mnemonic = Mnemonic("english")
SEED_PHRASE = mnemonic.generate(strength=128)
SEED_PHRASE = mnemonic.generate(strength=MNEMONIC_STRENGTH)
# Derive the HDKey from the seed phrase
hd_key = HDKey.from_passphrase(SEED_PHRASE)
# Derive the Bitcoin address from the HDKey
child_key = hd_key.subkey_for_path("m/0/0")
child_key = hd_key.subkey_for_path(SUBKEY_PATH)
address = child_key.address()
# Create a QR code instance
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_H,
box_size=10,
border=4,
)
# Add the data to the QR code
qr.add_data(SEED_PHRASE)
# Generate the QR code image
qr.make(fit=True)
QR_IMAGE = qr.make_image(fill_color="black", back_color="white")
# Convert the QR code image to base64
qr_base64 = base64.b64encode(QR_IMAGE.tobytes()).decode()
# Prompt for custom name for the wallet
wallet_name = input(
"Whould you like to name this wallet? (empty for using the address as name): "
@ -66,18 +49,16 @@ try:
# Create a KeePassXC database file
db = create_database(db_filename, password=passphrase)
# Create an entry in the root group
entry = db.add_entry(db.root_group, wallet_name, username=address, password=SEED_PHRASE)
# Add the QR code as a note (base64 encoded)
entry.notes = qr_base64
# Create an entrys in the root group
address_and_path_entry = db.add_entry(db.root_group, wallet_name, username=address, password=SUBKEY_PATH)
seed_phrase_entry = db.add_entry(db.root_group, "Bitcoin Master Seed", username="put me in safe", password=SEED_PHRASE)
# Save the database
db.save()
except Exception as e:
print("Error while creating keepassxc database. Disk full? Readonly?")
finally:
del SEED_PHRASE, address, hd_key, passphrase, QR_IMAGE, qr_base64, mnemonic
del SEED_PHRASE, address, hd_key, passphrase, mnemonic
gc.collect()
print("---")

View File

@ -0,0 +1,54 @@
# Steps to creating bitcoin wallet handing RPI3b setup
Made with ChatGPT on 22.5.2023
Understood. In that case, you can use the USB keys as temporary storage for the keepassxc databases and transfer them to a more permanent and secure location when not in use. This approach adds an extra layer of security by limiting the exposure of sensitive information.
Here's an updated outline of the steps involved:
Set up Raspberry Pi: Install the operating system (such as Raspbian) on your Raspberry Pi 3B and configure it accordingly.
Install necessary software: Install the required software packages, such as Python and any libraries or dependencies needed for key management and wallet operations.
Generate and store keys: Use appropriate libraries or tools to generate the necessary key pairs for each participant. Store the private keys securely on separate USB keys, ensuring they are encrypted and protected with strong passwords.
Securely store seed phrases: Generate the seed phrases for each participant and encrypt them. Store the encrypted seed phrases in the keepassxc databases, which can be stored temporarily on individual USB keys.
Develop wallet management scripts: Write scripts in Python (or any language of your choice) to interact with the generated keys, perform wallet operations, and handle transaction signing. These scripts should ensure the security of private keys, seed phrases, and any sensitive information.
Implement multi-signature functionality: Utilize appropriate libraries or methods to create multi-signature wallets and addresses using the public keys of the participants. Follow the recommended standards and protocols for multi-signature setups.
Test and secure the setup: Thoroughly test the functionality of the Raspberry Pi setup, including generating transactions, collecting signatures, and broadcasting transactions. Implement additional security measures such as firewalls, access controls, and regular updates to keep the system secure.
Educate and distribute responsibilities: Provide clear instructions and guidelines to the participants on their roles and responsibilities. Educate them on securely managing their USB keys, passwords, and the overall security practices they should follow.
Transfer keepassxc databases: When the USB keys are not in use, transfer the keepassxc databases to a more permanent and secure location, such as an offline storage medium or a highly secure cloud storage service. Ensure that the transferred databases are properly encrypted and protected.
By following these steps and customizing the setup to fit your specific requirements, you can create a Raspberry Pi-based solution that replicates the functionality of Seedsigner and securely manages the keys and seed phrases for your multi-signature setup. Remember to regularly review and update the security measures as needed to maintain the integrity of the system.
User
I feel this is good project to increase my coding skills since I'm more of a sysadmin by background.
ChatGPT
That's a fantastic mindset! Taking on a project like this can be a great opportunity to enhance your coding skills, especially if you come from a sysadmin background. It allows you to explore new programming concepts, deepen your understanding of cryptographic operations, and develop practical solutions for managing keys and wallets.
Here are a few benefits of engaging in this project:
Practical application: By building a Raspberry Pi-based solution for key and wallet management, you'll gain hands-on experience in working with cryptography, interacting with hardware, and implementing secure systems. It's a practical application of your coding skills.
Broadened skill set: Diving into this project will expose you to various aspects of software development, including scripting, library integration, and system configuration. It will broaden your skill set and make you more versatile in tackling future projects.
Security awareness: As you navigate the intricacies of key management and multi-signature wallets, you'll develop a deeper understanding of security practices and considerations. This knowledge can be applied to other areas of your work, enabling you to strengthen the security of your systems.
Problem-solving opportunities: Building a custom solution presents opportunities to solve unique challenges along the way. It encourages critical thinking, troubleshooting, and finding creative solutions to overcome obstacles.
Portfolio enhancement: Completing this project successfully adds a valuable item to your coding portfolio. It showcases your ability to design and implement secure systems, demonstrating your practical coding skills to potential employers or collaborators.
Remember to document your progress, learn from the experience, and seek feedback from others. Engaging in coding projects outside of your comfort zone is an excellent way to grow your skills and expand your knowledge base.
Enjoy the journey, and don't hesitate to seek support from relevant online communities or forums if you encounter difficulties or have specific questions. Happy coding!