Revisit how IPFS imports pre-made keys.
Hello,
I tried to follow the example provided in the documentation to import a key from a pem file and here is the result.
$ curl -X POST -F [email protected] "http://127.0.0.1:5001/api/v0/key/import?arg=test&ipns-base=base36"
{"Message":"proto: illegal wireType 7","Code":0,"Type":"error"}
I'm using ipfs version is 0.8.0
The HTTP error message looks like a protobuf error. Maybe my key is not formatted correctly.
The command I used to generate the key was ssh-keygen -t rsa which end up as a text file (and not a protobuf).
What is the required format for the keys and how to create them?
Also, the documentation says that :
- "Argument
keyis of file type": Does it means that I should rather use -F key[email protected] instead ? - "several files can be provided": Is it for importing several keys at the same time ? In that case how can I pass the name of each key ?
Thanks in advance for helping I'm trying to wrap my head around this for several hours now. I'm quite new to multipart/form-data so maybe this is why I'd wish also the documentation to be clearer.
Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additiona round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:
- "Priority" labels will show how urgent this is for the team.
- "Status" labels will show if this is ready to be worked on, blocked, or in progress.
- "Need" labels will indicate if additional input or analysis is required.
Finally, remember to use https://discuss.ipfs.io if you just need general support.
Sorry for the delay in getting to this issue. I just tried to import keys myself using the info in the docs, and it seems that they're not playing ball. I got a similar wireType error. I'll pull in an engineer from the Go-IPFS team to see if they can weigh in on what's going on here.
IPNS keys are libp2p keys which are defined in this spec (https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md#keys). The short version is that the key is wrapped in a protobuf that says what type it is.
If you construct the same protobuf format you'll be good to go (it's also a file, not an argument).
If you were going to construct the key file in Go you could use the tools in https://github.com/libp2p/go-libp2p-core/tree/master/crypto.
There's also some discussion of users constructing the key file using Python and Javascript in https://discuss.ipfs.io/t/how-can-i-set-my-own-ed25519-key/9183
Hello,
Sorry for the late reply. Thank you for your explanation, I was able to format the protobuf message. Unfortunately the import fails because the key has the wrong format (I tried to generate the key from several js librairies) I don't have time these days to search. I will try again later.
I find it sad that this process is not more straightforward (for the js/ts ecosystem). I think this is key for creating applications above IPFS and managing decentralized identification (DID). Maybe next time I try, someone will have provided an example (It certainly would help for choosing the right library for generating a key to the right format and how to encode it in the fileld of pb message).