{"version":3,"sources":["jsdelivr-header.js","/npm/ipfs-peer-id@0.3.2/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACFA,IAAI,aAAe,QAAQ,gBACvB,OAAS,QAAQ,QACjB,OAAS,QAAQ,UAIrB,SAAS,GAAI,EAAI,EAAS,GACxB,IAAI,EAAO,KAEX,KAAM,aAAgB,IACpB,MAAM,IAAI,MAAM,8BAGlB,EAAK,QAAU,EACf,EAAK,OAAS,EACd,EAAK,GAAK,EAIV,EAAK,QAAU,WACb,MAAO,CACL,GAAI,EAAG,cACP,QAAS,EAAQ,SAAS,OAC1B,OAAQ,EAAO,SAAS,OAE5B,EAIA,EAAK,YAAc,WACjB,OAAO,EAAK,GAAG,SAAS,MAC1B,EAEA,EAAK,QAAU,WACb,OAAO,EAAK,EACd,EAEA,EAAK,YAAc,WACjB,OAAO,OAAO,OAAO,EAAK,GAC5B,CAEF,CArCA,QAAU,OAAO,QAAU,GAyC3B,QAAQ,OAAS,WACf,IAAI,EAAO,OAAO,WAAW,aAK7B,OAJA,EAAK,eAIE,IAAI,GAFA,aAAa,EAAK,eAAgB,YAEzB,EAAK,gBAAiB,EAAK,eACjD,EAEA,QAAQ,oBAAsB,SAAU,GACtC,OAAO,IAAI,GAAG,IAAI,OAAO,GAAM,MACjC,EAEA,QAAQ,gBAAkB,SAAU,GAClC,OAAO,IAAI,GAAG,EAChB,EAEA,QAAQ,oBAAsB,SAAU,GACtC,OAAO,IAAI,GAAG,IAAI,OAAO,OAAO,OAAO,IACzC,EAEA,QAAQ,iBAAmB,SAAU,GAEnC,OAAO,IAAI,GADA,aAAa,EAAQ,YACZ,KAAM,EAC5B,EAEA,QAAQ,kBAAoB,WAE5B","file":"/npm/ipfs-peer-id@0.3.2/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ipfs-peer-id@0.3.2/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n * Id is an object representation of a peer Id. a peer Id is a multihash\n */\n\nvar multihashing = require('multihashing')\nvar base58 = require('bs58')\nvar crypto = require('crypto')\n\nexports = module.exports = Id\n\nfunction Id (id, privKey, pubKey) {\n  var self = this\n\n  if (!(self instanceof Id)) {\n    throw new Error('Id must be called with new')\n  }\n\n  self.privKey = privKey\n  self.pubKey = pubKey\n  self.id = id // multihash - sha256 - buffer\n\n  // pretty print\n\n  self.toPrint = function () {\n    return {\n      id: id.toHexString(),\n      privKey: privKey.toString('hex'),\n      pubKey: pubKey.toString('hex')\n    }\n  }\n\n  // encode/decode functions\n\n  self.toHexString = function () {\n    return self.id.toString('hex')\n  }\n\n  self.toBytes = function () {\n    return self.id\n  }\n\n  self.toB58String = function () {\n    return base58.encode(self.id)\n  }\n\n}\n\n// generation\n\nexports.create = function () {\n  var ecdh = crypto.createECDH('secp256k1')\n  ecdh.generateKeys()\n\n  var mhId = multihashing(ecdh.getPublicKey(), 'sha2-256')\n\n  return new Id(mhId, ecdh.getPrivateKey(), ecdh.getPublicKey())\n}\n\nexports.createFromHexString = function (str) {\n  return new Id(new Buffer(str), 'hex')\n}\n\nexports.createFromBytes = function (buf) {\n  return new Id(buf)\n}\n\nexports.createFromB58String = function (str) {\n  return new Id(new Buffer(base58.decode(str)))\n}\n\nexports.createFromPubKey = function (pubKey) {\n  var mhId = multihashing(pubKey, 'sha2-256')\n  return new Id(mhId, null, pubKey)\n}\n\nexports.createFromPrivKey = function () {\n  // TODO(daviddias) derive PubKey from priv\n}\n"]}