How to use the bs58.decode function in bs58

To help you get started, we’ve selected a few bs58 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 maxogden / emojilock / minilock.js View on Github external
function publicKeyFromId (id) {
  // The last byte is the checksum, slice it off
  return new Uint8Array(Base58.decode(id).slice(0, 32))
}
github kingswisdom / SteemMessenger / view / js / crypto / steem-js / auth / ecc / src / key_private.js View on Github external
static fromWif(_private_wif) {
        var private_wif = new Buffer(base58.decode(_private_wif));
        var version = private_wif.readUInt8(0);
        assert.equal(0x80, version, `Expected version ${0x80}, instead got ${version}`);
        // checksum includes the version
        var private_key = private_wif.slice(0, -4);
        var checksum = private_wif.slice(-4);
        var new_checksum = hash.sha256(private_key);
        new_checksum = hash.sha256(new_checksum);
        new_checksum = new_checksum.slice(0, 4);
        if (checksum.toString() !== new_checksum.toString())
            throw new Error('Invalid WIF key (checksum miss-match)')

        private_key = private_key.slice(1);
        return PrivateKey.fromBuffer(private_key);
    }
github maxogden / emojilock / minilock.js View on Github external
function validateId (id) {
  var idRegex = /^[1-9ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{40,55}$/
  if (!idRegex.test(id)) return false

  var bytes = Base58.decode(id)
  if (bytes.length !== 33) return false

  var hash = new BLAKE2s(1)
  hash.update(bytes.slice(0, 32))

  return hash.digest()[0] === bytes[32]
}
github ipfs-shipyard / ipfs-companion / lib / npm / is-ipfs.js View on Github external
function isMultihash(hash) {
  var formatted = convertToString(hash);
  try {
    var buffer = new Buffer(base58.decode(formatted));
    multihash.decode(buffer);
    return true;
  } catch (e) {
    return false;
  }
}
github ipfs / is-ipfs / src / index.js View on Github external
function isMultihash (hash) {
  const formatted = convertToString(hash)
  try {
    const buffer = Buffer.from(base58.decode(formatted))
    multihash.decode(buffer)
    return true
  } catch (e) {
    return false
  }
}
github pldespaigne / content-hash / dist / index.js View on Github external
exports.fromB58String = function fromB58String (hash) {
  let encoded = hash
  if (Buffer.isBuffer(hash)) {
    encoded = hash.toString()
  }

  return Buffer.from(bs58.decode(encoded))
}
github AudiusProject / audius-protocol / libs / src / utils.js View on Github external
static decodeMultihash (multihash) {
    const base16Multihash = bs58.decode(multihash)
    return {
      digest: `0x${base16Multihash.slice(2).toString('hex')}`,
      hashFn: parseInt(base16Multihash[0]),
      size: parseInt(base16Multihash[1])
    }
  }
github bonustrack / steemconnect / src / helpers / auth.js View on Github external
function decodePrivate(encodedKey) {
  const buffer = bs58.decode(encodedKey);

  if (buffer[0] !== 128) throw new Error('private key network id mismatch');

  return buffer.slice(0, -4);
}

bs58

Base 58 encoding / decoding

MIT
Latest version published 4 months ago

Package Health Score

79 / 100
Full package analysis

Popular bs58 functions