Solve the report endpoint's proof-of-work#116
Merged
Merged
Conversation
/merchants/report now requires a proof-of-work bound to the exact report (part of the backend's abuse layers, with the corroboration gate, subnet consensus, breaker, and bans). Before reporting, fetch the signed challenge and grind nonces with WebCrypto until the digest clears the server's difficulty — sub-second at the current 14 bits, bounded at ~8x the expected work or 15s. On any failure (old worker, offline, budget exceeded) the report goes out unproofed and the server declines the vote; the local experience — toast, passport, counts — is untouched. The difficulty check lives in the detector for tests; the server can retune bits via the challenge without an extension release.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pairs with knockoff-backend#4 (already deployed — PoW is enforced in prod now). Fetches the signed challenge from
/merchants/challengeand grinds nonces via WebCrypto (sub-second at 14 bits, capped at 15s/8x expected work), payload-bound so solutions can't be replayed across reports. Degrades cleanly: any failure sends the report unproofed, the server declines the vote, local UX unaffected. Difficulty is server-tunable via the challenge response. Verified live on a real seller page: challenge fetched, nonce ground, proof independently re-validated, pioneer toast intact. 219/219 tests, Safari synced. Note: until this ships in a release, v0.7.x installs' votes are declined (~auto-update window).