How to use the bcrypto/lib/hash256.digest function in bcrypto

To help you get started, we’ve selected a few bcrypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bcoin-org / bmultisig / test / util / wallet.js View on Github external
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
  };
};
github handshake-org / hsd / lib / net / bip150.js View on Github external
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);
  }
github handshake-org / hsd / lib / utils / gcs.js View on Github external
GCSFilter.prototype.hash = function hash(enc) {
  const h = hash256.digest(this.data);
  return enc === 'hex' ? h.toString('hex') : h;
};
github handshake-org / hsd / lib / net / bip150.js View on Github external
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);
  }
github handshake-org / hsd / lib / wallet / wallet.js View on Github external
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());
  }