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
PeerId objects not properly supported as argument to options.init privateKey entry #2261
Comments
|
I think we just need to add a PeerId "type" to Line 10 in 7544785
Would you be willing to send a PR? |
|
Yup, willing and able |
|
I'm not particularly familiar with |
|
I imagined the |
|
I believe this should be supported now, assigning myself to check. |
|
This is fixed, I was able to create and start a new node with this code: const PeerId = require('peer-id')
const IPFS = require('ipfs')
;(async function() {
const peerId = await PeerId.create({ bits: 256, keyType: 'ed25519' })
const node = await IPFS.create({
init: {
privateKey: peerId,
}
})
await node.start()
await node.stop()
})() |
|
@jacobheun I'm trying the same, but my init object is not taken into account. It does not matter what peer id I feed to init, my node always has the same id. Probably as defined somewhere in ~/.jsipfs |
|
@domwoe if you already have an initialized repo (~/.jsipfs is not empty) your existing key will always be used. You should be able to check the existing key in the ~/.jsipfs/config file. |
|
@jacobheun I think this issue should remain open until libp2p-keychain supports keys other than RSA. libp2p-keychain does not appear to be working with ed25519 keys. As soon as you try to use the ipfs node above created with an ed25519 key, you get a keychain pirvateKey.export error
KeyChain import/export is still tightly designed to RSA keys, and fails with any other key. We need to be able to import/export non-RSA keys to the keychain |
|
The ed25519 key issue is being tracked at #2553, it's high on our list to get resolved. |
carsonfarmer commentedJul 16, 2019
•
edited
Version:
{ version: '0.36.4', repo: 7, commit: '' }Platform:
Darwin carson.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64Subsystem:
new IPFS({}), based onlibp2p/js-peer-idThis should work (in Typescript):
Here's a simpler pure JS version:
However, I keep seeing
TypeError: Expected a value of type boolean | {bits,emptyRepo,privateKey,pass} | undefined for init but received {"privateKey":{"id":"blah","privKey":"blah","pubKey":"blah"}}. The 'fix' (thanks to @Stebalien) is to do something like:I ended up needing the
toB58Stringmethod onPeerId(see alternative below), as this is expected inipfs/src/core/components/init.js:92:26hence the alternative (which also seems to work):
Then, using
privateKeyin our IPFS init call works nicely.This seems to be associated with the
superstructdefinition. In fact, it seems there is a comment alluding to this fact in there: https://github.com/ipfs/js-ipfs/blob/master/src/core/config.js#L38.So the 'fix' here is either, support things other than objects in
options, or document that a 'raw' PeerId doesn't quite work here?Happy to provide additional examples if needed.
The text was updated successfully, but these errors were encountered: