# But Bitcoin users have keys to verify

But in today’s day and age, all forms of currency, from dollars to euros to rupees, are only valuable because humans give it value. Understanding this concept, an anonymous genius invented Bitcoin – a digital form of currency that has value because we think it has value. Every 10 minutes, a block of bitcoin is mined which equates to 180 blocks per day and 65,700 blocks per year. Bitcoin is based off of a compilation of concepts and technologies. The unit used to measure value is simply called bitcoin, and these have the ability to hold or pass on value to investors or people part of the bitcoin network.

These people who compose the network mainly interact online. The bitcoin software is easily accessible to the public, as there is a website as well as a smartphone app. Through this public network, people around the globe have a more rapid and secure way to buy and sell items, send money to other people, and do as they would with normal paper currency. Bitcoin is a completely electronic currency, meaning there are no physical bills or coins. The negotiation from sender to recipient of bitcoin implies value which implies coins, but there aren’t electronic coins either. Bitcoin users have keys to verify that they own their portion of the bitcoin network, and with these keys, the users can obtain and spend the value by sending it to another owner.

Digital wallets are used to store each user’s keys. Bitcoin is a networked system in its entirety; there is no head or central controlling server. Bitcoin can be created by mining, which users go about by processing bitcoin transactions through competing to solve complex mathematical problems. All users have the opportunity to act as miners, and through this network, there is little need for a central bank. For upkeep of the average block of bitcoin mined every 10 minutes, the Bitcoin protocol has built-in algorithms that decrease or increase the difficulty of the problems to allow success every 10 minutes. Every 4 years, the rate of bitcoin production is halved, but the maximum bitcoin that will ever be created is around 21 million.

However, bitcoin cannot be inflated if more than 21 million bitcoin are created. In summary, the four novel aspects of Bitcoin are the protocol which allows a peer-to-peer network with no central server, a public ledger for transactions called the blockchain, rules set for validation of a transaction and the issuing of currency, and a route to a global and decentralized agreement on the blockchain.Public and Private TransactionsThe elliptic curve digital signature algorithm (ECDSA) allows for Bitcoin transactions to be both public and private. This algorithm uses a finite field to draw an elliptic curve onto. The formula for an elliptic curve is y^2 = x^3 + ax + b.

In the bitcoin algorithm a = 0 and b = 7. Therefore the graph is as follows:A property of elliptic curves is when a non-vertical line intersects two points that are not tangent to each other, the line will intersect a third point on the curve. Also, a non-vertical line tangent to the curve at one point will intersect only one other point on the curve.

Two operations define these properties: point addition and point doubling.Point addition (P + Q = R) is when the third intersecting point (R) is reflected through the x-axis on a line that intersects both P and Q. An example of point addition is as follows:Point doubling (P + P = R) is when a line tangent to the point doubled (P) is found, and reflected through the x-axis of the point R on the curve to find R. An example of point doubling is as follows:Point addition and point doubling are used together for scalar multiplication (R = aP). For example:R = 9R = P = (P + (P + (P + (P + (P + (P + (P + P)))))))Scalar multiplication is simplified using both point addition and point doubling.

For example:R = 9PR = P + 8PR = P + 2 (4P)R = P + 2 (P + P + P)Through the algorithms that make up the elliptic curve, the curve is exclusive to the user, so it verifies that the user is eligible to go about the transaction. The two keys used for signing (the private key) and verifying (the public key) are separate algorithms in ECDSA. Finite fields when used with ECDSA are essentially a range of positive numbers that each algorithm calculation must fall between. One way to go about this calculation is by calculating remainders represented by the modulus (mod) operator of Bitcoin. For example, 9 mod 6 = 3. In this example, the finite field modulo is 6 and all mod operations in this finite field with fall between 0 and 5.

ECDSA’s use of finite curves changes the appearance of the curve, but not the equation or the properties. The same equation above (9 mod 6 = 3) except with a finite field of 67 is plotted as follows:The field is a group of points where all the x and y values are between 0 and 66. The curve retains horizontal symmetry no matter the field in which it was drawn on.Bitcoin sets parameters for the curve and its finite field in which it can fall on. The parameters also include an equation, the field’s prime modulo, and a base point falling on the curve.By using extremely large numbers for the prime modulo and base point, ECDSA applications have extremely large values.When using ECDSA, the private key is a random number from 1 to order and the public key is derived from the private by scalar multiplication as follows:public key = private key * base pointThe maximum possible amount of private keys is equal to the order.In a continuous field, the tangent line can be plotted and then the public key can be pinpointed on the graph, but equations to do so in a finite field through point addition of p + q to find r are as follows:c = (qy – py) / (qx – px)rx = c2 – px – qxry = c (px – rx) – pyTo find r through point doubling of p equations are as follows:c = (3px2 + a) / 2pyrx = c2 – 2pxry = c (px – rx) – pyTo compute the public key, point doubling and point addition are used from the base point.

An example of calculation both the public and private keys using small parameters is as follows: Equation: y2 = x3 + 7 (a = 0 and b = 7)Prime Modulo: 67Base Point: (2, 22)Order: 79Private key: 2To find the public key:c = (3 * 22 + 0) / (2 * 22) mod 67c = (3 * 4) / (44) mod 67c = 12 / 44 mod 6744-1 = 32c = 12 * 32 mod 67c = 384 mod 67c = 49rx = (492 – 2 * 2) mod 67rx = (2401 – 4) mod 67rx = 2397 mod 67rx = 52ry = (49 * (2 – 52) – 22) mod 67ry = (49 * (-50) – 22) mod 67ry = (-2450 – 22) mod 67ry = -2472 mod 67ry = 7Our public key is the point (52, 7), and our private key is 2!The operation of private to public key is much easier computationally than public to private key. Now that we have a public and private key we can sign some data! The first step is to choose a number with the same number of bits as the order of the curve (in our case, 256). To stay simple, our base point will be G, our order will be n, our private key will be d, and we will sign the raw data as “z.

“The steps are as follows:Choose an integer k between 1 and n – 1.Calculate with scalar multiplication the point (x, y) = k * G.Find r = x mod n. If r = 0, return to step 1.Find s = (z + r * d) / k mod n.

If s = 0, return to step 1.The signature is the pair (r, s)At step 4, if the numbers are a fraction, the numerator must be multiplied by the inverse of the denominator. Also, k should not be repeated in step 1 so that a third party cannot guess your signature. Now, our data is the number 17 and our variables:z = 17 (data)n = 79 (order)G = (2, 22) (base point)d = 2 (private key)Pick a random number:k = rand(1, n – 1)k = rand(1, 79 – 1)k = 3Calculate the point in the same way as determining the public key.(x, y) = 3G(x, y) = G + 2G(x, y) = (2, 22) + (52, 7)(x, y) = (62, 63)x = 62y = 63Next, find r:r = x mod nr = 62 mod 79r = 62Now, find s:s = (z + r * d) / k mod ns = (17 + 62 * 2) / 3 mod 79s = (17 + 124) / 3 mod 79s = 141 / 3 mod 79s = 47 mod 79s = 47s = (z + r * d) / k mod ns = (17 + 62 * 2) / 3 mod 79s = (17 + 124) / 3 mod 79s = 141 / 3 mod 79s = 141 * 3-1 mod 79s = 141 * 53 mod 79s = 7473 mod 79s = 47The signature will be the pair (r, s) = (62, 47).

With both the private and public keys, the signature is represented by a hexadecimal string.Now that we have data and a signature, we can verify our signature with the public key. Q is the public key and the other variables are as above. The steps for signature verification are as follows:Verify that r and s are between 1 and n – 1.

Calculate w = s-1 mod nCalculate u = z * w mod nCalculate v = r * w mod nCalculate the point (x, y) = uG + vQVerify that r = x mod n. The signature is invalid if it is not.Our variables:z = 17 (data)(r, s) = (62, 47) (signature)n = 79 (order)G = (2, 22) (base point)Q = (52, 7) (public key)We must verify that r and s are between 1 and n – 1.

r: 1 <= 62 < 79s: 1 <= 47 < 79Now, calculate w:w = s-1 mod nw = 47-1 mod 79w = 37Calculate u:u = zw mod nu = 17 * 37 mod 79u = 629 mod 79u = 76Calculate v:v = rw mod nv = 62 * 37 mod 79v = 2294 mod 79v = 3Calculate (x, y):(x, y) = uG + vQBy breaking up point doubling and addition in uG and vQ separately:uG = 76GuG = 2(38G)uG = 2( 2(19G) )uG = 2( 2(G + 18G) )uG = 2( 2(G + 2(9G) ) )uG = 2( 2(G + 2(G + 8G) ) )uG = 2( 2(G + 2(G + 2(4G) ) ) )uG = 2( 2(G + 2(G + 2( 2(2G) ) ) ) )uG = 2( 2(G + 2(G + 2( 2( 2(2, 22) ) ) ) ) )uG = 2( 2(G + 2(G + 2( 2(52, 7) ) ) ) )uG = 2( 2(G + 2(G + 2(25, 17) ) ) )uG = 2( 2(G + 2( (2, 22) + (21, 42) ) ) )uG = 2( 2(G + 2(13, 44) ) )uG = 2( 2( (2, 22) + (66, 26) ) )uG = 2( 2(38, 26) )uG = 2(27, 40)uG = (62, 4)And now vQ:vQ = 3QvQ = Q + 2QvQ = Q + 2(52, 7)vQ = (52, 7) + (25, 17)vQ = (11, 20)Both together:(x, y) = uG + vQ(x, y) = (62, 4) + (11, 20)(x, y) = (62, 63)Finally, verify that r = x mod nr = x mod n62 = 62 mod 7962 = 62Clearly, there are deep relations between public and private keys. The algorithms behind bitcoin make it enormously complicated to solve for a key, however the application of simple mathematical functions attempt to make solving take less time. Bitcoin is the future of banking. Bitcoin's blockchain technology has numerous applications to cloud storage, supply chain communications, digital identity, contracting, and digital voting.