Author

Topic: A sha256 digest and a private key (Read 209 times)

sr. member
Activity: 310
Merit: 727
---------> 1231006505
November 11, 2021, 10:02:42 AM
#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.
sr. member
Activity: 443
Merit: 350
November 07, 2021, 04: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
legendary
Activity: 3472
Merit: 10611
October 29, 2021, 10:40:03 PM
#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.
legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
October 29, 2021, 09:42:26 PM
#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".
sr. member
Activity: 631
Merit: 258
October 29, 2021, 06:53:59 PM
#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
Jump to: