Expand description
§Server identity with proof-of-work birth certificate
ServerId is the stable identity of a single server node. Unlike crate::tools::client_id::ClientId,
which costs nothing to produce, a ServerId is expensive: the server’s 32-byte Id
is the reversed bytes of a PoW hash computed over the server’s keys, a random
sponsor id, a timestamp, and a random content hash — with a minimum leading-zero-bit
count (SERVER_KEY_POW_MIN) configured in crate::tools::config.
Reversing the PoW hash means the id naturally has a large number of trailing
zero bits. The Kademlia DHT distributes responsibility by XOR distance, and the
trailing-zero structure spreads servers evenly across the keyspace while making
every id independently verifiable: anyone can recompute the PoW from the fields
embedded in the ServerId and confirm the id is real.
The PoW therefore acts as a “birth certificate” that gates server identities — you can’t cheaply spin up thousands of sybil servers targeting a specific keyspace region because each id costs real CPU time.
Beyond identity:
ServerId::to_peerwraps the identity into acrate::protocol::peer::Peerfor gossip on the DHT, signing the result with the server’s private key.ServerId::encode/ServerId::decodeprovide a compact fixed-length byte representation for on-disk persistence.ServerId::verifyre-runs the PoW check and confirms the embedded id matches.