* feat: support Peer ID represented as CID
This change adds two functions:
- createFromCID accepts CID as String|CID|Buffer
and creates PeerId from the multihash value inside of it
- toCIDString serializes PeerId multihash into a CIDv1 in Base32,
as agreed in https://github.com/libp2p/specs/pull/209
License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
* refactor: rename toCIDString to toString
CIDv1 is self describing, and toString was not defined.
Makes sense to use generic toString in this case.
This change also:
- remembers string with CID, so it is lazily generated only once
- switches createFromB58String to createFromCID (b58 is CIDv0),
making it easier to migrate existing codebases.
License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
* docs: comment tests
License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
* feat: validate CID multicodec
- require CID with 'libp2p-key' (CIDv1) or 'dag-pb' (CIDv0 converted to CIDv1)
- delegate CID validation to CID constructor
License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
* Always add public key to constructor if possible
* extending Non-default # of bits test time, travis took 59521ms
License: MIT
Signed-off-by: Yahya <ya7yaz@gmail.com>
* refactor: make import and creation async - This allows the use of native key generation in the browser
BREAKING CHANGE:
This changes the interface of .create, .createFromPrivKey,
.createFromPubKey, .createFromJSON