js-libp2p-crypto/index.html

597 lines
14 KiB
HTML
Raw Normal View History

2018-01-27 10:56:33 -08:00
<!doctype html>
2020-01-17 12:08:51 +01:00
<html lang="en">
2019-09-25 11:50:23 +02:00
<head>
<meta charset='utf-8'>
2020-04-07 16:15:59 +02:00
<title>libp2p-crypto 0.17.6 | Documentation</title>
2019-09-25 11:50:23 +02:00
<meta name='description' content='Crypto primitives for libp2p'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet'>
<link href='assets/style.css' rel='stylesheet'>
<link href='assets/github.css' rel='stylesheet'>
<link href='assets/split.css' rel='stylesheet'>
</head>
<body class='documentation m0'>
<div class='flex'>
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>libp2p-crypto</h3>
2020-04-07 16:15:59 +02:00
<div class='mb1'><code>0.17.6</code></div>
2019-09-25 11:50:23 +02:00
<input
placeholder='Filter'
id='filter-input'
class='col12 block input'
2020-04-07 16:15:59 +02:00
spellcheck='false'
autocapitalize='off'
autocorrect='off'
2019-09-25 11:50:23 +02:00
type='text' />
<div id='toc'>
<ul class='list-reset h5 py1-ul'>
<li><a
href='#intro'
class="h5 bold black caps">
Intro
</a>
</li>
<li><a
href='#id'
class="">
id
</a>
</li>
<li><a
href='#export'
class="">
export
</a>
</li>
2020-01-17 12:08:51 +01:00
<li><a
href='#keypair'
class="">
keypair
</a>
</li>
2019-09-25 11:50:23 +02:00
<li><a
href='#id'
class="">
id
</a>
</li>
2020-04-07 16:15:59 +02:00
<li><a
href='#id'
class="">
id
</a>
</li>
2019-09-25 11:50:23 +02:00
<li><a
href='#'
class="">
</a>
</li>
</ul>
</div>
<div class='mt1 h6 quiet'>
<a href='https://documentation.js.org/reading-documentation.html'>Need help reading this?</a>
</div>
</div>
</div>
<div id='split-right' class='relative overflow-auto height-viewport-100'>
<div class='keyline-top-not py2'><section class='py2 clearfix'>
<h2 id='intro' class='mt0'>
Intro
</h2>
<p>Installable via <code>npm install --save libp2p-crypto</code>, it can also be used directly in the browser.</p>
2018-01-27 10:56:33 -08:00
<h2>Download</h2>
<p>The source is available for download from <a href="https://github.com/libp2p/js-libp2p-crypto.git">GitHub</a>. Alternatively, you can install using npm:</p>
<pre class='hljs'>$ npm install --save libp2p-crypto</pre>
<p>You can then <code>require()</code> libp2p-crypto as normal:</p>
<pre class='hljs'><span class="hljs-keyword">const</span> libp2PCrypto = <span class="hljs-built_in">require</span>(<span class="hljs-string">'libp2p-crypto'</span>)</pre>
<h2>In the Browser</h2>
2020-02-26 17:21:52 +01:00
<p><code>libp2p-crypto</code> should work in any ECMAScript 2018 environment out of the box.</p>
2018-01-27 10:56:33 -08:00
<p>Usage:</p>
2019-07-11 15:24:07 +02:00
<pre class='hljs'><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text/javascript"</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"index.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></pre>
2020-02-26 17:21:52 +01:00
<p>The portable versions of <code>libp2p-crypto</code>, including <code>index.js</code> and <code>index.min.js</code>, are included in the <code>/dist</code> folder. <code>libp2p-crypto</code> can also be found on <a href="https://unpkg.com">unpkg.com</a> under</p>
2018-01-27 10:56:33 -08:00
<ul>
<li><a href="https://unpkg.com/libp2p-crypto/dist/index.min.js">https://unpkg.com/libp2p-crypto/dist/index.min.js</a></li>
<li><a href="https://unpkg.com/libp2p-crypto/dist/index.js">https://unpkg.com/libp2p-crypto/dist/index.js</a></li>
</ul>
2019-09-25 11:50:23 +02:00
</section></div>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='id'>
id
</h3>
2020-04-07 16:15:59 +02:00
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/e76142715390f59550df5fd26020bc505543d1e9/src/keys/rsa-class.js#L103-L106'>
2019-09-25 11:50:23 +02:00
<span>src/keys/rsa-class.js</span>
</a>
</div>
<p>Gets the ID of the key.</p>
2018-01-27 10:56:33 -08:00
<p>The key id is the base58 encoding of the SHA-256 multihash of its public key.
The public key is a protobuf encoding containing a type and the DER encoding
of the PKCS SubjectPublicKeyInfo.</p>
2019-09-25 11:50:23 +02:00
2020-01-17 12:08:51 +01:00
<div class='pre p1 fill-light mt0'>id(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>></div>
2019-09-25 11:50:23 +02:00
<div class='py1 quiet mt1 prose-big'>Returns</div>
2020-01-17 12:08:51 +01:00
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>></code>:
2019-09-25 11:50:23 +02:00
2020-04-07 16:15:59 +02:00
2019-09-25 11:50:23 +02:00
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='export'>
export
</h3>
2020-04-07 16:15:59 +02:00
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/e76142715390f59550df5fd26020bc505543d1e9/src/keys/rsa-class.js#L114-L134'>
2019-09-25 11:50:23 +02:00
<span>src/keys/rsa-class.js</span>
</a>
</div>
<p>Exports the key into a password protected PEM format</p>
2020-01-17 12:08:51 +01:00
<div class='pre p1 fill-light mt0'>export(password: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, format: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?)</div>
2019-09-25 11:50:23 +02:00
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>password</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
The password to read the encrypted PEM
</div>
</div>
<div class='space-bottom0'>
<div>
2020-01-17 12:08:51 +01:00
<span class='code bold'>format</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?
= <code>&#39;pkcs-8&#39;</code>)</code>
Defaults to 'pkcs-8'.
2019-09-25 11:50:23 +02:00
</div>
</div>
</div>
2020-01-17 12:08:51 +01:00
2020-04-07 16:15:59 +02:00
2020-01-17 12:08:51 +01:00
</section>
2019-09-25 11:50:23 +02:00
2020-01-17 12:08:51 +01:00
<section class='p2 mb2 clearfix bg-white minishadow'>
2019-09-25 11:50:23 +02:00
2020-01-17 12:08:51 +01:00
<div class='clearfix'>
<h3 class='fl m0' id='keypair'>
keypair
</h3>
2019-09-25 11:50:23 +02:00
2020-04-07 16:15:59 +02:00
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/e76142715390f59550df5fd26020bc505543d1e9/src/keys/rsa.js#L10-L10'>
2020-01-17 12:08:51 +01:00
<span>src/keys/rsa.js</span>
</a>
</div>
<div class='pre p1 fill-light mt0'>keypair</div>
<p>
Type:
PrivateKey
</p>
2019-09-25 11:50:23 +02:00
2020-04-07 16:15:59 +02:00
2019-09-25 11:50:23 +02:00
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='id'>
id
</h3>
2020-04-07 16:15:59 +02:00
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/e76142715390f59550df5fd26020bc505543d1e9/src/keys/ed25519-class.js#L85-L88'>
2019-09-25 11:50:23 +02:00
<span>src/keys/ed25519-class.js</span>
</a>
</div>
<p>Gets the ID of the key.</p>
2018-01-27 10:56:33 -08:00
<p>The key id is the base58 encoding of the SHA-256 multihash of its public key.
The public key is a protobuf encoding containing a type and the DER encoding
of the PKCS SubjectPublicKeyInfo.</p>
2019-09-25 11:50:23 +02:00
2020-01-17 12:08:51 +01:00
<div class='pre p1 fill-light mt0'>id(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>></div>
2019-09-25 11:50:23 +02:00
<div class='py1 quiet mt1 prose-big'>Returns</div>
2020-01-17 12:08:51 +01:00
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a>&#x3C;<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>></code>:
2019-09-25 11:50:23 +02:00
2020-04-07 16:15:59 +02:00
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='id'>
id
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/e76142715390f59550df5fd26020bc505543d1e9/src/keys/secp256k1-class.js#L84-L87'>
<span>src/keys/secp256k1-class.js</span>
</a>
</div>
<p>Gets the ID of the key.</p>
<p>The key id is the base58 encoding of the SHA-256 multihash of its public key.
The public key is a protobuf encoding containing a type and the DER encoding
of the PKCS SubjectPublicKeyInfo.</p>
<div class='pre p1 fill-light mt0'>id(callback: function (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, id)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</a></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>callback</span> <code class='quiet'>(function (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, id))</code>
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined">undefined</a></code>:
2019-09-25 11:50:23 +02:00
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id=''>
</h3>
2020-04-07 16:15:59 +02:00
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/e76142715390f59550df5fd26020bc505543d1e9/src/pbkdf2.js#L14-L18'>
2019-09-25 11:50:23 +02:00
<span>src/pbkdf2.js</span>
</a>
</div>
<p>Computes the Password-Based Key Derivation Function 2.</p>
<div class='pre p1 fill-light mt0'></div>
<div class='py1 quiet mt1 prose-big'>Parameters</div>
<div class='prose'>
<div class='space-bottom0'>
<div>
<span class='code bold'>password</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>salt</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>iterations</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code>
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>keySize</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>)</code>
(in bytes)
</div>
</div>
<div class='space-bottom0'>
<div>
<span class='code bold'>hash</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
The hash name ('sha1', 'sha2-512, ...)
</div>
</div>
</div>
<div class='py1 quiet mt1 prose-big'>Returns</div>
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>:
A new password
2020-04-07 16:15:59 +02:00
2019-09-25 11:50:23 +02:00
</section>
</div>
</div>
<script src='assets/anchor.js'></script>
<script src='assets/split.js'></script>
<script src='assets/site.js'></script>
</body>
</html>