@libp2p/keychain
TypeScript icon, indicating that this package has built-in type declarations

5.0.11 • Public • Published

@libp2p/keychain

libp2p.io Discuss codecov CI

Key management and cryptographically protected messages

About

  • Manages the lifecycle of a key
  • Keys are encrypted at rest
  • Enforces the use of safe key names
  • Uses encrypted PKCS 8 for key storage
  • Uses PBKDF2 for a "stetched" key encryption key
  • Enforces NIST SP 800-131A and NIST SP 800-132
  • Delays reporting errors to slow down brute force attacks

KeyInfo

The key management and naming service API all return a KeyInfo object. The id is a universally unique identifier for the key. The name is local to the key chain.

{
  "name": "rsa-key",
  "id": "QmYWYSUZ4PV6MRFYpdtEDJBiGs4UrmE6g8wmAWSePekXVW"
}

The key id is 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.

Private key storage

A private key is stored as an encrypted PKCS 8 structure in the PEM format. It is protected by a key generated from the key chain's passPhrase using PBKDF2.

The default options for generating the derived encryption key are in the dek object. This, along with the passPhrase, is the input to a PBKDF2 function.

const defaultOptions = {
  // See https://cryptosense.com/parameter-choice-for-pbkdf2/
  dek: {
    keyLength: 512 / 8,
    iterationCount: 1000,
    salt: 'at least 16 characters long',
    hash: 'sha2-512'
  }
}

key storage

Physical storage

The actual physical storage of an encrypted key is left to implementations of interface-datastore.

A key benefit is that now the key chain can be used in browser with the js-datastore-level implementation.

Install

$ npm i @libp2p/keychain

Browser <script> tag

Loading this module through a script tag will make its exports available as Libp2pKeychain in the global namespace.

<script src="https://unpkg.com/@libp2p/keychain/dist/index.min.js"></script>

API Docs

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.0.11
1,176latest
5.0.11-285dab7d7
62next

Version History

VersionDownloads (Last 7 Days)Published
5.0.11-285dab7d7
62
5.0.11-5acfae333
56
5.0.11-f4747450f
62
5.0.11-52f0f2f13
52
5.0.11-023ea575c
57
5.0.11-d3e5a3382
61
5.0.11-3c63482e5
58
5.0.11-5c4a79e5a
13
5.0.11-127abe24b
12
5.0.11
1,176
5.0.10-48e9cfa56
11
5.0.10-96654117c
4
5.0.10-9614de7c6
5
5.0.10-2625cc323
5
5.0.10-92cc74082
4
5.0.10-d19974d93
2
5.0.10-6ab85ea68
2
5.0.10-2c182d2e2
3
5.0.10-06f79b646
3
5.0.10-99f5f270b
3
5.0.10-f8da60e73
2
5.0.10-406b3916c
2
5.0.10-a0c8ceb99
2
5.0.10-f2f9008b8
2
5.0.10-339b7df88
2
5.0.10-8a9258a24
2
5.0.10-4761dd701
2
5.0.10-3650283f7
2
5.0.10-b02ea9b6e
4
5.0.10-bc90b4fd5
2
5.0.10-a82b07d8c
3
5.0.10-d6cd25d0d
2
5.0.10-98b43045c
2
5.0.10-4a85eb033
3
5.0.10-6ddc1b80e
3
5.0.10-0862522fe
3
5.0.10-b248eefc0
2
5.0.10-d866eb5bb
3
5.0.10-f53f65d18
4
5.0.10
677
5.0.9-05d559f54
2
5.0.9-656db81cf
3
5.0.9-432955390
3
5.0.9-eee97c7d4
3
5.0.9-2feaeddb4
4
5.0.9-c917314f3
4
5.0.9-844a8d2d1
2
5.0.9-7dcabb884
2
5.0.9-7626b224d
3
5.0.9-02f285fc8
3
5.0.9-32ca76fcb
2
5.0.9-665769021
2
5.0.9-7dead6d35
3
5.0.9-6bd7f9169
2
5.0.9-91687998d
2
5.0.9-d30d07e6f
2
5.0.9-adc767899
3
5.0.9-7c085d10c
2
5.0.9-0a3406a05
2
5.0.9-c2ff2e454
2
5.0.9-ad5cfd66a
2
5.0.9-a5cd8cfbe
3
5.0.9
53
5.0.8-a657bbd2e
2
5.0.8-d34642db1
2
5.0.8-7383821e1
2
5.0.8-717731e49
2
5.0.8
6
5.0.7-aa8de9fd3
2
5.0.7-3bc9769b8
2
5.0.7-3244ed086
3
5.0.7-4521cf1f7
2
5.0.7-75301ac7d
2
5.0.7-e6b4158c6
4
5.0.7-5d199f9b6
1
5.0.7
125
5.0.6-0d326d102
2
5.0.6-e99e8f448
1
5.0.6-d7a818e8e
1
5.0.6-934a891f9
2
5.0.6-d4da56961
2
5.0.6-27b2fa6b6
1
5.0.6-661d6586a
1
5.0.6-80e798cdc
1
5.0.6-b4f02a637
1
5.0.6-35b48025c
2
5.0.6-32c176fd5
2
5.0.6-58784abf7
2
5.0.6-d9c7e0f7e
1
5.0.6-24fa1d5af
1
5.0.6-dad979f9b
2
5.0.6-a390db4a4
1
5.0.6-82bd42bcf
1
5.0.6
28
5.0.5-0c5957836
1
5.0.5-c5988cce8
1
5.0.5-980038477
1
5.0.5-fa83ee1c7
2
5.0.5
7
5.0.4-c258b35af
1
5.0.4
1
5.0.3-7f7ec82ae
2
5.0.3-b3272cfce
1
5.0.3
1
5.0.2-21fe841f2
2
5.0.2-c628c44c5
1
5.0.2-4fd7eb2e1
1
5.0.2-6ccbb06f0
1
5.0.2
1
5.0.1-34455b5f2
1
5.0.1
1
5.0.0-18dd3cb26
1
5.0.0-1210884ed
2
5.0.0-d101aac4b
1
5.0.0-7cd984569
1
5.0.0
1
4.1.6-b6681bd25
1
4.1.6-2bbaf4361
1
4.1.6-e1ca9cced
1
4.1.6-71e5f7a5b
1
4.1.6-c010d575c
1
4.1.6-a142bb642
1
4.1.6-81ebe4e47
2
4.1.6-5214dec4a
1
4.1.6-df330695a
1
4.1.6-dd7b329c4
1
4.1.6-737b3ea5b
1
4.1.6-2265e59ba
1
4.1.6-1675adee2
1
4.1.6
496
4.1.5-7655e5200
1
4.1.5-50b897139
2
4.1.5-e211b46cc
1
4.1.5-3c8dd5bbf
1
4.1.5-359265a3a
2
4.1.5
30
4.1.4-1dfb74e79
1
4.1.4-7939dbd5c
1
4.1.4-c5dba70a9
1
4.1.4-0edbfe7af
1
4.1.4
240
4.1.3-f30e2ee8d
2
4.1.3-944935f8d
1
4.1.3
32
4.1.2-a8ec2bcb7
1
4.1.2-a82ff8221
1
4.1.2-34cf1f7cd
1
4.1.2-8b3114292
1
4.1.2-4a994c5ef
1
4.1.2-73f2b6b6d
1
4.1.2-40902d99b
1
4.1.2-928801a80
1
4.1.2-a130993ed
1
4.1.2
124
4.1.1-e9b6a242a
1
4.1.1-3319ff41e
1
4.1.1-e1f0b307c
2
4.1.1-d1aec4d9f
2
4.1.1-ce6da9896
2
4.1.1-151bc46fb
2
4.1.1
1
4.1.0-abb9f90c7
2
4.1.0-af85a7cad
2
4.1.0-21cf7bc56
1
4.1.0-b0b6cae12
1
4.1.0-6573cb8b0
1
4.1.0-15eb66428
1
4.1.0-3b9cbf7d8
1
4.1.0-0b55625d1
1
4.1.0
3
4.0.16-9e0236627
1
4.0.16-8e4fdcde9
1
4.0.16-94cac115a
1
4.0.16-d1f1c2be7
2
4.0.16-44791342
1
4.0.16-863b3de03
1
4.0.16
3
4.0.15-90d10b565
2
4.0.15-62e32252a
1
4.0.15-769461d3b
2
4.0.15-bc6556f96
1
4.0.15-6011d3697
1
4.0.15-f6fe2cc3c
1
4.0.15-4bd8e4f79
1
4.0.15-440c9b360
1
4.0.15-757fb2674
1
4.0.15-12106b5b0
1
4.0.15-169c9d85e
2
4.0.15-f4e572cd6
1
4.0.15-352699ab5
1
4.0.15-167bf2b3c
1
4.0.15-7aec7bd45
2
4.0.15-7464dc00c
1
4.0.15-e69a2f1b6
1
4.0.15
81
4.0.14-a3e8beabd
1
4.0.14-48444f750
1
4.0.14-1a41c28bb
1
4.0.14-8214dcfb0
1
4.0.14-1eb5b2713
2
4.0.14-5b7380259
2
4.0.14-7de56f244
1
4.0.14-1cd5aae11
1
4.0.14-1cc6a9405
1
4.0.14-3c73707ff
1
4.0.14-9d4b0596f
1
4.0.14-43046b9ae
2
4.0.14-83c14d08f
1
4.0.14-7ae6063df
2
4.0.14-4ad63bb79
1
4.0.14-510d9ce65
1
4.0.14-767b23e71
1
4.0.14-bfa7660d5
2
4.0.14-d9366f9aa
1
4.0.14-1488a7371
1
4.0.14-a11e135c2
2
4.0.14-9d13a2f6a
2
4.0.14
21
4.0.13-de3f7aeaf
1
4.0.13-c82432312
1
4.0.13-3d7a9da17
1
4.0.13-3bc94b403
2
4.0.13-e1923b0a7
2
4.0.13-998fcaf94
1
4.0.13-90cfd25e2
2
4.0.13
6
4.0.12-c2181f0cf
1
4.0.12-2281f802b
2
4.0.12-fd1f8343d
1
4.0.12-eaf8ac7cf
1
4.0.12-acef72613
1
4.0.12-ea4f26285
1
4.0.12-31c78f4ed
2
4.0.12-08dabd390
2
4.0.12
2
4.0.11-b17824a1d
2
4.0.11-2c56203f9
2
4.0.11-732c436d4
2
4.0.11-936dbba10
1
4.0.11-2b2958fe6
1
4.0.11
2
4.0.10-3e515f007
1
4.0.10-d446c6c31
1
4.0.10-a2b41f793
1
4.0.10-80278b36b
1
4.0.10-3ffecc5bf
2
4.0.10-ab5f05763
3
4.0.10-4fc0a7d30
2
4.0.10-1f589c822
1
4.0.10-afe15f669
1
4.0.10
5
4.0.9-82901e785
1
4.0.9-bf720c045
1
4.0.9-1fc929c1c
1
4.0.9-330a5ed72
1
4.0.9-59a97b61b
1
4.0.9-fad3074b8
2
4.0.9-cad9cf007
1
4.0.9-e1798aa26
1
4.0.9-f39ce5f13
2
4.0.9-83ef3717e
1
4.0.9-ab466004b
1
4.0.9-a9cc0ee49
1
4.0.9-2122a713d
1
4.0.9-28e51652a
1
4.0.9-f71bc49bd
1
4.0.9
39
4.0.8-f0d2b52d0
1
4.0.8-e1c01370b
1
4.0.8-8072a2e59
1
4.0.8-b1b77adb4
1
4.0.8-bedfd0aa2
1
4.0.8-fb7c51c3c
1
4.0.8-0c7bbbb07
1
4.0.8
10
4.0.7-9891ecd73
1
4.0.7-0321812e7
2
4.0.7-03ff9fd82
1
4.0.7-1cb2408ac
1
4.0.7-dab5cf724
1
4.0.7-2370d1c39
1
4.0.7-e1db332a4
1
4.0.7-6f323de7d
1
4.0.7-c9ed1c7d6
1
4.0.7-f4dda4a3c
1
4.0.7-74fb5671d
2
4.0.7-2e464c099
1
4.0.7-dbc92ab74
2
4.0.7-72f0e09f7
1
4.0.7-f27138ca1
1
4.0.7-74477f6ea
2
4.0.7-8c6654c3a
2
4.0.7-08f6f607d
1
4.0.7-9376e61a1
1
4.0.7-3e47d88fd
1
4.0.7
4
4.0.6-092861e23
1
4.0.6-8bbd43628
1
4.0.6
2
4.0.5-856ccd708
2
4.0.5-ddaa59a60
1
4.0.5-4691f4173
1
4.0.5-ee7ffe9b9
3
4.0.5-821a38e24
2
4.0.5-900236724
1
4.0.5
350
4.0.4-444d83751
1
4.0.4-d011f6130
1
4.0.4-528d73781
2
4.0.4-581574d6d
1
4.0.4-388d02b33
1
4.0.4-ba7089984
1
4.0.4
2
4.0.3-28587d24f
1
4.0.3-5d1f68e92
1
4.0.3-4e0135c7d
1
4.0.3-cd8cafcd5
1
4.0.3-6fd681d09
1
4.0.3-178fe2671
1
4.0.3-c00378909
1
4.0.3-83dfc7dc8
1
4.0.3-f71f2e14e
2
4.0.3-07f3afe2d
1
4.0.3-984f13e42
2
4.0.3-ad6f70bf3
3
4.0.3-230afea4b
2
4.0.3-a7c6a93c6
2
4.0.3-9eff7eff0
1
4.0.3-f81be145a
1
4.0.3-01e9a5fe4
2
4.0.3-742915567
1
4.0.3
1
4.0.2-341581166
2
4.0.2-6d11e8268
1
4.0.2-d10506189
2
4.0.2-64a915ae9
1
4.0.2-3bf6387ff
1
4.0.2-93890c8f9
3
4.0.2-887c6ffe1
1
4.0.2-16588d27c
1
4.0.2-bcfa15993
1
4.0.2-10ea19700
2
4.0.2-09dd02987
2
4.0.2-5a9362e21
1
4.0.2
1
4.0.1-738dd40f1
2
4.0.1-7861ed882
1
4.0.1-9197f10ba
1
4.0.1-e7167fe52
2
4.0.1-f537b3731
1
4.0.1-8c169db1b
1
4.0.1-561797a89
1
4.0.1-cf963694f
2
4.0.1-bca8d6e68
1
4.0.1
2
4.0.1-53224004f
1
4.0.0-273d8177c
1
4.0.1-6c1f0ee81
1
4.0.0-a32e70bac
1
4.0.0-06e6d235f
1
4.0.0-bcf18265e
1
4.0.0-8e4fbe13a
1
4.0.0-7682861f9
2
4.0.0-551622a96
1
4.0.0
1
3.0.8-8f921ee97
1
3.0.8-74e84bc29
1
3.0.8-8bb6d5333
1
3.0.8-7877a50e0
1
3.0.8-68db79f6b
1
3.0.8-e2267d4371
3.0.8-4a474d54d1
3.0.8-0b4a2ee791
3.0.8-6b6ba9ab71
3.0.8-d729d66a51
3.0.8-bb6ceb1921
3.0.8-d8f5bc2111
3.0.8-13a870cbe2
3.0.8-3dee5df4d1
3.0.8-adea7bbbf1
3.0.8-6625a27fc1
3.0.8-9c67c5b3d2
3.0.8-05b52d69c1
3.0.8-97ab31c0c2
3.0.8-0f5c305af1
3.0.8-c960eb6591
3.0.8-effcfaa8e3
3.0.8258
3.0.7-70d5efc2e1
3.0.7-fb8a6f1881
3.0.7-78db573f92
3.0.7-8b82e68e81
3.0.7-1d141331a1
3.0.7-d25d95101
3.0.7-dfbe0cc01
3.0.7-f4fac9611
3.0.7-051154dd1
3.0.7-fdcb801e2
3.0.756
3.0.6-025c082a1
3.0.6-16a870761
3.0.6-346ff5a21
3.0.6-50442d7a1
3.0.6-695813672
3.0.6-b686fb5a1
3.0.6-d5ef1c911
3.0.6-7903d7a52
3.0.63
3.0.5-50f912c21
3.0.5-b5a808af1
3.0.5-f9d1c0721
3.0.5-ab2c1f671
3.0.5-685049391
3.0.5-7534ae7b1
3.0.5-cf3ae8931
3.0.5-77e3cbc31
3.0.5-62a56b541
3.0.55
3.0.4-f670307a2
3.0.4-f10531592
3.0.4-7d8b15512
3.0.4-c97dea041
3.0.4-e9099d402
3.0.4-980857c31
3.0.4-28794fe41
3.0.4-e8123d3f1
3.0.4-5a6a43792
3.0.4-c88de8e11
3.0.4-96166ada1
3.0.4-b57bca441
3.0.4-ae36e86b1
3.0.4-91842c932
3.0.4-f09ac4a71
3.0.4-e3ab19291
3.0.4-72319fe61
3.0.4-972b10a91
3.0.4-6640116d1
3.0.4-6cb80f7d2
3.0.45
3.0.3-122f1e671
3.0.3-d9159dd51
3.0.3-20d5f2201
3.0.3-0ce318ec1
3.0.3-4db2f5f51
3.0.3-0ee4f7841
3.0.3-88c47f512
3.0.3-0d228f9f1
3.0.3-28d6722f1
3.0.3-5294f14c1
3.0.3-73b87c5a2
3.0.3-10cbc8fa1
3.0.3-46dc3ce93
3.0.3-c4eff4c51
3.0.3-7517082d4
3.0.3-2b755a821
3.0.3-0634e3b72
3.0.3-a6be8f0f2
3.0.3-a533cc391
3.0.3-328256331
3.0.3-4559a6241
3.0.3-24a5edae1
3.0.3-63041afe1
3.0.3-13f5b48e1
3.0.3-9a69e6f71
3.0.3-01acccef1
3.0.3-24c1c2481
3.0.3-6a02d7652
3.0.3-098ba0821
3.0.3-897786241
3.0.3-b599905c1
3.0.3-f3fd7b621
3.0.3-725f5df12
3.0.3-6abcd22f1
3.0.3-4ef9c79c1
3.0.3-87dc7e9f1
3.0.3-d99485961
3.0.3-d30f09f21
3.0.3-e664d14f1
3.0.3-871655511
3.0.3-7b2ddc171
3.0.314
3.0.2-02b893231
3.0.2-18567b7c1
3.0.2-a31b420f2
3.0.2-4c1a33b31
3.0.2-364e05921
3.0.2-9c0353cf1
3.0.2-3345f28b1
3.0.2-a1fbb7e21
3.0.2-5e85154b1
3.0.2-322129592
3.0.2-123ded591
3.0.2-6b8398071
3.0.2-eaac89431
3.0.2-e26848b01
3.0.210
3.0.1-446fff872
3.0.12
3.0.0-58421e111
3.0.0-8f681db31
3.0.0-5ffa7a741
3.0.0-8f855a3c1
3.0.0-8d49602f2
3.0.0-a4a10fd41
3.0.0-c858ca7f3
3.0.0-ef83dd1d1
3.0.0-e66f48911
3.0.0-72e81dc11
3.0.0-fdd808202
3.0.01
2.0.1-eabf6f361
2.0.1-1f7e18b01
2.0.1-57c327211
2.0.1-a41d25d42
2.0.1-7f60b5791
2.0.1-69c93ac51
2.0.1-c999d6a71
2.0.1-a1ec46b51
2.0.1-7debe0311
2.0.1-c22321661
2.0.1-791f56f03
2.0.1-b1024c6c1
2.0.1-e9cafd3d2
2.0.1-06f4901a1
2.0.1-7b5c54dd2
2.0.1-5eee70a42
2.0.1-daeb43d81
2.0.1-5315f7bc1
2.0.1-6eab9c5e1
2.0.1-7fb23cd31
2.0.1-42c1c0971
2.0.1-85a317bb1
2.0.1-2e561fe91
2.0.1-879f47941
2.0.1-f427cfc91
2.0.1-05abd49f1
2.0.1-8b0e6bef1
2.0.1-6fdaa7dc1
2.0.1-d853d1241
2.0.1-ea8a06371
2.0.1-ab0e39802
2.0.1-3dfc236e1
2.0.1386
2.0.023
1.0.15
1.0.02
0.6.22
0.6.12

Package Sidebar

Install

npm i @libp2p/keychain

Weekly Downloads

5,453

Version

5.0.11

License

Apache-2.0 OR MIT

Unpacked Size

272 kB

Total Files

29

Last publish

Collaborators

  • daviddias
  • alanshaw
  • achingbrain
  • vascosantos
  • npm-service-account-libp2p
  • jacobheun