elementToMessage :: Group group => Protocol group hashAlgorithm -> Element group -> ByteString
elementToMessage protocol element = prefix <> encodeElement (group protocol) element
  where
    prefix =
      case relation protocol of
        Symmetric _ -> "S"
        Asymmetric{us=SideA} -> "A"
        Asymmetric{us=SideB} -> "B"

-- | An error that occurs when interpreting messages from the other side of the exchange.
elementToMessage :: Group group => Protocol group hashAlgorithm -> Element group -> ByteString
elementToMessage protocol element = prefix <> encodeElement (group protocol) element
  where
    prefix =
      case relation protocol of
        Symmetric _ -> "S"
        Asymmetric{us=SideA} -> "A"
        Asymmetric{us=SideB} -> "B"

-- | An error that occurs when interpreting messages from the other side of the exchange.
elementToMessage protocol element = prefix <> encodeElement (group protocol) element
  where
    prefix =
      case relation protocol of
        Symmetric _ -> "S"
        Asymmetric{us=SideA} -> "A"
        Asymmetric{us=SideB} -> "B"

-- | An error that occurs when interpreting messages from the other side of the exchange.