Are Peer IDs valid CID?

See → CID Inspector | IPFS

This seams to imply that it’s valid but I read the docs and it does not conform to the algo for CID.

Also tried to go from Peer ID utf-8 string to CID with rust-cid and it’s not valid.

What is happening here? I’m confused.

From specs/peer-ids.md at master · libp2p/specs · GitHub

There are two ways to represent peer IDs in text: as a raw base58btc encoded multihash (e.g., Qm... , 1... ) and as a multibase encoded CID (e.g., bafz... ). Libp2p is slowly transitioning from the first (legacy) format to the second (new).

Implementations MUST support parsing both forms of peer IDs. Implementations SHOULD display peer IDs using the first (raw base58btc encoded multihash) format until the second format is widely supported.

Maybe your’e using a PeerID in the first format as a raw base58btc

1 Like

Good find! Thanks.

When the CID inspector works on the string you provide one would assume it’s a valid CID, am I wrong?

cid.ipfs.io don’t decode them correctly that weird.

12D3KooWQpscgjKc5VRMhFCs1ckNLgNAbpbzhSPxd4tAN4HtEKhc

Decodes to :

base58btc - cidv0 - dag-pb - (identity : 288 : 08011220DF00999B28EF4127B1B5FB952B630C8B841ED2AB7A4F404E0083BE8C5BEBE033)

Because that clearly not a CIDv0 (CIDv0 is Qm... 46 characters).
However the 288 bits long ECC key looks good.