Bitcoin Forum
October 31, 2024, 07:45:29 PM *
News: Bitcoin Pumpkin Carving Contest
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: I need help to generate my own key pair  (Read 141 times)
boldfi (OP)
Newbie
*
Offline Offline

Activity: 20
Merit: 1


View Profile
May 03, 2024, 09:42:53 AM
 #1

As a Newbie, i DCA-ed BTC for the past 6 months on Binance Shocked
I don't want to use any CEX no more. I want my keys.
So based on internet articles and a bit of chat-gpt  Shocked i could generate my key pair locally as follow:

Use secp256k1 elliptic curve to generate a priv key:
> openssl ecparam -genkey -name secp256k1 -noout -out privatekey.pem

Find matching pub key on the curve:
> openssl ec -in privatekey.pem -pubout -out publickey.pem

Derive an address in python:

from ecdsa import VerifyingKey
import hashlib
import base58

def generate_bitcoin_address_from_public_key(public_key_bytes):
    public_key = VerifyingKey.from_pem(public_key_bytes)

    # Hash the public key
    hash_pubkey = hashlib.sha256(public_key.to_string()).digest()
    hash_pubkey_ripemd160 = hashlib.new('ripemd160', hash_pubkey).digest()

    version_byte = b'\x00'
    hash_pubkey_with_version = version_byte + hash_pubkey_ripemd160

    checksum = hashlib.sha256(hashlib.sha256(hash_pubkey_with_version).digest()).digest()[:4]

    binary_address = hash_pubkey_with_version + checksum

    bitcoin_address = base58.b58encode(binary_address).decode('utf-8')
   
    return bitcoin_address

with open('publickey.pem', 'r') as file:
    public_key_pem = file.read()

bitcoin_address = generate_bitcoin_address_from_public_key(public_key_pem.encode('utf-8'))

print("Bitcoin Address:", bitcoin_address)


This got me the following:

-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIDRd6/hvSUmI3jubQv+FEve/bkPRBi4d4ddCKf1Cdz8yoAcGBSuBBAAK
oUQDQgAEr6/Q3oyxMl6Fourug/AVW2a/WyrhoGDPP0iXBPp2rEKSRF+p1G5DL7BL
gFsOOBN/U0IT3iiw7agk/DCTxEO0wQ==
gFsOOBN/U0IT3iiw7agk/DCTxEO0wQ==
-----END EC PRIVATE KEY-----

-----BEGIN PUBLIC KEY-----
MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAEr6/Q3oyxMl6Fourug/AVW2a/WyrhoGDP
P0iXBPp2rEKSRF+p1G5DL7BLgFsOOBN/U0IT3iiw7agk/DCTxEO0wQ==
-----END PUBLIC KEY-----

Bitcoin Address: 12XjArifNjhfNWDo5MBZaBMXjyYVVbVgxZ

So, did i do the correct thing ? Is it safe to transfer my BTC to an address generated this way (not this one ofc)
Or is there a better way to do it ?

Also keys seem to be base64 encoded, should i save it in another form ?

Thnaks in advance.
hd49728
Legendary
*
Offline Offline

Activity: 2268
Merit: 1115



View Profile
May 03, 2024, 10:22:06 AM
 #2

You complicate your life because there are open source Bitcoin softwares to use

Bitcoin Core, Electrum and more.

[General] Bitcoin Wallets - Which, what, why?

You can use the wallet software to create your wallet, backup, and use it to store your bitcoin.

[GUIDE] How to Safely Download and Verify Electrum

▄▄███████████████████▄▄
▄███████████████████████▄
████████▀░░░░░░░▀████████
███████░░░░░░░░░░░███████
███████░░░░░░░░░░░███████
██████▀░░░░░░░░░░░▀██████
██████▄░░░░░▄███▄░▄██████
██████████▀▀█████████████
████▀▄██▀░░░░▀▀▀░▀██▄▀███
███░░▀░░░░░░░░░░░░░▀░░███
████▄▄░░░░▄███▄░░░░▄▄████
▀███████████████████████▀
▀▀███████████████████▀▀
 
 CHIPS.GG 
▄▄███████▄▄
▄████▀▀▀▀▀▀▀████▄
███▀░▄░▀▀▀▀▀░▄░▀███
▄███
░▄▀░░░░░░░░░▀▄░███▄
▄███░▄░░░▄█████▄░░░▄░███▄
███░▄▀░░░███████░░░▀▄░███
███░█░░░▀▀▀▀▀░░░▀░░░█░███
███░▀▄░▄▀░▄██▄▄░▀▄░▄▀░██
▀███
░▀░▀▄██▀░▀██▄▀░▀░██▀
▀███
░▀▄░░░░░░░░░▄▀░██▀
▀███▄
░▀░▄▄▄▄▄░▀░▄███▀
▀█
███▄▄▄▄▄▄▄████▀
█████████████████████████
▄▄███████▄▄
███
████████████▄
▄█▀▀▀▄
█████████▄▀▀▀█▄
▄██████▀▄▄▄▄▄▀██████▄
▄█████████████▄████████▄
████████▄███████▄████████
█████▄█████████▄██████
██▄▄▀▀▀▀█████▀▀▀▀▄▄██
▀█████████▀▀███████████▀
▀███████████████████▀
██████████████████
▀████▄███▄▄
████▀
████████████████████████
3000+
UNIQUE
GAMES
|
12+
CURRENCIES
ACCEPTED
|
VIP
REWARD
PROGRAM
 
 
  Play Now  
boldfi (OP)
Newbie
*
Offline Offline

Activity: 20
Merit: 1


View Profile
May 03, 2024, 10:59:43 AM
 #3

You complicate your life because there are open source Bitcoin softwares to use

Bitcoin Core, Electrum and more.

[General] Bitcoin Wallets - Which, what, why?

You can use the wallet software to create your wallet, backup, and use it to store your bitcoin.

[GUIDE] How to Safely Download and Verify Electrum


Thanks for the documentation. I'm checking it out rn.
How to keep my DCA going on when migrating to a cold/paper wallet ? Do i still have to buy through a CEX manually every week ?
Amphenomenon
Sr. Member
****
Online Online

Activity: 700
Merit: 463


Hope Jeremiah 17vs7


View Profile WWW
May 03, 2024, 11:17:54 AM
Last edit: May 03, 2024, 11:34:29 AM by Amphenomenon
 #4

Thanks for the documentation. I'm checking it out rn.
How to keep my DCA going on when migrating to a cold/paper wallet ?
Actually its more better to go Hardware wallet which is still the best option for cold wallet and i will advice you to go for Trezor hardware wallet, this thread will be helpful in your choice of picking though 55 Hardware Wallets, compared feature by feature

Quote
Do i still have to buy through a CEX manually every week ?
Actually this is up to you, though there are Decentralise exchanges like peachbitcoin.com and others you can find here https://kycnot.me/

this also will be helpful in addition to what hd49728 shared Protect yourself from fake wallet software (guide)











██
██
██████
R


▀▀██████▄▄
████████████████
▀█████▀▀▀█████
████████▌███▐████
▄█████▄▄▄█████
████████████████
▄▄██████▀▀
LLBIT
██████
██
██
██████
██
██
██
██
██
██
██
██
██
██
██
██████
██████████████
 
 TH#1 SOLANA CASINO 
██████████████
██████
██
██
██
██
██
██
██
██
██
██
██
██████
████████████▄
▀▀██████▀▀███
██▄▄▀▀▄▄████
████████████
██████████
███▀████████
▄▄█████████
████████████
████████████
████████████
████████████
█████████████
████████████▀
████████████▄
▀▀▀▀▀▀▀██████
████████████
███████████
██▄█████████
████▄███████
████████████
█░▀▀████████
▀▀██████████
█████▄█████
████▀▄▀████
▄▄▄▄▄▄▄██████
████████████▀
[
[
5,000+
GAMES
INSTANT
WITHDRAWALS
][
][
HUGE
   REWARDS   
VIP
PROGRAM
]
]
████
██
██
██
██
██
██
██
██
██
██
██
████
████████████████████████████████████████████████
 
PLAY NOW
 

████████████████████████████████████████████████
████
██
██
██
██
██
██
██
██
██
██
██
████
nc50lc
Legendary
*
Offline Offline

Activity: 2590
Merit: 6309


Self-proclaimed Genius


View Profile
May 04, 2024, 11:39:16 AM
 #5

Also keys seem to be base64 encoded, should i save it in another form ?
The standard paper wallet backup for Bitcoin private keys is "WIF" (wallet import format).
More info: learnmeabitcoin.com/technical/keys/private-key/wif/

For public key, hex with compression prefix (pubKey isn't usually required to write in the backup).
More info: learnmeabitcoin.com/technical/keys/public-key/

However, those base64 strings when decoded don't look right,
Better stick to open-source software/hardware wallets than use the output from that script.

How to keep my DCA going on when migrating to a cold/paper wallet ? Do i still have to buy through a CEX manually every week ?
You can still use what you're familiar with (CEX to purchase) or use P2P.

But I would only suggest you to send bitcoin from the Exchange to your cold storage wallet when you accumulate a significant amount.
That's not only to minimize the accumulated fee when sending from exchange, but also to minimize the number of UTXO your wallet will be keeping.
The goal is to keep only a few higher value unspent outputs so that your wallet wouldn't have to use a lot of inputs in your future transactions.
The lower number of inputs, the lower the transaction's size will be; lower the transaction size results to lower absolute fee.

If you want to go P2P, you can use P2P exchanges available in your Country or purchase from users in this forum in Currency Exchange board.
Link: http://bitcointalk.org/index.php?board=53.0 (make use the "Trust system" since this is quite risky)

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!