How to use the bcrypto/lib/blake2b256.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 handshake-org / goosig / etc / generate.js View on Github external
function encode(name, data, desc) {
  assert(typeof name === 'string');
  assert(Buffer.isBuffer(data));
  assert(!desc || typeof desc === 'string');

  const blake2b = BLAKE2b.digest(data);
  const sha256 = SHA256.digest(data);
  const sha3 = SHA3.digest(data);
  const hex = data.toString('hex');

  // Digit Sum (used for RSA-2048 -- see challengenumbers.txt)
  const num = BN.fromBuffer(data);
  const base10 = num.toString(10);

  let sum = 0;
  for (let i = 0; i < base10.length; i++)
    sum += Number(base10[i]);

  // Checksum (used for RSA-617 -- see rsa-fact.txt)
  const checksum = num.modrn(991889);

  let out = '';
github handshake-org / hsd / lib / primitives / abstractblock.js View on Github external
hash() {
    if (this.mutable)
      return BLAKE2b256.digest(this.toHead());

    if (!this._hash)
      this._hash = BLAKE2b256.digest(this.toHead());

    return this._hash;
  }
github handshake-org / hsd / lib / primitives / abstractblock.js View on Github external
verifyPOW() {
    const data = this.toPrehead();
    const key = KMAC256.digest(data, this.nonce);
    const hash = BLAKE2b256.digest(data, key);

    return consensus.verifyPOW(hash, this.bits);
  }
github handshake-org / hsd / lib / primitives / abstractblock.js View on Github external
hash() {
    if (this.mutable)
      return BLAKE2b256.digest(this.toHead());

    if (!this._hash)
      this._hash = BLAKE2b256.digest(this.toHead());

    return this._hash;
  }
github handshake-org / hsd / lib / mining / template.js View on Github external
powHash() {
    const data = this.hdr.slice(0, -consensus.NONCE_SIZE);
    const key = KMAC256.digest(data, this.nonce);

    return BLAKE2b256.digest(data, key);
  }