| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.Crypto.Protobuf
Description
Deterministic protobuf encoding for libp2p PublicKey/PrivateKey messages.
Hand-rolled encoding to guarantee deterministic output: - Minimal varint encoding - Fields in field number order (Type=1, Data=2) - All fields present, no extras
Both messages share the same wire layout (per the peer-ids spec):
message PublicKey { required KeyType Type = 1; required bytes Data = 2; }
message PrivateKey { required KeyType Type = 1; required bytes Data = 2; }Synopsis
Documentation
encodePublicKey :: PublicKey -> ByteString Source #
Deterministic protobuf encoding of a PublicKey message.
decodePublicKey :: ByteString -> Either String PublicKey Source #
Decode a protobuf-encoded PublicKey message.
encodePrivateKey :: PrivateKey -> ByteString Source #
Deterministic protobuf encoding of a PrivateKey message. Note that PrivateKey messages are never sent over the wire; this is the on-disk format shared by libp2p implementations.
decodePrivateKey :: ByteString -> Either String PrivateKey Source #
Decode a protobuf-encoded PrivateKey message, e.g. a key file written
by another implementation. The Data field is returned as-is; use
keyPairFromPrivateKey to validate it and derive the
public key.