Source: https://www.abhineetbiju.com/writing/understanding-elliptic-curves/lessons/0004-scalar-multiplication-and-keypairs.html

Chapter IV · key derivation

# Scalar multiplication and keypairs

Objectivederive a toy public key

Solanasigner keypairs

Hard problemdiscrete log

If you know the secret scalar, computing the public point is fast. Reversing the operation is hard.

## Derive a public key from a private scalar

We choose a generator point G that everyone knows and a scalar k that only the owner knows. Repeated point addition produces the public point:

Q = kGPrivate input: k. Public parameters: the curve and G. Public output: Q.

This is scalar multiplication: repeated use of the curve's point-addition rule.

Keep secretscalar k

scalar multiplication

Safe to sharepoint Q

Ed25519 hashes secret bytes and derives a clamped scalar before computing the public point. Q=kG captures the group operation, not the full key format.

## Compute scalar multiplication with double-and-add

Suppose you want to compute 13G. We avoid thirteen separate additions by writing 13 in binary:

13 = 8 + 4 + 1 = 1101₂

Build 2G, 4G, and 8G by doubling, then combine the powers selected by the binary digits:

13G = 8G + 4G + GThis family of methods is called double-and-add. Work grows with the number of bits in k, not with the value of k.

### Quick check 1

Which decomposition computes 13G?

## Test scalar multiplication in a small group

This toy subgroup has 18 possible nonzero scalars. Choose one and watch the workbench derive its public point.

Private scalar k

Toy private key

compute kG

Toy public key

### Reverse-search attacker

The attacker knows G and Q. It tries every possible scalar until a candidate produces the same public point.

The attack succeeds because there are only 18 candidates. This group is educational, not secure.

## The elliptic-curve discrete logarithm problem

If you know k and G, double-and-add computes Q efficiently. If you know only G and Q, recovering k is the elliptic-curve discrete logarithm problem.

No efficient classical algorithm is known for a secure production group. A naive search through a subgroup of order N takes up to O(N) point operations. Generic attacks such as baby-step giant-step and Pollard rho reduce that to about O(√N). For Ed25519, the generic attack scale is still about 2^(126) curve operations. Real attackers do not need to try every scalar one by one.

k + G → Q is the wrong model
k acting on G → Q is the right modelThe arrow is easy because k is known. Reversing it means solving the discrete logarithm.

This is a computational hardness assumption, not a claim that reversal is mathematically impossible. A sufficiently capable quantum computer running Shor's algorithm would break this assumption.

### Quick check 2

Given the curve, G, and Q=kG, what does the attacker seek?

## Solana public keys and PDAs

When you use a normal Solana signer, its Ed25519 public key decodes to an on-curve point. Its secret key produces signatures that the runtime verifies.

A PDA is derived from seeds and a program ID and must be off-curve. No scalar k can produce it as kG. The runtime authorizes the PDA by checking its derivation instead.

**Signer address**On-curve public point. Authorization comes from a valid Ed25519 signature.

**Program address**Off-curve derived bytes. Authorization comes from the deriving program and matching seeds.

## Check your understanding

Try to answer each question before you open the solutions.

- What information is public in the equation Q=kG?

- Why can a computer calculate a large scalar multiple without adding G one step at a time?

- What is the elliptic-curve discrete logarithm problem?

- Why did the reverse attack work against the toy group?

- What authorization rule replaces private-key signing for a Solana PDA?

Show numbered solutions

- The curve, subgroup order, generator G, and point Q are public. Only k is secret. Production parameters make recovering it impractical.

- Double-and-add writes k in binary, builds doubled points, and adds only the powers selected by 1-bits. It takes roughly O(log k) point operations.

- The elliptic-curve discrete logarithm problem asks for k given G and Q=kG. A sequential search takes O(N) work. Baby-step giant-step and Pollard rho reduce generic attacks to about O(√N). For a group near 2²⁵², that is still about 2¹²⁶ curve operations.

- The toy subgroup has only 18 nonzero scalar candidates, so a sequential search finds the key quickly.

- During `invoke_signed`, the runtime combines the seeds, bump, and calling program ID to re-derive the PDA. A match grants signer privilege for the CPI. No Ed25519 signature is involved.

### Primary reading

- [RFC 8032, sections 3.2 and 5.1.5](https://www.rfc-editor.org/info/rfc8032/) defines EdDSA keys and the exact Ed25519 key-generation procedure.

- [SEC 1, section 3.2.1](https://www.secg.org/sec1-v2.pdf) specifies elliptic-curve keypair generation in the general model.

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