{
  "schema_version": 1,
  "title": "Scalar multiplication and keypairs",
  "url": "/writing/understanding-elliptic-curves/lessons/0004-scalar-multiplication-and-keypairs.html",
  "author": "Abhineet Biju",
  "text": "Chapter IV · key derivation Scalar multiplication and keypairs Objective derive a toy public key Solana signer keypairs Hard problem discrete 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 modelk 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 addressOn-curve public point. Authorization comes from a valid Ed25519 signature. Program addressOff-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 defines EdDSA keys and the exact Ed25519 key-generation procedure. SEC 1, section 3.2.1 specifies elliptic-curve keypair generation in the general model. Solana's PDA documentation explains off-curve derivation and program authorization.",
  "headings": [
    {
      "level": 1,
      "id": null,
      "text": "Scalar multiplication and keypairs"
    },
    {
      "level": 2,
      "id": null,
      "text": "Derive a public key from a private scalar"
    },
    {
      "level": 2,
      "id": null,
      "text": "Compute scalar multiplication with double-and-add"
    },
    {
      "level": 3,
      "id": null,
      "text": "Quick check 1"
    },
    {
      "level": 2,
      "id": null,
      "text": "Test scalar multiplication in a small group"
    },
    {
      "level": 3,
      "id": null,
      "text": "Reverse-search attacker"
    },
    {
      "level": 2,
      "id": null,
      "text": "The elliptic-curve discrete logarithm problem"
    },
    {
      "level": 3,
      "id": null,
      "text": "Quick check 2"
    },
    {
      "level": 2,
      "id": null,
      "text": "Solana public keys and PDAs"
    },
    {
      "level": 2,
      "id": null,
      "text": "Check your understanding"
    },
    {
      "level": 3,
      "id": null,
      "text": "Primary reading"
    }
  ],
  "sections": [
    {
      "id": "map",
      "heading": "Derive a public key from a private scalar",
      "text": "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."
    },
    {
      "id": "fast",
      "heading": "Compute scalar multiplication with double-and-add",
      "text": "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?"
    },
    {
      "id": "lab",
      "heading": "Test scalar multiplication in a small group",
      "text": "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."
    },
    {
      "id": "hard",
      "heading": "The elliptic-curve discrete logarithm problem",
      "text": "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 modelk 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?"
    },
    {
      "id": "solana",
      "heading": "Solana public keys and PDAs",
      "text": "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 addressOn-curve public point. Authorization comes from a valid Ed25519 signature. Program addressOff-curve derived bytes. Authorization comes from the deriving program and matching seeds."
    },
    {
      "id": "close",
      "heading": "Check your understanding",
      "text": "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 defines EdDSA keys and the exact Ed25519 key-generation procedure. SEC 1, section 3.2.1 specifies elliptic-curve keypair generation in the general model. Solana's PDA documentation explains off-curve derivation and program authorization."
    }
  ],
  "links": [
    {
      "label": "writing",
      "url": "/#writing"
    },
    {
      "label": "Chapter III",
      "url": "/writing/understanding-elliptic-curves/lessons/0003-point-doubling-derivation.html"
    },
    {
      "label": "Glossary",
      "url": "/writing/understanding-elliptic-curves/reference/0001-cryptography-glossary.html"
    },
    {
      "label": "RFC 8032, sections 3.2 and 5.1.5",
      "url": "https://www.rfc-editor.org/info/rfc8032/"
    },
    {
      "label": "SEC 1, section 3.2.1",
      "url": "https://www.secg.org/sec1-v2.pdf"
    },
    {
      "label": "Solana's PDA documentation",
      "url": "https://solana.com/docs/core/pda"
    },
    {
      "label": "Previous: Deriving the point-doubling formulas",
      "url": "/writing/understanding-elliptic-curves/lessons/0003-point-doubling-derivation.html"
    },
    {
      "label": "Next: Creating and verifying signatures",
      "url": "/writing/understanding-elliptic-curves/lessons/0005-signature-creation-and-verification.html"
    }
  ]
}
