OverviewFilesCommitsIssuesDocsReleasesPeers

git-remote-punch commits / f6c817d

derive-topic: switch to crypto.data to match hyper-sync
crypto.hash collides with daemon-level identity-swarm topics that use the same hash function and similar inputs. crypto.data has a domain-separation prefix that keeps per-repo topics in their own namespace. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f6c817dea640be225c0001d0134ed71358b01df2
by fleeky <noreply@anthropic.com> · 2026-04-21T02:14:56.000Z

Changed files (1) +9 -2

lib/derive-topic.js +9 -2
……@@ -18,8 +18,15 @@ export function deriveTopicFromKey (serverKey, repoName) {
1818 ? Buffer.from(serverKey, 'hex')
1919 : serverKey
2020
21 return crypto.hash(Buffer.concat([
21 // crypto.data (NOT crypto.hash) — has a domain-separation prefix so
22 // per-repo topics don't collide with crypto.hash-based topics used
23 // elsewhere (e.g. pear-git-v3's daemon-level identity swarm topic
24 // hashes (identity.publicKey + 'pear-git-v3') with crypto.hash —
25 // any repo named 'pear-git-v3' on the same server would collide).
26 // MUST match hyper-sync/lib/topics.js — both must produce identical
27 // topics for the same (serverKey, repoName) input.
28 return crypto.data(Buffer.concat([
2229 keyBuffer,
2330 Buffer.from(repoName, 'utf-8')
24 ])).subarray(0, 32)
31 ]))
2532}