diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-08-11 17:06:47 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-08-11 17:06:47 -0400 |
commit | dca9a15b797e30b095f306955310a40f2d1013b5 (patch) | |
tree | ad555b482bb22e4da74ad5f50c286d8a8c96612c /Serialization.hs | |
parent | 34c15caaaa96689dd342999f7d9a098903fd25b9 (diff) | |
download | keysafe-dca9a15b797e30b095f306955310a40f2d1013b5.tar.gz |
Shard data type
Diffstat (limited to 'Serialization.hs')
-rw-r--r-- | Serialization.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Serialization.hs b/Serialization.hs index 15f8881..4d6a671 100644 --- a/Serialization.hs +++ b/Serialization.hs @@ -33,5 +33,15 @@ instance Encodable StorableObjectIdent where toByteString (StorableObjectIdent i) = i fromByteString = Just . StorableObjectIdent +instance Encodable StorableObject where + toByteString (StorableObject b) = b + fromByteString = Just . StorableObject + +-- | A shard is serialized without its shard number. This prevents +-- an attacker from partitioning their shards by shard number. +instance Encodable Shard where + toByteString (Shard _n o) = toByteString o + fromByteString _ = Nothing + sepChar :: Word8 sepChar = 32 |