From 4d5bb2cffffbeb89f81ef91da6e09496e0b7610a Mon Sep 17 00:00:00 2001 From: Nate Foss Date: Sun, 29 Sep 2019 13:54:45 -0400 Subject: [PATCH] chore: include `marshalPubKey` and example (#104) --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 76caa0b..2520402 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,20 @@ Returns an `obj` of the form Returns a protocol-buffers encoded version of the id, public key and, if `excludePrivateKey` is not set, the private key. +### `marshalPubKey()` + +Returns a protobuf of just the public key, compatible with `libp2p-crypto` (unlike `marshal` above). + +For example: +```js +const crypto = require('libp2p-crypto') + +PeerId.create({ bits: 256, keyType: 'ed25519' }).then( pid => { + let pk = crypto.keys.unmarshalPublicKey(pid.marshalPubKey()) + // your code here +} +``` + ### `toPrint()` Returns the Peer ID as a printable string without the `Qm` prefix.