diff --git a/index.html b/index.html index 704c521..32d600b 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ font-family: Roboto, sans-serif; font-weight: 300; line-height: 26px; font-size: 17px;}*{box-sizing: border-box; --moz-box-sizing: border-box;}
peer-id
0.8.0
peer-id
0.8.0

Introduction

Generate, import, and export PeerIDs, for use with IPFS.

+font-weight: bold;}.hljs-deletion{background: #fdd;}.hljs-addition{background: #dfd;}.hljs-emphasis{font-style: italic;}.hljs-strong{font-weight: bold;}

Introduction

Generate, import, and export PeerIDs, for use with IPFS.

A Peer ID is the SHA-256 multihash of a public key.

The public key is a base64 encoded string of a protobuf containing an RSA DER buffer. This uses a node buffer to pass the base64 encoded public key protobuf to the multihash for ID generation.

@@ -83,11 +83,11 @@ the global namespace.

<script src="https://unpkg.com/peer-id/dist/index.min.js"></script>
 <!-- OR -->
 <script src="https://unpkg.com/peer-id/dist/index.js"></script>
-

PeerId

A Peer ID is the SHA-256 +

PeerId

A Peer ID is the SHA-256 multihash of a public key.

static

PeerId.create

create(opts: Object?, callback: function (Error, PeerId)): undefined

Create a new PeerId by generating a new public/private keypair.

+

static

PeerId.create

create(opts: Object?, callback: function (Error, PeerId)): undefined

Create a new PeerId by generating a new public/private keypair.

Parameters

  1. opts: Object?:  
    Configuration object.
  2. opts.bits: number? (=2048):  
    How many bits to use for the RSA key generation.
  3. callback: function (Error, PeerId):  
    Node.js style callback. @@ -99,46 +99,46 @@ PeerId.create((err, idthrow err } console.log('id', JSON.stringify(id)) -})

PeerId.createFromHexString

createFromHexString(str: string): PeerId

Creates a Peer ID from hex string representing the key's multihash.

+})

PeerId.createFromHexString

createFromHexString(str: string): PeerId

Creates a Peer ID from hex string representing the key's multihash.

Parameters

  1. str: string:  
    Hex encoded id

Returns

PeerId.createFromBytes

createFromBytes(buf: Buffer): PeerId

Creates a Peer ID from a buffer representing the key's multihash.

+

PeerId.createFromBytes

createFromBytes(buf: Buffer): PeerId

Creates a Peer ID from a buffer representing the key's multihash.

Parameters

  1. buf: Buffer:  

Returns

PeerId.createFromB58String

createFromB58String(str: string): PeerId

Creates a Peer ID from a base58 string representing the +

PeerId.createFromB58String

createFromB58String(str: string): PeerId

Creates a Peer ID from a base58 string representing the key's multihash.

Parameters

  1. str: string:  
    base58 encoded id

Returns

PeerId.createFromPubKey

createFromPubKey(key: (string | Buffer), callback: function (Error, PeerId)): undefined

Creates a Peer ID from a buffer containing a public key.

+

PeerId.createFromPubKey

createFromPubKey(key: (string | Buffer), callback: function (Error, PeerId)): undefined

Creates a Peer ID from a buffer containing a public key.

Parameters

  1. key: (string | Buffer):  
  2. callback: function (Error, PeerId):  

Returns

PeerId.createFromPrivKey

createFromPrivKey(key: (string | Buffer), callback: function (Error, PeerId)): undefined

Creates a Peer ID from a buffer containing a private key.

+

PeerId.createFromPrivKey

createFromPrivKey(key: (string | Buffer), callback: function (Error, PeerId)): undefined

Creates a Peer ID from a buffer containing a private key.

Parameters

  1. key: (string | Buffer):  
    The private key, if passed as string base64 encoding is assumed.
  2. callback: function (Error, PeerId):  

Returns

PeerId.createFromJSON

createFromJSON(obj: PeerIdJson, callback: function (Error, PeerId)): undefined

Import a PeerId from a serialized JSON object.

+

PeerId.createFromJSON

createFromJSON(obj: PeerIdJson, callback: function (Error, PeerId)): undefined

Import a PeerId from a serialized JSON object.

Parameters

  1. obj: PeerIdJson:  
  2. callback: function (Error, PeerId):  

Returns

instance

constructor

constructor(id: Buffer, privKey: RSAPrivateKey?, pubKey: RSAPublickKey?)

Parameters

  1. id: Buffer:  
  2. privKey: RSAPrivateKey?:  
  3. pubKey: RSAPublickKey?:  

PeerId.prototype.id

id: Buffer

PeerId.prototype.privKey

privKey: (RSAPrivateKey | undefined)

The private key of this id, if it exists.

-

PeerId.prototype.pubKey

pubKey: (RSAPublicKey | undefined)

The public key of this id, if it exists.

-

PeerId.prototype.marshalPubKey

marshalPubKey(): Buffer

Create the protobuf version of the public key, +

instance

constructor

constructor(id: Buffer, privKey: RSAPrivateKey?, pubKey: RSAPublickKey?)

Parameters

  1. id: Buffer:  
  2. privKey: RSAPrivateKey?:  
  3. pubKey: RSAPublickKey?:  

PeerId.prototype.id

id: Buffer

PeerId.prototype.privKey

privKey: (RSAPrivateKey | undefined)

The private key of this id, if it exists.

+

PeerId.prototype.pubKey

pubKey: (RSAPublicKey | undefined)

The public key of this id, if it exists.

+

PeerId.prototype.marshalPubKey

marshalPubKey(): Buffer

Create the protobuf version of the public key, matching go-ipfs formatting.

Returns

Buffer The marshalled public key -

PeerId.prototype.marshalPrivKey

marshalPrivKey(): Buffer

Create the protobuf version of the private key, +

PeerId.prototype.marshalPrivKey

marshalPrivKey(): Buffer

Create the protobuf version of the private key, matching go-ipfs formatting.

Returns

PeerId.prototype.toPrint

toPrint(): PeerIdJson

Alias for toJSON.

+

PeerId.prototype.toPrint

toPrint(): PeerIdJson

Alias for toJSON.

Returns

PeerId.prototype.toJSON

toJSON(): PeerIdJson

Return the jsonified version of the key, matching the formatting +

PeerId.prototype.toJSON

toJSON(): PeerIdJson

Return the jsonified version of the key, matching the formatting of go-ipfs for its config file.

Returns

PeerId.prototype.toHexString

toHexString(): String

Returns the Peer ID's id as a hex string.

+

PeerId.prototype.toHexString

toHexString(): String

Returns the Peer ID's id as a hex string.

Returns

PeerId.prototype.toBytes

toBytes(): Buffer

Returns the Peer ID's id as a buffer.

+

PeerId.prototype.toBytes

toBytes(): Buffer

Returns the Peer ID's id as a buffer.

Returns

PeerId.prototype.toB58String

toB58String(): String

Returns the Peer ID's id as a base58 string.

+

PeerId.prototype.toB58String

toB58String(): String

Returns the Peer ID's id as a base58 string.

Returns

PeerIdJson

Parameters

  1. id: string:  
    Base58 +

PeerIdJson

Parameters

  1. id: string:  
    Base58 encoded peer id
  2. privKey: string?:  
    The RSA private key in protobuf format, encoded in base64