carlos / movement Public

Clone
git clone https://amadan.net/carlos/movement

Plain git — no account needed to clone.

Download

Download this file

1// The Worker that hosts the solver.
2//
3// Thin on purpose: everything that could disagree with the Go verifier lives
4// in powcore.js, which the browser test imports and runs directly. A worker
5// cannot be imported, so any logic left in here would be untested by the one
6// gate that matters.
7//
8// It runs off the main thread because a few hundred thousand hashes on it
9// freezes a phone for seconds — the page stops scrolling and stops answering
10// taps at exactly the moment somebody is deciding whether to trust us.
11
12import { solve } from "./powcore.js";
13
14self.onmessage = (e) => {
15 const { nonce, email, difficulty } = e.data;
16 const counter = solve(nonce, email, difficulty, (tried) => {
17 self.postMessage({ done: false, tried });
18 });
19 self.postMessage({ done: true, counter });
20};
21