Bitcoin Forum
May 11, 2024, 06:01:03 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: base6 to base16 script beside bitaddress.org ?  (Read 76 times)
zappylappy (OP)
Newbie
*
Offline Offline

Activity: 16
Merit: 4


View Profile
February 28, 2021, 11:20:31 AM
Merited by hugeblack (2)
 #1

I am looking for a webbased script that converts base 6 (Dice) into base 16 (Private Key), that can be used on a offline PC.

I tried to code it, but parseInt (JavaScript Function) has a problem with big numbers:

var i = 32341234253543242345555;
out1 = parseInt (i, 6);
out2 = out1.toString(16);
document.write (out2);

I am also aware of bitaddress.org, but would like to have a second script that confirms the correct output of the later.

Has anyone a hint for a simple script?
1715407263
Hero Member
*
Offline Offline

Posts: 1715407263

View Profile Personal Message (Offline)

Ignore
1715407263
Reply with quote  #2

1715407263
Report to moderator
1715407263
Hero Member
*
Offline Offline

Posts: 1715407263

View Profile Personal Message (Offline)

Ignore
1715407263
Reply with quote  #2

1715407263
Report to moderator
1715407263
Hero Member
*
Offline Offline

Posts: 1715407263

View Profile Personal Message (Offline)

Ignore
1715407263
Reply with quote  #2

1715407263
Report to moderator
Each block is stacked on top of the previous one. Adding another block to the top makes all lower blocks more difficult to remove: there is more "weight" above each block. A transaction in a block 6 blocks deep (6 confirmations) will be very difficult to remove.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715407263
Hero Member
*
Offline Offline

Posts: 1715407263

View Profile Personal Message (Offline)

Ignore
1715407263
Reply with quote  #2

1715407263
Report to moderator
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
March 01, 2021, 12:45:37 AM
Merited by hugeblack (2)
 #2

There is a simple bash script available here: https://github.com/swansontec/dice2key

It's not web-based, but it is very simple! Wink


They have a full writeup on creating keys from dice here: https://www.swansontec.com/bitcoin-dice.html

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
NotATether
Legendary
*
Offline Offline

Activity: 1596
Merit: 6735


bitcoincleanup.com / bitmixlist.org


View Profile WWW
March 02, 2021, 10:54:39 AM
 #3

I guess you can reuse my other script that converts base6 to base58 if I modify it to return hex output instead?

Code:
import math
import hashlib
import codecs
import sys

def main():
    s = input("Enter the dice numbers: ")
    # Ensure that we have a 256-bit number
    digit2 = math.floor(math.log(6*len(s))/math.log(2) + 1)
    if digit2 > 256:
        raise ValueError("Number greater than 256 bits")
    s0 = sixtozero(s)
    i = to_int(s0)
    h1 = hex(i)
    h2 = hex_no0x(i)
    p = construct_privkey(h2)
    b = base58(p)
    print("Private key hex: {}".format(h1))
    print("Private key WIF: {}".format(b))

def hex_no0x(a):
    b = hex(a)[2:]
    return b

# https://gist.github.com/Jun-Wang-2018/3105e29e0d61ecf88530c092199371a7
def construct_privkey(PK0):
    PK0 = '{:0>64}'.format(PK0)
    PK1 = '80'+ PK0
    PK2 = hashlib.sha256(codecs.decode(PK1, 'hex'))
    PK3 = hashlib.sha256(PK2.digest())
    checksum = codecs.encode(PK3.digest(), 'hex')[0:8]
    PK4 = PK1 + str(checksum)[2:10]
    return PK4

# Define base58
def base58(address_hex):
    alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
    b58_string = ''
    # Get the number of leading zeros
    leading_zeros = len(address_hex) - len(address_hex.lstrip('0'))
    # Convert hex to decimal
    address_int = int(address_hex, 16)
    # Append digits to the start of string
    while address_int > 0:
        digit = address_int % 58
        digit_char = alphabet[digit]
        b58_string = digit_char + b58_string
        address_int //= 58
    # Add ‘1’ for each 2 leading zeros
    ones = leading_zeros // 2
    for one in range(ones):
        b58_string = '1' + b58_string
    return b58_string


def sixtozero(s):
    l = list(s)
    for i in range(0,len(s)):
        if s[i] == "6":
            l[i] = "0"
    return "".join(l)

def to_int(s):
    si = int(s, 6)
    return si

if __name__ == "__main__":
    main()

Code:
Enter the dice numbers: 123456
Private key hex: 0x2bb6
Private key WIF: 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEss1w8VWDR3

Note that this code assumes that 6 represents 0 in base6, which can only represent the numbers 0,1,2,3,4,5.



I am looking for a webbased script that converts base 6 (Dice) into base 16 (Private Key), that can be used on a offline PC.

Unless you are looking for stuff written in JavaScript Node.js, or you also want some HTML file to open a browser to it, "webbased script" and "can be used on an offline PC" sounds conflicting to me.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
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!