js-libp2p-crypto/index.html
2019-09-25 11:50:23 +02:00

471 lines
12 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>libp2p-crypto 0.16.2 | Documentation</title>
<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>
<div class='mb1'><code>0.16.2</code></div>
<input
placeholder='Filter'
id='filter-input'
class='col12 block input'
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>
<li><a
href='#id'
class="">
id
</a>
</li>
<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>
<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>
<p>Libp2p-crypto should work in any ES2015 environment out of the box.</p>
<p>Usage:</p>
<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>
<p>The portable versions of libp2p-crypto, including <code>index.js</code> and <code>index.min.js</code>, are included in the <code>/dist</code> folder. Libp2p-crypto can also be found on <a href="https://unpkg.com">unpkg.com</a> under</p>
<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>
</section></div>
<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://git@github.com/:libp2p/js-libp2p-crypto/blob/967594c9a387fa427d378c1fb03adea6790292bc/src/keys/rsa-class.js#L108-L115'>
<span>src/keys/rsa-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>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id='export'>
export
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://git@github.com/:libp2p/js-libp2p-crypto/blob/967594c9a387fa427d378c1fb03adea6790292bc/src/keys/rsa-class.js#L125-L158'>
<span>src/keys/rsa-class.js</span>
</a>
</div>
<p>Exports the key into a password protected PEM format</p>
<div class='pre p1 fill-light mt0'>export(format: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?, password: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, callback: function (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error">Error</a>, KeyInfo)): <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'>format</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>?)</code>
Defaults to 'pkcs-8'.
</div>
</div>
<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>
<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>, KeyInfo))</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>:
</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://git@github.com/:libp2p/js-libp2p-crypto/blob/967594c9a387fa427d378c1fb03adea6790292bc/src/keys/ed25519-class.js#L92-L99'>
<span>src/keys/ed25519-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>:
</section>
<section class='p2 mb2 clearfix bg-white minishadow'>
<div class='clearfix'>
<h3 class='fl m0' id=''>
</h3>
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://git@github.com/:libp2p/js-libp2p-crypto/blob/967594c9a387fa427d378c1fb03adea6790292bc/src/pbkdf2.js#L13-L17'>
<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
</section>
</div>
</div>
<script src='assets/anchor.js'></script>
<script src='assets/split.js'></script>
<script src='assets/site.js'></script>
</body>
</html>