Skip to content
BIP ATLAS

BIP 0340

Why did Bitcoin add Schnorr signatures?

BIP 340 gives Bitcoin a compact, precisely specified signature scheme. Its structure supports batch verification and protocols that combine several signers into one signature.

A signature lets someone check that a message was authorized by a particular key. BIP 340 adds Schnorr signatures to Bitcoin: a compact format with precisely specified checks, so different verifiers can agree on the same result.12345

The format also has practical benefits: fixed-size signatures, smaller public keys and efficient verification of many signatures together. Schnorr’s linear structure supports protocols in which several people cooperate to produce one signature. BIP 340 supplies the signature scheme; a protocol such as MuSig2 supplies the coordination between signers.5678910

The signer uses a secret key and a message to produce a signature. The verifier receives the public key, the message and that signature, and checks their mathematical relationship. The secret key stays with the signer. The overview below shows that handoff; the interactive example then follows the verifier using published test vectors.231112

Source revision
bitcoin/bips @ 3a10b5b
Source checked
1 October 2026
Review state
Awaiting review
Source details

This chapter is an independent explanation, not the proposal itself. Preamble fields are shown as the pinned files record them, without author e-mail addresses. Status is the proposal’s own field. It is not an endorsement or a sign of consensus.

BIP 340: Schnorr Signatures for secp256k1

BIP
340
Title
Schnorr Signatures for secp256k1
Authors
Pieter Wuille
Jonas Nick
Tim Ruffing
Comments-Summary
No comments yet.
Comments-URI
https://github.com/bitcoin/bips/wiki/Comments:BIP-0340
Status
Deployed
Type
Specification
Assigned
2020-01-19
License
BSD-2-Clause
License-Code
BSD-2-Clause OR MIT OR CC0-1.0

Pinned source · Reader view on bips.dev
SHA-256 17d64d6dc6bc97f4ecf178697bf810b92aa2a9e41ef13db809c25bc44a9b8109
Git blob f241effd77c275ee776ecf555629c9721a9d97ef

Fig. A06.1 From signing to verification

The signing handoffSchematic: a signer keeps the secret key private and combines it with the message and auxiliary random data to produce a signature. The verifier receives the public key, message and signature. No signing runs on this page.SIGNER · SCHEMATICSECRET KEY STAYS HEREMESSAGE + AUXILIARY RANDOM DATASIGNATUREVERIFIER RECEIVESPUBLIC KEY + MESSAGE + SIGNATUREONLY PUBLIC INPUTS ENTER THE CHECK BELOW ↓Three inputs, one answerVector 1 from the BIP 340 CSV goes into the verifier. Public key pk, 32 bytes: dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659. Message m, 32 bytes here, though any length is allowed: 243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89. Signature, 64 bytes: r = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341, then s = 8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a. No secret key goes in. The verifier answers true, as the CSV says.PK · PUBLIC KEY · 32 BYTESdff1d77f…M · MESSAGE · ANY LENGTH, HERE 32 BYTES243f6a88…SIG · SIGNATURE · 64 BYTES = r ‖ sBYTES 0–31BYTES 32–63r = 6896bd60…s = 8906d11a…x of a point Ra number below nVERIFYBIP 340✓TRUENO SECRET KEY GOES INVECTOR 1 · BIP 340 CSV LINE 3
Exact values
pk (32 bytes)
dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659
m (32 bytes)
243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89
r (signature bytes 0–31)
6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341
s (signature bytes 32–63)
8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a
The signing handoff is schematic; this page does not sign. Below it, published vector 1 enters the verifier: an x-only public key, a message and a signature. No secret key enters the verifier.211131415

Three inputs, one answer

The verifier’s inputs have fixed shapes. The public key is exactly 32 bytes. The signature is exactly 64 bytes. The message is a byte array of any length, including none at all.21617

Those sizes were deliberate choices. ECDSA signatures in Bitcoin are DER-encoded, so they vary in size and can reach 72 bytes; BIP 340 uses a simple fixed format instead. Public keys shrink from the usual 33-byte compressed point to 32 bytes, because only the x coordinate is kept.5

Fig. A06.2 Fixed sizes, smaller keys

Fixed sizes, smaller keysOn one byte ruler from 0 to 72: an ECDSA signature in DER encoding has no fixed size and can reach 72 bytes. A BIP 340 signature is always 64 bytes: r (32) then s (32). A compressed public key is 33 bytes, the prefix 02 or 03 and the x coordinate; a BIP 340 key keeps only the 32-byte x coordinate, here dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659 from vector 1, which stands for the compressed key 02 followed by the same bytes.081624324048566472BYTESECDSA SIGNATURE · DER · VARIABLE, UP TO 72 Blength depends on the valuesBIP 340 SIGNATURE · 64 B, ALWAYSr · 32 Bs · 32 BCOMPRESSED KEY · 33 Bx = dff1d77f… · 32 B02BIP 340 KEY · 32 B · x ONLY, y TAKEN EVENx = dff1d77f… · 32 BTHE SAME x, DRAWN UNDER IT
Exact values
Vector 1: x-only key pk
dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659
The same key, compressed
02dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659
One byte ruler. A DER signature’s size depends on its values; a BIP 340 signature never changes size, and a key keeps only the x coordinate of its compressed form.2514

Consensus requires verifiers to agree about which signatures are valid. BIP 340’s authors therefore specify verification at the byte level, including each rejection condition. They cite Bitcoin’s earlier problems with loosely specified DER parsing. An implementation cannot choose different checks and still follow this specification.4

The first 32 bytes, r, encode the x coordinate of a curve point R chosen by the signer. The remaining 32 bytes encode a number, s. Verification checks the equation s⋅G = R + e⋅P. Here G is the curve’s fixed base point and P is the public key’s point. The challenge e is a hash that binds R, the public key and the message.13

Fig. A06.3 The equation a signature satisfies

The equation a signature satisfiesA balance for vector 1. On the left pan s⋅G, on the right R + e⋅P, and the beam is level because the signature is valid. s is the second half of the signature, 8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a. G is the curve's fixed base point. R is the point whose x coordinate is r, the first half of the signature (6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341), with even y. e is the challenge, a tagged hash of r, P and m reduced mod n: cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a. P is the public key lifted to its point with even y. The verifier rearranges the equation to R = s⋅G − e⋅P and checks that x(R) equals r.VECTOR 1: THE BEAM IS LEVEL=s·GR+e·PsSIGNATURE BYTES 32–63 · 8906d11a…GTHE CURVE'S FIXED BASE POINTRx(R) = r, SIGNATURE BYTES 0–31 · 6896bd60…eHASH OF r ‖ P ‖ m, MOD n · cfb58e74…PTHE KEY pk, LIFTED WITH EVEN yVERIFY COMPUTES R = s·G − e·P, THEN THE CHECKS ON R
Exact values
r
6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341
s
8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a
e
cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a
For vector 1 the two sides balance. Each term comes from the inputs, from the challenge hash, or from the curve’s fixed point G; Verify rearranges the equation to compute R.31318

Eight steps, in order

Keep the original key and signature, then switch from Original message to Different message. The signature no longer passes. Step through the gates to see where the changed message breaks the check.31819

Fig. A06.4 Verify, gate by gate

Static view: vector 1 checked against its own message, every gate shown. With JavaScript you can choose any of the 12 published vectors, swap in another vector’s message, and step through the gates.

Verify, gate by gateVerify for vector 1: public key dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659, its own 32-byte message 243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89, signature r = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341, s = 8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a. Gate 1, Lift the key: passes, P found, with even y (y = 2ce19b946c4ee58546f5251d441a065ea50735606985e5b228788bec4e582898). Gate 2, Read r: passes, r is below p (r = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341). Gate 3, Read s: passes, s is below n (s = 8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a). Gate 4, Hash the challenge: passes, e computed (the hash was already below n) (hash = cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a, e = cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a). Gate 5, Compute R: passes, R computed, y even (x = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341, y = 20bc7663da14be43c22eb2ccb49cd746573b2766b277273fcb20a2f6c1a60c6c). Gate 6, R is not infinity: passes, R is an ordinary point. Gate 7, R has even y: passes, y(R) is even. Gate 8, x(R) equals r: passes, x(R) equals r (x(R) = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341, r = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341). The lamp shows true.PK · 32 Bdff1d77f…M · 32 B243f6a88…SIG · 64 B = r ‖ sr 6896bd60…s 8906d11a…1LIFT P✓2r < p✓3s < n✓4HASH e✓5R✓6R ≠ ∞✓7EVEN y✓8▲ x = r✓✓TRUEGATE 8 · x(R) equals r · passesx(R) equals rx(R) 6896bd60…r 6896bd60…
Verify, gate by gateVerify for vector 1: public key dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659, its own 32-byte message 243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89, signature r = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341, s = 8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a. Gate 1, Lift the key: passes, P found, with even y (y = 2ce19b946c4ee58546f5251d441a065ea50735606985e5b228788bec4e582898). Gate 2, Read r: passes, r is below p (r = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341). Gate 3, Read s: passes, s is below n (s = 8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a). Gate 4, Hash the challenge: passes, e computed (the hash was already below n) (hash = cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a, e = cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a). Gate 5, Compute R: passes, R computed, y even (x = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341, y = 20bc7663da14be43c22eb2ccb49cd746573b2766b277273fcb20a2f6c1a60c6c). Gate 6, R is not infinity: passes, R is an ordinary point. Gate 7, R has even y: passes, y(R) is even. Gate 8, x(R) equals r: passes, x(R) equals r (x(R) = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341, r = 6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341). The lamp shows true.PK · 32 Bdff1d77f…M · 32 B243f6a88…SIG · 64 B = r ‖ sr 6896bd60…s 8906d11a…1LIFT P✓2r < p✓3s < n✓4HASH e✓5R✓6R ≠ ∞✓7EVEN y✓8▲ x = r✓✓TRUEGATE 8 · x(R) equals r · passesx(R) equals rx(R) 6896bd60…r 6896bd60…

Vector 1 with its own 32-byte message. Every gate passes: Verify succeeds. Published result for vector 1: TRUE.

Exact values for this view
pk (32 bytes)
dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659
m (32 bytes)
243f6a8885a308d313198a2e03707344a4093822299f31d0082efa98ec4e6c89
r
6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341
s
8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a
Gate 1: y
2ce19b946c4ee58546f5251d441a065ea50735606985e5b228788bec4e582898
Gate 2: r
6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341
Gate 3: s
8906d11ac976abccb20b091292bff4ea897efcb639ea871cfa95f6de339e4b0a
Gate 4: hash
cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a
Gate 4: e
cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a
Gate 5: x
6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341
Gate 5: y
20bc7663da14be43c22eb2ccb49cd746573b2766b277273fcb20a2f6c1a60c6c
Gate 8: x(R)
6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341
Gate 8: r
6896bd60eeae296db48a229ff71dfe071bde413e6d43f917dc8dcf8c78de3341

BIP 340 test-vectors.csv line 3. Arithmetic by @noble/curves; every result is cross-checked against noble’s own verifier.

Twelve published vectors, three valid and nine invalid. On a valid vector, swapping in another fixture’s message keeps the key and signature but changes e, so the recomputed R no longer fits.3181920
The verification algorithm, step by step

Verification starts by converting the public key into a curve point. The function lift_x reads the key’s 32 bytes as an x coordinate. It returns the point with that x coordinate and an even y coordinate. It fails if x is too large or no such point exists. The verifier then reads r and s from the signature. It rejects r at or above the field size p, and s at or above the curve order n.321

Next, compute the challenge e from a tagged hash of r, the public key and the message, reduced modulo n. Use it to compute R = s⋅G − e⋅P. Reject the signature if R is the point at infinity, its y coordinate is odd, or its x coordinate differs from r. Accept it only if every check passes.3

For a valid signature in this figure, changing the message leaves the early input checks intact and makes a later gate fail. The verifier checks the message it is given; it cannot know which one was intended.319

Fig. A06.5 Compare where the failures occur

Where each vector stopsVector 1: passes all eight gates; true. Vector 15 (CSV comment: “message of size 0 (added 2022-12)”): passes all eight gates; true. Vector 17 (CSV comment: “message of size 17 (added 2022-12)”): passes all eight gates; true. Vector 5 (CSV comment: “public key not on the curve”): stops at gate 1 (Lift the key); later gates are not reached. Vector 14 (CSV comment: “public key is not a valid X coordinate because it exceeds the field size”): stops at gate 1 (Lift the key); later gates are not reached. Vector 12 (CSV comment: “sig[0:32] is equal to field size”): stops at gate 2 (Read r); later gates are not reached. Vector 13 (CSV comment: “sig[32:64] is equal to curve order”): stops at gate 3 (Read s); later gates are not reached. Vector 9 (CSV comment: “sG - eP is infinite. Test fails in single verification if has_even_y(inf) is defined as true and x(inf) as 0”): stops at gate 6 (R is not infinity); later gates are not reached. Vector 6 (CSV comment: “has_even_y(R) is false”): stops at gate 7 (R has even y); later gates are not reached. Vector 7 (CSV comment: “negated message”): stops at gate 7 (R has even y); later gates are not reached. Vector 8 (CSV comment: “negated s value”): stops at gate 8 (x(R) equals r); later gates are not reached. Vector 11 (CSV comment: “sig[0:32] is not an X coordinate on the curve”): stops at gate 8 (x(R) equals r); later gates are not reached.1LIFT P2r < p3s < n4HASH e5R6R ≠ ∞7EVEN y8x = rVECTOR · CSV COMMENTOKV1 · (no comment) Valid · 32-byte mes…✓V15 · message of size 0 (added 2022-1…✓V17 · message of size 17 (added 2022-…✓V5 · public key not on the curve✕V14 · public key is not a valid X coo…✕V12 · sig[0:32] is equal to field size✕V13 · sig[32:64] is equal to curve or…✕V9 · sG - eP is infinite. Test fails …✕V6 · has_even_y(R) is false✕V7 · negated message✕V8 · negated s value✕V11 · sig[0:32] is not an X coordinat…✕● PASSED · ✕ STOPPED HERE · NOTHING AFTER IT: NOT REACHED · ✓ TRUE
Where each vector stopsVector 1: passes all eight gates; true. Vector 15 (CSV comment: “message of size 0 (added 2022-12)”): passes all eight gates; true. Vector 17 (CSV comment: “message of size 17 (added 2022-12)”): passes all eight gates; true. Vector 5 (CSV comment: “public key not on the curve”): stops at gate 1 (Lift the key); later gates are not reached. Vector 14 (CSV comment: “public key is not a valid X coordinate because it exceeds the field size”): stops at gate 1 (Lift the key); later gates are not reached. Vector 12 (CSV comment: “sig[0:32] is equal to field size”): stops at gate 2 (Read r); later gates are not reached. Vector 13 (CSV comment: “sig[32:64] is equal to curve order”): stops at gate 3 (Read s); later gates are not reached. Vector 9 (CSV comment: “sG - eP is infinite. Test fails in single verification if has_even_y(inf) is defined as true and x(inf) as 0”): stops at gate 6 (R is not infinity); later gates are not reached. Vector 6 (CSV comment: “has_even_y(R) is false”): stops at gate 7 (R has even y); later gates are not reached. Vector 7 (CSV comment: “negated message”): stops at gate 7 (R has even y); later gates are not reached. Vector 8 (CSV comment: “negated s value”): stops at gate 8 (x(R) equals r); later gates are not reached. Vector 11 (CSV comment: “sig[0:32] is not an X coordinate on the curve”): stops at gate 8 (x(R) equals r); later gates are not reached.12345678VEC.OKV1✓V15✓V17✓V5✕V14✕V12✕V13✕V9✕V6✕V7✕V8✕V11✕● PASSED · ✕ STOPPED · BLANK: NOT REACHED● PASSED · ✕ STOPPED · BLANK: NOT REACHED● PASSED · ✕ STOPPED · BLANK: NOT REACHED1 LIFT P2 r < p3 s < n4 HASH e5 R6 R ≠ ∞7 EVEN y8 x = r
The CSV comments in full
Vector 1 (line 3)
no comment
Vector 15 (line 17)
“message of size 0 (added 2022-12)”
Vector 17 (line 19)
“message of size 17 (added 2022-12)”
Vector 5 (line 7)
“public key not on the curve”
Vector 14 (line 16)
“public key is not a valid X coordinate because it exceeds the field size”
Vector 12 (line 14)
“sig[0:32] is equal to field size”
Vector 13 (line 15)
“sig[32:64] is equal to curve order”
Vector 9 (line 11)
“sG - eP is infinite. Test fails in single verification if has_even_y(inf) is defined as true and x(inf) as 0”
Vector 6 (line 8)
“has_even_y(R) is false”
Vector 7 (line 9)
“negated message”
Vector 8 (line 10)
“negated s value”
Vector 11 (line 13)
“sig[0:32] is not an X coordinate on the curve”
Each row follows a different published vector. The cross marks the first failed check; later checks are never reached.31820
Why a vector’s comment can differ from its failure stage

Each vector in the CSV carries a short comment. These describe how a failing vector was built, not necessarily which check catches it. Vector 7 is labelled “negated message”, yet it never reaches the comparison of x(R) with r: the R it produces has an odd y coordinate, so it fails one step earlier. Vectors 8 and 11 do reach that comparison, and fail there. Reading the BIP’s algorithm and watching it run are two different kinds of evidence, and this page shows both.1820

Caveat

The figures show computed values and checks instead of a smooth curve. Points on secp256k1 use integer coordinates modulo a 256-bit prime. A textbook curve drawn over the real numbers would not represent those coordinates.22

What the challenge binds together

The challenge e is where the message enters. BIP 340 hashes it with a tagged hash: SHA-256 of the tag’s own SHA-256 written twice, followed by the data. Here the tag is the text BIP0340/challenge. The authors use tags so that a hash computed for one purpose cannot be reinterpreted as a hash for another.2324

The data is r, then the public key, then the message. Including the key is called key prefixing, and the authors explain why it matters. Without it, anyone could turn a valid signature for a key P into a valid signature for P + a⋅G, for any tweak a they like. They note this would make signatures insecure for keys made by adding tweaks, as BIP 32’s unhardened derivation and Taproot both do.1325

The message is hashed whole, whatever its length. Earlier revisions of BIP 340 required exactly 32 bytes, and the changelog records the lifting of that rule in April 2023. The published vectors include valid signatures over messages of 0, 1, 17 and 100 bytes alongside the usual 32. The BIP still recommends pre-hashing large messages for performance, and BIP 341’s transaction signatures do sign a 32-byte digest.161726

Fig. A06.6 One hash, any message

One hash, any messageThe challenge e is SHA-256 of SHA256("BIP0340/challenge") written twice (7bb52d7a9fef58323eb1bf7a407db382d2f3f2d81bb1224f49fe518f6d48d37c), then r, then P, then the message, reduced mod n. Vector 15: a 0-byte message, so the hash reads 128 bytes; the hash is d3561670cd8b50b077cd4e229a6e1c09a1a663ad08264632a8596194b9e0abc7. Vector 16: a 1-byte message, so the hash reads 129 bytes; the hash is 4535cf052478f0f45f226501cf68dd6898143de5d6905e7f6607a1c6b4323a60. Vector 17: a 17-byte message, so the hash reads 145 bytes; the hash is 63f0aac9b6b870317dee839c5f5a7f1b584d0cd82c2bba4002cfca02ddef9b74. Vector 1: a 32-byte message, so the hash reads 160 bytes; the hash is cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a. Vector 18: a 100-byte message, so the hash reads 228 bytes; the hash is 44dd9fe38ba9fefa45d2aca76a95ff66cc535e11fd695b65448374f2016efae3.H(TAG) = SHA256("BIP0340/challenge") = 7bb52d7a…H(tag)32 BH(tag)32 Br32 BP32 BmANYSHA-256HASH;e = HASH mod nV15 · 0-BYTE MESSAGE · 128 BYTES INhash → d3561670…V16 · 1-BYTE MESSAGE · 129 BYTES INhash → 4535cf05…V17 · 17-BYTE MESSAGE · 145 BYTES INhash → 63f0aac9…V1 · 32-BYTE MESSAGE · 160 BYTES INhash → cfb58e74…V18 · 100-BYTE MESSAGE · 228 BYTES INhash → 44dd9fe3…
Exact values
SHA256("BIP0340/challenge")
7bb52d7a9fef58323eb1bf7a407db382d2f3f2d81bb1224f49fe518f6d48d37c
Vector 15: challenge hash (0-byte message)
d3561670cd8b50b077cd4e229a6e1c09a1a663ad08264632a8596194b9e0abc7
Vector 16: challenge hash (1-byte message)
4535cf052478f0f45f226501cf68dd6898143de5d6905e7f6607a1c6b4323a60
Vector 17: challenge hash (17-byte message)
63f0aac9b6b870317dee839c5f5a7f1b584d0cd82c2bba4002cfca02ddef9b74
Vector 1: challenge hash (32-byte message)
cfb58e748d9648b71fdc909fb7432fc0c954da5bd75cdc9d4804d32648f9839a
Vector 18: challenge hash (100-byte message)
44dd9fe38ba9fefa45d2aca76a95ff66cc535e11fd695b65448374f2016efae3
The challenge input for five valid vectors, to scale: 128 fixed bytes, then the message. A longer message only lengthens the tail.3161723
Details: why the signature carries R and not e

Schnorr signatures come in two forms. One publishes e and s; the other publishes R and s. BIP 340 chose R, which the authors say supports batch verification because no curve operation sits inside a hash. Batch verification checks many signatures together: it always succeeds if every signature is valid, and succeeds with only negligible probability if any is not.67

Why only x coordinates

Every valid x coordinate on the curve has two possible y values, one even and one odd. BIP 340 removes the ambiguity by rule: the key’s point P and the signature’s point R are always taken to have even y. That is why an x-only key is equivalent to a compressed key beginning with the byte 0x02.1314

The figure below shows the consequence in two places. The verifier lifts the key to its even-y point before anything else, and it rejects any R whose y turns out odd. The authors argue that, although it halves the set of valid public keys, it is not a reduction in security. In their argument, breaking an x-only key is at most a small constant faster than breaking a full one. One side effect is stated outright: every public key has two matching secret keys, sk and n − sk.212728

Fig. A06.7 One x, two y, one kept

One x, two y, one keptThe key of vector 1, x = dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659, matches two curve points: one with even y and one with odd y. lift_x keeps the even one, y = 2ce19b946c4ee58546f5251d441a065ea50735606985e5b228788bec4e582898; the odd one, p − y, is never used. The same rule applies to R: in vector 6, R = s⋅G − e⋅P has x = fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556 and odd y = ae12777aacfbb620f3be96017f45c560de80f0f6518fe4a03c870c36b075f297, so Verify stops at gate 7, the even-y check. A side effect: every public key has two secret keys, sk and n − sk, that give the same x-only key.THE KEY · VECTOR 1x dff1d77f…y 2ce19b94…EVEN · KEPT AS Pother y = p − y · ODDNOT USED BY VERIFYR · VECTOR 6x fff97bd5…y ae12777a…ODD✕GATE 7VERIFY STOPS: R MUST HAVE EVEN yTWO SECRET KEYS, ONE X-ONLY KEYskn − skthe same pkNO VALUES: SECRET
Exact values
Vector 1: pk = x(P)
dff1d77f2a671c5f36183726db2341be58feae1da2deced843240f7b502ba659
y(P), even
2ce19b946c4ee58546f5251d441a065ea50735606985e5b228788bec4e582898
Vector 6: x(R)
fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556
y(R), odd
ae12777aacfbb620f3be96017f45c560de80f0f6518fe4a03c870c36b075f297
The even y is kept for the key and required of R: vector 6’s R has odd y, so Verify rejects it. The two secret keys are drawn without values.314182128
Details: lift_x and the constants

lift_x fails if x ≥ p. Otherwise it computes c = x³ + 7 mod p and y = c^((p+1)/4) mod p, fails if y² ≠ c, and returns the point with whichever of y and p − y is even. The field size p and the curve order n are fixed 256-bit constants; the curve is y² = x³ + 7 over the integers modulo p.2229

What a passing check does not say

Successful verification means that the signature is valid for this public key and message under BIP 340. It does not establish what the message means. BIP 340 says applications should ensure that a message signed for one context is never accepted in a different context. For example, a signed application message should not be accepted as a transaction. The authors also explain that Schnorr signatures are non-malleable under their security assumptions, while ECDSA signatures are inherently malleable.33031

Nor does BIP 340 by itself provide a multisignature protocol. The key may belong to one person or be an aggregate of several. Schemes such as MuSig2, specified separately in BIP 327, let several parties build one key and one signature through an interactive protocol. To a verifier the result looks like any other signature. BIP 340 warns that multisignature schemes are generally insecure with the nonce generation of its default signing algorithm, or with any other deterministic method.910

Signing algorithms and the reference implementation

BIP 340 was assigned in 2020 and is recorded as deployed. This page explains the signing handoff but does not implement a signer. The BIP specifies a default signer, but signatures are not unique. Other ways of generating its random value produce different, equally valid signatures. However that value is generated, it must be uniformly random and not even partially predictable to an attacker. Verification is guaranteed to accept what a correct signer produces. The BIP’s own Python code is labelled for demonstration only; the values here come from the audited @noble/curves library, checked against all 19 vectors in the CSV.1215183233

Why add another signature scheme?

Bitcoin already had ECDSA signatures. BIP 340 standardizes Schnorr signatures over the same curve, secp256k1. Its authors point to security proofs under established assumptions and non-malleability: a third party cannot turn a valid signature into a different valid signature for the same key and message under those assumptions.13134

The signature binds a public key to a message. Changing the message changes what the verifier checks, even when the key and signature stay untouched.2319

Evidence

Each numbered marker in the text points here, and the ↩ links lead back to the text. Quotes are verbatim from the BIP files at commit 3a10b5b, wiki markup included. Links open the exact lines. Labels say what kind of statement each entry is: a rule, the author’s rationale, history, a test vector, or our own inference.

  1. ↩ a b Rule BIP 340 proposes a standard for 64-byte Schnorr signatures over the curve secp256k1. It reuses the curve and hash function Bitcoin already uses for ECDSA.

    Quoted source text (2)

    This document proposes a standard for 64-byte Schnorr signatures over the elliptic curve ''secp256k1''.

    BIP 340, line 21

    By reusing the same curve and hash function as Bitcoin uses for ECDSA

    BIP 340, line 48
  2. ↩ a b c d e f Rule Verify takes a 32-byte public key, a message of any length (a byte array), and a 64-byte signature.

    Quoted source text (1)

    * The public key ''pk'': a 32-byte array * The message ''m'': a byte array * A signature ''sig'': a 64-byte array

    BIP 340, lines 177–179
  3. ↩ a b c d e f g h i j k l m Rule Verify lifts pk to a point P, checks r < p and s < n, computes the challenge e, computes R = s⋅G − e⋅P, and fails if R is infinite, has odd y, or has an x coordinate different from r; it succeeds only if no step failed.

    Quoted source text (1)

    * Let ''P = lift_x(int(pk))''; fail if that fails. * Let ''r = int(sig[0:32])''; fail if ''r &ge; p''. * Let ''s = int(sig[32:64])''; fail if ''s &ge; n''. * Let ''e = int(hash<sub>BIP0340/challenge</sub>(bytes(r) || bytes(P) || m)) mod n''. * Let ''R = s⋅G - e⋅P''. * Fail if ''is_infinite(R)''. * Fail if ''not has_even_y(R)''. * Fail if ''x(R) &ne; r''. * Return success iff no failure occurred before reaching this point.

    BIP 340, lines 182–190
  4. ↩ a b Author’s rationale The authors require the verification algorithm to be completely specified at the byte level, so that nobody can make a signature valid to some verifiers but not others; they cite DER parsing problems with ECDSA.

    Quoted source text (3)

    To be safe for usage in consensus systems, the verification algorithm must be completely specified at the byte level. This guarantees that nobody can construct a signature that is valid to some verifiers but not all.

    BIP 340, line 46

    the lack of exact specification for the DER parsing of ECDSA signatures has caused problems for Bitcoin

    BIP 340, line 46

    This is traditionally not a requirement for digital signature schemes

    BIP 340, line 46
  5. ↩ a b c d Author’s rationale BIP 340 uses a fixed 64-byte signature instead of DER encoding (variable size, up to 72 bytes) and 32-byte public keys instead of 33-byte compressed points.

    Quoted source text (2)

    -encoding for signatures (which are variable size, and up to 72 bytes), we can use a simple fixed 64-byte format.

    BIP 340, line 43

    public keys in this proposal are encoded as 32 bytes.

    BIP 340, line 44
  6. ↩ a b Author’s rationale BIP 340 signatures reveal R (as r) rather than e; the authors chose this because it supports batch verification, as no elliptic-curve operations sit inside the hashes.

    Quoted source text (2)

    This supports batch verification, as there are no elliptic curve operations inside the hashes.

    BIP 340, line 60

    We choose the ''R''-option, which supports batch verification.

    BIP 340, line 62
  7. ↩ a b Rule BIP 340 also specifies batch verification: if every signature is valid it succeeds; if any is invalid it succeeds only with negligible probability.

    Quoted source text (1)

    If all individual signatures are valid (i.e., ''Verify'' would return success for them), ''BatchVerify'' will always return success. If at least one signature is invalid, ''BatchVerify'' will return success with at most a negligible probability.

    BIP 340, line 215
  8. ↩ Author’s rationale The authors identify linearity as a building block for efficient multiparty signatures and other higher-level constructions.

    Quoted source text (1)

    * '''Linearity''': Schnorr signatures provide a simple and efficient method that enables multiple collaborating parties to produce a signature that is valid for the sum of their public keys.

    BIP 340, line 36
  9. ↩ a b Rule Multiparty signing is left to interactive schemes such as MuSig2 (BIP 327); BIP 340 warns that multisignature schemes are generally insecure with the rand generation of its default signing algorithm or any other deterministic method.

    Quoted source text (2)

    By means of an interactive scheme such as [https://eprint.iacr.org/2020/1261.pdf MuSig2] ([[bip-0327.mediawiki|BIP327]]), participants can aggregate their public keys into a single public key which they can jointly sign for.

    BIP 340, line 268

    It is important to note that multisignature signing schemes in general are insecure with the ''rand'' generation from the default signing algorithm above (or any other deterministic method).

    BIP 340, line 170
  10. ↩ a b Author’s rationale From a verifier's perspective, an n-of-n MuSig2 signature is no different from an ordinary signature.

    Quoted source text (1)

    This allows ''n''-of-''n'' multisignatures which, from a verifier's perspective, are no different from ordinary signatures

    BIP 340, line 268
  11. ↩ a b Rule The default signer takes a secret key, message and auxiliary random data, derives a nonce, and returns a signature; verification uses public inputs.

    Quoted source text (2)

    Input: * The secret key ''sk'': a 32-byte array * The message ''m'': a byte array * Auxiliary random data ''a'': a 32-byte array

    BIP 340, lines 140–143

    * Return the signature ''sig''.

    BIP 340, line 159
  12. ↩ a b Rule The BIP's Python reference implementation is naive, non-constant-time and for demonstration only; the vectors are published as a CSV file.

    Quoted source text (3)

    a naive, highly inefficient, and non-constant time [[bip-0340/reference.py|pure Python 3.7 reference implementation of the signing and verification algorithm]]

    BIP 340, line 289

    The reference implementation is for demonstration purposes only and not to be used in production environments.

    BIP 340, line 292

    we provide a [[bip-0340/test-vectors.csv|collection of test vectors in CSV format]]

    BIP 340, line 288
  13. ↩ a b c d e Rule The public key pk is the x coordinate of a point P with even y; a signature is (r, s) where r is the x coordinate of a point R with even y, and s⋅G = R + tagged_hash(r || pk || m)⋅P.

    Quoted source text (1)

    our final scheme ends up using public key ''pk'' which is the X coordinate of a point ''P'' on the curve whose Y coordinate is even and signatures ''(r,s)'' where ''r'' is the X coordinate of a point ''R'' whose Y coordinate is even. The signature satisfies ''s⋅G = R + tagged_hash(r || pk || m)⋅P''.

    BIP 340, line 92
  14. ↩ a b c d Rule Every valid x coordinate has two possible y coordinates, one even and one odd; BIP 340 implicitly takes the even one for both P and R, so an x-only key is equivalent to a compressed key with the prefix byte 0x02.

    Quoted source text (3)

    we pick that option for ''P'', and thus our X-only public keys become equivalent to a compressed public key that is the X-only key prefixed by the byte 0x02. For consistency, the same is done for ''R''

    BIP 340, line 82

    (every valid X coordinate has two possible Y coordinates)

    BIP 340, line 77

    This means that for a valid X coordinate, one of the corresponding Y coordinates will be even, and the other will be odd.

    BIP 340, line 79
  15. ↩ a b Rule For every valid secret key and message, verifying the default signer's signature with the matching public key succeeds.

    Quoted source text (1)

    For every valid secret key ''sk'' and message ''m'', ''Verify(PubKey(sk),m,Sign(sk,m))'' will succeed.

    BIP 340, line 192
  16. ↩ a b c History BIP 340 accepts messages of arbitrary size; earlier revisions required exactly 32 bytes, and the changelog records the change in 2023-04. Pre-hashing is still recommended for performance with large messages. Implementations may reject messages too large for their environment.

    Quoted source text (5)

    The signature scheme specified in this BIP accepts byte strings of arbitrary size as input messages.

    BIP 340, line 221

    Earlier revisions of this BIP required messages to be exactly 32 bytes.

    BIP 340, line 225

    2023-04: Allow messages of arbitrary size

    BIP 340, line 299

    We note that pre-hashing is recommended for performance reasons in applications that deal with large messages.

    BIP 340, line 234

    It is understood that implementations may reject messages which are too large in their environment or application context,

    BIP 340, line 222
  17. ↩ a b c Test vector The published vectors include valid signatures on messages of 0, 1, 17, 32 and 100 bytes; for each, the challenge hash input is 64 tag bytes, 32 bytes of r, 32 bytes of P and the whole message.

    Quoted source text (4)

    message of size 0 (added 2022-12)

    BIP 340 (test-vectors.csv), line 17

    message of size 1 (added 2022-12)

    BIP 340 (test-vectors.csv), line 18

    message of size 17 (added 2022-12)

    BIP 340 (test-vectors.csv), line 19

    message of size 100 (added 2022-12)

    BIP 340 (test-vectors.csv), line 20
  18. ↩ a b c d e f g Test vector All 19 published vectors (9 valid, 10 invalid) give the published result when run through this site's step-by-step verifier, which uses @noble/curves arithmetic and is cross-checked against noble's own verifier; the eight vectors with secret keys also reproduce their signatures.

    Quoted source text (1)

    index,secret key,public key,aux_rand,message,signature,verification result,comment

    BIP 340 (test-vectors.csv), line 1
  19. ↩ a b c d Test vector Checking each valid hero vector's key and signature against another fixture's message fails, in every such pairing, at the even-y or x(R) step, because the message changes e and therefore R.

    Quoted source text (1)

    * Let ''e = int(hash<sub>BIP0340/challenge</sub>(bytes(r) || bytes(P) || m)) mod n''. * Let ''R = s⋅G - e⋅P''.

    BIP 340, lines 185–186
  20. ↩ a b c Test vector The CSV comment says how an invalid vector was made, not necessarily which check rejects it: vector 7 ('negated message') is rejected because the recomputed R has odd y, before any x comparison; vectors 8 and 11 fail at the x(R) comparison.

    Quoted source text (3)

    FALSE,negated message

    BIP 340 (test-vectors.csv), line 9

    * Fail if ''not has_even_y(R)''.

    BIP 340, line 188

    FALSE,negated s value

    BIP 340 (test-vectors.csv), line 10
  21. ↩ a b c Rule lift_x(x) returns the point with that x coordinate and even y, or fails if x is greater than p − 1 or no such point exists.

    Quoted source text (2)

    returns the point ''P'' for which ''x(P) = x''

    BIP 340, lines 113–114

    and ''has_even_y(P)'', or fails if ''x'' is greater than ''p-1'' or no such point exists.

    BIP 340, line 114
  22. ↩ a b Rule Points are on the curve y² = x³ + 7 over the integers modulo p; p is the field size and n the curve order, both given as exact constants.

    Quoted source text (2)

    Uppercase variables refer to points on the curve with equation ''y2 = x3 + 7'' over the integers modulo ''p''.

    BIP 340, line 100

    The constant ''p'' refers to the field size, ''0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F''. ** The constant ''n'' refers to the curve order, ''0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141''.

    BIP 340, lines 98–99
  23. ↩ a b Rule hash_name(x) is SHA256(SHA256(tag) || SHA256(tag) || x), where tag is the UTF-8 encoding of name.

    Quoted source text (1)

    returns the 32-byte hash ''SHA256(SHA256(tag) || SHA256(tag) || x)'', where ''tag'' is the UTF-8 encoding of ''name''.

    BIP 340, line 120
  24. ↩ Author’s rationale Tags keep a hash computed for one purpose from being reinterpreted in another context.

    Quoted source text (1)

    To make sure hashes used in one context can't be reinterpreted in another one, hash functions can be tweaked with a context-dependent tag name, in such a way that collisions across contexts can be assumed to be infeasible.

    BIP 340, line 86
  25. ↩ Author’s rationale Without the public key in the challenge, a third party could turn a signature for P into one for P + a⋅G for any additive tweak a, which the authors say would make signatures insecure with BIP 32 unhardened derivation and with tweaks such as Taproot's; so the public key is prefixed to the message in the challenge.

    Quoted source text (3)

    a third party can convert a signature ''(R, s)'' for public key ''P'' into a signature ''(R, s + a⋅hash(R || m))'' for public key ''P + a⋅G'' and the same message ''m'', for any given additive tweak ''a'' to the signing key.

    BIP 340, line 64

    and other methods that rely on additive tweaks to existing keys such as Taproot.

    BIP 340, line 64

    which means that the public key is prefixed to the message in the challenge hash input.

    BIP 340, line 66
  26. ↩ Rule BIP 340 gives BIP 341 as an example of pre-hashing to a 32-byte digest; BIP 341's key-path rule verifies a signature over hash_TapSighash(0x00 || SigMsg(...)), a 32-byte tagged hash.

    Quoted source text (2)

    to create a 32-byte digest which can be passed to signing or verification (as for example done in [[bip-0341.mediawiki|BIP341]].)

    BIP 340, lines 227–229

    return ''Verify(q, hash<sub>TapSighash</sub>(0x00 || SigMsg(0x00, 0)), sig)''

    BIP 341, line 142
  27. ↩ Author’s rationale The authors argue that implicit y coordinates are not a reduction in security, although they halve the set of valid public keys: breaking an x-only key can be at most a small constant term faster than breaking a full one.

    Quoted source text (2)

    Despite halving the size of the set of valid public keys, implicit Y coordinates are not a reduction in security.

    BIP 340, line 84

    This shows that breaking an X-only public key can be at most a small constant term faster than breaking a full one.

    BIP 340, line 84
  28. ↩ a b Rule Every BIP 340 public key has two corresponding secret keys, sk and n − sk.

    Quoted source text (1)

    A side effect is that ''PubKey(sk) = PubKey(bytes(n - int(sk))'', so every public key has two corresponding secret keys.

    BIP 340, line 132
  29. ↩ Rule lift_x fails if x ≥ p, computes c = x³ + 7 mod p and y = c^((p+1)/4) mod p, fails if y² ≠ c, and returns the point with the even one of y and p − y.

    Quoted source text (1)

    *** Fail if ''x &ge; p''. *** Let ''c = x3 + 7 mod p''. *** Let ''y = c(p+1)/4 mod p''. *** Fail if ''c &ne; y2 mod p''. *** Return the unique point ''P'' such that ''x(P) = x'' and ''y(P) = y'' if ''y mod 2 = 0'' or ''y(P) = p-y'' otherwise.

    BIP 340, lines 115–119
  30. ↩ Rule BIP 340 says applications should make sure a message signed for one context is never accepted in another, and recommends a tagged pre-hash or a 33-byte context prefix.

    Quoted source text (2)

    applications should ensure that a signed application message intended for one context is never deemed valid in a different context

    BIP 340, line 249

    we recommend applications to use exactly one of the following methods to pre-process application messages before passing it to the signature scheme:

    BIP 340, line 255
  31. ↩ a b Author’s rationale The authors state that the SUF-CMA security of Schnorr signatures implies they are non-malleable, whereas ECDSA signatures are inherently malleable.

    Quoted source text (1)

    The SUF-CMA security of Schnorr signatures implies that they are non-malleable. On the other hand, ECDSA signatures are inherently malleable

    BIP 340, line 35
  32. ↩ Rule Signing is not unique: other ways of generating the rand value produce different but equally valid signatures; however rand is generated, it must be a fresh uniformly random 32-byte string not even partially predictable to an attacker.

    Quoted source text (2)

    producing a different but still valid signature (in other words, this is not a ''unique'' signature scheme)

    BIP 340, line 165

    the value must be a fresh uniformly random 32-byte string which is not even partially predictable for the attacker.

    BIP 340, line 165
  33. ↩ History BIP 340 was assigned in 2020; its preamble records the status Deployed and the type Specification.

    Quoted source text (3)

    Assigned: 2020-01-19

    BIP 340, line 11

    Status: Deployed

    BIP 340, line 9

    Type: Specification

    BIP 340, line 10
  34. ↩ Author’s rationale The authors motivate Schnorr with security proofs under stated assumptions; they contrast these with the stronger assumptions of known ECDSA security results.

    Quoted source text (1)

    * '''Provable security''': Schnorr signatures are provably secure. In more detail, they are ''strongly unforgeable under chosen message attack (SUF-CMA)''<ref>Informally, this means that without knowledge of the secret key but given valid signatures of arbitrary messages, it is not possible to come up with further valid signatures.</ref> [https://www.di.ens.fr/~pointche/Documents/Papers/2000_joc.pdf in the random oracle model assuming the hardness of the elliptic curve discrete logarithm problem (ECDLP)] and [http://www.neven.org/papers/schnorr.pdf in the generic group model assuming variants of preimage and second preimage resistance of the used hash function]<ref>A detailed security proof in the random oracle model, which essentially restates [https://www.di.ens.fr/~pointche/Documents/Papers/2000_joc.pdf the original security proof by Pointcheval and Stern] more explicitly, can be found in [https://eprint.iacr.org/2016/191 a paper by Kiltz, Masny and Pan]. All these security proofs assume a variant of Schnorr signatures that use ''(e,s)'' instead of ''(R,s)'' (see Design above). Since we use a unique encoding of ''R'', there is an efficiently computable bijection that maps ''(R,s)'' to ''(e,s)'', which allows to convert a successful SUF-CMA attacker for the ''(e,s)'' variant to a successful SUF-CMA attacker for the ''(R,s)'' variant (and vice-versa). Furthermore, the proofs consider a variant of Schnorr signatures without key prefixing (see Design above), but it can be verified that the proofs are also correct for the variant with key prefixing. As a result, all the aforementioned security proofs apply to the variant of Schnorr signatures proposed in this document.</ref>. In contrast, the [https://nbn-resolving.de/urn:nbn:de:hbz:294-60803 best known results for the provable security of ECDSA] rely on stronger assumptions.

    BIP 340, line 34