-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve docs around creating peerId from private key and improve support #82
Comments
Treat documentation mistakes as bugs. That said, proposal sounds good :) |
And Please can you provide examples to start with in the docs, its tough to find out the starting point for many of the methods defined in the library. Thanks |
Hi! Is this still actual? |
Yes, eg: import { keys } from "libp2p-crypto"
const privateKey = await keys.generateKeypair('secp256k1')
// this doesn't work
const peerId = await createFromPrivKey(privateKey.marshal())
// this works
const peerId = await createFromPrivKey(privateKey.bytes) |
@wemeetagain can you please elaborate on your example? I see that everything works in the tests https://github.com/libp2p/js-peer-id/blob/master/test/peer-id.spec.js#L214. From what I see the API has changed: const privKey = await crypto.keys.generateKeyPair('secp256k1', 256)
const id = await PeerId.createFromPrivKey(privKey.bytes) |
Ah, sorry, there are a bunch of bugs in my example. (I just updated it)
|
@wemeetagain As a beginner I can create a PR that updates documentation. Please look at the branch of my fork https://github.com/libp2p/js-peer-id/compare/master...vogdb:readme-privkey?expand=1. If it is ok then I will create it. If you want to change API to accept |
Doc Updates
The docs for
createFromPrivKey
currently reads:This is missleading as it requires a ProtoBuf.
We should clarify the documentation for this as users may try to use simple Buffer.
Improved Support
It would be nice if we improved the support for creating a peerid from a private key to accept a simple buffer. This could allow users to generate a keypair and use that privatekey to create their peerid. A use case of this might be an EC2 instance where the private key is stored in AWS KMS. It's possible to do this leveraging
libp2p-crypto
, but it would be nice if a factory method existed in peer-id to handle this for users.The text was updated successfully, but these errors were encountered: