Post

# How Public And Private Keys Are Generated In Blockchain Networks

Blockchain networks use an asymmetric encryption technique. The public and private key is used for verification and the signing of transactions.

What algorithm is used to generate Public/Private key ?

RSA Algorithm.

How to generate Public/Private key using RSA ?

1. Choose two distinct large prime numbers, p and q, randomly.
2. Compute n =p*q .
3. Compute Euler totient function such that ϕ(n) = (p-1)*(q-1).
4. Choose e such that e is 1<e<ϕ(n). n and e forms public key.
5. Determine d, such that d *e = 1 * (mod(ϕ(n)) or d = (k*Φ(n) + 1) / e where k = integer.

With n,d,e  public and private keys can be generated.

Public key generation

Public key = (e,n) , the integer e and n along with the message ‘m ‘ constitutes encryption in network.

"Encrypted message(EM) = me mod n "

Private Key generation

Private key = (d,n) , the integer d and n with the encrypted message (EM) is used for decryption.

"Decrypted message = EM d mod n"

ECDSA

Elliptical Curve digital signature algorithm is used to generate the p and q large prime numbers randomly in Bitcoin and Ethereum networks.