top of page
secp256k1 FOR BITCOIN IN EXCEL, NO MACROS, NO ARRAYS

***RECENT UPDATE MAY 2024—MAKE SURE TO USE MOST CURRENT VERSION***

Presenting the first bitcoin ECDSA secp256k1 spreadsheet calculator

I set out in October 2020 to attempt to put the ECDSA curve into an Excel spreadsheet without using array formulas or macros.  It sounded like a good exercise in spreadsheet building and a chance to learn how bitcoin uses the ECDSA curve

What I thought would be a few months of constructing and building turned into a multi-year project that finished in April 2023.  The project took me down many paths such as building the SHA256 spreadsheet, a private key tutorial spreadsheet, a number of aspects around math, all the while the secp2561k ECDSA completion eluded me

I put the ECDSA spreadsheet on the shelf a few times, incomplete, stopped by time constraints, computer constraints, Excel constraints, but primarily brain constraints—my own understanding of the math behind the code was limited and I had to learn so much.  There were many times I thought I would not complete the task

Thankfully I had help.  A lot of help.  A big thank you to my mathematician guide KP who made modulo inverse multiplication and many other aspects of ECDSA math within the curve become less difficult and without whom I would have not finished this project.  Also big thank you to AP and a supportive crew, as well as to tutorials within Mastering Bitcoin by Antonopoulos and Programming Bitcoin by Song, also the learnmeabitcoin.com website, and many other people and websites that have helped along the way.  They contribute magnitudes above what I have done in this exercise

As for the spreadsheet, a nice aspect is it lays bare the inner workings of the ECDSA curve, and you can use it to see one of the steps of how a private key is converted into a public key.  Instructions are in a separate tab

Play with the spreadsheet and if you break it please give me feedback for improvement.  I used a few well-known methods in the calculation such as 256 precalculated points; at over 150MB the spreadsheet is already too large.  Why is it so large?  The spreadsheet has to go through a number of steps in order to achieve accurate calculations, notably

  • All numbers are at sizes well above Excel's floating point limitations, as such, simple math (addition, subtraction, multiplication, division) must be done long form

  • Maths operate within a modulus finite field, so Euclidian Division (remainders) must be used

  • The biggest and bulkiest demand for computer memory comes from the Extended Euclidian Algorithm and the steps necessary to derive the Greatest Common Divisor of the algorithm's points.  This in itself added over 180 tabs of division and multiplication to the spreadsheet (!), but the upside is the tabs are all identical with automated references between

All 150+MB of calculations is just for the result of adding two points on the ECDSA curve.  That's it, one step.  It is not the entire number of times around the ECDSA curve.  The good news is I built the spreadsheet so you can continue adding and bouncing around the curve by copy-pasting the resulting ECDSA third point and adding the next point to manually find subsequent points, which eventually results in the bitcoin x,y public key.  Like the description in hackernoon article points out, the most calculations within the ECDSA curve (read: this spreadsheet's copy/pasting) you will have to do is 255 times lol

Maybe when I get some energy back I will turn attention to streamlining the spreadsheet, or adding additional pre-interpolated points to reduce the number from 255, or build the conversion of the ECDSA output into a public key and public address within another spreadsheet.  Would be fun to try to receive bitcoin completely through the spreadsheet, but I need to make the RIPMD160 algo [update: I made the RIPMD160 algo not long after; you can find it on the front page of this website].  I could use a short break, and tbh, *don't try this at home*.  Lots of risk in using spreadsheets for holding bitcoin value

Anyway, enjoy

dp

E59E6D72B13AB19C883D7127F371328D0E6A88C5D5EC7CED332BE834B9D40461
(starts with e-5-nine-e-6 and ends with d-4-0-four-6-1)
bottom of page