# Public key

> A Pearl public key is the point d·G on secp256k1. The 65, 33 and 32-byte forms, why Pearl uses 32-byte x-only keys, and what a Schnorr signature proves.

Source: https://pearlcodex.com/technical/keys/public-key/ · Last updated: 2026-11-02 · Checked against Pearl's source code at v1.5.5

A [public key](https://pearlcodex.com/glossary/#public-key) is a point on a curve, computed from your private key. Anyone can use it to check your signatures. No one can use it to find your private key.

The trick is a one-way street. Multiplying a starting point by your secret number takes a computer microseconds. Working out the secret number from the result would take every computer on Earth longer than the universe has existed. So you can show your public key to the world and keep the private key to yourself.

## Try it

Multiply points on a tiny curve you can see, then watch the same idea at full size.

_Interactive: Toy elliptic curve. Try it on the page: <https://pearlcodex.com/technical/keys/public-key/>_

## What is a point on secp256k1?

Pearl uses [secp256k1](https://pearlcodex.com/glossary/#secp256k1), the same [elliptic curve](https://pearlcodex.com/glossary/#elliptic-curve) as Bitcoin. Its points are pairs of whole numbers (x, y) that satisfy one equation, with all arithmetic done modulo a prime p:

$$
y^2 \equiv x^3 + 7 \pmod{p}, \qquad p = 2^{256} - 2^{32} - 977
$$

One point is special. The [generator](https://pearlcodex.com/glossary/#generator-point) G is fixed by the standard, and every public key is a multiple of it:

|     | Value                                                              |
| --- | ------------------------------------------------------------------ |
| G.x | `79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798` |
| G.y | `483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8` |

## How is the public key computed?

By multiplying G by the private key d:

$$
P = d \cdot G
$$

“Multiplying” a point means adding it to itself d times, using the curve’s own addition rule. Computers do it with about 256 doublings and additions, not d steps, so it’s quick even for a 78-digit d.

Some easy cases:

- **Key 1** gives P = G itself. That’s why the x-coordinate above appears so often in examples.
- **Key 2** gives a point with x = `c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5`.
- **Key 3** gives x = `f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9`.

The x-coordinates look unrelated, even though the keys are 1, 2 and 3. That’s the point: nothing about P hints at d. Finding d from P is the _discrete logarithm problem_, and no known method on ordinary computers solves it for a curve this size.

## What formats are there?

A point is two 32-byte numbers. There are three ways to write one down, and Pearl uses all three in different places.

| Field        | Size | Type       | Description                                                                                      |
| ------------ | ---- | ---------- | ------------------------------------------------------------------------------------------------ |
| uncompressed | 65   | 04 ‖ x ‖ y | `04` `79be…1798` `483a…d4b8`. Old and wasteful. In Pearl only a legacy WIF flag can mean it.     |
| compressed   | 33   | 02/03 ‖ x  | `02` `79be…1798`. Used in HD wallets: extended keys, fingerprints and the WIF “compressed” flag. |
| x-only       | 32   | x          | `79be…1798`. **Everything on chain**: Taproot output keys, signatures and keys inside scripts.   |

- **Size:** 32 bytes
- **Type:** x-coordinate of a curve point
- **Format:** Big-endian

### Why can you throw away y?

Because the curve is symmetric. For each x on the curve, there are exactly two points, (x, y) and (x, p − y). One y is even and the other is odd.

- A **compressed** key keeps one byte to say which: `02` for even y, `03` for odd y. Key 1 starts with `02`; key 6 starts with `03` (`03fff97bd5…297556`).
- An **x-only** key drops even that byte. By rule (BIP-340’s “lift_x”), it always means the point with even y.

That saves a byte everywhere a key appears on chain, and Taproot was designed around it.

## What does a signature prove?

A [Schnorr signature](https://pearlcodex.com/glossary/#schnorr-signature) proves that whoever made it knew d for this public key and this exact message, without revealing anything about d.

It is 64 bytes: the x-coordinate of a random-looking point R, then a number s. The verifier computes a challenge e from R, P and the message m, and checks one equation:

$$
\begin{aligned} s \cdot G &= R + e \cdot P \\ e &= \text{TaggedHash}_{\text{BIP0340/challenge}}(R_x \parallel P \parallel m) \end{aligned}
$$

Here is a signature made with Pearl’s own code, over the message SHA256(“Pearl”):

|                       | Value                                                              |
| --------------------- | ------------------------------------------------------------------ |
| Secret key            | `0c28fca386c7a227600b2fe50b7cae11ec86d3bf1fbe471be89827e19d72aa1d` |
| Public key P (x-only) | `d0de0aaeaefad02b8bdc8a01a1b8b11c696bd3d66a2c5f10780d95b7df42645c` |
| Message m             | `72bc556112e9538a2433f0a9b87b032eae43c69e367e9dca1b176929dcf20ed5` |
| R.x                   | `85df688c0be1ff7cf23866497fda839fbb6009b820451ff3600caa2cf32dc490` |
| s                     | `80e136b1f442d43275a394cf4b007d7031e052499ad02984cea0bbd3179af2db` |

That signature used the auxiliary random value 00…01 from BIP-340’s recipe. Flip one bit of m and verification fails.

_Interactive: Schnorr signature. Try it on the page: <https://pearlcodex.com/technical/keys/public-key/>_

> **Note: Pearl's signer is deterministic**
>
> Pearl’s transaction signer picks the secret nonce behind R with RFC 6979 (as btcd does), not with fresh random bytes. For the key and message above it produces a different, equally valid signature starting `c3a52ccd…`. Signing the same transaction twice gives the same 64 bytes. Verifiers can’t tell the two methods apart.

The [Schnorr page](https://pearlcodex.com/technical/cryptography/schnorr/) derives the equation and shows why it can’t be forged.

## Where do public keys appear on Pearl’s chain?

Mostly in disguise.

- **In Taproot outputs** the 32 bytes are the tweaked output key Q, not your P. The [Taproot tweak](https://pearlcodex.com/technical/keys/taproot-tweak/) page explains why.
- **Inside scripts** a key is pushed as `20` followed by 32 bytes. The real 2-of-2 P2MR spend in block 130,822 pushes two of them, `b5b010c0…4d307d` and `03b77fbc…c7ae89`. (That second key’s first byte happens to be `03`. In an x-only key that’s just data, not a parity flag.)
- **In HD wallets** extended keys carry 33-byte compressed keys, and parent fingerprints hash them. These never go on chain.

> **Pearl vs Bitcoin**
>
> - Same curve, same G, same formats. Key 1 has the same public key on both chains.
> - No ECDSA in Pearl transactions: `OP_CHECKSIG` exists only in tapscript and only checks 64- or 65-byte Schnorr signatures against 32-byte keys.
> - In Bitcoin’s tapscript, a non-empty key that isn’t 32 bytes is an upgrade hook: the check is treated as passing. Pearl’s engine fails instead (“unsupported public key length”).

> **Note: Public keys and quantum computers**
>
> A large enough quantum computer could, in principle, work backwards from a public key to its private key. A Taproot output shows its key Q on chain from the moment it’s created. Pearl’s rules allow a post-quantum backup, a script leaf checked with [OP_CHECKXMSSSIG](https://pearlcodex.com/technical/script/op-checkxmsssig/), but no Pearl wallet adds one. See [quantum safety](https://pearlcodex.com/beginners/quantum-safety/).

## In short

- The public key is the private key d times a fixed point G on secp256k1: P = d·G. Going forward is fast; going back is believed impossible.
- A point is two 32-byte numbers, x and y. Written in full that’s 65 bytes, compressed it’s 33 (02 or 03, then x), and x-only it’s 32.
- Everything on Pearl’s chain uses the 32-byte x-only form: output keys, signatures and keys inside scripts. The 33-byte form survives in HD wallets.
- A Schnorr signature is 64 bytes and proves the signer knew d for this exact message, without revealing d.
- On chain you rarely see your public key P itself: a Taproot address holds the tweaked key Q instead.

## Read the code

- [The curve: secp256k1 from decred's library, unmodified](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/btcec/btcec.go#L23-L41) `node/btcec/btcec.go:23-41`
- [Compressed 33-byte keys](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/btcec/pubkey.go#L15) `node/btcec/pubkey.go:15`
- [32-byte x-only keys](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/btcec/schnorr/pubkey.go#L17-L49) `node/btcec/schnorr/pubkey.go:17-49`
- [BIP-340 signing with an RFC 6979 nonce](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/btcec/schnorr/signature.go#L376-L530) `node/btcec/schnorr/signature.go:376-530`
- [Unknown public-key sizes fail](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/txscript/sigvalidate.go#L209-L214) `node/txscript/sigvalidate.go:209-214`

## Sources

### Bitcoin standards

- [BIP-340: Schnorr signatures for secp256k1](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki)

### Papers

- [SEC 2: Recommended elliptic curve domain parameters (secp256k1)](https://www.secg.org/sec2-v2.pdf)
- [RFC 6979: Deterministic usage of DSA and ECDSA (the nonce Pearl's signer uses)](https://www.rfc-editor.org/rfc/rfc6979)

### Other

- [learnmeabitcoin: Elliptic curve](https://learnmeabitcoin.com/technical/cryptography/elliptic-curve/)
