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 ?
- Choose two distinct large prime numbers, p and q, randomly.
- Compute n =p*q .
- Compute Euler totient function such that ϕ(n) = (p-1)*(q-1).
- Choose e such that e is 1<e<ϕ(n). n and e forms public key.
- 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.