@staticmethod
def peer_id(pk_bytes: Union[(str, BytesLike)]) -> 'CID':
    '\n            Wraps the raw hash of a public key into a `PeerID <https://docs.libp2p.io/concepts/peer-id/>`_, as a CIDv1.\n\n            The ``pk_bytes`` argument should be the binary public key, encoded according to the\n            `PeerID spec <https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md>`_.\n            This can be passed as a bytestring or as a hex string (which will be converted to :obj:`bytes` using :obj:`bytes.fromhex`).\n            Note: the hex string is not multibase encoded.\n\n            Example usage with Ed25519 public key:\n\n            >>> pk_bytes = bytes.fromhex(\n            ... "1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93")\n            ... # a 32-byte Ed25519 public key\n            >>> peer_id = CID.peer_id(pk_bytes)\n            >>> peer_id\n            CID(\'base32\', 1, \'libp2p-key\',\n            \'00201498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93\')\n            #^^   0x00 = \'identity\' multihash used (public key length <= 42)\n            #  ^^ 0x20 = 32-bytes of raw hash digestlength\n            >>> str(peer_id)\n            \'bafzaaiautc2um6td375c3soz4bu4v4dv2fx4gp65jq5qdp5nvzsdg5t5sm\'\n\n            Snippet showing how to obtain the `Ed25519 <https://cryptography.io/en/latest/hazmat/primitives/asymmetric/ed25519/>`_\n            public key bytestring using the `cryptography <https://github.com/pyca/cryptography>`_ library:\n\n            >>> from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey\n            >>> from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat\n            >>> private_key = Ed25519PrivateKey.generate()\n            >>> public_key = private_key.public_key()\n            >>> pk_bytes = public_key.public_bytes(\n            ...     encoding=Encoding.Raw,\n            ...     format=PublicFormat.Raw\n            ... )\n            >>> pk_bytes.hex()\n            "1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93"\n\n            Example usage with DER-encoded RSA public key:\n\n            >>> pk_bytes = bytes.fromhex(\n            ... "30820122300d06092a864886f70d01010105000382010f003082010a02820101"\n            ... "009a56a5c11e2705d0bfe0cd1fa66d5e519095cc741b62ed99ddf129c32e046e"\n            ... "5ba3958bb8a068b05a95a6a0623cc3c889b1581793cd84a34cc2307e0dd74c70"\n            ... "b4f230c74e5063ecd8e906d372be4eba13f47d04427a717ac78cb12b4b9c2ab5"\n            ... "591f36f98021a70f84d782c36c51819054228ff35a45efa3f82b27849ec89036"\n            ... "26b4a4c4b40f9f74b79caf55253687124c79cb10cd3bc73f0c44fbd341e5417d"\n            ... "2e85e900d22849d2bc85ca6bf037f1f5b4f9759b4b6942fccdf1140b30ea7557"\n            ... "87deb5c373c5953c14d64b523959a76a32a599903974a98cf38d4aaac7e359f8"\n            ... "6b00a91dcf424bf794592139e7097d7e65889259227c07155770276b6eda4cec"\n            ... "370203010001")\n            ... # a 294-byte RSA public key\n            >>> peer_id = CID.peer_id(pk_bytes)\n            >>> peer_id\n            CID(\'base32\', 1, \'libp2p-key\',\n            \'1220c1a6513ffb14f202f75453c49666a5b9d7ed9a1a068891daf824d477573f829f\')\n            #^^   0x12 = \'sha2-256\' multihash used (public key length > 42)\n            #  ^^ 0x20 = 32-bytes of raw hash digest length\n            >>> str(peer_id)\n            \'bafzbeigbuzit76yu6ibpovctyslgnjnz27wzugqgrci5v6be2r3vop4ct4\'\n\n            Snippet showing how to obtain the `RSA <https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/>`_\n            public key bytestring using the `cryptography <https://github.com/pyca/cryptography>`_ library:\n\n            >>> from cryptography.hazmat.primitives.asymmetric import rsa\n            >>> from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat\n            >>> private_key = rsa.generate_private_key(\n            ...     public_exponent=65537,\n            ...     key_size=2048,\n            ... )\n            >>> public_key = private_key.public_key()\n            >>> pk_bytes = public_key.public_bytes(\n            ...     encoding=Encoding.DER,\n            ...     format=PublicFormat.SubjectPublicKeyInfo\n            ... )\n            >>> pk_bytes.hex()\n            "30820122300d06092a864886f70d01010105000382010f003082010a02820101"\n            "009a56a5c11e2705d0bfe0cd1fa66d5e519095cc741b62ed99ddf129c32e046e"\n            "5ba3958bb8a068b05a95a6a0623cc3c889b1581793cd84a34cc2307e0dd74c70"\n            "b4f230c74e5063ecd8e906d372be4eba13f47d04427a717ac78cb12b4b9c2ab5"\n            "591f36f98021a70f84d782c36c51819054228ff35a45efa3f82b27849ec89036"\n            "26b4a4c4b40f9f74b79caf55253687124c79cb10cd3bc73f0c44fbd341e5417d"\n            "2e85e900d22849d2bc85ca6bf037f1f5b4f9759b4b6942fccdf1140b30ea7557"\n            "87deb5c373c5953c14d64b523959a76a32a599903974a98cf38d4aaac7e359f8"\n            "6b00a91dcf424bf794592139e7097d7e65889259227c07155770276b6eda4cec"\n            "370203010001"\n\n            :param pk_bytes: the public key bytes\n            :type pk_bytes: :obj:`str` or :obj:`~multiformats.varint.BytesLike`\n\n            :raises ValueError: if ``pk_bytes`` is passed as a string and is not the hex-string of some bytes\n\n            '
    if isinstance(pk_bytes, str):
        pk_bytes = bytes.fromhex(pk_bytes)
    else:
        validate(pk_bytes, BytesLike)
    if (len(pk_bytes) <= 42):
        mh = multihash.get('identity')
        digest = multihash.digest(pk_bytes, mh)
    else:
        mh = multihash.get('sha2-256')
        digest = multihash.digest(pk_bytes, mh)
    mc = multicodec.get(code=114)
    mb = multibase.get('base32')
    return CID._new_instance(CID, mb, 1, mc, mh, digest)
Wraps the raw hash of a public key into a `PeerID <https://docs.libp2p.io/concepts/peer-id/>`_, as a CIDv1.

The ``pk_bytes`` argument should be the binary public key, encoded according to the
`PeerID spec <https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md>`_.
This can be passed as a bytestring or as a hex string (which will be converted to :obj:`bytes` using :obj:`bytes.fromhex`).
Note: the hex string is not multibase encoded.

Example usage with Ed25519 public key:

>>> pk_bytes = bytes.fromhex(
... "1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93")
... # a 32-byte Ed25519 public key
>>> peer_id = CID.peer_id(pk_bytes)
>>> peer_id
CID('base32', 1, 'libp2p-key',
'00201498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93')
#^^   0x00 = 'identity' multihash used (public key length <= 42)
#  ^^ 0x20 = 32-bytes of raw hash digestlength
>>> str(peer_id)
'bafzaaiautc2um6td375c3soz4bu4v4dv2fx4gp65jq5qdp5nvzsdg5t5sm'

Snippet showing how to obtain the `Ed25519 <https://cryptography.io/en/latest/hazmat/primitives/asymmetric/ed25519/>`_
public key bytestring using the `cryptography <https://github.com/pyca/cryptography>`_ library:

>>> from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
>>> from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
>>> private_key = Ed25519PrivateKey.generate()
>>> public_key = private_key.public_key()
>>> pk_bytes = public_key.public_bytes(
...     encoding=Encoding.Raw,
...     format=PublicFormat.Raw
... )
>>> pk_bytes.hex()
"1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93"

Example usage with DER-encoded RSA public key:

>>> pk_bytes = bytes.fromhex(
... "30820122300d06092a864886f70d01010105000382010f003082010a02820101"
... "009a56a5c11e2705d0bfe0cd1fa66d5e519095cc741b62ed99ddf129c32e046e"
... "5ba3958bb8a068b05a95a6a0623cc3c889b1581793cd84a34cc2307e0dd74c70"
... "b4f230c74e5063ecd8e906d372be4eba13f47d04427a717ac78cb12b4b9c2ab5"
... "591f36f98021a70f84d782c36c51819054228ff35a45efa3f82b27849ec89036"
... "26b4a4c4b40f9f74b79caf55253687124c79cb10cd3bc73f0c44fbd341e5417d"
... "2e85e900d22849d2bc85ca6bf037f1f5b4f9759b4b6942fccdf1140b30ea7557"
... "87deb5c373c5953c14d64b523959a76a32a599903974a98cf38d4aaac7e359f8"
... "6b00a91dcf424bf794592139e7097d7e65889259227c07155770276b6eda4cec"
... "370203010001")
... # a 294-byte RSA public key
>>> peer_id = CID.peer_id(pk_bytes)
>>> peer_id
CID('base32', 1, 'libp2p-key',
'1220c1a6513ffb14f202f75453c49666a5b9d7ed9a1a068891daf824d477573f829f')
#^^   0x12 = 'sha2-256' multihash used (public key length > 42)
#  ^^ 0x20 = 32-bytes of raw hash digest length
>>> str(peer_id)
'bafzbeigbuzit76yu6ibpovctyslgnjnz27wzugqgrci5v6be2r3vop4ct4'

Snippet showing how to obtain the `RSA <https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/>`_
public key bytestring using the `cryptography <https://github.com/pyca/cryptography>`_ library:

>>> from cryptography.hazmat.primitives.asymmetric import rsa
>>> from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
>>> private_key = rsa.generate_private_key(
...     public_exponent=65537,
...     key_size=2048,
... )
>>> public_key = private_key.public_key()
>>> pk_bytes = public_key.public_bytes(
...     encoding=Encoding.DER,
...     format=PublicFormat.SubjectPublicKeyInfo
... )
>>> pk_bytes.hex()
"30820122300d06092a864886f70d01010105000382010f003082010a02820101"
"009a56a5c11e2705d0bfe0cd1fa66d5e519095cc741b62ed99ddf129c32e046e"
"5ba3958bb8a068b05a95a6a0623cc3c889b1581793cd84a34cc2307e0dd74c70"
"b4f230c74e5063ecd8e906d372be4eba13f47d04427a717ac78cb12b4b9c2ab5"
"591f36f98021a70f84d782c36c51819054228ff35a45efa3f82b27849ec89036"
"26b4a4c4b40f9f74b79caf55253687124c79cb10cd3bc73f0c44fbd341e5417d"
"2e85e900d22849d2bc85ca6bf037f1f5b4f9759b4b6942fccdf1140b30ea7557"
"87deb5c373c5953c14d64b523959a76a32a599903974a98cf38d4aaac7e359f8"
"6b00a91dcf424bf794592139e7097d7e65889259227c07155770276b6eda4cec"
"370203010001"

:param pk_bytes: the public key bytes
:type pk_bytes: :obj:`str` or :obj:`~multiformats.varint.BytesLike`

:raises ValueError: if ``pk_bytes`` is passed as a string and is not the hex-string of some bytes
@staticmethod
def peer_id(pk_bytes: Union[(str, BytesLike)]) -> 'CID':
    '\n            Wraps the raw hash of a public key into a `PeerID <https://docs.libp2p.io/concepts/peer-id/>`_, as a CIDv1.\n\n            The ``pk_bytes`` argument should be the binary public key, encoded according to the\n            `PeerID spec <https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md>`_.\n            This can be passed as a bytestring or as a hex string (which will be converted to :obj:`bytes` using :obj:`bytes.fromhex`).\n            Note: the hex string is not multibase encoded.\n\n            Example usage with Ed25519 public key:\n\n            >>> pk_bytes = bytes.fromhex(\n            ... "1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93")\n            ... # a 32-byte Ed25519 public key\n            >>> peer_id = CID.peer_id(pk_bytes)\n            >>> peer_id\n            CID(\'base32\', 1, \'libp2p-key\',\n            \'00201498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93\')\n            #^^   0x00 = \'identity\' multihash used (public key length <= 42)\n            #  ^^ 0x20 = 32-bytes of raw hash digestlength\n            >>> str(peer_id)\n            \'bafzaaiautc2um6td375c3soz4bu4v4dv2fx4gp65jq5qdp5nvzsdg5t5sm\'\n\n            Snippet showing how to obtain the `Ed25519 <https://cryptography.io/en/latest/hazmat/primitives/asymmetric/ed25519/>`_\n            public key bytestring using the `cryptography <https://github.com/pyca/cryptography>`_ library:\n\n            >>> from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey\n            >>> from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat\n            >>> private_key = Ed25519PrivateKey.generate()\n            >>> public_key = private_key.public_key()\n            >>> pk_bytes = public_key.public_bytes(\n            ...     encoding=Encoding.Raw,\n            ...     format=PublicFormat.Raw\n            ... )\n            >>> pk_bytes.hex()\n            "1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93"\n\n            Example usage with DER-encoded RSA public key:\n\n            >>> pk_bytes = bytes.fromhex(\n            ... "30820122300d06092a864886f70d01010105000382010f003082010a02820101"\n            ... "009a56a5c11e2705d0bfe0cd1fa66d5e519095cc741b62ed99ddf129c32e046e"\n            ... "5ba3958bb8a068b05a95a6a0623cc3c889b1581793cd84a34cc2307e0dd74c70"\n            ... "b4f230c74e5063ecd8e906d372be4eba13f47d04427a717ac78cb12b4b9c2ab5"\n            ... "591f36f98021a70f84d782c36c51819054228ff35a45efa3f82b27849ec89036"\n            ... "26b4a4c4b40f9f74b79caf55253687124c79cb10cd3bc73f0c44fbd341e5417d"\n            ... "2e85e900d22849d2bc85ca6bf037f1f5b4f9759b4b6942fccdf1140b30ea7557"\n            ... "87deb5c373c5953c14d64b523959a76a32a599903974a98cf38d4aaac7e359f8"\n            ... "6b00a91dcf424bf794592139e7097d7e65889259227c07155770276b6eda4cec"\n            ... "370203010001")\n            ... # a 294-byte RSA public key\n            >>> peer_id = CID.peer_id(pk_bytes)\n            >>> peer_id\n            CID(\'base32\', 1, \'libp2p-key\',\n            \'1220c1a6513ffb14f202f75453c49666a5b9d7ed9a1a068891daf824d477573f829f\')\n            #^^   0x12 = \'sha2-256\' multihash used (public key length > 42)\n            #  ^^ 0x20 = 32-bytes of raw hash digest length\n            >>> str(peer_id)\n            \'bafzbeigbuzit76yu6ibpovctyslgnjnz27wzugqgrci5v6be2r3vop4ct4\'\n\n            Snippet showing how to obtain the `RSA <https://cryptography.io/en/latest/hazmat/primitives/asymmetric/rsa/>`_\n            public key bytestring using the `cryptography <https://github.com/pyca/cryptography>`_ library:\n\n            >>> from cryptography.hazmat.primitives.asymmetric import rsa\n            >>> from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat\n            >>> private_key = rsa.generate_private_key(\n            ...     public_exponent=65537,\n            ...     key_size=2048,\n            ... )\n            >>> public_key = private_key.public_key()\n            >>> pk_bytes = public_key.public_bytes(\n            ...     encoding=Encoding.DER,\n            ...     format=PublicFormat.SubjectPublicKeyInfo\n            ... )\n            >>> pk_bytes.hex()\n            "30820122300d06092a864886f70d01010105000382010f003082010a02820101"\n            "009a56a5c11e2705d0bfe0cd1fa66d5e519095cc741b62ed99ddf129c32e046e"\n            "5ba3958bb8a068b05a95a6a0623cc3c889b1581793cd84a34cc2307e0dd74c70"\n            "b4f230c74e5063ecd8e906d372be4eba13f47d04427a717ac78cb12b4b9c2ab5"\n            "591f36f98021a70f84d782c36c51819054228ff35a45efa3f82b27849ec89036"\n            "26b4a4c4b40f9f74b79caf55253687124c79cb10cd3bc73f0c44fbd341e5417d"\n            "2e85e900d22849d2bc85ca6bf037f1f5b4f9759b4b6942fccdf1140b30ea7557"\n            "87deb5c373c5953c14d64b523959a76a32a599903974a98cf38d4aaac7e359f8"\n            "6b00a91dcf424bf794592139e7097d7e65889259227c07155770276b6eda4cec"\n            "370203010001"\n\n            :param pk_bytes: the public key bytes\n            :type pk_bytes: :obj:`str` or :obj:`~multiformats.varint.BytesLike`\n\n            :raises ValueError: if ``pk_bytes`` is passed as a string and is not the hex-string of some bytes\n\n            '
    if isinstance(pk_bytes, str):
        pk_bytes = bytes.fromhex(pk_bytes)
    else:
        validate(pk_bytes, BytesLike)
    if (len(pk_bytes) <= 42):
        mh = multihash.get('identity')
        digest = multihash.digest(pk_bytes, mh)
    else:
        mh = multihash.get('sha2-256')
        digest = multihash.digest(pk_bytes, mh)
    mc = multicodec.get(code=114)
    mb = multibase.get('base32')
    return CID._new_instance(CID, mb, 1, mc, mh, digest)