Bitcoin Forum
June 26, 2024, 11:21:25 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: A sha256 digest and a private key  (Read 192 times)
irukandji (OP)
Sr. Member
****
Offline Offline

Activity: 629
Merit: 258



View Profile
October 29, 2021, 11:53:59 PM
Merited by ABCbits (1)
 #1

If I generate a sha256 digest from some text I get one string of letters and numbers, but if I generate a key pair using bitaddress, using the same text I get a private key.
What is the relationship between the digest and the private key?

Also I thought (and I'm probably wrong) that putting some text through the Sha256 algorithm produced a 256 character string of ones and zeroes.  If that correct. If so how do we them get the digest?

Thanks for your help in understanding this
nc50lc
Legendary
*
Offline Offline

Activity: 2450
Merit: 5735


Self-proclaimed Genius


View Profile
October 30, 2021, 02:42:26 AM
Merited by ABCbits (1)
 #2

If I generate a sha256 digest from some text I get one string of letters and numbers, but if I generate a key pair using bitaddress, using the same text I get a private key.
What is the relationship between the digest and the private key? -snip-
You must be talking about "brainwallet" tab of bitaddress, yes?
You can get a 256bit result from SHA256 that can be used as an "ECDSA Private Key" [letters (A-F) and numbers (0-9)];
The difference is, brainwallet encodes the private key into WIF (Wallet Import Format) private key which what you might have meant by "private key".

█▀▀▀











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











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
pooya87
Legendary
*
Offline Offline

Activity: 3486
Merit: 10673



View Profile
October 30, 2021, 03:40:03 AM
 #3

putting some text through the Sha256 algorithm produced a 256 character string of ones and zeroes.  If that correct. If so how do we them get the digest?
Hash algorithms such as SHA256 doesn't produce characters, they produce bits (which is the zeros and ones) with a fixed length. Then you can encode those bits using any form of encoding you like. The most common one is base16 or hexadecimal which is why you end up with alphanumerical characters between 0-9 and a-f.

If I generate a sha256 digest from some text I get one string of letters and numbers, but if I generate a key pair using bitaddress, using the same text I get a private key.
What is the relationship between the digest and the private key?
The reverse is the same. You can decode those alphanumerical characters (base16 or whatever else) to get the bits and then interpret those bits however you like. In bitaddress.org when you enter 256-bit hexadecimal you are interpreting it as a 256-bit number between 1 and secp256k1 order (n) or in other words a bitcoin private key.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
MrFreeDragon
Sr. Member
****
Offline Offline

Activity: 443
Merit: 350


View Profile
November 07, 2021, 09:21:53 PM
 #4

If I generate a sha256 digest from some text I get one string of letters and numbers, but if I generate a key pair using bitaddress, using the same text I get a private key.
What is the relationship between the digest and the private key?
-snip-

Private key encoded in WIF (wallet import format) is the same 256 bit number but in base58 with some check sums.
Example. Try to calcualate the bitcoin address from passphrase "irukandji-irukandji":

bitaddress shows you the WIF KwThwcqDd3hgbUg6T1UsAH6L4Rm3VUuxTntBsiqoznBNWT8vHUjs
the btc address 1H94mfp8QUGjs1ZnPL6XbdsRiGXwXVLfzS

sha256 digests:
Code:
~$ echo -n "irukandji-irukandji" | sha256sum
07333219cdab39342ed1fc0dc5fa621ddfa701764462fd7e3a1212bd60dbc105  -

You can go to https://learnmeabitcoin.com/technical/wif tool and check that your sha256 hash digest is the same WIF private key

TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
November 11, 2021, 03:02:42 PM
Merited by ranochigo (2)
 #5

Also I thought (and I'm probably wrong) that putting some text through the Sha256 algorithm produced a 256 character string of ones and zeroes.  If that correct. If so how do we them get the digest?

The 256 refers to the outcome of the SHA-256 algorithm always being 256 bits, so 256 elements of either a value 0 or 1. For readability you could write them down like '010100100010001001011101111..' but that does not mean the algorithm produces a 256 character string as you think.

So once these 256 bits are known you can represent those in many ways. One way is to write them down in hexadecimal where 8 bits are grouped into a byte and this byte is represented by a hex value. For instance:

Code:
Imagine the private key starts with these 8 bits:
11110110

The hex represenation of that would be:
f6

Since a private key consists of 256 bits you will get 32 (256/8) of these "letters (a-f) and numbers". Written down in human dreadable form in 64 characters.

The exact same key is often encoded in Wallet Import Format (WIF) as well, this is what you (probably) saw when generating an address on the bitaddress site. If you copy the WIF and paste it in the "Wallet Details" tab you can check out the full private key as well.

All in all: SHA-256 always produces a 256 bit result, this result can be encoded in many different ways but they all will refer to the same outcome.

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
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!