Derive the swarm ID with PBKDF2 instead of SHA-1

Anyone who sees the swarm IDs could test a GPU's worth of codes against all
of them at once, about 8 % of the codes within a share's 6 minutes. 600,000
iterations of PBKDF2-SHA-256 cost a share ~50 ms and make that negligible.
Old and new clients no longer find each other.

Also note the open decisions for the server at pagequit.net.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SchluffeandClaude Opus 5.5 committed 2026-10-25 12:46:36 +01:00
1 parent b6b6e7c29b
commit 707248f36b
3 files changed
+76 -5

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
import { createHash, randomBytes } from 'node:crypto';
import { createHash, pbkdf2Sync, randomBytes } from 'node:crypto';
import { createSocket, type Socket } from 'node:dgram';
import { createReadStream } from 'node:fs';
import { open as openFile, readFile, writeFile } from 'node:fs/promises';
@@ -968,7 +968,7 @@ async function announceGarbage(code: string) {
ws.send(
JSON.stringify({
action: 'announce',
info_hash: binary(createHash('sha1').update(`hellcon:${code}`).digest()),
info_hash: binary(pbkdf2Sync(code, 'hellcon', 600_000, 20, 'sha256')),
peer_id: binary(randomBytes(20)),
numwant: 1,
uploaded: 0,