UNPKG

@olympus-protocol/bip32-bls

Version:

A BIP32 compatible library using BLS12-381

37 lines (36 loc) 984 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.doubleSha256 = exports.hmacSHA512 = exports.hash160 = void 0; const createHash = require("create-hash"); const createHmac = require("create-hmac"); function hash160(buffer) { const sha256Hash = createHash('sha256') .update(buffer) .digest(); try { return createHash('rmd160') .update(sha256Hash) .digest(); } catch (err) { return createHash('ripemd160') .update(sha256Hash) .digest(); } } exports.hash160 = hash160; function hmacSHA512(key, data) { return createHmac('sha512', key) .update(data) .digest(); } exports.hmacSHA512 = hmacSHA512; function doubleSha256(buffer) { const sha256Hash = createHash('sha256') .update(buffer) .digest(); return createHash('sha256') .update(sha256Hash) .digest(); } exports.doubleSha256 = doubleSha256;