Open In App

Blockchain – Elliptic Curve Cryptography

Cryptography is the study of techniques for secure communication in the presence of adversarial behavior. Encryption uses an algorithm to encrypt data and a secret key to decrypt it. There are 2 types of encryption:

  1. Symmetric-key Encryption (secret key encryption): Symmetric-key algorithms are cryptographic algorithms that employ the same cryptographic keys both for plaintext encryption and ciphertext decoding. The keys could be identical, or there could be a simple transition between them.
  2. Asymmetric-key encryption (public key encryption): Asymmetric-key algorithms encrypt and decrypt a message using a pair of related keys (one public key and one private key) and safeguard it from unauthorized access or usage.

The following topics of Elliptic Curve Cryptography will be discussed here:



  1. Introduction to Elliptic Curve Cryptography
  2. History of Elliptic Curve Cryptography
  3. Components of Elliptic Curve Cryptography
  4. Elliptic Curve Cryptography Algorithms
  5. Application of Elliptic Curve Cryptography
  6. ECC vs RSA
  7. Elliptic Curve Diffie-Hellman Protocol Implementation
  8. Types of Security Attacks
  9. Benefits of Elliptic Curve Cryptography
  10. Limitations of Elliptic Curve Cryptography
  11. Conclusion

Introduction to Elliptic Curve Cryptography

ECC, as the name implies, is an asymmetric encryption algorithm that employs the algebraic architecture of elliptic curves with finite fields.

History of Elliptic Curve Cryptography

Components of Elliptic Curve Cryptography

Below are the components of elliptic curve cryptography:



1. ECC keys:

2. Generator Point:

Elliptic Curve Cryptography Algorithms

Based on the arithmetic of elliptic curves over finite fields, Elliptic-Curve Cryptography (ECC) provides numerous sets of algorithms:

Digital signature algorithms:

Encryption algorithms:   

Key Agreement algorithm:

 Application of Elliptic Curve Cryptography

ECC vs RSA

Below is the difference between ECC and RSA: 

Parameters

ECC

RSA

Working algorithm ECC is a cryptography technique that works just on a mathematical model of elliptic curves. RSA cryptography algorithm is primarily based on the prime factorization approach.
Bandwidth savings ECC gives significant bandwidth savings over RSA. RSA provides much lesser bandwidth saving than ECC.
Encryption process The encryption process takes less time in ECC. The encryption process takes more time in RSA.
Decryption process The decryption process takes more time. Decryption is faster than ECC.
Security ECC is much safer than RSA and is currently in the process of adapting.  RSA is heading toward the end of its tenure.

ECC vs RSA: Key Length Comparison:

Security(in Bits)

RSA key length required

ECC key length required

80

1024

160-223

112

2048

224-255

128

3072

256-383

192

7680

384-511

256

15360

512+

Elliptic curve Diffie-Hellman Protocol Implementation

Prerequisite: Basics of python programming language, basics of cryptography techniques, and Elliptic curve Diffie-Hellman Protocol.

Install tinyec in Python:

pip install tinyec

 

After the required modules and dependencies are installed then use the following code for the calculation of the shared secret key between user A and user B.   




# Importing required libraries used 
# to perform arithmetic operations 
# on elliptic curves
from tinyec import registry
import secrets
  
# Function to calculate compress point 
# of elliptic curves
def compress(publicKey):
 return hex(publicKey.x) + hex(publicKey.y % 2)[2:]
  
# The elliptic curve which is used for the ECDH calculations
curve = registry.get_curve('brainpoolP256r1')
  
# Generation of secret key and public key
Ka = secrets.randbelow(curve.field.n)
X = Ka * curve.g 
print("X:", compress(X))
Kb = secrets.randbelow(curve.field.n)
Y = Kb * curve.g 
print("Y:", compress(Y))
print("Currently exchange the publickey (e.g. through Internet)")
  
# (A_SharedKey): represents user A
# (B_SharedKey): represents user B
A_SharedKey = Ka * Y
print("A shared key :",compress(A_SharedKey))
B_SharedKey = Kb * X
print("(B) shared key :",compress(B_SharedKey))
print("Equal shared keys:", A_SharedKey == B_SharedKey)

Output:

 

Explanation:

Types of Security Attacks

Benefits of Elliptic Curve Cryptography

Limitations of Elliptic Curve Cryptography

Conclusion


Article Tags :