Glossary

Compact Signature (Recoverable Signature)

A compact signature is a 65-byte ECDSA signature format that includes a recovery flag to derive the signer's public key.

Key Takeaways

  • A compact signature is a 65-byte ECDSA signature format that prepends a recovery byte to the standard 32-byte R and 32-byte S values, enabling anyone to derive the signer's public key from the signature alone.
  • The recovery flag (values 0 through 3) identifies which of up to four candidate elliptic curve points produced the signature, eliminating the need to transmit the public key separately.
  • Bitcoin message signing and Ethereum transaction signatures both use recoverable signatures, while Schnorr signatures (BIP-340) avoid recovery bytes entirely by enforcing an implicit even-Y convention.

What Is a Compact Signature?

A compact signature (also called a recoverable signature) is a serialized digital signature format used with the ECDSA algorithm on the secp256k1 curve. It consists of 65 bytes: one header byte encoding a recovery ID, followed by the 32-byte R value and 32-byte S value of the ECDSA signature. The recovery ID allows a verifier to reconstruct the signer's public key directly from the signature and message hash, without needing the public key to be provided separately.

In standard ECDSA verification, the verifier already knows the signer's public key and checks whether the signature is valid for that key. Compact signatures reverse this: the verifier recovers the public key from the signature first, then checks whether the recovered key matches an expected identity (such as a Bitcoin address or Ethereum account). This technique saves bandwidth and storage in protocols where the signer's identity can be inferred from context.

How It Works

ECDSA signatures produce two values, R and S. The R value is the x-coordinate of a random curve point chosen during signing (called the nonce point). To verify a signature, the verifier needs R, S, the message hash, and the signer's public key Q. However, the mathematical relationship between these values means that Q can be computed if R is known as a full curve point (both x and y coordinates) rather than just an x-coordinate.

The Recovery ID

A single x-coordinate on an elliptic curve corresponds to two possible y-coordinates (one even, one odd). The recovery ID uses two bits to resolve this ambiguity:

  • Bit 0 (parity bit): indicates whether the y-coordinate of R is even (0) or odd (1)
  • Bit 1 (overflow bit): indicates whether the x-coordinate of R exceeds the curve order n, meaning the actual x-value is r + n rather than r

This gives four possible recovery ID values (0, 1, 2, 3), corresponding to four candidate public keys. In practice on secp256k1, the overflow case (recovery IDs 2 and 3) is astronomically unlikely because the curve order n is very close to the field prime p. Almost all real-world signatures use recovery ID 0 or 1.

Recovery Algorithm

Given a compact signature and a message hash, the verifier recovers the public key Q through these steps:

  1. Extract the recovery ID, R (as x-coordinate), and S from the 65-byte signature
  2. Use the recovery ID to reconstruct R as a full curve point with the correct y-coordinate
  3. Compute the public key using the formula: Q = r⁻¹ × (s × R − e × G), where e is the message hash and G is the generator point
  4. Verify that the recovered public key matches the expected identity (an address, a known key, etc.)

Byte Layout

The 65-byte compact signature is laid out as follows:

| Byte 0          | Bytes 1-32  | Bytes 33-64 |
|-----------------|-------------|-------------|
| Header / recid  | R (32 bytes)| S (32 bytes)|

The exact encoding of the header byte varies by protocol. In Bitcoin's message signing format, the header is calculated as 27 + recovery_id, with an additional 4 added if the key is compressed:

// Bitcoin message signing header byte
header = 27 + recovery_id          // uncompressed: 27-30
header = 27 + recovery_id + 4      // compressed:   31-34

Use Cases

Bitcoin Message Signing

Bitcoin Core's signmessage RPC produces a compact signature that proves ownership of a Bitcoin address without revealing the private key. The message is prefixed with the string "Bitcoin Signed Message:\n", then double-SHA256 hashed. The resulting 65-byte signature is base64-encoded for display.

The verifymessage RPC recovers the public key from the compact signature, derives the corresponding address, and checks whether it matches the claimed address. This is why no public key argument is needed: the signature itself carries enough information to recover it.

BIP-137 extends the header byte ranges to indicate the address type: headers 27 through 30 for uncompressed P2PKH, 31 through 34 for compressed P2PKH, 35 through 38 for P2SH-P2WPKH, and 39 through 42 for native P2WPKH.

Ethereum Transaction Signatures

Ethereum uses recoverable signatures to identify the sender of every transaction. Instead of including the sender's address or public key in the transaction, the protocol recovers it from the signature. This is why Ethereum transactions have no explicit "from" field in their serialized form.

In legacy Ethereum transactions, the recovery value v was simply 27 or 28 (mapping to recovery IDs 0 and 1). EIP-155 changed this to encode the chain ID into v using the formula:

// EIP-155 v value encoding
v = recovery_id + chain_id * 2 + 35

// Examples:
// Ethereum mainnet (chain_id = 1): v = 37 or 38
// Legacy (no replay protection):   v = 27 or 28

This chain ID encoding provides replay protection by making signatures chain-specific. A transaction signed for Ethereum mainnet cannot be replayed on a different network because the v value encodes a different chain ID, changing the hash used in recovery.

Smart Contract Verification

Ethereum's ecrecover precompiled contract accepts a hash, v, r, and s values and returns the address of the signer. This enables on-chain signature verification for permit signatures, meta-transactions, and other patterns where a user signs a message off-chain and a contract verifies it. The gas cost of ecrecover (3,000 gas) is significantly cheaper than storing and transmitting full public keys.

Comparison with Other Signature Formats

DER-Encoded Signatures

Before SegWit, Bitcoin transactions used DER-encoded signatures, which are variable-length (typically 71 to 73 bytes). DER encoding includes type tags, length bytes, and optional leading zeros for R and S. Compact signatures are more space-efficient at a fixed 65 bytes, but they serve a different purpose: DER signatures are used for transaction validation (where the public key is provided in the scriptSig or witness), while compact signatures are used for message signing (where the public key must be recovered).

Schnorr Signatures (BIP-340)

Schnorr signatures as defined in BIP-340 take a different approach entirely. Instead of including a recovery byte, BIP-340 enforces conventions that make recovery unnecessary:

  • Public keys are 32 bytes (x-coordinate only), with the y-coordinate implicitly defined as even
  • The nonce point R is also constrained to have an even y-coordinate
  • Signatures are a fixed 64 bytes (32-byte R + 32-byte s) with no recovery byte needed

This implicit even-Y convention eliminates ambiguity at the protocol level. If a signer's key has an odd y-coordinate, the signer negates their private key so the corresponding public key has an even y-coordinate. The result is a cleaner, more compact format that also enables efficient batch verification.

Why It Matters

Compact signatures are foundational to how identity works in cryptocurrency protocols. In Ethereum, every transaction relies on public key recovery to determine the sender. In Bitcoin, message signing uses compact signatures to prove address ownership for proof-of-reserves attestations, domain verification, and authentication systems. The technique also appears in protocols that need bandwidth-efficient identity verification, such as peer-to-peer messaging and Lightning channel announcements.

For developers building on Bitcoin Layer 2 protocols like Spark, understanding compact signatures helps contextualize how identity and authorization work across the stack: from on-chain Taproot key-path spends (which use Schnorr) to off-chain message authentication (which may use ECDSA recovery).

Risks and Considerations

Nonce Reuse Vulnerability

Compact signatures share the same critical vulnerability as all ECDSA signatures: if the random nonce k used during signing is ever reused with a different message, the private key can be algebraically extracted from the two signatures. Deterministic nonce generation (RFC 6979) mitigates this by deriving k from the private key and message hash, ensuring uniqueness without relying on a random number generator.

Malleability

ECDSA signatures are inherently malleable: given a valid signature (R, S), the pair (R, n − S) is also valid, where n is the curve order. Bitcoin addresses this with a low-S rule (BIP-62, BIP-146) that requires S to be in the lower half of the range. Ethereum enforces the same constraint after EIP-2. Without this normalization, a third party could modify the recovery ID and S value to produce a different-looking but still-valid signature, which could confuse systems that use signature bytes as unique identifiers.

Recovery Ambiguity

The recovery process produces a public key, but it does not prove that the recovered key is the "correct" signer. The verifier must separately check that the recovered key corresponds to an authorized identity. If the verifier skips this step, an attacker could craft a signature with any recovery ID and produce a valid-looking but meaningless public key. The security of compact signatures depends entirely on the application-level identity check that follows recovery.

Cross-Library Compatibility

The position and encoding of the recovery byte differ across libraries and protocols. Bitcoin message signing places a header byte (27+) first. Ethereum uses a separate v field. Some libraries store the recovery ID as the last byte (byte 64) rather than the first. Developers must ensure they match the encoding convention expected by their target protocol to avoid signature verification failures.

This glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.