Author

Topic: I need help to generate my own key pair (Read 154 times)

legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
May 04, 2024, 06: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)
sr. member
Activity: 700
Merit: 470
Hope Jeremiah 17vs7
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)
newbie
Activity: 20
Merit: 1
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 ?
legendary
Activity: 2044
Merit: 1018
Not your keys, not your coins!
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
newbie
Activity: 20
Merit: 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.
Jump to: