Js-ipfs: Initializing nodes with a pre-baked private key

Created on 2 Feb 2017  路  9Comments  路  Source: ipfs/js-ipfs

Are there practices you'd suggest to initialize a node with a pre-baked private key? I ask because the files are always pulled into the .init call and I'd love to ensure a constant identity. It doesn't need to be the most secure option (I'm currently building for prototypes), but suggestions are welcome.

All 9 comments

For the ipfs.io gateways/bootstappers, we first init the repo, then overwrite the config file with what we actually want, then start the daemon

Thanks for the link @lgierth - much appreciated

Awesome, thank you for getting this one @lgierth :)

@diasdavid - I have a brief follow up on this: To give ipfs/pubsub + nomad a whirl we've been building a few sample apps to demo the possibilities. Today we wrapped up building an in-browser messaging app.

Using the file overwrite as Lars suggested works well in node, but when I want to init with a private key in the browser, do you have a recommendation as to how you'd approach it? After poking around the code, and due to time constraints, I ended up overloading the init function鈥攂ut this is clearly an unsustainable patch to get things working.

Any suggestions here?

Have you seen https://github.com/ipfs/js-ipfs/blob/master/test/utils/ipfs-factory-instance/index.js ? We have a default config here: https://github.com/ipfs/js-ipfs/blob/master/test/utils/ipfs-factory-instance/index.js#L82-L98 and load that one, in that example, we create a PeerId per node, but you can do a PeerId.createfromJSON instead, keeping the same peer id all the time.

Thank you @diasdavid鈥攚orking this into our library this morning!

@gavinmcdermott looking at doing the same thing, could you help me understand how you did this for the browser? How can I get my node instance setup with a private key I already have?

This isn't a solution to the original issue, but I would like to save people who end up here from Google like me.

PSA: If you want to maintain a constant identity/private key across tabs and page refreshes, just use a fixed repo name when initializing your IPFS node in the browser and it will happen automatically.

Was this page helpful?
0 / 5 - 0 ratings