Submit a solution
Called from the visitor's browser. Verification is all-or-nothing: there is no endpoint that tells a client whether it is getting warmer.
POST /api/v1/solve
Rate limited to about 10 requests per second per IP. Also answers OPTIONS.
| Parameter | Type | Required | Description |
|---|---|---|---|
challenge_id |
string | yes | the id from /api/v1/challenge, max 64 characters |
pow_nonce |
string | yes | the proof-of-work nonce, max 64 characters |
solution |
JSON object | yes | the puzzle answer; may be sent as a JSON string |
curl -X POST https://privcaptcha.com/api/v1/solve \
-H "Origin: https://example.com" \
-d "challenge_id=8Zq4..." \
-d "pow_nonce=418327" \
-d 'solution={"x":146.5}'
{ "success": true, "token": "Vv7...opaque..." }
The token is single-use and lives for 120 seconds. Put it in your form and verify it server-side.
Solution shapes
| Type | Solution | Solved when |
|---|---|---|
slider |
{"x": <px>} |
the piece's x is within 5–12 px of the notch, depending on difficulty |
rotate |
{"angle": <degrees>} |
your counter-rotation cancels the hidden angle to within 8–20° |
pick |
{"x": <px>, "y": <px>} |
the click falls inside the target shape's hit radius |
powonly |
{} |
the proof of work alone is accepted |
Coordinates are in the image's own pixel space, as given by the challenge hint — 320×200
for slider, 260×260 for rotate, 320×240 for pick. Scale from your rendered size before
submitting.
Proof of work
Find a nonce such that SHA-256 of pow.challenge concatenated with the nonce has at least
pow.bits leading zero bits. Verification costs us one hash; solving costs about
2^bits. That asymmetry is what puts a price on every attempt.
async function solvePow(challenge, bits) {
const enc = new TextEncoder();
for (let nonce = 0; ; nonce++) {
const buf = await crypto.subtle.digest('SHA-256', enc.encode(challenge + nonce));
if (leadingZeroBits(new Uint8Array(buf)) >= bits) return String(nonce);
}
}
function leadingZeroBits(bytes) {
let count = 0;
for (const byte of bytes) {
if (byte === 0) { count += 8; continue; }
return count + Math.clz32(byte) - 24;
}
return count;
}
The nonce is sent as a decimal string. bits scales with the client's risk score — 12 to 20
for a visual challenge, 22 for powonly — and is never above 26. Run it in a Web Worker
while the visitor solves the puzzle, and it costs a human no wall-clock time.
Failure
Attempts are checked in the cheapest order: the proof of work first, then the puzzle answer.
{ "success": false, "error-codes": ["incorrect-solution"] }
Each wrong attempt is counted against the challenge. After three the challenge is destroyed
and the client must request a new one — which, because the failure is also recorded against
the hashed IP, will be harder. challenge-expired covers an expired, already-solved or
never-existing id alike: distinguishing them would confirm to an attacker that an id was
real.
See Error codes.