Copyright | Peter Robinson 2014 |
---|---|
License | LGPL |
Maintainer | Peter Robinson <peter.robinson@monoid.at> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
- data Fragment = Fragment {
- fragmentId :: !Int
- trailLength :: !Int
- reconstructionThreshold :: !Int
- theContent :: ![FField]
- msgLength :: !Int
- encode :: Int -> Int -> ByteString -> [Fragment]
- decode :: [Fragment] -> ByteString
- toIntVec :: Int -> ByteString -> (Vector FField, Int)
- fromIntVec :: Int -> Vector FField -> ByteString
- groupInto :: Int -> Vector a -> [Vector a]
Documentation
A fragment of the original data.
Fragment | |
|
:: Int | m: we need ≥ |
-> Int | n: total number of fragments into which we are going to
split the message; |
-> ByteString | the original message |
-> [Fragment] |
|
Takes a message (a bytestring) and yields n
fragments such that any m
of
them are sufficient for reconstructing the original message.
decode :: [Fragment] -> ByteString Source
Takes a list of at least m fragments (where m
is the reconstruction
threshold used for encode
) and tries to reconstruct the original message.
Throws an AssertionFailed
exception if there are less than m fragments
or if the fragments belong to a different message.
toIntVec :: Int -> ByteString -> (Vector FField, Int) Source
Takes an integer m and a bytestring and converts the bytestring into a 'Vector Word8', appending 0s at the end such that the length is dividable by m.
fromIntVec :: Int -> Vector FField -> ByteString Source
Converts a bytestring to a 'Vector Word8', removing the trailing 0s.