ASymmetric key Encryption
What is asymmetric key encrption
Types of Asymmetric key Encryption
1. DH(Diffe-Helman)
Once both parties derive the shared secret key(ssk), DH Pvt, public keys are dropped(to prevent derivation of ssk by hacker if DH keys are compromised in future)
Understand Deeply
|
|
Key size in DH
key size = Size of Prime number. Small number is used for easy
calculation, in practice large sizes are choosen
1024, 2048(standard minumum), 3072(strong), 4096(max) bits
2. RSA (Ronald Rivest, Adi Shamir, Len Adleman)
A. Pre-calculate Public, pvt key
1. Choose 2 numbers p(1024 bit),q(1024 bit). {p=3,q=11}
2. Find n = p`*`q, z =(p-1)(q-1) {n=33, z=20}
3. Choose a number d relatively prime to z. {d=7} //7 and 20 has no common factor
4. Find e. So that e × d = 1 mod(z)
e x 7 = 1 mod(20)
e = mod(20)/7 = 3 (approx)
Public Key = (e,n). Private Key = (d,n)
B. Divide Plain-text into blocks input=10101111. {block1=1010 block2=1111}
C. Encrypt: cipher text© = Block-of-plain-texte (mod n)
C = P^3 mod(33)
D. Decrypt: Plain text(P) = Cd (mod n)
P = C^7 mod(33)
Public Key (n, e) Private Key (n, d) or 5-value
Host-A Host-B
-----Prime-1=53, Prime-2=59------> //In real calculations P & Q are large numbers (64 bytes)
Modulus(n)=P*Q=64x64=128 bytes=1024 bit
Phy(n)=(P-1)(Q-1)=3016
Exponent(e)=coprime of Phy
Public-key calculated Public-key= n&e
Pvt key=2 (Phy(n) + 1)/e
encryption of data: data pow(e)mod(n)
<---cipher-text------ 89 pow(3)mod(3127) //if data=89
Decryption of data
(cipher Text)pow(Pvt Key) mod(n)
(1394) pow(2011) mod(3127) = 89
3. Elliptic Curve
Public, Pvt keys are calculated using elliptic curve(y2 =
x3 + ax + b) over Galois field.
Galois field: Field containing finite number of elements rather than
real numbers.
Advantage of ECC? Smaller keys in ECC provides equivalent
security to larger non-ECC based algos.
Applications of ECC?
Calculating keys for following: Key agreement, Digital Signature,
Pseudo-random generators.
ECCs can be used after combining with Symmetric encryption schemes.
DH vs ECC keys: ECC provides the same cryptographic security as DH with significantly smaller key sizes. ECC achieves identical protection with DH on
| DH Key Size (Bits) | ECC Key Size (Bits) |
|---|---|
| 1024 | 160–192 |
| 2048 | 224 |
| 3072 | 256 |
| 7680 | 384 |
3.1 (ECDH) Ecliptic Curve based Diffie Hellman
Allows two parties, each having an elliptic-curve public–private key
pair, to establish a shared secret over an insecure channel.
This shared secret maybe used directly as key or derive another key.
The key, or the derived key, can then be used to encrypt subsequent
communications using a symmetric-key cipher.
3.2 secp256k1 ECC Algorithm (Used in Bitcoin/Ethereum/Blockchain)
Private Key: This is just a random number between (1 & (2256
= 1077)). But should be generated using good source of
randomness(called entropy).
K(Public Key) = k(pvt Key) * G(constant called Generator point). //G is
same for all users