Repository navigation
Description
Summary
The spec says Blocktrails derivation is "Compatible with BIP-341 Taproot" ("Benefits of BIP-341 derivation: … Standards alignment"). It is not, and by design: the spec adds the tweak to the full point ("Blocktrails operate on full secp256k1 private keys and public keys internally … Parity normalization is an output encoding concern"), while BIP 341 lifts the internal key to its even-y point before every tweak. The two agree only when the running point happens to have even y.
Measured with the reference implementation's own derivePublicKey / deriveChainedPublicKey against a BIP 341 reference that reproduces all 7 official scriptPubKey vectors:
- one step: the same output as BIP 341 for 49.5% of random keys (exactly the even-y ones; every odd-y key differs);
- chains of 2, 5 and 10 steps: 257, 37 and 0 of 1000 agree, about 2⁻ᵏ.
Nothing is broken on-chain. A trail is internally consistent (private and public derivations agree, 300/300 chains), spendable (BIP 340 signatures with adjustPrivateKeyForSigning verify, 300/300, including 146 odd-y output keys) and its own verify() accepts it (300/300). But no standard taproot tool, descriptor or hardware wallet can reproduce or sign a trail output from "internal key + merkle root", because the derivation is not BIP 341's. The claim should go, and the rule be stated as what it is.
What the rule actually is, and why it is the right one
Full-point arithmetic is the cleaner model: d + t ↔ P + t·G for every key, whatever the parity, with no sign tracking anywhere in the chain. BIP 341's lift replaces d by n − d at every odd-y step, which turns small additive offsets into a chain-position-dependent mess; keeping the point whole avoids that. The x-only form belongs only at the edge: the output is x(P), and a BIP 340 signature uses d or n − d to match, inside the signing.
This rule is now written down and tested once, for every project that shares it: sidestr/spec siding/lib/keys.mjs (sidestr/spec#27, #28), with the official BIP 340, 341 and 86 vectors at the edge, property tests over both parities, and known-answer vectors (siding/test/keys-vectors.json; also offered as did:nostr additive-tweak vectors, nostrcg/did-nostr#146, #147). Under it, BIP 341's own tweak on an even-y point reproduces BIP 341 exactly, so the two models meet where they should.
Proposed changes to spec.md
- Replace the compatibility claim. In "Benefits of BIP-341 derivation", "Standards alignment: Compatible with BIP-341 Taproot" becomes: "The tweak hash is BIP 341's tagged
TapTweak; the derivation is not BIP 341's: the tweak is added to the point as it is, never to its even-y lift. A trail output is a raw taproot key (rawtr()in descriptor terms), spendable by key path by whoever holds the chained secret, and not derivable by a BIP 341 tool from an internal key and a merkle root." - State the rule in one place (the "Design" paragraph already has most of it): keys are full compressed points; tweaks are scalar additions
d + t,P + t·G; the x-only form only at the output and in the BIP 340 sign. Referencekeys.mjsas the tested statement of it. - Publish the full base key. A trail file carries
pubkeyBaseas a 33-byte compressed point (02/03 + x), never x-only; with x-only only, a verifier has to guess the parity (the git-mark profile's verify step currently "tries both Y parities"). With the full point there is nothing to guess. Equivalently, following did:nostr: a base given as a bare x is the02point, and the holder normalises the secret once (n − dif odd) so that it is exactly theirs. p2tr_xonlysimplification. Sincex(P) = x(−P), the function is justx(P); the "if y(P) is even … else x(−P)" branch is a no-op and reads as if parity mattered there. State: the output isx(P); the sign is applied only when signing.
Refs: the audit scripts that produced the figures can be re-run against src/index.js; sidestr/spec#27 for the shared rule and vectors.
Activity