mirror of
https://gitgud.io/fatchan/haproxy-protection.git
synced 2025-05-09 02:05:37 +00:00
- Fix some docker-compose issues close #14
- Move to new scheme with some hashing, sigs, and a random user key. close #13 - Change to sha256 rather than sha1 (temporary, but i guess its slightly more secure which is nice for now) ref #10 - Change POW output checked value - Add lib for randombytes, udpate lua sha lib - Remove outdated difficulty checks in frontend (was hardcoded 0 anyway) and since algo change is coming soon, there is no need to keep it
This commit is contained in:
@ -5,19 +5,14 @@ async function hash(data, method) {
|
||||
}
|
||||
|
||||
onmessage = async function(e) {
|
||||
const [challenge, difficulty, id, threads] = e.data;
|
||||
console.log('Worker thread', id,'got challenge', challenge, 'with difficulty', difficulty);
|
||||
const [challenge, id, threads] = e.data;
|
||||
console.log('Worker thread', id,'got challenge', challenge);
|
||||
let i = id;
|
||||
let challengeIndex = parseInt(challenge[0], 16);
|
||||
while(true) {
|
||||
let result = await hash(challenge+i, 'sha-1');
|
||||
let middle = true;
|
||||
for(let imiddle = 1; imiddle <= difficulty; imiddle++) {
|
||||
middle = (middle && (result[challengeIndex+imiddle] === 0x00));
|
||||
}
|
||||
if(result[challengeIndex] === 0xb0
|
||||
&& middle === true
|
||||
&& result[challengeIndex+difficulty+1] === 0x0b){
|
||||
let result = await hash(challenge+i, 'sha-256');
|
||||
if(result[challengeIndex] === 0x00
|
||||
&& result[challengeIndex+1] === 0x41){
|
||||
console.log('Worker thread found solution:', i);
|
||||
postMessage([id, i]);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user