I'm looking at nodejs-pool and this is what I extracted from it to verify the hash sent by the miner:
// All the variables are self explanatory
const cnUtil = require("cryptonote-util");
const cryptoNight = require("cryptonight-hashing")['cryptonight'];
let template = new Buffer(blockTemplateBlob,'hex');
let poolNonce = new Buffer(_poolNonce,'hex');
poolNonce.copy(template,reservedOffset);
let shareBuffer = cnUtil.construct_block_blob(template, new Buffer(nonce, 'hex'));
let convertedBlob = cnUtil.convert_blob(shareBuffer);
let hash = cryptoNight(convertedBlob, 13, blockHeightWhenJobWasIssued);
if (hash.toString('hex') != resultHashFromMiner){
console.log("hashes don't match");
return false;
} else {
console.log("hashes match");
}
It always prints hashes don't match
. I've checked every variable is correct. Also I have verified that the algorithm being used on the miner side is CryptonightR, but still can't figure out what's wrong. Can anybody help here?