PeerId class

Implementation of PeerId that follows the libp2p specification

Constructors

PeerId.new(Uint8List? _multihash)
PeerId.fromJson(Map<String, dynamic> json)
PeerId.fromPrivateKey(PrivateKey privateKey)
Creates a PeerId from a private key
PeerId.fromPublicKey(PublicKey publicKey)
Creates a PeerId from a public key
PeerId.fromString(String str)
Creates a PeerId from a string representation (either legacy or CIDv1)

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

extractPublicKey() Future<PublicKey?>
isValid() bool
loggable() Map<String, dynamic>
matchesPrivateKey(PrivateKey privateKey) bool
matchesPublicKey(PublicKey publicKey) bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shortString() String
toBase58() String
toBytes() Uint8List
toCid() → CID
ToCid encodes a peer ID as a CID of the public key.
toCIDString() String
Converts to the new CIDv1 format string (e.g., base32 encoded for v1)
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

decode(String s) PeerId
fromBytes(Uint8List bytes) PeerId
Creates a PeerId from bytes
fromCid(CID cid) PeerId
FromCid converts a CID to a peer ID, if possible.
fromMultihash(Uint8List bytes) PeerId
Creates a PeerId from a multihash
random() Future<PeerId>