PeerKeyRegistry class

Registry for caching and verifying bindings between PeerId strings and their corresponding Ed25519 public keys.

In IPFS/libp2p, a peer's identity is derived from its public key (PeerId.fromPublicKey). Because the SHA-256 derivation is one-way, remote public keys must either be supplied alongside signed payloads or discovered via the Identify protocol.

PeerKeyRegistry verifies that any supplied public key cryptographically hashes to the peer ID before storing it, preventing identity spoofing.

Constructors

PeerKeyRegistry()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → int
Number of registered peer keys.
no setter

Methods

clear() → void
Clears all registered keys.
getPublicKey(String peerId) → Uint8List?
Retrieves the verified public key bytes for peerId, or null if not registered.
hasPublicKey(String peerId) → bool
Checks if a verified public key is registered for peerId.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerPublicKey(String peerId, Uint8List publicKeyBytes) → bool
Registers publicKeyBytes for peerId after verifying cryptographic binding.
removeKey(String peerId) → void
Removes a stored key for peerId.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

verifyPeerBinding(String peerId, Uint8List publicKeyBytes) → bool
Verifies that publicKeyBytes cryptographically derives to peerId.

Constants

maxRegisteredKeys → const int
Maximum verified key bindings retained. Keys arrive from remote peers (pubsub messages, identify) so the map must stay bounded; the oldest-registered binding is evicted when the cap is hit and will be re-registered on the peer's next message or identify exchange.