Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.fakeBlock = (height) => {
const prev = hash256.digest(fromU32LE((height - 1) >>> 0));
const hash = hash256.digest(fromU32LE(height >>> 0));
const root = hash256.digest(fromU32LE((height | 0x80000000) >>> 0));
return {
hash: hash,
prevBlock: prev,
merkleRoot: root,
time: 500000000 + (height * (10 * 60)),
bits: 0,
nonce: 0,
height: height
};
};
hash(sid, ch, key) {
const data = Buffer.allocUnsafe(66);
sid.copy(data, 0);
data[32] = ch.charCodeAt(0);
key.copy(data, 33);
return hash256.digest(data);
}
GCSFilter.prototype.hash = function hash(enc) {
const h = hash256.digest(this.data);
return enc === 'hex' ? h.toString('hex') : h;
};
rekey(sid, key, req, res) {
const seed = Buffer.allocUnsafe(130);
sid.copy(seed, 0);
key.copy(seed, 32);
req.copy(seed, 64);
res.copy(seed, 97);
return hash256.digest(seed);
}
getToken(nonce) {
if (!this.master.key)
throw new Error('Cannot derive token.');
const key = this.master.key.derive(44, true);
const bw = bio.write(36);
bw.writeBytes(key.privateKey);
bw.writeU32(nonce);
return hash256.digest(bw.render());
}