How to use the libp2p-crypto.unmarshalPrivateKey function in libp2p-crypto

To help you get started, we’ve selected a few libp2p-crypto 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 peer-base / peer-pad / src / keys.js View on Github external
exports.from = (_publicKey, _privateKey, callback) => {
  console.log('creating keys from', _publicKey.length, _privateKey && _privateKey.length)
  const publicKey = crypto.unmarshalPublicKey(_publicKey)
  if (!_privateKey) {
    return callback(null, {
      'public': publicKey
    })
  }

  crypto.unmarshalPrivateKey(_privateKey, (err, privateKey) => {
    if (err) { return callback(err) }
    callback(null, {
      'public': publicKey,
      'private': privateKey
    })
  })
}