How to use the libp2p-crypto.unmarshalPublicKey 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 libp2p / js-iprs-record / test / validator.spec.js View on Github external
it('record with key from from go', (done) => {
      const pubKey = crypto.unmarshalPublicKey(fixture.publicKey)

      pubKey.hash((err, hash) => {
        expect(err).to.not.exist
        const k = `/pk/${mh.toB58String(hash)}`

        validator.validators.pk.func(k, pubKey.bytes, done)
      })
    })
  })
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
    })
  })
}