Introduction to ECDSA and Its Implementation in Blockchain

Saxena Aditi
csivit
Published in
12 min read1 day ago

In the ever-evolving landscape of digital technology, blockchain has emerged as a transformative force, promising secure and transparent transactions without the need for intermediaries. At the heart of blockchain’s security infrastructure lies a sophisticated cryptographic technique known as Elliptic Curve Digital Signature Algorithm (ECDSA). This algorithm plays a pivotal role in ensuring the integrity, authenticity, and confidentiality of transactions within blockchain networks.

Understanding ECDSA

ECDSA belongs to the family of public-key cryptography, where each participant in a communication network possesses a pair of cryptographic keys: a public key and a private key. These keys are mathematically related but computationally impractical to derive one from the other. The public key is openly distributed and serves as an address for receiving transactions, while the private key is kept secret and used for signing transactions securely.

Basically, ECDSA is like an exclusive club membership card. Your private key is your personal ID that grants you access (signs the message). The public key is the club’s guest list that anyone can check to see if you’re a legitimate member (verify the signature).

The core operations of ECDSA involve elliptic curve mathematics and modular arithmetic. Elliptic curve cryptography leverages the properties of elliptic curves over finite fields, making it computationally efficient compared to traditional RSA encryption. The algorithm ensures that only the holder of the private key can generate a valid digital signature for a given message, while anyone with the corresponding public key can verify the authenticity of that signature.

Significance of ECDSA in today’s world

ECDSA finds its use in various fields of technology mostly that relates to a certain degree of securtity and authentication. The purpose of using ELLIPTIC CURVE DIGITAL SIGNATURES alone is the fact that one wants to be able to make a message or a document available only to selected individuals without the use of any secure communication channel but just mathematical algorithms that are largely not breachable.

From the SSH Keys you might use while cloning a repository, to the ‘secure’ sites you might visit under HTTP protocol — It is all ECDSA. File transfer, VPNs, VoIP- all that requires a secure communication mechanism use ECDSA.

Fundamentals of Elliptic Curve Cryptography

We have been talking about cryptography, elliptic curves, mathematical complexity and digital signatures for quite sometime now…

Let me break it down for you. Let’s start with the basics.

Cryptography is that field of technology, science or innovation rather that serves as a mechanism to hide your data while one transfers it through various mediums and channels. You want to give someone a message such that no one else is able to decipher it- that is cryptography.

Elliptic Curves is just a way to channel this cryptographic spirit through a complex mathematical problem. Such problem statements are not designated difficult because they are calculation intensive but because there are streamlined methods to reach to the solution in shortest time possible. These methods are so carefully designed that if approached in the wrong way- they can lead to hindrance in finding the parameters without the additional noise.

Weirstrass Curve used for ECDSA

By Definition, an elliptic curve is a plane curve defined by the equation 𝑦²=𝑓(𝑥), where f(x) is a cubic polynomial with no repeated roots. They are mathematical objects described by equations like y²=x³+ax+by² = x³ + ax + by²=x³+ax+b, deriving their name from elliptic integrals despite not being ellipses in the geometric sense. The standard form, known as the Weierstrass form y²= x³+ax+b, facilitates analysis and transformations such as x′=x+d/3x’ = x + d/3x′=x+d/3 for simplification. These curves can be defined over various fields including complex numbers, real numbers, rational numbers, or finite fields, each influencing their properties and applications. In our case, we choose it to be defined over integers so that it aligns with discrete logarithmic problem ( Yes , we will get to ECDLP).

Elliptic curves find extensive use in cryptography, particularly in Elliptic Curve Cryptography (ECC) for secure communication and digital signatures (ECDSA), as well as in number theory for solving Diophantine equations and in computer science for error-correcting codes and algorithms. The characteristics of elliptic curves are shaped by the field over which they are defined, affecting computational capabilities and transformation feasibility. Their compactness, efficiency, and security properties make them indispensable in modern cryptographic protocols and mathematical investigations.

Components of ECDSA

For Alice to be able to sign a message and enable bob to be able to access it, the signature algorithm plays along with the public and private key via the mathematical metric of the elliptic curve involving some Parameters:

  • Field Type: Prime field (F_p) or binary field (F_ 2^m).
  • Elliptic Curve Equation: Defines the shape of the curve (e.g., y² = x³ + a+b).
  • Curve Coefficients (a, b): Parameters in the curve equation.
  • Base Point (G): A point on the curve used as a generator.
  • Order (n): The prime order of the base point G.
  • Field Size: Size of the finite field over which the curve is defined.
  • Security Strength: Ensures resistance against cryptographic attacks.
  • Standardization: Adherence to recognized standards (e.g., NIST curves).
  • Implementation Considerations: Efficient algorithms for curve operations.
  • Parameter Generation: Secure methods for generating curve parameters.

How ECDSA difffers from traditional cryptography?

ECDSA (Elliptic Curve Digital Signature Algorithm) and traditional cryptographic methods like RSA and DSA differ fundamentally in their mathematical foundations. Traditional cryptography relies on problems like integer factorization and discrete logarithms, while ECDSA is based on the elliptic curve discrete logarithm problem (ECDLP). This allows ECDSA to achieve high security with smaller key sizes. For instance, a 256-bit ECDSA key offers similar security to a 3072-bit RSA key, making ECDSA more efficient in terms of computational resources.

ECDSA’s efficiency makes it ideal for environments with limited processing power and memory, such as mobile devices and IoT applications. Traditional methods, with their larger key sizes, result in higher computational overhead and slower performance. ECDSA also simplifies key management due to smaller keys, reducing storage requirements and easing transmission. While traditional cryptography remains prevalent in many legacy systems, ECDSA is increasingly adopted in modern protocols and applications, like cryptocurrencies and secure communications, due to its enhanced security and efficiency.

Basically, ECDSA follows the way of asymmetric way of cryptography rather than symmetric option. In layman terms, we need a pair of keys in way the assymetric route and need only one key for symmetric .

Components of ELLIPTIC CURVES

Private and Public Keys:

  • Private Key: A randomly generated integer (nonce) , kept secret by the owner. It is used to create digital signatures.
  • Public Key: A point on the elliptic curve, derived from the private key by multiplying it with a predefined point on the curve (known as the base point GG). The public key can be shared openly and is used to verify digital signatures.

2. Elliptic Curve Domain Parameters:

These parameters define the specific elliptic curve and finite field over which the cryptographic operations are performed. They include:

  • p: A prime number defining the size of the finite field.
  • a & b: Coefficients defining the elliptic curve equation y2=x3+ax+by2=x3+ax+b.
  • G: The base point (generator point) on the elliptic curve, used for key generation.
  • n: The order of the base point GG, which is the number of points on the elliptic curve that can be generated by repeatedly adding GG to itself.
  • h: The cofactor, which is the ratio of the total number of points on the elliptic curve to the order nn.

Process Overview:

  1. Key Generation: Involves selecting a private key and deriving the corresponding public key using the elliptic curve parameters.
  2. Signature Generation: Uses the private key to produce a digital signature for a given message.
  3. Signature Verification: Uses the public key and the elliptic curve parameters to verify the authenticity of the digital signature.

How ECDSA Works

  • Key Generation -Process of generating private and public keys using elliptic curves.

The Private Key is generated using a psuedo-random number generator that is capable of delivering a 256 bit number through CSPRNGs.

CSPRNGs (Cryptographically Secure Pseudo-Random Number Generators) generate sequences of numbers that are indistinguishable from true randomness and secure against cryptographic attacks. Their key principles include unpredictability, where outputs are computationally infeasible to predict; reliance on a high-entropy seed to initialize the generator; and resistance to state compromise, ensuring that even if the internal state is partially exposed, past and future outputs remain secure. They provide backtracking resistance to prevent reconstruction of previous outputs from the current state and forward secrecy to maintain security of future outputs despite state compromise.

Common CSPRNG algorithms, such as Hash_DRBG, HMAC_DRBG, and CTR_DRBG, use cryptographic functions like hash functions, HMAC, and block ciphers to ensure the output’s randomness and security. These principles make CSPRNGs essential for cryptographic applications, ensuring secure key generation, encryption, and digital signatures.

The Public Key is generated using the modular multiplication principle on an elliptic curve using the Public Key & Generator Point. Elliptic curve scalar multiplication is the operation of successively adding a point along an elliptic curve to itself repeatedly. It is used in ECC. The literature presents this operation as scalar multiplication.

Signing a Message:

  • Hash the Message: Compute the hash of the message m using a cryptographic hash function (e.g., SHA-256), producing the hash value z.
  • Generate a Random Integer: Select a random integer k within the range [1, n-1]. One can use CSPRNGs for the same.
  • Compute Elliptic Curve Point: Calculate the elliptic curve point R=(x1,y1)=kG.
  • Calculate Signature Component rr: Set r=x1mod n. If r=0, choose a new k and repeat the calculation.
  • Calculate Signature Component ss: Compute s=k−1(z+rd)mod n. If s=0, choose a new k and repeat the calculation.
  • Signature: The signature is the pair (r,s).

Verifying a Signature :

  • Hash the Message: Compute the hash of the received message mm using the same hash function, producing the hash value zz.
  • Check Signature Validity: Ensure that rr and ss are within the range [1, n-1].
  • Compute Inverse of ss: Calculate w=s−1mod n.
  • Compute Elliptic Curve Points: Calculate u1=z*w*mod n and u2=r*w*mod n.
  • Calculate Point: Compute the elliptic curve point R=(x1,y1)=u1 G+u2 QR.
  • Verify Signature: If r≡x1mod n, the signature is valid; otherwise, it is invalid.

Breaking Down the Components of ECDSA

The Need for a field

The points on an elliptic curve and the operations performed on these points are defined within a finite field. This ensures that all calculations remain within a finite set of elements, which is essential for the cryptographic strength and efficiency of ECDSA. The security of ECDSA relies on the difficulty of the elliptic curve discrete logarithm problem (ECDLP). This problem is computationally hard within a finite field, making it infeasible for attackers to derive private keys from public keys.

The Problem of ECDLP- Or is it a Solution?

ECDLP stands for Elliptic Curve Discrete Logarithmic Problem. It defines the complexity of the mathematical problem. It’s a one way to approach a problem such that it can-not be backtraced.

Given two points P and Q on an elliptic curve, the problem is to find the integer k such that Q=kP where kP denotes the point P added to itself k times- scalar multiplication.

Why are we picky with choosing only prime numbers to make our finite fields ?

  1. Simpler Arithmetic: Arithmetic operations (addition, subtraction, multiplication, and inversion) are simpler and more efficient in prime fields. For a prime field FpFp​, the operations are performed modulo a prime number pp. This simplicity translates to faster computation and easier implementation, which is crucial for performance in cryptographic applications.
  2. Avoidance of Weak Curves: Using prime fields helps avoid certain classes of weak elliptic curves. In particular, the choice of a prime field avoids the presence of non-trivial subgroups, which can make the discrete logarithm problem easier to solve. This ensures that the elliptic curve used in the cryptographic protocol is strong and resistant to attacks.
  3. Security: Prime fields provide a high level of security due to the difficulty of solving the discrete logarithm problem (DLP) in these fields. The hardness of the Elliptic Curve Discrete Logarithm Problem (ECDLP) in a prime field underpins the security of ECDSA and other ECC-based cryptographic schemes.
  4. Well-Studied: Prime fields are well-studied in mathematics and cryptography. Their properties are well-understood, and many cryptographic protocols have been designed and analyzed using prime fields. This extensive research and understanding contribute to the reliability and security of cryptographic systems based on prime fields.
  5. Avoidance of Certain Attacks: Prime fields help avoid certain types of attacks that are more feasible in composite fields (fields with non-prime order). For example, attacks exploiting the structure of the field, such as Weil descent attacks, are less effective in prime fields, making them a safer choice for cryptographic applications.

Standardisation with NIST Curves particularly for ECDSA

P-256 (also known as secp256r1):

  • Prime Field: Fp where p=2²⁵⁶−2²²⁴+2¹⁹²+2⁹⁶−1
  • Curve Equation: y²=x³−3x+b*mod p

Exploring Double and Add Algorithm

The Double and Add algorithm is an efficient method for performing scalar multiplication on an elliptic curve. Scalar multiplication involves multiplying a point P on the elliptic curve by an integer k to get another point Q=kP. This operation is fundamental in elliptic curve cryptography.

The Double and Add algorithm leverages the binary representation of the scalar k to minimise the number of elliptic curve point additions and doublings required.

Looking into Montgomery Ladder

The Montgomery Ladder is an algorithm used in elliptic curve cryptography for performing scalar multiplication, where a point P is multiplied by an integer kk to obtain another point Q=kP. It is particularly valued for its protection against side-channel attacks, such as timing and power analysis attacks, due to its uniform execution pattern that conceals information about the scalar k. The algorithm operates in constant time, meaning the number of operations is independent of k, which further enhances security against timing attacks. Additionally, the Montgomery Ladder’s simple and regular structure simplifies implementation and reduces the risk of vulnerabilities, ensuring consistent and secure performance.

EdDSA: A Modern Digital Signature Algorithm

EdDSA, or Edwards-Curve Digital Signature Algorithm, is a digital signature scheme that has gained significant traction due to its efficiency and security. It builds upon the Schnorr signature and employs twisted Edwards curves for its mathematical underpinnings.

One of the key advantages of EdDSA is its deterministic nature. This means that given the same message and private key,the algorithm will always produce the same signature. This property is valuable in various cryptographic applications.Additionally, EdDSA is generally faster than other digital signature schemes without compromising security.

The security of EdDSA is grounded in the elliptic curve discrete logarithm problem (ECDLP), which is considered computationally difficult to solve. Furthermore, EdDSA is less susceptible to timing attacks and other side-channel attacks compared to some of its predecessors. This makes it a more resilient option in the face of evolving threats.

Popular implementations of EdDSA include Ed25519 and Ed448, which utilize different elliptic curves. These implementations have found widespread adoption in various cryptographic protocols and systems.

Beyond ECDSA: The Promise of Post-Quantum Cryptography

The specter of quantum computing has cast a long shadow over the cryptographic landscape. While ECDSA has been a stalwart in securing digital transactions for years, its vulnerability to quantum attacks is a stark reality. This impending threat necessitates a proactive approach to safeguarding our digital infrastructure.

ECDSA’s susceptibility to quantum attacks arises from its reliance on mathematical problems that can be efficiently solved by quantum computers. The Shor algorithm, in particular, poses a grave threat to the security of ECDSA. Additionally, implementation vulnerabilities, such as the reuse of random numbers or side-channel attacks, can further compromise the security of ECDSA systems.

Post-quantum cryptography (PQC) emerges as a potential solution to this challenge. Among the leading contenders in this field are lattice-based and hash-based algorithms. Lattice-based cryptography leverages the complex structures of mathematical lattices to underpin its security. These systems are known for their versatility, applicable to encryption, digital signatures, and key exchange. While they offer the potential for high performance, their complex nature poses implementation challenges.

Hash-based cryptography, on the other hand, relies on the properties of cryptographic hash functions. These algorithms are particularly well-suited for digital signatures and offer the advantage of being relatively simple to understand. However, they often produce larger signature sizes compared to traditional methods.

Both lattice-based and hash-based algorithms represent significant advancements in cryptographic research.While each approach has its strengths and weaknesses, they collectively offer a promising path towards a post-quantum future. As research progresses, we can anticipate further refinements and the emergence of new algorithms. The transition to post-quantum cryptography will undoubtedly require careful planning and implementation to ensure a seamless and secure migration.

The urgency to transition to post-quantum cryptography cannot be overstated. By proactively addressing the quantum threat, we can safeguard our digital assets and maintain the integrity of our critical infrastructure.

--

--