cborg icon indicating copy to clipboard operation
cborg copied to clipboard

serialise: add deserialiseFullyOrFail

Open infinity0 opened this issue 3 years ago • 1 comments

This is useful in protocol-related logic where you want to be strict as possible and don't allow an attacker to send junk after a valid piece of data.

infinity0 avatar Nov 24 '20 19:11 infinity0

ping again on this :)

In case it wasn't clear, my last comment boils down to modifying this PR to instead have

tryDeserialise :: Serialise a => ByteString -> Either DeserialiseFailure (ByteString, a)
tryDeserialise = deserialiseFromBytes decode

the main purpose being to allow the user to avoid a direct dependency on cborg whilst also having full control over the decode process -- analogous to Data.Binary.decodeOrFail

infinity0 avatar Apr 21 '21 20:04 infinity0