import assert from 'node:assert/strict'; const started = process.cpuUsage(); const primes = [2, 3, 5, 7, 11, 13, 17, 19]; const period = primes.reduce((a, p) => a * p, 1); const dead = new Uint8Array(period); for (const p of primes) { for (let n = 0; n < period; n += p) dead[n] = 1; for (let n = (p - 2) % p; n < period; n += p) dead[n] = 1; } const slots = []; for (let n = 0; n < period; n++) if (!dead[n]) slots.push(n); assert.equal(slots.length, 378675); const rank = new Map(slots.map((n, i) => [n, i])); const modulus = 13082761331670030n; const gap = 618n; const witnesses = [830330079152051n, 1403312099425139n]; const chunks = [[0, 10], [10, 20], [20, 30], [30, 40], [40, 47]]; function locate(start) { const residue = Number(start % BigInt(period)); const index = rank.get(residue); assert.notEqual(index, undefined); const tile = Math.floor(index / (128 * 64)); const chunk = chunks.find(([lo, hi]) => lo <= tile && tile < hi); assert.notEqual(chunk, undefined); return { start: String(start), residue, index, tile, chunk }; } const positions = witnesses.flatMap(s => [s, (modulus - s - gap - 2n) % modulus]); const rows = positions.map(s => { const end = locate((s + gap) % modulus); const partner = locate((modulus - s - gap - 2n) % modulus); // The last slot, period - 1, is a fixed point of slot reflection. assert.equal(partner.index, (slots.length - 2 - end.index + slots.length) % slots.length); return { ...locate(s), endIndex: end.index, partner }; }); console.log(JSON.stringify({ scope: 'New shard ownership map of four published witnesses; no full-period enumeration', basePeriod: period, baseSlots: slots.length, tileWidthSlots: 128 * 64, rows, }, null, 2)); const used = process.cpuUsage(started); console.error(JSON.stringify({ cpu_seconds: (used.user + used.system) / 1e6 }));