mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
1274 words
6 minutes
EOA Wallet Signature Verification and Related Topics
2026-06-10

The following represents only the author’s current understanding.

========

This is more or less a theoretical supplement to the previous article. It essentially works through the process and theoretical proof of signature verification, while also filling in some gaps in my knowledge of group theory (

dreaife.tokyo
An EVM Wallet Login Interface for EOAs
React/wagmi EVM login walkthrough: wallet connection, server nonces, SIWE messages, signing, backend address recovery, and proof of control.
dreaife.tokyo/en/posts/evm-wallet-login/

Prerequisites: secp256k1, Finite Fields, and Elliptic-Curve Point Operations#

Because this involves a great deal of modular arithmetic and elliptic-curve point operations, I have prepared some prerequisite material (and included what I learned along the way, lol). Of course, you can skip it if you are already familiar with these concepts.

Prerequisites

Ethereum wallet signatures use ECDSA, with secp256k1 as the underlying curve. Before understanding r/s/v, public-key recovery, and address generation, you first need to understand three objects:

  • The finite field F_p
  • The elliptic-curve point group E(F_p)
  • The base point G and its order n

1. The secp256k1 Curve#

secp256k1 is defined over a finite field F_p. Its curve equation is:

y2x3+7(modp)y^2 \equiv x^3 + 7 \pmod p

where:

p=2256232977p = 2^{256} - 2^{32} - 977

In other words, the point coordinates are not ordinary real numbers, but integers modulo p: x,yFpx, y \in \mathbb{F}_p

Thus, the set of points on the curve is: E(Fp)={(x,y)y2x3+7(modp)}{O}E(\mathbb{F}_p) = \{(x,y) \mid y^2 \equiv x^3 + 7 \pmod p\} \cup \{O\}

Here, O is the point at infinity, which can be understood as the identity element for point addition.

2. Point Addition on an Elliptic Curve#

A form of “addition” can be defined between points on an elliptic curve:

P+Q=RP + Q = R

Note that this does not mean directly adding the coordinates. That is:

(x1,y1)+(x2,y2)(x1+x2,y1+y2)(x_1, y_1) + (x_2, y_2) \neq (x_1 + x_2, y_1 + y_2)

Instead, another point on the curve is calculated according to the elliptic-curve group rules.

Let:

P=(x1,y1),Q=(x2,y2)P = (x_1, y_1), \quad Q = (x_2, y_2)

When P != Q, first calculate the slope:

λy2y1x2x1(modp)\lambda \equiv \frac{y_2 - y_1}{x_2 - x_1} \pmod p

Division here means division modulo p, which is equivalent to multiplication by a modular inverse.

Then:

x3λ2x1x2(modp)y3λ(x1x3)y1(modp) \begin{aligned} x_3 \equiv \lambda^2 - x_1 - x_2 \pmod p \\ y_3 \equiv \lambda(x_1 - x_3) - y_1 \pmod p \end{aligned}

This gives:

P+Q=(x3,y3)P + Q = (x_3, y_3)

When P = Q, the operation is called point doubling:

2P=P+P2P = P + P

Tip: Note that the addition here is also elliptic-curve addition, not scalar-field addition.

The slope is then:

λ3x122y1(modp)\lambda \equiv \frac{3x_1^2}{2y_1} \pmod p

Because the secp256k1 curve is:

y2=x3+7y^2 = x^3 + 7

there is no ax term, so there is no additional a here.

3. Scalar Multiplication#

Scalar multiplication is repeated point addition:

[k]P=P+P++Pk times[k]P = \underbrace{P + P + \cdots + P}_{k \text{ times}}

For example:

[3]P=P+P+P[3]P = P + P + P

The most important relationship in a wallet is:

Q=[d]GQ = [d]G

where:

  • d: The private key, a scalar
  • G: The base point specified by secp256k1
  • Q: The public key, a point on the curve

Calculating the public key Q from the private key d is fast, but deriving the private key d from the public key Q is extremely difficult. This is the elliptic-curve discrete logarithm problem.

4. The Base Point G and Order n#

G is the generator point selected by the secp256k1 standard, also known as the base point. Its order is n, meaning:

[n]G=O[n]G = O

Furthermore:

G={O,G,[2]G,[3]G,,[n1]G}\langle G \rangle = \{O, G, [2]G, [3]G, \ldots, [n-1]G\}

Here, n is a large prime close to 2^256.

secp256k1 has an important property:

h=1h = 1

That is, its cofactor is 1. Therefore, the cyclic group of order n generated by G is the entire point group of the curve:

#E(Fp)=n\#E(\mathbb{F}_p) = n

5. The Difference Between p and n#

The easiest things to confuse here are p and n.

p is the size of the coordinate field:

x,y(modp)x, y \pmod p

All coordinate calculations in point addition and point doubling are performed under mod p.

n is the order of the base point G:

[n]G=O[n]G = O

Scalar calculations involving private keys, nonces, and signature values such as r/s are all performed under mod n.

You can therefore remember it this way:

  • Point-coordinate calculations: mod p
  • Scalar calculations: mod n

A private key in an Ethereum wallet satisfies:

1dn11 \le d \le n-1

The public key is:

Q=[d]GQ = [d]G

The random or deterministic nonce k used during signing also satisfies:

1kn11 \le k \le n-1

This structure is the mathematical foundation for the ECDSA signing formula, public-key recovery, and Ethereum address generation discussed below.

Alternatively, you can also look at my conversation with Gemini for additional context (honestly, AI has made learning much faster

gemini.google.com
gemini.google.com
gemini.google.com/share/f72d7ecbcf76

Signing and Verifying with an EOA Wallet#

As described in the previous article, when an EOA wallet needs to prove ownership of an address, the following process takes place:

  1. A SWIE-compliant message is sent by the frontend to the wallet with a signature request.

  2. When the wallet receives such a signature request, it displays a prompt asking for the user’s approval.

  3. Once the user confirms, the wallet begins the signing process:

    • First, the SIWE message is processed using keccak-256 to produce a 32-byte hash ee for the subsequent calculations.

    • Next, given the wallet’s private key dd, the finite field pp of secp256k1, its standard base point GG, and the order nn of GG, the wallet generates a random number kk within [1,n-1] for the subsequent verification calculations. Note that because only the values in [1,n-1] within n are usable, non-repeating results, calculations involving scalar selection and similar operations use mod n, while calculations over secp256k1 itself are performed within its defined field p, i.e. mod p.

    • The final signature is actually the concatenation of the three calculated values r/s/vr/s/v, containing 32 bytes, 32 bytes, and 1 byte respectively. They are calculated as follows:

      • R=kG=(Rx,Ry)R = kG = (R_{x}, R_{y})

      • r=Rxmodnr = R_{x} \bmod n

      • s=k1(z+rd)modns = k^{-1} * (z + r * d) \bmod n

      • vv exists because, for a secp256k1 elliptic curve

        y2=x3+7modpy^2 = x^3 + 7 \bmod p

        at x=Rxx=R_x, apart from the point at infinity 00, there are two solutions reflected across the x-axis. By providing 0 or 1, vv specifies the yParity that determines which solution should be selected. Of course, secp256k1 also permits the case where r+n<pr+n<p, but because its probability is extremely low, the EVM does not account for this case during recovery in practice.

    • This produces the final signature r/s/vr/s/v, which the wallet returns to the server.

  4. The server then verifies the received r/s/v.Atthispoint,theserverknowsthesecp256k1basepointr/s/v`. At this point, the server knows the secp256k1 base point G,theSIWEmessagesenttothewalletanditskeccak256hash, the SIWE message sent to the wallet and its keccak-256 hash e,andthesignature, and the signature r/s/v$ returned by the wallet.

  5. The server then begins verification:

    • The server now has GG / ee / rr / ss / vv. It needs to determine whether the wallet address calculated from these values matches the wallet address received at the beginning. According to

      address=keccak256(QxQy)[1232]address = keccak256(Q_x || Q_y)[12\:32]

      (that is, the address consists of the final 20 bytes of the keccak-256 hash of the public key QQ), the current goal is to calculate the public key QQ from the available information.

    • In addition to the data above, we also know how ss was derived through integer calculations in the scalar field:

      s=k1(z+rd)modns = k^{-1} * (z + r * d) \bmod n

      We can therefore rearrange it as:

      d=r1(skz)modnd = r^{-1} * (s*k - z) \bmod n

      We then move into the domain of elliptic-curve point operations and multiply both sides of the equation by the base point GG:

      dG=(r1(skz)modn)G=r1(skGeG)\begin{aligned} dG &= \left(r^{-1}(sk - z) \bmod n\right)G \\ &= r^{-1}(skG - eG) \end{aligned}

      We also know that the public key Q=dGQ = dG and R=kG.SinceweknowR=kG`. Since we know r=R_x,wecanrecover, we can recover Rusingusingv.Wecanthereforetransformtheexpressionaboveintoanequationforthepublickey. We can therefore transform the expression above into an equation for the public key Q$ that consists entirely of known values:

      Q=r1(sReG)Q = r^{-1}(sR - eG)

      This gives us the calculated public key QQ of the wallet that produced the signature.

    • We can then apply keccak-256 to the recovered public key QQ and take the final 20 bytes to obtain the wallet address used for verification. This address is compared with the address provided earlier. If they match, control of the wallet can be verified using only the available information, without knowing the private key dd. At the same time, because Q=dGmodnQ=dG \bmod n is an elliptic-curve operation (under mod n), the result of dGdG—where d is within nn, a large prime close to 22562^{256}—can be reached quickly through repeated addition. Deriving d from Q, however, is the elliptic-curve discrete logarithm problem on secp256k1. There is currently no practical algorithm capable of solving it with realistic resources: generic attacks have a complexity of approximately 21282^{128}, while according to thermodynamics, even all the energy in the universe would be insufficient to perform 22562^{256} computations. This makes the problem effectively unsolvable in engineering practice.

      Tip: Actual EVM verification also validates fields such as domain/address/chainId within the SIWE message. This article mainly discusses the mathematical implementation, so those checks are omitted here.

  6. In this way, the server and wallet can confirm wallet ownership using only the signature, the SIWE message, and some defined mathematical information, without exposing the private key.

Conclusion#

The above is roughly the mathematical proof behind wallet signing and verification. Although it may apparently need to change soon given Google’s advances in quantum computing, there should still be plenty of time, and there is no harm in learning the classics (

That is all. This is essentially a supplement covering the theoretical foundation behind the engineering practice of wallet signature verification.

Share

If this article helped you, please share it with others!

EOA Wallet Signature Verification and Related Topics
https://dreaife.tokyo/en/posts/eoa-sign-verify/
Author
dreaife
Published at
2026-06-10
License
CC BY-NC-SA 4.0

Some information may be outdated

Table of Contents