mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-04-25 16:12:41 +00:00
141 lines
58 KiB
HTML
141 lines
58 KiB
HTML
<!doctype html>
|
|
<html><head><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>peer-id - Documentation</title><link href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,500|Roboto:300,500,700" rel="stylesheet"/><style>body{margin: 0;
|
|
padding: 0;
|
|
color: #000;
|
|
font-family: Roboto, sans-serif;
|
|
font-weight: 300;
|
|
line-height: 26px;
|
|
font-size: 17px;}*{box-sizing: border-box;
|
|
-moz-box-sizing: border-box;}</style></head><body><main id="app"><div data-radium="true"><div style="box-shadow:0px 2px 3px 0px rgba(0, 0, 0, 0.25);height:65px;width:100%;min-width:100%;margin-left:0px;margin-right:0px;position:fixed;z-index:99;background:#FFFFFF;padding-top:10px;padding-bottom:10px;padding-left:20px;padding-right:20px;" data-radium="true"><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:50.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-21ab0466 rmq-a01b93a4 rmq-d226cb7e rmq-5cc71c8" data-radium="true"><div style="text-transform:uppercase;font-family:Roboto, sans-serif;" data-radium="true">peer-id</div><div style="font-family:Roboto Mono, Menlo, Monaco, Courier, monospace;font-weight:300;" data-radium="true">0.8.0</div></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:right !important;width:25.00000%;text-align:right;font-size:36px;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-77267d84 rmq-5c0c1446 rmq-4605701c rmq-34ee8e6a" data-radium="true"><a href="https://github.com/libp2p/js-peer-id"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m20 0c-11 0-20 9-20 20 0 8.8 5.7 16.3 13.7 19 1 0.2 1.3-0.5 1.3-1 0-0.5 0-2 0-3.7-5.5 1.2-6.7-2.4-6.7-2.4-0.9-2.3-2.2-2.9-2.2-2.9-1.9-1.2 0.1-1.2 0.1-1.2 2 0.1 3.1 2.1 3.1 2.1 1.7 3 4.6 2.1 5.8 1.6 0.2-1.3 0.7-2.2 1.3-2.7-4.5-0.5-9.2-2.2-9.2-9.8 0-2.2 0.8-4 2.1-5.4-0.2-0.5-0.9-2.6 0.2-5.3 0 0 1.7-0.5 5.5 2 1.6-0.4 3.3-0.6 5-0.6 1.7 0 3.4 0.2 5 0.7 3.8-2.6 5.5-2.1 5.5-2.1 1.1 2.8 0.4 4.8 0.2 5.3 1.3 1.4 2.1 3.2 2.1 5.4 0 7.6-4.7 9.3-9.2 9.8 0.7 0.6 1.4 1.9 1.4 3.7 0 2.7 0 4.9 0 5.5 0 0.6 0.3 1.2 1.3 1 8-2.7 13.7-10.2 13.7-19 0-11-9-20-20-20z"></path></g></svg></a></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;padding-top:104px;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:fixed;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;height:80%;max-width:300px;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-5c4c5b38 rmq-5c0c1446 rmq-4605701c rmq-34ee8e6a rmq-35757987 rmq-f09e82ae" data-radium="true"><div style="border-radius:4px;border:1px solid #e6e9ed;padding-top:0;padding-bottom:0;margin-top:52px;font-family:Roboto, sans-serif;font-weight:500;font-size:15px;line-height:18px;height:70vh;overflow-x:auto;" data-radium="true"><ul style="list-style:none;margin-top:0;margin-bottom:0;padding-left:0;" data-radium="true"><div data-radium="true"><li style="padding-left:20px;padding-right:20px;padding-top:13px;padding-bottom:13px;border-bottom:1px solid #e6e9ed;" data-radium="true"><a style="color:#000;" href="#PeerIdJson" data-radium="true">PeerIdJson</a></li></div><div data-radium="true"><li style="padding-left:20px;padding-right:20px;padding-top:13px;padding-bottom:13px;border-bottom:1px solid #e6e9ed;" data-radium="true"><a style="color:#000;" href="#PeerId" data-radium="true">PeerId</a></li><li style="padding-left:20px;padding-right:20px;padding-top:13px;padding-bottom:13px;border-bottom:none;" data-radium="true"><div style="padding-top:0;" data-radium="true"><span style="text-transform:uppercase;font-size:13px;line-height:18px;color:#666;" data-radium="true">Static</span><ul style="list-style:none;padding-left:0;" data-radium="true"><li data-radium="true"><a href="#PeerId.create" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">create</a></li><li data-radium="true"><a href="#PeerId.createFromHexString" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">createFromHexString</a></li><li data-radium="true"><a href="#PeerId.createFromBytes" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">createFromBytes</a></li><li data-radium="true"><a href="#PeerId.createFromB58String" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">createFromB58String</a></li><li data-radium="true"><a href="#PeerId.createFromPubKey" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">createFromPubKey</a></li><li data-radium="true"><a href="#PeerId.createFromPrivKey" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">createFromPrivKey</a></li><li data-radium="true"><a href="#PeerId.createFromJSON" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">createFromJSON</a></li></ul></div><div style="padding-top:13px;" data-radium="true"><span style="text-transform:uppercase;font-size:13px;line-height:18px;color:#666;" data-radium="true">Instance</span><ul style="list-style:none;padding-left:0;" data-radium="true"><li data-radium="true"><a href="#PeerId#constructor" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">constructor</a></li><li data-radium="true"><a href="#PeerId#id" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">id</a></li><li data-radium="true"><a href="#PeerId#privKey" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">privKey</a></li><li data-radium="true"><a href="#PeerId#pubKey" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">pubKey</a></li><li data-radium="true"><a href="#PeerId#marshalPubKey" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">marshalPubKey</a></li><li data-radium="true"><a href="#PeerId#marshalPrivKey" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">marshalPrivKey</a></li><li data-radium="true"><a href="#PeerId#toPrint" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">toPrint</a></li><li data-radium="true"><a href="#PeerId#toJSON" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">toJSON</a></li><li data-radium="true"><a href="#PeerId#toHexString" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">toHexString</a></li><li data-radium="true"><a href="#PeerId#toBytes" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">toBytes</a></li><li data-radium="true"><a href="#PeerId#toB58String" style="font-family:Roboto, sans-serif;font-weight:300;font-size:13px;line-height:16px;text-decoration:none;color:#555;" data-radium="true">toB58String</a></li></ul></div></li></div></ul></div></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-89bb2272 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-4d29a8df rmq-ea7683a5 rmq-ad95cc33" data-radium="true"><div class="content" data-radium="true"><style>h1, h2, h3, h4, h5, h6{font-family: Roboto, sans-serif;
|
|
font-weight: 300;}h1{font-size: 48px;
|
|
line-height: 72px;}h2{font-size: 24px;
|
|
line-height: 36px;}h3{font-size: 19px;
|
|
line-height: 29px;
|
|
font-weight: 400;}h4{font-size: 17px;
|
|
line-height: 22px;
|
|
font-weight: 400;}a{text-decoration: none;
|
|
color: #00AAFF;
|
|
:hover: [object Object];}a.anchor:before{content: "";
|
|
display: block;
|
|
height: 100px;
|
|
margin: -80px 0 0;}.content blockquote{padding-left: 20px;
|
|
margin: 0;
|
|
border-left: 4px solid #eee;}.content ul, content li{list-style: none;}.content ul li:before{color: #CCC;
|
|
float: left;
|
|
margin-left: -20px;
|
|
margin-top: 1px;
|
|
content: "•";}pre.hljs, pre > code{font-family: Roboto Mono, Menlo, Monaco, Courier, monospace;
|
|
display: block;
|
|
padding: 12px 15px 12px 15px;
|
|
border-radius: 4px;
|
|
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
|
margin-bottom: 30px;
|
|
position: relative;
|
|
overflow-x: auto;
|
|
font-size: 13px;
|
|
color: #666;
|
|
white-space: pre;}code{font-family: Roboto Mono, Menlo, Monaco, Courier, monospace;
|
|
display: inline;
|
|
font-size: 13px;
|
|
font-weight: 400;
|
|
margin: 0 2px;
|
|
padding: 1px 6px;
|
|
box-shadow: 0 0 0 1px #DDD;
|
|
white-space: nowrap;
|
|
border-radius: 4px;}.hljs{display: block;
|
|
overflow-x: auto;}.hljs-comment, .hljs-quote{color: #998;
|
|
font-style: italic;}.hljs-keyword, .hljs-selector-tag, .hljs-subst{color: #333;
|
|
font-weight: bold;}.hljs-number, .hljs-literal, .hljs-variable, .hljs-template-variable, .hljs-tag .hljs-attr{color: #008080;}.hljs-string, .hljs-doctag{color: #d14;}.hljs-title, .hljs-section, .hljs-selector-id{color: #900;
|
|
font-weight: bold;}.hljs-subst{font-weight: normal;}.hljs-type, .hljs-class .hljs-title{color: #458;
|
|
font-weight: bold;}.hljs-tag, .hljs-name, .hljs-attribute{color: #000080;
|
|
font-weight: normal;}.hljs-regexp, .hljs-link{color: #009926;}.hljs-symbol, .hljs-bullet{color: #990073;}.hljs-built_in, .hljs-builtin-name{color: #0086b3;}.hljs-meta{color: #999;
|
|
font-weight: bold;}.hljs-deletion{background: #fdd;}.hljs-addition{background: #dfd;}.hljs-emphasis{font-style: italic;}.hljs-strong{font-weight: bold;}</style><div style="margin-bottom:104px;" data-radium="true"><h1 data-radium="true"><a class="anchor" name="PeerIdJson"></a>PeerIdJson<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L24-L141" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h1><div></div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>id: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"><code>Base58</code>
|
|
encoded peer id
|
|
</div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>privKey: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true">The RSA private key in protobuf format, encoded in
|
|
<code>base64</code>
|
|
.
|
|
</div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>pubKey: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true">The RSA public key in protobuf format, encoded in
|
|
<code>base64</code>
|
|
.
|
|
</div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div></div><div style="margin-bottom:104px;" data-radium="true"><h1 data-radium="true"><a class="anchor" name="PeerId"></a>PeerId<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L24-L141" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h1><div><p>A Peer ID is the SHA-256
|
|
<a href="https://github.com/multiformats/multihash">multihash</a> of a
|
|
public key.</p>
|
|
</div><div style="display:inline;" data-radium="true"><h4>See</h4><ul data-radium="true"><li><div><p><a href="htttps://github.com/libp2p/js-libp2p-crypto">libp2p-crypto</a></p>
|
|
</div></li></ul></div><div data-radium="true"><h2 style="text-transform:uppercase;" data-radium="true">static</h2><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId.create"></a>PeerId.create<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L161-L181" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>create(opts: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?, callback: function (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, <a href="#peerid">PeerId</a>))</code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Create a new <code>PeerId</code> by generating a new public/private keypair.</p>
|
|
</div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>opts: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>?</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true">Configuration object.
|
|
</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>opts.bits: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>? (=2048)</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true">How many bits to use for the RSA key generation.
|
|
</div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>callback: function (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, <a href="#peerid">PeerId</a>)</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true">Node.js style callback.
|
|
</div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div data-radium="true"><h4>Example</h4><pre><code><span class="hljs-keyword">const</span> PeerId = <span class="hljs-built_in">require</span>(<span class="hljs-string">'peer-id'</span>)
|
|
|
|
PeerId.create(<span class="hljs-function">(<span class="hljs-params">err, id</span>) =></span> {
|
|
<span class="hljs-keyword">if</span> (err) {
|
|
<span class="hljs-keyword">throw</span> err
|
|
}
|
|
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'id'</span>, <span class="hljs-built_in">JSON</span>.stringify(id))
|
|
})</code></pre></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId.createFromHexString"></a>PeerId.createFromHexString<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L189-L191" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>createFromHexString(str: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#peerid">PeerId</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Creates a Peer ID from hex string representing the key's multihash.</p>
|
|
</div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>str: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true">Hex encoded id
|
|
</div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="#peerid">PeerId</a></code><span>
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId.createFromBytes"></a>PeerId.createFromBytes<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L199-L201" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>createFromBytes(buf: <a href="https://nodejs.org/api/buffer.html">Buffer</a>): <a href="#peerid">PeerId</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Creates a Peer ID from a buffer representing the key's multihash.</p>
|
|
</div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>buf: <a href="https://nodejs.org/api/buffer.html">Buffer</a></code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="#peerid">PeerId</a></code><span>
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId.createFromB58String"></a>PeerId.createFromB58String<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L210-L212" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>createFromB58String(str: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="#peerid">PeerId</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Creates a Peer ID from a <code>base58</code> string representing the
|
|
key's multihash.</p>
|
|
</div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>str: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"><code>base58</code>
|
|
encoded id
|
|
</div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="#peerid">PeerId</a></code><span>
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId.createFromPubKey"></a>PeerId.createFromPubKey<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L220-L238" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>createFromPubKey(key: (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>), callback: function (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, <a href="#peerid">PeerId</a>))</code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Creates a Peer ID from a buffer containing a public key.</p>
|
|
</div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>key: (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>callback: function (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, <a href="#peerid">PeerId</a>)</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId.createFromPrivKey"></a>PeerId.createFromPrivKey<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L247-L269" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>createFromPrivKey(key: (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>), callback: function (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, <a href="#peerid">PeerId</a>))</code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Creates a Peer ID from a buffer containing a private key.</p>
|
|
</div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>key: (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true">The private key, if passed as
|
|
string
|
|
<code>base64</code>
|
|
encoding is assumed.
|
|
</div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>callback: function (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, <a href="#peerid">PeerId</a>)</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId.createFromJSON"></a>PeerId.createFromJSON<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L277-L320" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>createFromJSON(obj: <a href="#peeridjson">PeerIdJson</a>, callback: function (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, <a href="#peerid">PeerId</a>))</code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Import a <code>PeerId</code> from a serialized JSON object.</p>
|
|
</div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>obj: <a href="#peeridjson">PeerIdJson</a></code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>callback: function (<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, <a href="#peerid">PeerId</a>)</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div></div></div><div data-radium="true"><h2 style="text-transform:uppercase;" data-radium="true">instance</h2><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#constructor"></a>constructor<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L30-L43" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>constructor(id: <a href="https://nodejs.org/api/buffer.html">Buffer</a>, privKey: RSAPrivateKey?, pubKey: RSAPublickKey?)</code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"></div><div data-radium="true"><h4>Parameters</h4><div style="margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px;max-width:100%;" class="rmq-87b609c0 rmq-159a7c96 rmq-27601239" data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e rmq-35757987" data-radium="true">Name</div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:8.33333%;text-align:left;font-weight:bold;font-family:Roboto, sans-serif;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea rmq-35757987" data-radium="true">Description</div><div style="clear:both;" data-radium="true"></div></div><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>id: <a href="https://nodejs.org/api/buffer.html">Buffer</a></code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>privKey: RSAPrivateKey?</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div data-radium="true"><div style="margin-left:-15px;margin-right:-15px;" data-radium="true"><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-61e2cd20 rmq-6a8184e2 rmq-8dd7a0f8 rmq-2189018e" data-radium="true"><code>pubKey: RSAPublickKey?</code></div><div style="position:relative;min-height:1px;padding-left:15px;padding-right:15px;float:left;width:100.00000%;" class="rmq-aa1729d5 rmq-a22eaf97 rmq-1918856d rmq-6156e77b rmq-4828d204 rmq-2d0e68c6 rmq-3752549c rmq-3b9282ea" data-radium="true"></div><div style="clear:both;" data-radium="true"></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#id"></a>PeerId.prototype.id<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L40-L40" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>id</code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#privKey"></a>PeerId.prototype.privKey<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L50-L52" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>privKey</code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>The private key of this id, if it exists.</p>
|
|
</div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#pubKey"></a>PeerId.prototype.pubKey<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L59-L67" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>pubKey</code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>The public key of this id, if it exists.</p>
|
|
</div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#marshalPubKey"></a>PeerId.prototype.marshalPubKey<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L75-L79" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>marshalPubKey(): <a href="https://nodejs.org/api/buffer.html">Buffer</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Create the protobuf version of the public key,
|
|
matching go-ipfs formatting.</p>
|
|
</div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="https://nodejs.org/api/buffer.html">Buffer</a></code><span> The marshalled public key
|
|
</span></div></div><div data-radium="true"><h4>Throws</h4><div data-radium="true"><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a></code><span> Failure
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#marshalPrivKey"></a>PeerId.prototype.marshalPrivKey<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L86-L90" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>marshalPrivKey(): <a href="https://nodejs.org/api/buffer.html">Buffer</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Create the protobuf version of the private key,
|
|
matching go-ipfs formatting.</p>
|
|
</div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="https://nodejs.org/api/buffer.html">Buffer</a></code><span>
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#toPrint"></a>PeerId.prototype.toPrint<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L97-L99" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>toPrint(): <a href="#peeridjson">PeerIdJson</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Alias for <code>toJSON</code>.</p>
|
|
</div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="#peeridjson">PeerIdJson</a></code><span>
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#toJSON"></a>PeerId.prototype.toJSON<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L107-L113" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>toJSON(): <a href="#peeridjson">PeerIdJson</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Return the jsonified version of the key, matching the formatting
|
|
of go-ipfs for its config file.</p>
|
|
</div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="#peeridjson">PeerIdJson</a></code><span>
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#toHexString"></a>PeerId.prototype.toHexString<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L120-L122" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>toHexString(): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Returns the Peer ID's <code>id</code> as a hex string.</p>
|
|
</div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code><span>
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#toBytes"></a>PeerId.prototype.toBytes<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L129-L131" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>toBytes(): <a href="https://nodejs.org/api/buffer.html">Buffer</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Returns the Peer ID's <code>id</code> as a buffer.</p>
|
|
</div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="https://nodejs.org/api/buffer.html">Buffer</a></code><span>
|
|
</span></div></div></div><div style="margin-bottom:52px;" data-radium="true"><h3 data-radium="true"><a class="anchor" name="PeerId#toB58String"></a>PeerId.prototype.toB58String<a href="https://github.com/libp2p/js-peer-id/blob/0d3d9f835b0fc6d6ea6e10115ef619b16f386c59/src/index.js#L138-L140" title="src/index.js" style="float:right;" data-radium="true"><svg fill="currentColor" preserveAspectRatio="xMidYMid meet" height="1em" width="1em" viewBox="0 0 40 40" style="vertical-align:middle;"><g><path d="m26.3 7.5l-3.8 3.8 8.8 8.7-8.8 8.8 3.8 3.7 11.2-12.5-11.2-12.5z m-12.5 0l-11.3 12.5 11.3 12.5 3.7-3.7-8.7-8.8 8.7-8.7-3.7-3.8z"></path></g></svg></a></h3><pre><code>toB58String(): <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code></pre><div style="margin-top:13px;margin-bottom:13px;" data-radium="true"><p>Returns the Peer ID's <code>id</code> as a base58 string.</p>
|
|
</div><div data-radium="true"><h4>Returns</h4><div data-radium="true"><code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">String</a></code><span>
|
|
</span></div></div></div></div></div></div></div><div style="clear:both;" data-radium="true"></div></div><div style="clear:both;" data-radium="true"></div></div><style>@media (min-width: 768px) and (max-width: 991px){ .rmq-87b609c0{width: 750px !important;}}
|
|
@media (min-width: 992px) and (max-width: 1199px){ .rmq-159a7c96{width: 970px !important;}}
|
|
@media (min-width: 1200px){ .rmq-27601239{width: 1170px !important;}}
|
|
@media (min-width: 480px) and (max-width: 767px){ .rmq-aa1729d5{float: left !important;}}
|
|
@media (min-width: 768px) and (max-width: 991px){ .rmq-a22eaf97{float: left !important;}}
|
|
@media (min-width: 992px) and (max-width: 1199px){ .rmq-1918856d{float: left !important;}}
|
|
@media (min-width: 1200px){ .rmq-6156e77b{float: left !important;}}
|
|
@media (min-width: 480px) and (max-width: 767px) { .rmq-21ab0466{width: 50.00000% !important;}}
|
|
@media (min-width: 768px) and (max-width: 991px) { .rmq-a01b93a4{width: 50.00000% !important;}}
|
|
@media (min-width: 992px) and (max-width: 1199px) { .rmq-d226cb7e{width: 50.00000% !important;}}
|
|
@media (min-width: 1200px) { .rmq-5cc71c8{width: 50.00000% !important;}}
|
|
@media (min-width: 480px) and (max-width: 767px) { .rmq-77267d84{width: 25.00000% !important;}}
|
|
@media (min-width: 768px) and (max-width: 991px) { .rmq-5c0c1446{width: 25.00000% !important;}}
|
|
@media (min-width: 992px) and (max-width: 1199px) { .rmq-4605701c{width: 25.00000% !important;}}
|
|
@media (min-width: 1200px) { .rmq-34ee8e6a{width: 25.00000% !important;}}
|
|
@media (min-width: 480px) and (max-width: 767px) { .rmq-5c4c5b38{width: 8.33333% !important;}}
|
|
@media (max-width: 479px){ .rmq-35757987{display: none !important;}}
|
|
@media (min-width: 480px) and (max-width: 767px) { .rmq-f09e82ae{display: none !important;}}
|
|
@media (min-width: 480px) and (max-width: 767px) { .rmq-89bb2272{width: 100.00000% !important;}}
|
|
@media (min-width: 768px) and (max-width: 991px) { .rmq-2d0e68c6{width: 66.66667% !important;}}
|
|
@media (min-width: 992px) and (max-width: 1199px) { .rmq-3752549c{width: 66.66667% !important;}}
|
|
@media (min-width: 1200px) { .rmq-3b9282ea{width: 66.66667% !important;}}
|
|
@media (min-width: 768px) and (max-width: 991px) { .rmq-4d29a8df{left: 33.33333% !important;}}
|
|
@media (min-width: 992px) and (max-width: 1199px) { .rmq-ea7683a5{left: 33.33333% !important;}}
|
|
@media (min-width: 1200px) { .rmq-ad95cc33{left: 33.33333% !important;}}
|
|
@media (min-width: 480px) and (max-width: 767px) { .rmq-61e2cd20{width: 33.33333% !important;}}
|
|
@media (min-width: 768px) and (max-width: 991px) { .rmq-6a8184e2{width: 33.33333% !important;}}
|
|
@media (min-width: 992px) and (max-width: 1199px) { .rmq-8dd7a0f8{width: 33.33333% !important;}}
|
|
@media (min-width: 1200px) { .rmq-2189018e{width: 33.33333% !important;}}
|
|
@media (min-width: 480px) and (max-width: 767px) { .rmq-4828d204{width: 66.66667% !important;}}</style></div></main></body></html> |