Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Return type from generateKeyPair is inconsistent #129

Closed
achingbrain opened this issue Sep 7, 2018 · 3 comments
Closed

Return type from generateKeyPair is inconsistent #129

achingbrain opened this issue Sep 7, 2018 · 3 comments
Assignees
Labels
exp/expert Having worked on the specific codebase is important kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked

Comments

@achingbrain
Copy link
Member

If you specify rsa as the key type, you get an object with an export method. If you specify ed25519 you don't, which leads to:

$ jsipfs key gen -t rsa my-rsa-key
generated QmSdrjFr32xsvt6yLnD8LS8Uc4riNnRUS4eLT6qogYT2P9 my-rsa-key
$ jsipfs key gen -t ed25519 my-ed25519-key
/path/to/js-libp2p-keychain/src/keychain.js:206
          keypair.export(this._(), (err, pem) => {
                        ^

TypeError: keypair.export is not a function
    at keypair.id (/path/to/js-libp2p-keychain/src/keychain.js:206:25)
    at public.hash (/path/to/js-ipfs/node_modules/libp2p-crypto/src/keys/ed25519-class.js:97:7)
    at Multihashing.Multihashing.digest (/path/to/js-ipfs/node_modules/libp2p-crypto/node_modules/multihashing-async/src/index.js:33:5)
...

Go does not have the same problem:

$ ipfs key gen -t rsa my-rsa-key
QmTtWZKxgxkyGG4B7uW7eqkNPyuTKGwFGaqJx34hF8SCVL
$ ipfs key gen -t ed25519 my-ed25519-key
12D3KooWNXoeAFst3J9AUeJiKxcjecZL2v16Kq3UfVqK1ADWeaS5
@achingbrain
Copy link
Member Author

Digging a bit deeper it looks like ed25519 support was added to go-ipfs in response to ipfs/notes#241 (though it seems to stall on a discussion about first converting peer IDs to be v1 CIDs) and is awaiting ipfs/kubo#3896 to be merged. Full support never seems to have made it to js-ipfs.

@daviddias daviddias added kind/bug A bug in existing code (including security flaws) exp/expert Having worked on the specific codebase is important P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked labels Oct 31, 2018
@jacobheun
Copy link
Contributor

jacobheun commented Dec 19, 2018

This is a blocker for libp2p/js-peer-id#85 that I am going to be looking into.

@lidel
Copy link
Member

lidel commented Feb 11, 2022

ed25519 keys are the default in js-ipfs these days, this was fixed a while ago

$ jsipfs key gen -t rsa my-rsa-key 
generated QmPMwGnukVx2HKPHGGUg91MStuKwmePbLb78BuAzM9K73i my-rsa-key

$ jsipfs key gen -t ed25519 my-ed25519-key
generated 12D3KooWFBU6aMwR5DPzEZJD5jdFPnkXw8iB69HNytJq3kdikp5b my-ed25519-key

@lidel lidel closed this as completed Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/expert Having worked on the specific codebase is important kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

4 participants