2018-01-27 10:56:33 -08:00
<!doctype html>
2019-09-25 11:50:23 +02:00
< html >
< head >
< meta charset = 'utf-8' >
2019-10-25 13:57:03 +02:00
< title > libp2p-crypto 0.17.1 | 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 >
2019-10-25 13:57:03 +02:00
< div class = 'mb1' > < code > 0.17.1< / code > < / div >
2019-09-25 11:50:23 +02:00
< 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 >
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 >
< p > Libp2p-crypto should work in any ES2015 environment out of the box.< / p >
< p > Usage:< / p >
2019-07-11 15:24:07 +02:00
< pre class = 'hljs' > < span class = "hljs-tag" > < < 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 > > < / span > < span class = "hljs-tag" > < /< span class = "hljs-name" > script< / span > > < / span > < / pre >
2018-11-05 18:29:12 +00:00
< 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 >
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 >
2019-10-25 13:57:03 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p-crypto/blob/b5d94ecae7cf56bfc536cbfd326f968f3488f50b/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
2019-10-25 13:57:03 +02:00
< 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 >
2019-09-25 11:50:23 +02:00
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
2019-10-25 13:57:03 +02:00
< 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 > :
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 >
2019-10-25 13:57:03 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p-crypto/blob/b5d94ecae7cf56bfc536cbfd326f968f3488f50b/src/keys/rsa-class.js#L115-L135' >
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 >
2019-10-25 13:57:03 +02: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 > ?): KeyInfo< / 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 >
2019-10-25 13:57:03 +02: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 > ' pkcs-8' < / code > )< / code >
Defaults to 'pkcs-8'.
2019-09-25 11:50:23 +02:00
< / div >
< / div >
< / div >
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
2019-10-25 13:57:03 +02:00
< code > KeyInfo< / 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 = 'id' >
id
< / h3 >
2019-10-25 13:57:03 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p-crypto/blob/b5d94ecae7cf56bfc536cbfd326f968f3488f50b/src/keys/ed25519-class.js#L84-L87' >
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
2019-10-25 13:57:03 +02:00
< 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 >
2019-09-25 11:50:23 +02:00
< div class = 'py1 quiet mt1 prose-big' > Returns< / div >
2019-10-25 13:57:03 +02:00
< 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 > :
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 >
2019-10-25 13:57:03 +02:00
< a class = 'fr fill-darken0 round round pad1x quiet h5' href = 'https://github.com/libp2p/js-libp2p-crypto/blob/b5d94ecae7cf56bfc536cbfd326f968f3488f50b/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
< / section >
< / div >
< / div >
< script src = 'assets/anchor.js' > < / script >
< script src = 'assets/split.js' > < / script >
< script src = 'assets/site.js' > < / script >
< / body >
< / html >