diff --git a/html/index.html b/html/index.html index 294cc9a..fd70009 100644 --- a/html/index.html +++ b/html/index.html @@ -240,16 +240,6 @@ const challengeSig = "{{ tl:text challengeSignature }}"; const challengeFingerprint = "{{ tl:text challengeFingerprint }}"; - function valid(sha) { - const MIN_ZEROES = difficulty; - for (let i = 0; i < MIN_ZEROES; i += 1) { - if (sha[i] != '0') - return false; - } - - return true; - } - function itShort(it) { if (it > 1000000) return parseInt(it / 100000) / 10 + "M"; @@ -297,18 +287,25 @@ }); } - const encoder = new TextEncoder(); - while (true) { - const data = encoder.encode(challengeNonce + it); - const buffer = await window.crypto.subtle.digest("SHA-256", data); - const hashArray = Array.from(new Uint8Array(buffer)); - const sha = hashArray - .map((item) => item.toString(16).padStart(2, "0")) - .join(""); + const workBuffer = new Uint8Array(challengeNonce.length + 10); + for (let i = 0; i < challengeNonce.length; i++) + workBuffer[i] = challengeNonce.charCodeAt(i); - if (valid(sha)) { + while (true) { + const digits = it === 0 ? 1 : (~~Math.floor(Math.log10(it)) + 1); + for (let i = digits - 1; i >= 0; i--) + workBuffer[challengeNonce.length + (digits - 1 - i)] = 48 + ~~Math.floor((it / Math.pow(10, i)) % 10); + + const hashedData = new Uint8Array(await window.crypto.subtle.digest('sha-256', workBuffer.slice(0, challengeNonce.length + digits))); + let zeroPos = 0; + for (; zeroPos < difficulty; zeroPos++) { + if ((zeroPos % 2 == 0 ? (hashedData[~~(zeroPos / 2)] >> 4) : (hashedData[~~(zeroPos / 2)] & 0x0F)) != 0) + break; + } + + if (zeroPos >= difficulty) { success(it); - console.log("Success: it " + it + ": " + sha); + console.log("Success: it " + it + ": " + Array.from(hashedData).map((item) => item.toString(16).padStart(2, "0")).join("")); break; } diff --git a/html/index.min.html b/html/index.min.html index dcb6f1f..1b232ef 100644 --- a/html/index.min.html +++ b/html/index.min.html @@ -1,2 +1,2 @@ STOP! - Checkpoint

🛑

STOP!


Verifying that you are not a bot. This might take a short moment.

You do not need to do anything.

Why am I seeing this?


This website protects itself from AI bots and scrapers by asking you to complete a cryptographic challenge before allowing you entry.

Difficulty {{ tl:text challengeDifficulty }}, elapsed 0ms, 0h, 0h/s

Powered by checkpoint v{{ tl:text checkpointVersion }}
- \ No newline at end of file + \ No newline at end of file