| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Network.LibP2P.Core.Multihash
Description
Multihash encoding/decoding.
Multihash is a self-describing hash format: hash-function-codedigest-sizedigest Used for Peer ID derivation and content addressing.
Synopsis
- data HashFunction
- encodeMultihash :: HashFunction -> ByteString -> ByteString
- decodeMultihash :: ByteString -> Either String (HashFunction, ByteString)
- validateMultihash :: ByteString -> Either String (HashFunction, ByteString)
Documentation
data HashFunction Source #
Supported hash functions for multihash encoding.
Instances
| Show HashFunction Source # | |
Defined in Network.LibP2P.Core.Multihash Methods showsPrec :: Int -> HashFunction -> ShowS # show :: HashFunction -> String # showList :: [HashFunction] -> ShowS # | |
| Eq HashFunction Source # | |
Defined in Network.LibP2P.Core.Multihash | |
encodeMultihash :: HashFunction -> ByteString -> ByteString Source #
Encode data as a multihash. For Identity: stores raw bytes. For SHA256: hashes first, stores digest.
decodeMultihash :: ByteString -> Either String (HashFunction, ByteString) Source #
Decode a multihash into its hash function and digest/data. Note: does not reject trailing bytes after the digest.
validateMultihash :: ByteString -> Either String (HashFunction, ByteString) Source #
Validate a multihash strictly: decode, check digest length constraints, and reject trailing bytes.