Wednesday, December 11, 2013

Fun With Bitcoin For Beginners: Part Four

Bitcoin is thinking BIG.  Take a look (*click* on the image to see the smaller details) at the image above (one of many from, there apparently is "no official image")...  Liberty, Equality, Truth.  "21,000,000 to infinity".  2009, their foundation year.  In cryptography they trust.

This article is rather technical in nature.  I have had two people review this and suggest changes to make (which I did) to make it "easier".  You be the judge.


BTC mining is a complicated process that actually, at root, as more to do with probability than with strictly cycles of fast computers, and thus differs at heart from Phil Zimmerman's "PGP" ("Pretty Good Privacy", a used-to-be free email encryption program) technology of some 15 + years ago.  The core of PGP was that multiplying two LARGE prime numbers together (and calculating their solution of course) is computationally much easier that starting with one very large product and "backwards deriving" the two primes.  Here is a simplified example of the two prime numbers method.  YOU try to guess the two prime multiples of the below number, go ahead, guess or tell me!  

Contest!  The FIRST one to leave me the two prime multiples below wins FREE 0.05 BTC, that is worth +/- $40.00, so get to work!  Of course, you would need to send me your BTC wallet, and ONLY post below by Comment, first Comment to guess wins the BTC!  You also MUST tell me how you derived the primes, you don't tell me, you don't win.

12,094,091    <--- get cracking!

[Update!  The contest is over, see first Comment, "Unknown" already won!]

Of course in the real world, the primes used in the above would be (say) 60 digits or so each, meaning a huge number.  It becomes computationally impossible (last I heard anyway) to break a number like the above that is 100 or 200 digits long...  But, a big (fast) enough computer COULD DO it in theory (big numbers).


Mining BTC uses a completely different mathematical technique, called a "hashing function".   A hashing function (here anyway) takes some input, and by some weirdo math, turns into a hard-to-reverse piece of output (encrypted).  By complete coincidence I developed my own little 'hashing function" a few years ago in SQL ("Structured Query Language" a database-only language, Oracle and MS Access use SQL)) when I wanted a way to encrypt our Customer IDs (a number, kind of like our Social Security numbers here) yet list the amounts they bought.  Show prospective customers that Ameru was REAL, that we moved real amounts of bearings.

Here is the heart of my SQL (this is just a clip from the whole encryption function I made up) coding to do that.  The below takes an 11 digit Customer ID and completely changes it into a completely different 12 digit number:

((Right(([df_2].RUC),2) Mod 2) + 1) * 10)  & (Right(Left((([df_2].RUC) * 599),11),10))

I will not bore you with dissecting the above (fairly complicated) SQL, but I take the Customer ID number ("RUC"), multiply it by 599, then take the second through eleventh digits in that product, but prefixed (fairly randomly) by "10" or "20" (that "Mod 2" you see at the left).

Real Customer ID:  20121941962
Secure Customer ID:  102053043235  <--- hard to derive the real Customer ID

Obviously the hashing function with Bitcoin is much more secure and robust than mine, there is real money at stake with BTC!

Once again I have asked the help of BTC expert "Bitcoin Insider" ("B.I") to help me better understand the subject so that I can pass it along to you all in terms that even I can understand (smile).  One aspect of the BTC Ecosystem I wanted to gain a little understanding of is the BTC mining process.  I had read a lot of somewhat contradictory comments at Zero Hedge re mining for BTC, and I wanted him to straighten me out.  I asked him to explain in simple terms something about the mechanism of encryption used in BTC:

Short initial answer:

(List of recent transactions for the next 10 minute block) +
(random number selected by mining computer) = a hashed number with
many leading zeros below a threshold number

Whichever mining computer finds this low hash number first creates
the block and gets the 25 Bitcoin reward plus transaction fees.

I'll look for the best easy answer at some of the educational sites
and send you a link.

That "leading zeros" I bolded is explained in more detail here from this article that B.I. sent me ( by "azotic";  Key quotations from the article, (it is NOT that hard, I encourage everyone to read it).

"...bitcoin hash outputs need to start with about 14 zeroes at the time of this writing in order to be accepted by the network as a solution."


"That number of zeroes that the output has to start with is known as the "difficulty." right now, the entire network of miners makes about 30 trillion(!) attempts at this solution every SECOND. You can see the "hash rate" at sites like A solution (which yields 25 bitcoins to the finder) is found approximately every 10 minutes."

Note from the above second clip that 30 TRILLION attempts per second are made worldwide to solve the BTC "math problem".

The Bitcoin hash function is based on the open-source "SHA-256" mechanism, here is a link that will allow any of you to generate your OWN hash functions:

For illustration, here are some results when I went to play with it.

Inputs (I know what the below three things mean even if you do not!):


Outputs (in above order):


Oooh!  Look at those lovely outputs!  As in PGP's "two prime number" method of encrypting data, taking the OUTPUT and trying to guess the Input is computationally infeasible...  Note that the THIRD one starts with a zero.  To solve a BTC math problem, your computer would have to stumble upon a correct hashed output that starts with 14 zeros!  See first snippet above with yellow background.

Another wrinkle is that even if you have a very powerful "ASIC computer" (or even a "server farm" of 100 of them), that there is no guarantee that you would get a solution, not even in 10 years.  It is probability based!  Yes, a fast rig (or farm of 'em) is much more likely to find a solution in a reasonable amount of time, but there are no guarantees...

Keep in mind I asked him for a simple explanation, ha ha ha!  But, to get this level of understanding is NOT THAT DIFFICULT (even if it is not necessary to understand this to use BTC, although to mine BTC you would need to know this and more).  That "25 Bitcoin reward" would now be worth some $20,000, perhaps more by the time you read this).


There is other math, probably at least as complicated as the above securing Bitcoin.  Apparently "elliptical curve encryption" where they use equations of the type:

 y^2 = x^3 + ax + b, \,

(see here:

This is used in showing who owns which pieces of Bitcoin (this is needed for transferring BTC).

Zero Hedge member "zaphod" posted this comment which I quote in full (minor edits for spelling):

ECDSA (Elliptic Curve Digital Signature Algorithm) is the cryptography that is used to prove ownership of individual bitcoins. 
In ECDSA there are 2 keys, a public key and a private key. Basically an address is the public key and the private key is what you keep secret, essentially possession of the private key equals possession of a bitcoin. 
The way transactions work is you create a public/private key pair and then provide the public key (actually the hash of the public) as the address to "receive" bitcoins. When someone sends you a bitcoin they create a transaction that specifies your address (public key) as the receiver of X bitcoins. Once that transaction is recognized by the network, the only way to release those bitcoins in your address is to sign them with your private key. Now when you want to send the bitcoin you received, you use your private key to create a unique signature on the previously received coins. The way ECDSA works is anyone with the public key (your address) can verify that the signature is correct, however the only way to create the signature requires the private key. 
This is a great walkthrough of ECDSA if you are interested in the concept. Will take a few hours to absorb the concepts/math.

Elliptic curve cryptography, I read, is much more secure than the "two primes" method of PGP.

OK, elliptic curves take care of ownership of BTC, the SHA-256 hashing method takes care of the mining.


Zero Hedge reader "Prisoners_dilemna" asked about another encryption method (


Mmm, got me there, Prisoners_dilemna!

Update!  "Prisoners_dilemna" wrote another piece at Zero Hedge where he provided some information and link to a wikipedia article on RIPEMD160.  Here is the link to his explanation of how a "public address" (a BTC wallet) is created, it is a nine step process and it is not easy...

And a wikipedia link to RIPEMD160, which was created in Belgium by the academic sector (NOT the NSA like SHA-256 was), and is not patented:

And THAT hereby finishes my article.


I had hoped that I would have word on my purchase of the 0.25 oz Gold Eagle by now.  Nope, no word yet.  Maybe that will be in my article "Fun With Bitcoin For Beginners: Part Five".


  1. [user@kasse ~]$ factor 12094091
    12094091: 2347 5153


  2. OK, Mr. Unknown very good. But, you guys programming computers have to SHOW YOUR WORK! And I want to see it (with comments) in C++, PERL, Visual Basic and Python (or in MS Excel). YOU WIN, as long as you comply.

  3. @ Unknown, never mind, I just Googled to find online sites that do prime number factorization. You win. I will send the 0.05 BTC momentarily.

  4. @ Unknown, here are the transaction details, as of the moment, MultiBit shows "4 peers" having seen it. You should receive it soon.

    Congratulations! I would still be interested in your exact technique, but your BTC is on the way whether you comply or not.

    Transaction details (slightly edited):

    edf0d52f32a37c2e18e01e0a72e62a05191be93071d7b4f7c1a4364ef5c552b0: Seen by 4 peers. Pending/unconfirmed.
    from 1P11[,..]R / 7ee1dd29207f8e6650ca47aa75bf9d46c4bef66eb7ae9fe467b8a19d283beccb:1
    to 17eMbnhXdkMPnCPQaESKcVDSJ6A3HEZ3Tg 0.05 BTC
    to 1P11[...]R 0.0143 BTC

  5. Hi Robert,

    I'm sorry about the late reply - I just found your post before I had to run off to work, and didn't catch your replies before now.

    I used the 'factor' program to solve your puzzle - I know this as a toy that comes with most linux-distributions. It's included in the one I run at home, CentOS 6, and it decomposes integer-numbers into their factors;

    [root@scider-1 ~]# factor 1073741824
    1073741824: 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

    As every smartphone today has the computational power of a supercomputer from the 1990s, this takes no perceptible time;

    [root@scider-1 ~]# time factor 1152921504606846975
    1152921504606846975: 3 3 5 5 7 11 13 31 41 61 151 331 1321

    real 0m0.001s
    user 0m0.000s
    sys 0m0.000s

    As to BitCoins - I was vaguely aware of them until the beginning of this year, and then started running the 'GuiMiner' application on my Windows desktop, getting about 20Mhashes/s, and seeing that I'd need a few months to get a whole BitCoin mined. I then included another two desktops into my 'mining cluster', and am currently mining at 0.2Ghashes/s - and according to my statistics I'm awarded about 1-2% of 0.01BtC pr day for that, so for me as a hard-working miner, your gift represents about a year of payouts at current rates (and the rates are still dropping quickly, of course).

    If you don't mind, I'd like to make a donation back to the running of your blog and your presence at ZH. I do find you an inspiring presence.

    Best regards,
    (Google surely tells you my email address, right? Please drop me a line)


Note: Only a member of this blog may post a comment.