# Are Peer IDs valid CID?

**URL:** <https://discuss.ipfs.tech/t/are-peer-ids-valid-cid/12617>\
**Category:** rust-ipfs\
**Created:** [November 10, 2021, 6:01pm UTC](https://discuss.ipfs.tech/t/are-peer-ids-valid-cid/12617 "2021-11-10T18:01:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SionoiS](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/sionois/32/5103_2.png) [@SionoiS](https://discuss.ipfs.tech/u/SionoiS)\
**Post date:** [November 10, 2021, 6:01pm UTC](https://discuss.ipfs.tech/t/are-peer-ids-valid-cid/12617/1 "2021-11-10T18:01:39Z")

</div>

See → [CID Inspector | IPFS](https://cid.ipfs.io/#12D3KooWRsEKtLGLW9FHw7t7dDhHrMDahw3VwssNgh55vksdvfmC)

This seams to imply that it’s valid but I read the docs and it does not conform to the [algo](https://github.com/multiformats/cid/blob/ef1b2002394b15b1e6c26c30545fd485f2c4c138/README.md#decoding-algorithm) 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.

---

<div class="post-metadata">

**Author:** ![zacharywhitley](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/zacharywhitley/32/2670_2.png) [@zacharywhitley](https://discuss.ipfs.tech/u/zacharywhitley)\
**Post date:** [November 10, 2021, 8:02pm UTC](https://discuss.ipfs.tech/t/are-peer-ids-valid-cid/12617/2 "2021-11-10T20:02:21Z")

</div>

From [https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md](https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md)

> There are two ways to represent peer IDs in text: as a raw [base58btc](https://en.bitcoinwiki.org/wiki/Base58#Alphabet_Base58) encoded multihash (e.g., `Qm...` , `1...` ) and as a [multibase](https://github.com/multiformats/multibase) encoded [CID](https://github.com/multiformats/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

---

<div class="post-metadata">

**Author:** ![SionoiS](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/sionois/32/5103_2.png) [@SionoiS](https://discuss.ipfs.tech/u/SionoiS)\
**Post date:** [November 11, 2021, 2:18pm UTC](https://discuss.ipfs.tech/t/are-peer-ids-valid-cid/12617/3 "2021-11-11T14:18:43Z")

</div>

Good find! Thanks.

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

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [November 11, 2021, 3:18pm UTC](https://discuss.ipfs.tech/t/are-peer-ids-valid-cid/12617/4 "2021-11-11T15:18:37Z")

</div>

[cid.ipfs.io](http://cid.ipfs.io) don’t decode them correctly that weird.

```auto
12D3KooWQpscgjKc5VRMhFCs1ckNLgNAbpbzhSPxd4tAN4HtEKhc

```

Decodes to :

```auto
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.
