Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: David Rabahy on October 03, 2014, 04:46:54 PM



Title: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 03, 2014, 04:46:54 PM
https://docs.google.com/spreadsheets/d/1mOTrqckdetCoRxY5QkVcyQ7Z0gcYIH-Dc0tu7t9f7tw now works.  It computes the SHA-256 hash of the null string or a string of up to 55 printable ASCII characters.  It does so from scratch, so to speak; it calculates the 2 set of constants.  All steps are fully revealed demonstrating the intricate details of the algorithm.

Ken Shirriff was my inspiration.  http://www.righto.com/2014/09/mining-bitcoin-with-pencil-and-paper.html


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: itod on October 05, 2014, 10:50:51 PM
Nice!

Where you inspired by this?
http://gizmodo.com/mining-bitcoin-with-pencil-and-paper-1640353309 (http://gizmodo.com/mining-bitcoin-with-pencil-and-paper-1640353309)


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 06, 2014, 12:50:09 PM
Nice!

Where you inspired by this?
http://gizmodo.com/mining-bitcoin-with-pencil-and-paper-1640353309 (http://gizmodo.com/mining-bitcoin-with-pencil-and-paper-1640353309)
Yes, but I've gone considerably further now.


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 07, 2014, 09:42:58 PM
donations to 17MCh7jJ4dHU5iAfLPv2t8hdjGDDzn95DK


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 08, 2014, 03:41:26 PM
I'm thinking about my next enhancement.  Any suggestions/requests?


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: shorena on October 08, 2014, 08:33:15 PM
I'm thinking about my next enhancement.  Any suggestions/requests?

There was a thread [1] where someone asked about generating a BTC address by hand. Basic idea would be to start with a number as private key and go from there.


[1] found it https://bitcointalk.org/index.php?topic=816123.0


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: PRab on October 09, 2014, 01:16:26 AM
Is there a way to type in a string to hash and get the SHA256 of it? I would like to compare to results to something like http://www.xorbin.com/tools/sha256-hash-calculator.


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 09, 2014, 02:11:37 PM
Is there a way to type in a string to hash and get the SHA256 of it? I would like to compare to results to something like http://www.xorbin.com/tools/sha256-hash-calculator.
Copy the sheet (File->Make a copy...) (it is now standalone, i.e. it no longer uses any script) and then in your copy go to 'input'!B2 and enter up to 55 printable ASCII characters.  The resulting 512-bit hash will be displayed as 64 hex-digits at 'post-round 64'!A10.

I used that same site to double check the results of;

{the null string} (leave the cell empty)
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

abc
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad

,.<>;':"/?[]\{}|`~!@#$%^&*()_-+=
55ef293e848487fb2673965531ef1777332307044b178f44fa970f63ed251125

I am content.


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 09, 2014, 02:43:04 PM
I'm thinking about my next enhancement.  Any suggestions/requests?
There was a thread https://bitcointalk.org/index.php?topic=816123.0 where someone asked about generating a BTC address by hand. Basic idea would be to start with a number as private key and go from there.
I am willing; I will research it.


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 09, 2014, 03:05:46 PM
I'm thinking about my next enhancement.  Any suggestions/requests?
There was a thread https://bitcointalk.org/index.php?topic=816123.0 where someone asked about generating a BTC address by hand. Basic idea would be to start with a number as private key and go from there.
I am willing; I will research it.
Oh dear; per https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses, it requires the SHA256 hash of 65 bytes.  As it stands as of now my sheet only handles up to 55 printable ASCII characters.  I will need to enhance it to handle one more chunk (medium effort) and binary/hex input (easy).

Far worse; the very first step involves "Having a private ECDSA key" which looks to be crazy hard to do in a sheet.


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: shorena on October 09, 2014, 04:21:49 PM
I'm thinking about my next enhancement.  Any suggestions/requests?
There was a thread https://bitcointalk.org/index.php?topic=816123.0 where someone asked about generating a BTC address by hand. Basic idea would be to start with a number as private key and go from there.
I am willing; I will research it.
Oh dear; per https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses, it requires the SHA256 hash of 65 bytes.  As it stands as of now my sheet only handles up to 55 printable ASCII characters.  I will need to enhance it to handle one more chunk (medium effort) and binary/hex input (easy).

You will also need RIPEMD-160, BASE58Check and be able to get a public ECDSA key from a private one. All sounds complicated on paper.

Far worse; the very first step involves "Having a private ECDSA key" which looks to be crazy hard to do in a sheet.

From what I read [1] its "just" a number between 0x0 and 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140 which would be given as input by you.

[1] https://en.bitcoin.it/wiki/Private_key


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 09, 2014, 04:38:55 PM
I'm thinking about my next enhancement.  Any suggestions/requests?
There was a thread https://bitcointalk.org/index.php?topic=816123.0 where someone asked about generating a BTC address by hand. Basic idea would be to start with a number as private key and go from there.
I am willing; I will research it.
Oh dear; per https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses, it requires the SHA256 hash of 65 bytes.  As it stands as of now my sheet only handles up to 55 printable ASCII characters.  I will need to enhance it to handle one more chunk (medium effort) and binary/hex input (easy).
You will also need RIPEMD-160, BASE58Check and be able to get a public ECDSA key from a private one. All sounds complicated on paper.
Far worse; the very first step involves "Having a private ECDSA key" which looks to be crazy hard to do in a sheet.
From what I read https://en.bitcoin.it/wiki/Private_key its "just" a number between 0x0 and 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140 which would be given as input by you.
Well, ok, yes, the very first step is not too tough but per http://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm it gets hard fast.


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: itod on October 09, 2014, 06:41:24 PM
Since you are using Excel maybe this VB.net code may help you:
http://www.reddit.com/r/Bitcoin/comments/1utg95/how_do_you_calculate_a_public_key_from_the/celjnof (http://www.reddit.com/r/Bitcoin/comments/1utg95/how_do_you_calculate_a_public_key_from_the/celjnof)
Although you'll need ecPoint object which may not be available through Excel.

If you want to roll your own EC calculations good starting points are here:
http://arstechnica.com/security/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/ (http://arstechnica.com/security/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/)
http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript (http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript)

It could be done, there are some already written attempts in Python, but I can tell you it's some work. IMHO it's best to enhance your table to accept longer strings, and leave Eliptic curve cryptography out of the Excel.


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 09, 2014, 07:01:18 PM
Since you are using Excel maybe this VB.net code may help you:
http://www.reddit.com/r/Bitcoin/comments/1utg95/how_do_you_calculate_a_public_key_from_the/celjnof (http://www.reddit.com/r/Bitcoin/comments/1utg95/how_do_you_calculate_a_public_key_from_the/celjnof)
Although you'll need ecPoint object which may not be available through Excel.

If you want to roll your own EC calculations good starting points are here:
http://arstechnica.com/security/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/ (http://arstechnica.com/security/2013/10/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/)
http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript (http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript)

It could be done, there are some already written attempts in Python, but I can tell you it's some work. IMHO it's best to enhance your table to accept longer strings, and leave Eliptic curve cryptography out of the Excel.
Although I started off in Excel at the very beginning, I am now working in Google sheet.  I found the Google sheet script engine to be *very* slow.

Thank you for the pointers but EC looks a little tougher than I am willing to take on at the moment.

I am working on my SHA256 Google sheet to get it to handle longer strings, i.e. 119 (as opposed to just 55), right now; tedious.  I am wondering when I might trip over some limitation, e.g. number of tabs, etc., in Google sheet.


Title: Re: spreadsheet showing SHA-256 calculations in step-by-step detail
Post by: David Rabahy on October 09, 2014, 09:09:11 PM
I've added some "instructions" within the sheet.  Enjoy.