• Welcome to forex.pm forex forum binary options trade. Please login or sign up.
 

public key from private key math [closed]

Started by Bitcoin, Feb 25, 2022, 03:59 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bitcoin

public key from private key math [closed]

Please guide me if following is the actual math to drive public key from a private key then how would this apply to generate public key from private key 1 please guide me step by step


Private keys and public keys
With these formalities out of the way, we are now in a position to understand private and public keys and how they are related. Here it is in a nutshell: In ECDSA, the private key is an unpredictably chosen number between 1 and the order. The public key is derived from the private key by scalar multiplication of the base point a number of times equal to the value of the private key. Expressed as an equation:


public key = private key * base point


This shows that the maximum possible number of private keys (and thus bitcoin addresses) is equal to the order.


In a continuous field we could plot the tangent line and pinpoint the public key on the graph, but there are some equations that accomplish the same thing in the context of finite fields. Point addition of p + q to find r is defined component-wise as follows:


c = (qy - py) / (qx - px)
rx = c2 - px - qx
ry = c (px - rx) - py


And point doubling of p to find r is as follows:


c = (3px2 + a) / 2py
rx = c2 - 2px
ry = c (px - rx) - py


In practice, computation of the public key is broken down into a number of point doubling and point addition operations starting from the base point.


Let's run a back of the envelope example using small numbers, to get an intuition about how the keys are constructed and used in signing and verifying. The parameters we will use are:


Equation: y2 = x3 + 7  (which is to say, a = 0 and b = 7)
Prime Modulo: 67
Base Point: (2, 22)
Order: 79
Private key:  2


First, let's find the public key. Since we have selected the simplest possible private key with value = 2, it will require only a single point doubling operation from the base point. The calculation looks like this:


c = (3 * 22 + 0) / (2 * 22) mod 67
c = (3 * 4) / (44) mod 67
c = 12 / 44 mod 67


Here we have to pause for a bit of sleight-of-hand: how do we perform division in the context of a finite field, where the result must always be an integer? We have to multiply by the inverse, which space does not permit us to define here (we refer you to here and here if interested). In the case at hand, you will have to trust us for the moment that:


44-1 = 32


Moving right along:


c = 12 * 32 mod 67
c = 384 mod 67
c = 49


rx = (492 - 2 * 2) mod 67
rx = (2401 - 4) mod 67
rx = 2397 mod 67
rx = 52


ry = (49 * (2 - 52) - 22) mod 67
ry = (49 * (-50) - 22) mod 67
ry = (-2450 - 22) mod 67
ry = -2472 mod 67
ry = 7


Our public key thus corresponds to the point (52, 7). All that work for a private key of 2!


Source: public key from private key math [closed]