mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-15 16:10:58 +00:00
1361 lines
32 KiB
HTML
1361 lines
32 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset='utf-8'>
|
|
<title>libp2p-crypto 0.19.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.19.2</code></div>
|
|
<input
|
|
placeholder='Filter'
|
|
id='filter-input'
|
|
class='col12 block input'
|
|
spellcheck='false'
|
|
autocapitalize='off'
|
|
autocorrect='off'
|
|
type='text' />
|
|
<div id='toc'>
|
|
<ul class='list-reset h5 py1-ul'>
|
|
|
|
|
|
<li><a
|
|
href='#import'
|
|
class="">
|
|
import
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#import'
|
|
class="">
|
|
import
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#create'
|
|
class="">
|
|
create
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#encrypt'
|
|
class="">
|
|
encrypt
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#decrypt'
|
|
class="">
|
|
decrypt
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#id'
|
|
class="">
|
|
id
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#export'
|
|
class="">
|
|
export
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#keypair'
|
|
class="">
|
|
keypair
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#export'
|
|
class="">
|
|
export
|
|
|
|
</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='#export'
|
|
class="">
|
|
export
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
|
|
<li><a
|
|
href='#pbkdf2'
|
|
class="">
|
|
pbkdf2
|
|
|
|
</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'>
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='import'>
|
|
import
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/index.js#L119-L135'>
|
|
<span>src/keys/index.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>import(encryptedKey: <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>)</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>encryptedKey</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'>password</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='import'>
|
|
import
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/importer.js#L16-L21'>
|
|
<span>src/keys/importer.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Attempts to decrypt a base64 encoded PrivateKey string
|
|
with the given password. The privateKey must have been exported
|
|
using the same password and underlying cipher (aes-gcm)</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>import(privateKey: <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>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>privateKey</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>)</code>
|
|
A base64 encoded encrypted key
|
|
|
|
</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>
|
|
|
|
</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/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>></code>:
|
|
The private key protobuf
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='create'>
|
|
create
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/ciphers/aes-gcm.js#L20-L126'>
|
|
<span>src/ciphers/aes-gcm.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>create(options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?): any</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a>?
|
|
= <code>{}</code>)</code>
|
|
|
|
</div>
|
|
|
|
<table class='mt1 mb2 fixed-table h5 col-12'>
|
|
<colgroup>
|
|
<col width='30%' />
|
|
<col width='70%' />
|
|
</colgroup>
|
|
<thead>
|
|
<tr class='bold fill-light'>
|
|
<th>Name</th>
|
|
<th>Description</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class='mt1'>
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.algorithmTagLength</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
|
|
|
|
(default <code>16</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.nonceLength</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
|
|
|
|
(default <code>12</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.keyLength</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
|
|
|
|
(default <code>16</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.digest</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code>
|
|
|
|
(default <code>sha256</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.saltLength</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
|
|
|
|
(default <code>16</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
<td class='break-word'><span class='code bold'>options.iterations</span> <code class='quiet'><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">Number</a></code>
|
|
|
|
(default <code>32767</code>)
|
|
</td>
|
|
<td class='break-word'><span></span></td>
|
|
</tr>
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code>any</code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='encrypt'>
|
|
encrypt
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/ciphers/aes-gcm.js#L56-L69'>
|
|
<span>src/ciphers/aes-gcm.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Uses the provided password to derive a pbkdf2 key. The key
|
|
will then be used to encrypt the data.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>encrypt(data: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, password: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>data</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
The data to decrypt
|
|
|
|
</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> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>))</code>
|
|
A plain password
|
|
|
|
</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/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>></code>:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='decrypt'>
|
|
decrypt
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/ciphers/aes-gcm.js#L106-L120'>
|
|
<span>src/ciphers/aes-gcm.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Uses the provided password to derive a pbkdf2 key. The key
|
|
will then be used to decrypt the data. The options used to create
|
|
this decryption cipher must be the same as those used to create
|
|
the encryption cipher.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>decrypt(data: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, password: (<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>))</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>data</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
The data to decrypt
|
|
|
|
</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> | <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>))</code>
|
|
A plain password
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</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/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/rsa-class.js#L106-L109'>
|
|
<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(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</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://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/rsa-class.js#L117-L135'>
|
|
<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(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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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>
|
|
<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>pkcs-8</code>)</code>
|
|
The format in which to export as
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='keypair'>
|
|
keypair
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/rsa.js#L10-L10'>
|
|
<span>src/keys/rsa.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='pre p1 fill-light mt0'>keypair</div>
|
|
|
|
<p>
|
|
Type:
|
|
PrivateKey
|
|
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</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://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/exporter.js#L16-L21'>
|
|
<span>src/keys/exporter.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Exports the given PrivateKey as a base64 encoded string.
|
|
The PrivateKey is encrypted via a password derived PBKDF2 key
|
|
leveraging the aes-gcm cipher algorithm.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>export(privateKey: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>, password: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Parameters</div>
|
|
<div class='prose'>
|
|
|
|
<div class='space-bottom0'>
|
|
<div>
|
|
<span class='code bold'>privateKey</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>)</code>
|
|
The PrivateKey protobuf
|
|
|
|
</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>
|
|
|
|
</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/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code>:
|
|
A base64 encoded string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</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/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/ed25519-class.js#L85-L88'>
|
|
<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(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">String</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://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/ed25519-class.js#L97-L103'>
|
|
<span>src/keys/ed25519-class.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Exports the key into a password protected <code>format</code></p>
|
|
|
|
<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>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>></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>
|
|
The password to encrypt the key
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<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>libp2p-key</code>)</code>
|
|
The format in which to export as
|
|
|
|
</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/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a>></code>:
|
|
The encrypted private key
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</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/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/secp256k1-class.js#L87-L90'>
|
|
<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(): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class='py1 quiet mt1 prose-big'>Returns</div>
|
|
<code><a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</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://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/keys/secp256k1-class.js#L99-L105'>
|
|
<span>src/keys/secp256k1-class.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Exports the key into a password protected <code>format</code></p>
|
|
|
|
<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>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></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>
|
|
The password to encrypt the key
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<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>libp2p-key</code>)</code>
|
|
The format in which to export as
|
|
|
|
</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/Promise">Promise</a><<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>></code>:
|
|
The encrypted private key
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
<section class='p2 mb2 clearfix bg-white minishadow'>
|
|
|
|
|
|
<div class='clearfix'>
|
|
|
|
<h3 class='fl m0' id='pbkdf2'>
|
|
pbkdf2
|
|
</h3>
|
|
|
|
|
|
<a class='fr fill-darken0 round round pad1x quiet h5' href='https://github.com/libp2p/js-libp2p-crypto/blob/a05e870c45df7352e1b1952c25ac8da3c08c9cd2/src/pbkdf2.js#L30-L43'>
|
|
<span>src/pbkdf2.js</span>
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
<p>Computes the Password-Based Key Derivation Function 2.</p>
|
|
|
|
<div class='pre p1 fill-light mt0'>pbkdf2(password: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, salt: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>, iterations: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, keySize: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>, hash: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>): <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></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>
|