PeerIdJson
Parameters
Name | Description |
---|---|
id: string | Base58
+font-weight: bold;}.hljs-deletion{background: #fdd;}.hljs-addition{background: #dfd;}.hljs-emphasis{font-style: italic;}.hljs-strong{font-weight: bold;}PeerIdJsonParametersName Description id: string Base58
encoded peer id
- |
PeerId
A Peer ID is the SHA-256 multihash of a public key.
static
PeerId.create
create(opts: Object?, callback: function (Error, PeerId))
Create a new PeerId
by generating a new public/private keypair.
Parameters
Name | Description |
---|
Example
const PeerId = require('peer-id')
+
Parameters
Example
const PeerId = require('peer-id')
PeerId.create((err, id) => {
if (err) {
@@ -72,23 +73,23 @@ PeerId.create((err, idconsole.log('id', JSON.stringify(id))
})
PeerId.createFromHexString
createFromHexString(str: string): PeerId
Creates a Peer ID from hex string representing the key's multihash.
-Parameters
Name | Description |
---|---|
str: string | Hex encoded id - |
Returns
PeerId.createFromPubKey
createFromPubKey(key: (string | Buffer), callback: function (Error, PeerId))
Creates a Peer ID from a buffer containing a public key.
-PeerId.createFromPrivKey
createFromPrivKey(key: (string | Buffer), callback: function (Error, PeerId))
Creates a Peer ID from a buffer containing a private key.
-PeerId.createFromJSON
createFromJSON(obj: PeerIdJson, callback: function (Error, PeerId))
Import a PeerId
from a serialized JSON object.
Parameters
Name | Description |
---|---|
obj: PeerIdJson |
instance
constructor
constructor(id: Buffer, privKey: RSAPrivateKey?, pubKey: RSAPublickKey?)
Parameters
Name | Description |
---|---|
id: Buffer | |
privKey: RSAPrivateKey? | |
pubKey: RSAPublickKey? |
PeerId.prototype.id
id: Buffer
PeerId.prototype.privKey
privKey: (RSAPrivateKey | undefined)
The private key of this id, if it exists.
+