Peers & Peer IDs

Cryptography

A Peer Identity is a unique reference to a specific peer within the overall peer-to-peer network.

As well as serving as a unique identifier for each peer, a Peer ID is a verifiable link between a peer and its public cryptographic key.

Each libp2p peer controls a private key, which it keeps secret from all other peers. Every private key has a corresponding public key, which is shared with other peers.

Together, the public and private key (or "key pair") allow peers to establish secure communication channels with each other.

Conceptually, a Peer ID is a cryptographic hash of a peer’s public key. When peers establish a secure channel, the hash can be used to verify that the public key used to secure the channel is the same one used to identify the peer.

The Peer ID spec goes into detail about the byte formats used for libp2p public keys and how to hash the key to produce a valid Peer ID.

https://docs.libp2p.io/concepts/fundamentals/peers/


Peer IDs are the cornerstone of authentication and should always be generated in a deterministic manner. We suggest NEVER using randomly generated peer_id's to ensure signatures can be authenticated for secure communication channels within the subnet.

Peer IDs in the subnet must match the peer IDs registered on-chain.

Each subnet validator node should generate three peer IDs: a main peer ID for communication, a bootnode peer ID, and a client peer ID. When registering a subnet on-chain, all peer IDs are required.

Peer IDs

Main Peer ID

The main peer ID is used for the validator node and all communications. This will be used to authenticate proof of stake from the Hypertensor blockchain to the subnet, and for authentication between communication of other peers in the subnet.

Bootnode Peer ID

The bootnode peer ID is used specifically for the bootnode node. This bootnode peer ID is also tied to the same subnet node on-chain and is also used for proof-of-stake.

What is a bootstrap or bootnode?

When a new node joins a decentralized network, it needs to connect to nodes that are already on the network in order to then discover new peers. These entry points into the network are called bootnode nodes (or bootnodes). Subnets should have a public list of bootnode nodes in their documentation for other nodes to connect to.

Bootnode nodes do not validate anything, but are an entry point for others to connect to.

The main validator nodes that run application logic can be bootnode nodes, although it is suggested not to use these nodes as entry points and not make these IPs and ports known to the general public.

Client Peer ID

The client peer ID is designed for use as a client, such as for hosting a frontend for an inference subnet.


Generating Peer IDs Deterministically

Private keys for the subnet peer (not to be confused with the blockchain account private key) can be generated with the following CLI command:

keygen \
    --path path_to_store_main_peer_pk.key \
    --bootstrap_path path_to_store_bootstrap_peer_pk.key \
    --client_path path_to_store_client_peer_pk.key \
    --key_type ed25519

Last updated