-
Notifications
You must be signed in to change notification settings - Fork 1.2k
JS-IPFS misrepresents key IDs when Ed25519 keys are generated #3591
Comments
This comment has been minimized.
This comment has been minimized.
The bytes listed decode to I believe if these are encoded using |
What's odd is that the output of a ~ 2h 17m 14.2s ❱ ipfs key list
self
derp
trains
~ ❱ ipfs key list -l
k51qzi5uqu5dj4xrzah5jq2pyrkivhvex4o0ahuxrwm7502ftn87id0u7tqo6m self
k51qzi5uqu5dku8yffnih1qtxv5fynst4v01du45hzsd9tmuuat3l97ebchlzg derp
k51qzi5uqu5dl6ewcsn0advx9ajfjl0vur383jysnvgjcptgljgqpc32q2suaf trains How can I get these IPNS name values in |
This looks like Ed25519 keys aren't being handled correctly. Would you like to open a PR with a fix? A test should be added to the interface suite here: https://github.com/ipfs/js-ipfs/blob/master/packages/interface-ipfs-core/src/key/list.js They are returned from libp2p here: https://github.com/ipfs/js-ipfs/blob/master/packages/ipfs-core/src/components/key/list.js libp2p returns them here: https://github.com/libp2p/js-libp2p/blob/master/src/keychain/index.js#L250 The bug might be on this line where the key gets added to the datastore, it may not be handling the serialization properly: https://github.com/libp2p/js-libp2p/blob/master/src/keychain/index.js#L227 |
@achingbrain Fix proposed here: libp2p/js-libp2p-crypto#185 |
As discussed here: ipfs/js-ipfs#3591 Satisfy linter test: actually verify ids
As discussed here: ipfs/js-ipfs#3591 Satisfy linter test: actually verify ids
The fix has been released in |
Update on this based on chat room. EdDSA/Ed25519 keys are still returning Qm multihashes (should be 12D). |
@achingbrain @jacobheun Further fixes to this issue have been proposed in libp2p/js-libp2p-crypto#186. |
* Fix Ed25519 PeerID generation This commit pushes further fixes to the generation of Ed25519 peer IDs, building upon the discussion in ipfs/js-ipfs#3591 and the subsequent pull request #185. The purpose of this new pull request is to harmonize the encoding of PeerIDs for Ed25519 keys such that the same new format is used everywhere: peer IDs when assigned upon key generation, peer IDs when shown via key listing, as well as the peer IDs displayed as IPNS names when the key is used as the basis for an IPNS record. Concretely, this changes the peer ID representation of Ed25519 keys from the `Qm...` format to the newer `1...` format. The accompanying test has been modified accordingly. * Satisfy linter
Latest version is out now, |
@jacobheun Your quick responses and version updates are helping us push forward with building on top of IPFS. Thank you very much. |
I created #3693 to explore if we in a place where we can switch js-ipfs to generate ED25519 by default, just like go-ipfs does. (At some point we should switch both js-ipfs and go-ipfs to output peerids as CIDv1 in Base36, so the same text representation is works in subdomains, but we need ED25519 first) |
Switch from RSA to ed25519 to match what we already do in go-ipfs. Closes #3591 Co-authored-by: achingbrain <alex@achingbrain.net>
Switch from RSA to ed25519 to match what we already do in go-ipfs. Closes ipfs/js-ipfs#3591 Co-authored-by: achingbrain <alex@achingbrain.net>
Platform:
Darwin Nadims-Mac.home 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
Subsystem: Probably
libp2p-crypto
Severity: Medium/High
Description:
JS-IPFS does not correctly encode key IDs in the case of Ed25519 keys:
Gives us:
The key ID for the
self
key, an RSA key, appears to be encoded correctly as a Qm multihash. However the key ID for the example Ed25519 key appears to be encoded as an odd string of bytes represented in decimal format. It looks to me like this encoding is incorrect or corrupted somehow.I'm not sure what the procedure is to turn this bad encoding into a real ID, although, the following does seem to produce something resembling a QmHash:
I don't know if I can expect the resulting value from the above to be reliable. Either way the output does not seem correct and clarification on this issue is appreciated.
The text was updated successfully, but these errors were encountered: