{"id":16025,"date":"2021-06-18T19:30:00","date_gmt":"2021-06-18T19:30:00","guid":{"rendered":"http:\/\/ci0285f98030002548"},"modified":"2025-01-29T15:17:20","modified_gmt":"2025-01-29T15:17:20","slug":"overview-bitcoins-cryptography","status":"publish","type":"post","link":"https:\/\/bitcoinmagazine.com\/technical\/overview-bitcoins-cryptography","title":{"rendered":"An Overview Of Bitcoin\u2019s Cryptography"},"content":{"rendered":"<div id=\"bsf_rt_marker\"><\/div><p>I\u2019m going to talk about the security behind Bitcoin addresses and keys, called Public Key Cryptography. This includes <a href=\"https:\/\/en.wikipedia.org\/wiki\/SHA-2\" target=\"_blank\" rel=\"noopener\">SHA256<\/a>, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Random_number_generation\" target=\"_blank\" rel=\"noopener\">Random Number Generators<\/a>(RNGs), <a href=\"https:\/\/en.wikipedia.org\/wiki\/Hash_function\" target=\"_blank\" rel=\"noopener\">Hash Functions<\/a>, and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Elliptic_Curve_Digital_Signature_Algorithm\" target=\"_blank\" rel=\"noopener\">Elliptic Curve Digital Signatures<\/a> (ECDSA.) If you have questions beyond this, please feel free to DM me. I am a mathematician by training, and I have a deep love for it. If you find that you have a new interest in cryptography as a hobby, there are many people who create cryptographic algorithms for fun, and their community can be helpful for your journey.<\/p>\n<p>I promise that you only need some basic algebra for this, as well as a simple understanding of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Exponential_function\" target=\"_blank\" rel=\"noopener\">exponential functions<\/a>. If you are familiar with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Modular_arithmetic\" target=\"_blank\" rel=\"noopener\">modular arithmetic<\/a>, that\u2019s wonderful. If not,no biggie.<\/p>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Cryptography\" target=\"_blank\" rel=\"noopener\">Cryptography<\/a> has been around for thousands of years, and currently has a very robust community of professionals and hobbyists alike. The technology has come an extremely long way, and its current iterations allow for the online security which we hardly have to think about.<\/p>\n<p>Let\u2019s start with the concept of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Public-key_cryptography\" target=\"_blank\" rel=\"noopener\">Public Key Cryptography<\/a>, specifically within the context of Bitcoin. On the most basic level, PKC involves your private keys, and the public keys generated from them. PKC utilizes what are called \u201c<a href=\"https:\/\/en.wikipedia.org\/wiki\/Trapdoor_function\" target=\"_blank\" rel=\"noopener\">trapdoor functions<\/a>\u201d which are easy to solve (easy to generate a public key from a private key), but almost impossible to reverse engineer (find a private key given a public key.) This is due to the usage of modular arithmetic, exponential functions, and very large <a href=\"https:\/\/en.wikipedia.org\/wiki\/Prime_number\" target=\"_blank\" rel=\"noopener\">prime numbers<\/a>.<\/p>\n<p>Your bitcoin private keys are probably words, but they can also be a very large number. To be specific, when we begin the encryption, your private keys will be converted to a large number or binary string (series of ones and zeros) regardless of what its initial form was. How neat! This is why people sometimes say your private keys \u201crepresent a very, very large number\u201d and is the reason for its security. While this is technically true in a deterministic\/algorithmic sense, it\u2019s not necessarily obvious why.<\/p>\n<p>Private key generation is another interesting facet. Hardware and custodial wallets do this for you, and they may or may not tell you precisely how they go about it (open-source vs closed-source software.) This is definitely worth considering when choosing a wallet. The other option is to create your own from scratch. You can roll a good die, flip a coin or use some other similar method. There are also online random number generators which have been tested and graded by the professional cryptography community. RNGs frequently use the current time as their generator to create a small initial difference which, after enough iterations, makes a totally unique number. Choose an online RNG at your own risk. Even if the RNG itself is good, there may be malware on the site. The more you know!<\/p>\n<p>So we have our secret words. Let\u2019s see what happens next.<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/bitcoinmagazine.com\/wp-content\/uploads\/2025\/01\/215_image2.png\" title=\"\"><\/figure>\n<p>This is a very simple form of our trapdoor function. \u201cG to the a mod n\u201d represents our final public key (mod is short for modular arithmetic, which restricts our answer to a certain limit of numbers, as opposed to every single <a href=\"https:\/\/en.wikipedia.org\/wiki\/Natural_number\" target=\"_blank\" rel=\"noopener\">natural number<\/a>). But, even if you know G and n, there\u2019s no easy way for you to find a, which represents your private key. Calculating G to the mod n is relatively easy, but there\u2019s no going backwards, thanks to the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Discrete_logarithm\" target=\"_blank\" rel=\"noopener\">Discrete Log Problem<\/a>. N is generally a large prime number because they are unfactorable by definition. Also, If relative complexities of functions\/problems interest you, feel free to look into <a href=\"https:\/\/en.wikipedia.org\/wiki\/Time_complexity\" target=\"_blank\" rel=\"noopener\">Algorithm Time Complexity<\/a>.<\/p>\n<p>Let\u2019s go a little deeper, and look at it graphically for a more concrete understanding.<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/bitcoinmagazine.com\/wp-content\/uploads\/2025\/01\/287_image1.png\" title=\"\"><\/figure>\n<p>The red line is our curve, and is the specific one used by Bitcoin\u2019s ECDSA. G is the point we start at, our \u201cgenerator,\u201d if you will. Then, we are going to \u201cadd\u201d G to itself (although it isn\u2019t addition in the usual sense &#8211; those crazy mathematicians love to redefine things. Don\u2019t even get me started on <a href=\"https:\/\/en.wikipedia.org\/wiki\/Clopen_set\" target=\"_blank\" rel=\"noopener\">topology<\/a>!). In this case, adding it means we are going to take the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Tangent\" target=\"_blank\" rel=\"noopener\">tangent line<\/a> of this point. Wherever that tangent line intersects the curve will be our next point. We will again take the tangent, and find a new point. In practice (on a computer) this is being done many thousands, or even millions, of times. The end result is that even if you know where I started, you don\u2019t know how many times I \u201cadded\u201d G to itself in order to get to the final point. How many times we performed the addition is your private key (your private number). Again, this is easy to check given a potential answer, but almost impossible to \u201cbrute force.\u201d Voila!<\/p>\n<p>So we have our first deterministic (one input gives you one answer) scrambling of information, but it\u2019s not in a great format (right now, it\u2019s just an ordered pair (x,y). We now have a public key, derived from a private one. Let\u2019s scramble that information again and transform it.<\/p>\n<p>We do this via SHA 256, which stands for Secure Hashing Algorithm. A Hashing Algorithm is a specific set of steps one applies to information, which results in an encrypted dataset of fixed length, regardless of the length of the input.<\/p>\n<p>Yes, this family of algorithms was developed by the United States National Security Agency (NSA), but don\u2019t let that worry you. The beauty of applied science \u2014 including mathematics, is that discovery and knowledge stand independent of who developed it. This is why we have proofs. If a proof is \u201csound,\u201d then it stands on its own two feet, and cannot be \u201chacked\u201d or worked around. The SHA2 family is public knowledge. You can go online and look at the code, and if you like <a href=\"https:\/\/xorbin.com\/tools\/sha256-hash-calculator\" target=\"_blank\" rel=\"noopener\">use SHA256 yourself<\/a> to encrypt some things. You\u2019ll find that a very small change in input will have a dramatic output on the answer. <a href=\"https:\/\/en.wikipedia.org\/wiki\/Chaos_theory\" target=\"_blank\" rel=\"noopener\">Chaos Theory<\/a> is beautiful. But anyhow.<\/p>\n<p>As many people secure billions of dollars with SHA256, they have also spent a lot of money testing it to ensure its security. People frequently bring up quantum computing as a potential way to break this encryption. However, were quantum computing to become feasible, there is a lot more money to be stolen by hacking the top five major banks in the world. I\u2019m sure Bitcoin is far down the list since, once it was hacked, its value would probably decrease dramatically. All that being said, if SHA256 becomes less secure in the future, we can always upgrade Bitcoin\u2019s encryption methods. Programmable money!<\/p>\n<p>SHA256 is similar to ECDSA in that it\u2019s easy to check an answer, but very difficult to brute force \u2014 trying every answer until you find the right one. SHA256 is so named because it creates a string of 256 bits \u2014 a series of 256 zeros and ones. This makes for an absurdly high number of possible combinations,<a href=\"https:\/\/www.universetoday.com\/36302\/atoms-in-the-universe\/#:~:text=At%20this%20level%2C%20it%20is,hundred%20thousand%20quadrillion%20vigintillion%20atoms.\" target=\"_blank\" rel=\"noopener\"> more than<\/a> the number of atoms in the observable universe.<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/bitcoinmagazine.com\/wp-content\/uploads\/2025\/01\/155_image3.png\" title=\"\"><\/figure>\n<p>We are going to use a different hash again in order to get a smaller output, which makes for a shorter final address. This hash function is called RIPEMD-160. Once we have this result, we are going to convert it into what\u2019s called Base58, which is just a form that\u2019s more readable for humans.It omits both the number zero (0) and the uppercase letter O (o), so that they aren\u2019t mistaken for each other, as well as omitting the uppercase letter I (i), so that it isn\u2019t mistaken for the number one (1) or the lower case letter l (L) It omits both the number zero (0) and the uppercase letter O (o), so that they aren\u2019t mistaken for each other, as well as omitting the uppercase letter I (i), so that it isn\u2019t mistaken for the number one (1) or the lower case letter l (L).<\/p>\n<p>And now we have a public address which is provably (in a formal, mathematical sense) created from a unique private address. Even if all seven billion people in the world create a new bitcoin public key every day for a thousand years, there are so many possibilities that the likelihood of creating the same one twice is almost zero.<\/p>\n<p>All of this is quite the process, creating and verifying keys, hence our ten minute average block time. Ten minutes for mathematically-guaranteed final settlement is worth everything.<\/p>\n<p><em>This is a guest post by Nameless. Opinions expressed are entirely their own and do not necessarily reflect those of BTC Inc. or <\/em>Bitcoin Magazine<em>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A look at the securing mechanisms of the global monetary system millions entrust their value with.<\/p>\n","protected":false},"author":3241,"featured_media":8914,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[329,2974],"class_list":["post-16025","post","type-post","status-publish","format-standard","has-post-thumbnail","category-technical","tag-cryptography","tag-ecdsa"],"author_data":{"id":3241,"name":"Nameless","nicename":"nameless","avatar_url":"https:\/\/bitcoinmagazine.com\/wp-content\/uploads\/2024\/12\/screen-shot-2021-04-10-at-70511-pm-96x96.png"},"featured_image_url":"https:\/\/bitcoinmagazine.com\/wp-content\/uploads\/2024\/11\/bitcoin-magazine-quantum.png","_links":{"self":[{"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/posts\/16025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/users\/3241"}],"replies":[{"embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/comments?post=16025"}],"version-history":[{"count":0,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/posts\/16025\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/media\/8914"}],"wp:attachment":[{"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/media?parent=16025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/categories?post=16025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bitcoinmagazine.com\/wp-json\/wp\/v2\/tags?post=16025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}