Source: https://www.abhineetbiju.com/writing/understanding-elliptic-curves/lessons/0005-signature-creation-and-verification.html

Chapter V · digital signatures

# Creating and verifying signatures

Objectiveexplain signing and verification

Solanatransaction signatures

Modelsimplified signature equation

You can use a signature to prove that a private key authorized one exact message without revealing the key.

## The public-key relationship used by signatures

You already know the key relationship:

Q = kGKeep k private. Publish Q and G.

Anyone can see Q, but production parameters make recovering k infeasible. Signatures use this same relationship.

Signer knowsprivate scalar k

creates evidence

Verifier knowspublic point Q

A signature proves that someone who knows the secret behind Q approved one exact message. It does not reveal the secret and it does not encrypt the message.

## Create a signature for one message

Let's build a simplified Schnorr-shaped signature to see the core EdDSA relationship:

The signer creates a one-message secret r and its public point R = rG.

A hash binds R, Q, and the message m into a challenge h.

The signer combines both secrets into s = r + hk.

The published signature is (R, s). Neither k nor r is published.

Lowercase r is the one-message secret nonce scalar. Uppercase R=rG is its public curve point. Although h and s are public, they bind the hidden scalars without exposing them. Reusing the same r for two messages creates two equations that can reveal k.

To verify the signature, we recompute h and check:

sG ?= R + hQ

The equation works because:

sG = (r + hk)G

sG = rG + h(kG)

sG = R + hQ

The verifier replaces the secret-derived terms rG and kG with their public points R and Q. Matching sides show that the signature has the right hidden relationship.

### Quick check 1

What gives the signer its unique ability?

## Verify that the message has not changed

Sign the default message, then change `send 5 SOL` to `send 6 SOL`. You will see the hash change and the verification equation fail. The stored signature does not change; the same signature simply stops verifying against the modified message.

Toy private scalar k

### Signer keeps

The private scalar stays inside the signer.

k is hidden

### Everyone knows

The public point identifies the signer.

### Signer publishes

The signature contains R and s, not k.

Message to sign

Message presented to verifier

sG**must equal**R + hQ

No signature to verify yet.

Show the toy arithmetic

This uses an insecure 19-element group and a toy hash to expose the relationship.

One-message secret

Message challenge

Signer response

### Quick check 2

What should changing the signed message do?

## Solana transaction signatures

When your wallet signs a Solana transaction, it signs the serialized message with Ed25519. If you change an instruction, account, amount, or recent blockhash, the bytes change and the signature becomes invalid.

A valid signature authorizes those exact bytes. It does not prove that a wallet's human-readable description matched the signer's intent.

A PDA has no Ed25519 private key. During `invoke_signed`, the runtime checks the program ID and seeds and grants signer privilege for that CPI.

**Transaction signer**Private key signs exact message bytes. Public key verifies them.

**Program address**No private key exists. Runtime seed derivation grants CPI authority.

Ed25519 has exact hashing, scalar derivation, encoding, and cofactor rules. Use audited libraries. The equation here explains the relationship; it is not production implementation code.

## Check your understanding

Try to answer each question before you open the solutions.

- Why can Q=kG be public while k remains private?

- What does a signature prove, and what does it not hide?

- How can the verifier check sG=R+hQ without knowing k?

- Why does changing the message invalidate the signature?

- How does Solana PDA authorization differ from an Ed25519 signature?

Show numbered solutions

- Double-and-add computes Q=kG efficiently. Recovering k from G and Q requires solving the discrete logarithm problem, which is infeasible at production scale.

- A valid signature proves that the private-key holder authorized the exact message. It detects changes but does not encrypt the message or prove that a human-readable interpretation matched the signer's intent.

- Lowercase r is the hidden nonce scalar, while uppercase R=rG is its public point. The signer publishes R and s=r+hk. Multiplying by G gives sG=rG+h(kG)=R+hQ, so the verifier can compute both sides from public values. Reusing r for two challenges creates two equations that can reveal k.

- The challenge h=H(R,Q,m) binds the equation to m. A changed message produces a different challenge, so the unchanged stored signature fails against the modified message.

- A wallet produces an Ed25519 signature. A PDA has no private key. During a CPI, `invoke_signed` re-derives the PDA from its seeds, bump, and program ID and grants signer privilege when the address matches.

### Primary reading

- [RFC 8032, sections 3.2 through 3.4](https://www.rfc-editor.org/rfc/rfc8032.html#section-3.2) defines EdDSA keys, signing, and verification.

- [Solana's transaction documentation](https://solana.com/docs/core/transactions) connects signatures to serialized transaction messages and signer public keys.

- [Solana's PDA documentation](https://solana.com/docs/core/pda) explains off-curve addresses and `invoke_signed` authorization.
