Skip to content

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

Merged
melvincarvalho merged 2 commits into
gh-pagesfrom
live-rule
Oct 1, 2026
Merged

melvincarvalho merged 2 commits into
gh-pagesfrom
live-rule

Conversation

@melvincarvalho

Copy link
Copy Markdown
Contributor

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 blocktrails package's scalar: 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/hashes and @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 trail give blocktrails.json (pubkeyBase as a full point, states, txo). export() also carries pubkeyBase.

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 through verify.

README: the rule, the URI table (commit on every TXO, pubkey optional), the API.

…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)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Low severity

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.verify to require pubkeyBase, verify every link, and return the expected x-only outputs; add a trail()/git mark trail blocktrails.json emitter and the --commit/--pubkey-base CLI 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.

Comment thread README.md
Comment on lines +143 to +145
### `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)
@melvincarvalho

Copy link
Copy Markdown
Contributor Author

Addressed: the usage example now verifies with Gitmark.verify(trail.txo, trail.pubkeyBase) and shows trail(); the stale Gitmark.verify(uris) section is removed, leaving the two-argument one.

@melvincarvalho
melvincarvalho merged commit 902be9f into gh-pages Oct 1, 2026
@melvincarvalho
melvincarvalho deleted the live-rule branch October 1, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The profile and the code derive keys by different rules: make the profile describe the raw additive chain the live trails use, and verify every link

2 participants