| … | … | @@ -18,8 +18,15 @@ export function deriveTopicFromKey (serverKey, repoName) { |
| 18 | 18 | ? Buffer.from(serverKey, 'hex') |
| 19 | 19 | : serverKey |
| 20 | 20 | |
| 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([ |
| 22 | 29 | keyBuffer, |
| 23 | 30 | Buffer.from(repoName, 'utf-8') |
| 24 | | ])).subarray(0, 32) |
| 31 | ])) |
| 25 | 32 | } |