Bitcoin Forum
December 12, 2024, 01:45:43 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [ANN] HOW TO Generate Secure Bitcoin Minikeys using base57 and base32  (Read 295 times)
ZipReg (OP)
Hero Member
*****
Offline Offline

Activity: 912
Merit: 747



View Profile WWW
August 22, 2024, 05:22:27 PM
Last edit: August 30, 2024, 06:55:31 PM by ZipReg
Merited by krogothmanhattan (25), MoparMiningLLC (5), Kazkaz27 (1)
 #1

Greetings Everyone! I hope you're all doing well. As you all know there's been some controversy lately surrounding our keys and the methods of their generation.

Today I am going to show you how to generate secure 30 and 22 character BTCitcoin minikeys in two formats, base57 and base32.


Here is an AI answering to the security of a base32 minikey:



I have played around with all kinds of key-gen stuff and originally found this script on the forums here years ago, it used a non-crypto-graphically secure random function.

https://bitcointalk.org/index.php?topic=1337457.0

I updated this script to use the crypto-safe function random.SystemRandom() which is a standard python library, and have created two three new versions. Cheesy

One generates keys from base57 the other from base32, and the last creates 22 character base32 minikeys.

base57 = 23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
base32 = 23456789ABCDEFGHJKLMNPQRSTUVWXYZ


What is required?
  • COMPETENCE! This is not a system, it requires focus and careful work.
  • An air-gapped system running macos or a linux distribution.
  • A copy of bitaddress.org source code
  • These two python scripts

base57
Code:
import random
import hashlib
 
BASE58 = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'

def Candidate():

    srandom = random.SystemRandom()

    return('%s%s' % ('S', ''.join(
        [BASE58[ srandom.randrange(0,len(BASE58)) ] for i in range(29)])))
 
def GenerateKeys(numKeys = 21):
    """
    Generate mini private keys and output the mini key as well as the full
    private key. numKeys is The number of keys to generate, and
    """
    keysGenerated = 0
    totalCandidates = 0
    while keysGenerated < numKeys:
        try:
            cand = Candidate()
            # Do typo check
            t = '%s?' % cand
            # Take one round of SHA256
            candHash = hashlib.sha256(t).digest()
            # Check if the first eight bits of the hash are 0
            if candHash[0] == '\x00':
                privateKey = GetPrivateKey(cand)
                print('\n%s\nSHA256( ): %s\nsha256(?): %s' %
                      (cand, privateKey, candHash.encode('hex_codec')))
                if CheckShortKey(cand):
            print('Validated.')
                else:
                    print('Invalid!')
                keysGenerated += 1
            totalCandidates += 1
        except KeyboardInterrupt:
            break
    print('\n%s: %i\n%s: %i\n%s: %.1f' %
          ('Keys Generated', keysGenerated,
           'Total Candidates', totalCandidates,
           'Reject Percentage',
           100*(1.0-keysGenerated/float(totalCandidates))))
 
def GetPrivateKey(shortKey):
    """
    Returns the hexadecimal representation of the private key corresponding
    to the given short key.
    """
    if CheckShortKey(shortKey):
        return hashlib.sha256(shortKey).hexdigest()
    else:
        print('Typo detected in private key!')
        return None
 
def CheckShortKey(shortKey):
    """
    Checks for typos in the short key.
    """
    if len(shortKey) != 30:
        return False
    t = '%s?' % shortKey
    tHash = hashlib.sha256(t).digest()
    # Check to see that first byte is \x00
    if tHash[0] == '\x00':
        return True
    return False

GenerateKeys()
base57 RESULT example:
Code:
SmXsUbKQfLMaosBFKyJD38xiyveb7i
SHA256( ): 40253945df729cde57311cc82183ecb0f84410853ec6b79c5320889ce1f9f400
sha256(?): 00c17a8a028ecf9ccf471614900a0ebb52852d783af8f5cd186ebf1956fd7be2
Validated.


base32
Code:
import random
import hashlib
 
BASE58 = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'

def Candidate():

    srandom = random.SystemRandom()

    return('%s%s' % ('S', ''.join(
        [BASE58[ srandom.randrange(0,len(BASE58)) ] for i in range(29)])))
 
def GenerateKeys(numKeys = 21):
    """
    Generate mini private keys and output the mini key as well as the full
    private key. numKeys is The number of keys to generate, and
    """
    keysGenerated = 0
    totalCandidates = 0
    while keysGenerated < numKeys:
        try:
            cand = Candidate()
            # Do typo check
            t = '%s?' % cand
            # Take one round of SHA256
            candHash = hashlib.sha256(t).digest()
            # Check if the first eight bits of the hash are 0
            if candHash[0] == '\x00':
                privateKey = GetPrivateKey(cand)
                print('\n%s\nSHA256( ): %s\nsha256(?): %s' %
                      (cand, privateKey, candHash.encode('hex_codec')))
                if CheckShortKey(cand):
            print('Validated.')
                else:
                    print('Invalid!')
                keysGenerated += 1
            totalCandidates += 1
        except KeyboardInterrupt:
            break
    print('\n%s: %i\n%s: %i\n%s: %.1f' %
          ('Keys Generated', keysGenerated,
           'Total Candidates', totalCandidates,
           'Reject Percentage',
           100*(1.0-keysGenerated/float(totalCandidates))))
 
def GetPrivateKey(shortKey):
    """
    Returns the hexadecimal representation of the private key corresponding
    to the given short key.
    """
    if CheckShortKey(shortKey):
        return hashlib.sha256(shortKey).hexdigest()
    else:
        print('Typo detected in private key!')
        return None
 
def CheckShortKey(shortKey):
    """
    Checks for typos in the short key.
    """
    if len(shortKey) != 30:
        return False
    t = '%s?' % shortKey
    tHash = hashlib.sha256(t).digest()
    # Check to see that first byte is \x00
    if tHash[0] == '\x00':
        return True
    return False

GenerateKeys()
base32 RESULT example:
Code:
SXRN5EH92YJDRREAX8VDZBPEUMXDMN
SHA256( ): 2fc9356894e881541865b8dca800f120cbfcac32627bf0aabba6dcaa7658b409
sha256(?): 0077992753bab69bdeb420cedad11b41bef0182b43ccb29cf4fdcb0399fbfcc2
Validated.


** UPDATE I have also added a 22 character base32 minikey script below **

Multiple AI have confirmed even at 22 characters, a base32 minikey would be impossible to crack for the foreseeable future.


base32 - 22 Character Minikey
Code:
import random
import hashlib
 
BASE58 = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'

def Candidate():

    srandom = random.SystemRandom()

    return('%s%s' % ('S', ''.join(
        [BASE58[ srandom.randrange(0,len(BASE58)) ] for i in range(21)])))
 
def GenerateKeys(numKeys = 21):
    """
    Generate mini private keys and output the mini key as well as the full
    private key. numKeys is The number of keys to generate, and
    """
    keysGenerated = 0
    totalCandidates = 0
    while keysGenerated < numKeys:
        try:
            cand = Candidate()
            # Do typo check
            t = '%s?' % cand
            # Take one round of SHA256
            candHash = hashlib.sha256(t).digest()
            # Check if the first eight bits of the hash are 0
            if candHash[0] == '\x00':
                privateKey = GetPrivateKey(cand)
                print('\n%s\nSHA256( ): %s\nsha256(?): %s' %
                      (cand, privateKey, candHash.encode('hex_codec')))
                if CheckShortKey(cand):
            print('Validated.')
                else:
                    print('Invalid!')
                keysGenerated += 1
            totalCandidates += 1
        except KeyboardInterrupt:
            break
    print('\n%s: %i\n%s: %i\n%s: %.1f' %
          ('Keys Generated', keysGenerated,
           'Total Candidates', totalCandidates,
           'Reject Percentage',
           100*(1.0-keysGenerated/float(totalCandidates))))
 
def GetPrivateKey(shortKey):
    """
    Returns the hexadecimal representation of the private key corresponding
    to the given short key.
    """
    if CheckShortKey(shortKey):
        return hashlib.sha256(shortKey).hexdigest()
    else:
        print('Typo detected in private key!')
        return None
 
def CheckShortKey(shortKey):
    """
    Checks for typos in the short key.
    """
    if len(shortKey) != 22:
        return False
    t = '%s?' % shortKey
    tHash = hashlib.sha256(t).digest()
    # Check to see that first byte is \x00
    if tHash[0] == '\x00':
        return True
    return False

GenerateKeys()
base32 - 22 Character Minikey RESULT example:
Code:
SHAGB2RML58MRVTUZYJAGE
SHA256( ): bdae5d37db5a11fb7e5f5ac336df631f7dd9f15efc28d57b5704c1f84546bfb8
sha256(?): 00e66ee72d46056864da6ed5ec59579f302d6623958a5b0b3664af4ee8f6c0bb
Validated.


Save these scripts as minikey57.py, minikey32.py, and minikey22.py

To run the script "obviously air-gapped / offline" you simply open your terminal, navigate to your file location and type:

python minikey32.py

The scripts will generate 21 minikeys on each run, you can edit def GenerateKeys(numKeys = 21): <- and change the 21 to the amount you want to generate.

To discover the public addresses of the minikeys you paste the minikey into the wallet details section of an offline copy of bitaddress.org.

That's it! If you find this helpful throw some sats at my TIP Jar below which I generated with this script! Guess which version I used! Cool Thanks! Cheesy

I will also be including these two script on the usb keys provided with the Cool Storage wallet kits preparation utility.


TIP Jar
1KZA2K4gEicijgK6umBdCooGnepRTPzsG3




ZipReg (OP)
Hero Member
*****
Offline Offline

Activity: 912
Merit: 747



View Profile WWW
August 28, 2024, 03:43:14 PM
 #2

What no tips yet? With all the key-gen drama recently I though this thread would be at least 20 posts deep by now guys.

How else are we supposed to real world test it Grin

(That's a joke BTW) I take my trusted reputation here very seriously.

MoparMiningLLC
aka Stryfe
Legendary
*
Online Online

Activity: 2296
Merit: 2517


EIN: 82-3893490


View Profile WWW
August 28, 2024, 03:53:19 PM
 #3

I have a lot to say about it, but after you call me a liar and a fraud. I don't see how any input I can give - positive even - would be beneficial.

Mine BTC @ kano.is
Offering escrow services https://bitcointalk.org/index.php?topic=5154480
All Bitcoin 3D printing needs at CryptoCloaks
ZipReg (OP)
Hero Member
*****
Offline Offline

Activity: 912
Merit: 747



View Profile WWW
August 28, 2024, 04:40:00 PM
Last edit: August 28, 2024, 05:31:48 PM by ZipReg
 #4

I have a lot to say about it, but after you call me a liar and a fraud. I don't see how any input I can give - positive even - would be beneficial.

I would suggest you not put words in my mouth. I absolutely never called you a fraud, I called you a hypocrite, there is a big difference between their definitions.

You're just going to have to accept the fact that I do not believe you and no one with half a brain will either.

You're trying to claim you didn't see this thread https://bitcointalk.org/index.php?topic=5503931.0 that was posted on July 23rd.

but you saw this thread https://bitcointalk.org/index.php?topic=5503805.0 that was posted around the same time?

After I called you out you then claimed you only read the first post of my release thread and did not see the very next post below it stating the link to the site!?!?

You're here virtually everyday, and because its been so slow here my posts were on the front page for at least an entire week, being bumped daily.

Your first post in my release thread was on August 1st. So you're saying between July 22nd and August 1st you didn't see any of my posts.

You're a liar. You purposely came into my release thread to proclaim you would not be using my site.



What does any of that have to do with this thread, these scripts, and how am I stopping you from saying anything?

You can say whatever you want, clearly, you just came in here and derailed this thread, did you not?




MoparMiningLLC
aka Stryfe
Legendary
*
Online Online

Activity: 2296
Merit: 2517


EIN: 82-3893490


View Profile WWW
August 28, 2024, 05:07:09 PM
Last edit: August 28, 2024, 05:21:03 PM by MoparMiningLLC
 #5

You are right, while you did not use the specific word "fraud" by calling me a liar repeatedly - that is the same thing as a fraud.

You can say you don't believe me, that is your choice. But you went further - you are so passive aggressive against so many here. You act like the world is out to get you - it is not so.

To set the record straight - I am not a liar. If I say something that is wrong, I will admit, apologize if needed and move on.

If I saw that thread, I did not read it - quite often, I hit the "mark read" I do not read every thread.

Yes, I saw the first post and quickly scrolled down to the bottom so that I could post my desire for #10 of each - I do not always read every single comment in every single thread. Does anyone?  Had I actually read it, I would have not even commented.

And when you did reply to my post saying it would be on the irlbtc.com site, I simply thought you were linking to what was yet another off forum auction house - we have seen many lately. And I stated that I would not be using it - you asked why - I answered - all truthfully. Between my 3 full time jobs, the forums, X, Telegram groups - I am tapped out for time. So, I have been cutting quite a few things out - I have left many groups on discord and telegram both. I have limited my buying to pretty much just the forums and occasionally on scarce.city

Rather than accept the truth that I missed where you said it was your site and of your work, you instead think I am out to get you - I am not out to get anyone here. Never have been, never will be. (except rainbowsky  - fuck that guy).

In the end, you attacked me with wild, off the hook and blatantly wrong accusations. You have to stop being so paranoid to think everyone is out to get you. You alienate yourself when you act this way. And that is the quite possibly why this thread has gone so long without anyone chiming in.

All that said and done, I still wish you luck in your endeavors.


edit:

to add for clarification - Real timeline:

I posted my interest in the two pieces at 10:23 pm on July 31st.

You told me they were listed on irlbtc at 9:29 am on August 1st

I said I wouldnt be going to/using yet another 3rd party site at 9:43 am on August 1st

You told me it was your site at 10:14 am on August 1st.   <------ this is the first time I realized that irlbtc was your site.

I still merited your ANN for the site on August 1st at 2:58 pm - why? if I was shitting on your work as you claim and out to get you - why would I merit it?

For another 3 or so hours after that even, you continue to send me dm's calling me a liar and accusing me of being out to get you.

You are your own worst enemy, buddy.

Mine BTC @ kano.is
Offering escrow services https://bitcointalk.org/index.php?topic=5154480
All Bitcoin 3D printing needs at CryptoCloaks
raritycheck
Copper Member
Full Member
***
Offline Offline

Activity: 712
Merit: 182


View Profile WWW
August 28, 2024, 09:54:43 PM
 #6

The generator we shared recently gives you the address and the mini key

https://bitcointalk.org/index.php?topic=5506456.0

One doesn’t need to connect to bitaddress.org
Or don’t connect to internet.

ZipReg (OP)
Hero Member
*****
Offline Offline

Activity: 912
Merit: 747



View Profile WWW
August 30, 2024, 07:05:53 PM
 #7



Hey I'm not ignoring you buddy, just don't have time to reply ATM.



The generator we shared recently gives you the address and the mini key

https://bitcointalk.org/index.php?topic=5506456.0

One doesn’t need to connect to bitaddress.org
Or don’t connect to internet.


One of the reasons I posted this information is because of your generator.

These script I have posted function on PURE python, your solution relies on external libraries.

You can't be lazy in this space, do the work, download a copy of bitaddress.org ckeck the MD5 and generate keys using PURE solutions only.

PURE python, PURE javascript, PURE PHP, it's very simple. I hope this helps.



UPDATE: I have also added a 22 character minikey generator script to the OP Cheesy
Vip_Bitcoins
Copper Member
Newbie
*
Offline Offline

Activity: 12
Merit: 9

₿IT VIP COINS LLC


View Profile WWW
August 30, 2024, 11:10:07 PM
Last edit: August 31, 2024, 04:48:35 AM by Vip_Bitcoins
 #8

Hey, ZipReg

Awesome work  Grin

Bitvipcoins.com - ₿it VIP Coins - VIP Physical ₿itcoins & Collectables. First Product Release is in 3 - 6 months.
Kazkaz27
Copper Member
Full Member
***
Offline Offline

Activity: 169
Merit: 111


₿IT VIP COINS CEO


View Profile WWW
October 25, 2024, 08:20:12 PM
 #9

Hey Zip, do you have a GitHub link?

raritycheck
Copper Member
Full Member
***
Offline Offline

Activity: 712
Merit: 182


View Profile WWW
October 27, 2024, 09:39:15 AM
Last edit: October 27, 2024, 09:53:00 AM by raritycheck
 #10



Hey I'm not ignoring you buddy, just don't have time to reply ATM.



The generator we shared recently gives you the address and the mini key

https://bitcointalk.org/index.php?topic=5506456.0

One doesn’t need to connect to bitaddress.org
Or don’t connect to internet.


One of the reasons I posted this information is because of your generator.

These script I have posted function on PURE python, your solution relies on external libraries.

You can't be lazy in this space, do the work, download a copy of bitaddress.org ckeck the MD5 and generate keys using PURE solutions only.

PURE python, PURE javascript, PURE PHP, it's very simple. I hope this helps.



UPDATE: I have also added a 22 character minikey generator script to the OP Cheesy

I see. Good work.

 It is indeed very simple. You use hash lib and systemrandomness
I use secrets. Secrets is part of Python https://docs.python.org/3/library/secrets.html
Base58 is managed library which is equivalent to the one used by btc https://pypi.org/project/base58/
Sure base58 can be replaced. Plus more randomness with audio https://pypi.org/project/PyAudio/

I just want to avoid downloading a site.



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!