Bitcoin Forum
May 24, 2024, 04:12:13 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: spreadsheet showing SHA-256 calculations in step-by-step detail  (Read 8535 times)
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 03, 2014, 04:46:54 PM
Last edit: October 07, 2014, 09:40:07 PM by David Rabahy
Merited by ABCbits (1)
 #1

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
itod
Legendary
*
Offline Offline

Activity: 1974
Merit: 1076


^ Will code for Bitcoins


View Profile
October 05, 2014, 10:50:51 PM
 #2

Nice!

Where you inspired by this?
http://gizmodo.com/mining-bitcoin-with-pencil-and-paper-1640353309
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 06, 2014, 12:50:09 PM
Last edit: October 06, 2014, 06:38:46 PM by David Rabahy
 #3

Yes, but I've gone considerably further now.
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 07, 2014, 09:42:58 PM
 #4

donations to 17MCh7jJ4dHU5iAfLPv2t8hdjGDDzn95DK
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 08, 2014, 03:41:26 PM
 #5

I'm thinking about my next enhancement.  Any suggestions/requests?
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
October 08, 2014, 08:33:15 PM
 #6

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

Im not really here, its just your imagination.
PRab
Member
**
Offline Offline

Activity: 98
Merit: 10


View Profile
October 09, 2014, 01:16:26 AM
 #7

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.
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 09, 2014, 02:11:37 PM
Last edit: October 09, 2014, 02:37:13 PM by David Rabahy
 #8

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.
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 09, 2014, 02:43:04 PM
 #9

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.
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 09, 2014, 03:05:46 PM
 #10

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.
shorena
Copper Member
Legendary
*
Offline Offline

Activity: 1498
Merit: 1520


No I dont escrow anymore.


View Profile WWW
October 09, 2014, 04:21:49 PM
 #11

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

Im not really here, its just your imagination.
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 09, 2014, 04:38:55 PM
 #12

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.
itod
Legendary
*
Offline Offline

Activity: 1974
Merit: 1076


^ Will code for Bitcoins


View Profile
October 09, 2014, 06:41:24 PM
 #13

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
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://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.
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 09, 2014, 07:01:18 PM
 #14

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
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://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.
David Rabahy (OP)
Hero Member
*****
Offline Offline

Activity: 709
Merit: 503



View Profile
October 09, 2014, 09:09:11 PM
 #15

I've added some "instructions" within the sheet.  Enjoy.
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!