encodeAndDecode :: (Binary a, Binary b) => KeyPair -> KeyPair -> Nonce -> a -> Maybe b
encodeAndDecode senderKeyPair receiverKeyPair nonce payload =
  let
    KeyPair _ receiverPublicKey = receiverKeyPair
    packet = DhtPacket.encode senderKeyPair receiverPublicKey nonce payload
    packet' = Binary.runGet Binary.get $ Binary.runPut $ Binary.put packet
  in
  DhtPacket.decode receiverKeyPair packet'
encodeAndDecode :: (Binary a, Binary b) => KeyPair -> KeyPair -> Nonce -> a -> Maybe b
encodeAndDecode senderKeyPair receiverKeyPair nonce payload =
  let
    KeyPair _ receiverPublicKey = receiverKeyPair
    packet = DhtPacket.encode senderKeyPair receiverPublicKey nonce payload
    packet' = Binary.runGet Binary.get $ Binary.runPut $ Binary.put packet
  in
  DhtPacket.decode receiverKeyPair packet'
encodeAndDecode senderKeyPair receiverKeyPair nonce payload =
  let
    KeyPair _ receiverPublicKey = receiverKeyPair
    packet = DhtPacket.encode senderKeyPair receiverPublicKey nonce payload
    packet' = Binary.runGet Binary.get $ Binary.runPut $ Binary.put packet
  in
  DhtPacket.decode receiverKeyPair packet'