Skip to content

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

Closed

Description

@melvincarvalho

Summary

The git-mark profile (blocktrails/spec, profiles/gitmark.html, v0.2) and this code derive keys by two different rules.

The profile says, with the key bound in:

scalar(P, commit): t = tagged_hash("TapTweak", x_only(P) || commit_hash); return int(t) mod n

The code does (index.js, commitScalar and deriveChainedPublicKeyFromCommits): the commit hash itself, zero-padded to 32 bytes, read as a number mod n, added to the point:

t_i = int(commit_i) mod n
P_i = P_{i-1} + t_i·G

No tagged hash, no binding to the key. The live trails since 18 September were made by the code, so the profile does not describe them. One of the two has to change, and since the trails exist and the raw additive rule is the simpler and better one, the profile should describe the code.

Why the raw additive rule is fine, with one condition

A chain of plain additions is the clean model (see blocktrails/spec issue on the BIP 341 claim): d_i = d_{i-1} + c_i, P_i = P_{i-1} + c_i·G, every intermediate point kept whole, the x-only form only at the output. The offsets stay small (160-bit commit hashes in a 256-bit field), which the BIP 341 lift would destroy.

The condition: every link must be verified, not just the head. Plain addition commutes, so the head key alone commits only to the sum of the commit scalars. Someone who can grind commit hashes (timestamps, messages) could build a different history with the same sum; finding k values that add to a target is a k-sum problem, roughly 2⁵⁰ work for 160-bit values, not 2¹⁶⁰. What closes it is that every intermediate output is on-chain and P_i − P_{i-1} = c_i·G pins each c_i individually. That holds only if a verifier walks the chain link by link and compares every output. (The standalone verifier does not today: blocktrails/verify issue.)

Proposed

  1. Profile text (in blocktrails/spec profiles/gitmark.html): replace the TapTweak scalar with the raw rule the code uses: t_i = int(commit_hash_i, left-padded to 32 bytes) mod n, rejected if 0; P_i = P_{i−1} + t_i·G on the full point, never lifted; the output is x(P_i). Add the requirement: a verifier MUST recompute and check every link's output against the chain, and MUST NOT accept a trail from its head alone. Note git's hash: SHA-1 repositories rely on git's collision-hardened SHA-1; SHA-256 repositories are safe as they are.
  2. The trail file carries the full compressed base key (pubkeyBase as 02/03 + x). The profile's verify step "tries both Y parities (x-only loses parity)" then goes: with the full point there is nothing to guess. (Equivalently, a bare x is the 02 point and the holder normalises the secret once, as did:nostr and sidestr's keys.mjs state.)
  3. Tests here: a known-answer test for a short chain (base key, three commits, the three expected x-only outputs), so the rule is pinned by numbers, and a test that a verifier walking the links rejects a trail whose links are reordered (same sum, different outputs).
  4. Shared code: the arithmetic is the same as sidestr/spec siding/lib/keys.mjs (chainPoints, chainSecrets, xOnly, signingKey; keys.mjs: keys as group elements — full points, additive tweaks, normalise once, x-only only at the edge sidestr/spec#27, #28), tested against the official BIP 340/341/86 vectors. Importing it by commit would make git-mark's derivation the shared, tested one rather than its own copy.

Refs: the first git-mark trail (18 Sep 2026); blocktrails/spec profiles/gitmark.html v0.2; sidestr/spec#27.

Activity

  1. melvincarvalho commented on Oct 1, 2026

    @melvincarvalho
    ContributorAuthor

    Correction to the issue text, after checking the live trail against the chain. The 68-mark trail of 1 October 2026 (made by the other git-mark implementation, solidpayorg/gitmark) does not use the raw commit-scalar rule in this repository's commitScalar. It uses Blocktrails Core's scalar with the state being the commit hash as text: t = TapTweak(x(P) || sha256(utf8(commit))), added to the full point at every step (35 of its 68 intermediate points are odd-y, and every sampled mark — 0, 1, 2, 10, 33, 50, 66, 67 — matches the on-chain output under that rule and under no other candidate). Its genesis TXO carries the first commit, and the trail file publishes pubkeyBase as a full compressed point.

    So the alignment goes the other way from what I wrote: this repository's code (raw commit bytes as the scalar, genesis without a commit, parity guessing) is the odd one out, and no on-chain trail was made with it. The profile is being rewritten to the live rule in blocktrails/spec (PR linked from #5), and the PR here will switch commitScalar to the Core rule, let every TXO carry a commit, take pubkeyBase in verify so nothing is guessed, and pin the rule with the live trail's first three marks as known answers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions