libp2p-hs-0.1.0.0: Haskell implementation of the libp2p networking stack
Safe HaskellNone
LanguageGHC2021

Network.LibP2P.Crypto.PeerId

Description

Peer ID derivation from public keys.

A Peer ID is a multihash of the serialized PublicKey protobuf message. Ed25519 keys (36 bytes serialized) use identity multihash. Larger keys (RSA) use SHA-256 multihash.

Synopsis

Documentation

newtype PeerId Source #

A Peer ID is a multihash of the serialized public key.

Constructors

PeerId ByteString 

Instances

Instances details
Show PeerId Source # 
Instance details

Defined in Network.LibP2P.Crypto.PeerId

Eq PeerId Source # 
Instance details

Defined in Network.LibP2P.Crypto.PeerId

Methods

(==) :: PeerId -> PeerId -> Bool #

(/=) :: PeerId -> PeerId -> Bool #

Ord PeerId Source # 
Instance details

Defined in Network.LibP2P.Crypto.PeerId

fromPublicKey :: PublicKey -> PeerId Source #

Derive a Peer ID from a public key.

toBase58 :: PeerId -> Text Source #

Encode a Peer ID as base58btc text.

fromBase58 :: Text -> Either String PeerId Source #

Decode a Peer ID from base58btc text. Validates that decoded bytes are a well-formed multihash.

peerIdBytes :: PeerId -> ByteString Source #

Get the raw multihash bytes of a Peer ID.

parsePeerId :: Text -> Either String PeerId Source #

Parse a Peer ID from text, accepting both base58btc and CIDv1 (base32lower) formats. CIDv1 format: b prefix + base32lower(0x01 || 0x72 || multihash)

toCIDv1 :: PeerId -> Text Source #

Encode a Peer ID as CIDv1 text (base32lower, no padding). Format: b + base32lower(varint(1) + varint(0x72) + multihash_bytes)