Repository navigation
The rule the live trails use: Core TapTweak over the commit as text, on the full point; a commit at genesis; verify from the base key, every link - #3
Conversation
…xt (TapTweak(x(P) || sha256(utf8(commit))) on the full point, never lifted), computed here since the published blocktrails 0.0.3 still derives by the earlier simple rule; the genesis TXO carries the first commit and the base key is never an output; verify takes the base key (nothing guessed), walks every link and returns the expected outputs; trail() and git mark trail give blocktrails.json; tests pinned to the first three marks of the live trail, two commits swapped refused (closes #2)
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It changes security-sensitive key-derivation and verification cryptography whose correctness hinges on matching real on-chain trail data that cannot be independently verified in this environment, warranting human review.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
This PR changes git-mark's key-derivation rule to match what the live on-chain trails actually use, resolving issue #2. Instead of the previous raw additive scalar (t = commit_hash mod n), keys are now derived as a key-bound TapTweak chain: tᵢ = TapTweak(x(Pᵢ₋₁) || sha256(utf8(commitᵢ))), Pᵢ = Pᵢ₋₁ + tᵢ·G on the full (unlifted) point. It also makes every TXO — including genesis — carry a commit, publishes the base key with the trail (pubkeyBase), and rewrites verify to walk every link from that base key rather than bootstrapping from the genesis pubkey.
Changes:
- Replace the raw-scalar tweak with a TapTweak-over-commit-text scalar computed locally via the noble libraries, and make genesis the base key tweaked by the first commit (no untweaked base output).
- Rework
Gitmark.verifyto requirepubkeyBase, verify every link, and return theexpectedx-only outputs; add atrail()/git mark trailblocktrails.json emitter and the--commit/--pubkey-baseCLI flags. - Update tests (known-answer pins from the 1 Oct 2026 trail, swapped-commit rejection, missing-commit rejection, base-key-required) and README/API docs.
| File | Description |
|---|---|
| index.js | New TapTweak commitScalar(pubkey, commit), point-dependent chain derivation, genesis carries first commit, verify(uris, pubkeyBase) rewrite, new trail(), export() adds pubkeyBase. |
| bin/git-mark.js | genesis accepts --commit (default HEAD), verify requires --pubkey-base/state base key, new trail command and help entry. |
| test/gitmark.test.js | Updates all genesis calls to pass a commit, adds known-answer/link-ordering/base-key tests, and trail() round-trip. |
| README.md | Documents the TapTweak rule, updated URI table (commit required, pubkey optional), and new trail()/verify API. |
| package.json | Declares @noble/hashes and @noble/secp256k1 as direct dependencies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ### `Gitmark.verify(uris, pubkeyBase)` | ||
|
|
||
| Walk every link from the base key. Returns `{ valid, error?, expected }` with the expected x-only output of every TXO. |
…rgument verify section removed (Copilot review)
|
Addressed: the usage example now verifies with |

Closes #2 (with the correction posted there: the live trail follows Core's rule, not this repository's raw-commit scalar).
Derivation (
index.js):commitScalar(P, commit) = TapTweak(x(P) || sha256(utf8(commit))) mod n, computed here with the noble libraries. Each tweak depends on the point before it and is added to that point as it is, never to its even-y lift. Established against the chain: every sampled mark of the 68-mark trail of 1 October 2026 (0, 1, 2, 10, 33, 50, 66, 67) matches under this rule and no other candidate, through 35 odd-y intermediate points.Why not the
blocktrailspackage'sscalar: the published 0.0.3 is the earlier v0.2 simple rule (t = sha256(state), no tagged hash, no key binding), which gives different outputs from the live trails; the TapTweak rule exists only in that repository's unpublished HEAD (blocktrails/blocktrails#20).@noble/hashesand@noble/secp256k1, already used transitively, are now declared.Shape: every TXO carries its commit, the genesis one too (
genesis(txid, vout, amount, commit); the CLI defaults to HEAD); the base key is never an output.Gitmark.verify(uris, pubkeyBase)walks every link from the base key (a bare x is read as the 02 point), compares with the URI's pubkey when it has one, and returns the expected outputs so a caller with the chain compares them with the outputs on-chain; nothing is guessed.trail()/git mark trailgiveblocktrails.json(pubkeyBaseas a full point,states,txo).export()also carriespubkeyBase.Tests (37, all passing): the first three marks of the live trail as known answers (base, commits, the three x-only outputs the chain shows), with and without pubkeys in the URIs, and the base as a bare x; two commits swapped (same sum, other outputs) refused at the right index; a TXO without a commit refused; verify without the base key asks for it rather than guessing;
trail()'s shape round-trips throughverify.README: the rule, the URI table (commit on every TXO, pubkey optional), the API.