-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Information-theoretic secure secret sharing
--   
--   Please see the README on GitHub at
--   <a>https://github.com/pwrobinson/secret-sharing#readme</a>
@package secret-sharing
@version 1.0.1.2


module Crypto.SecretSharing.Internal

-- | Evaluate a Lagrange interpolation polynomial passing through the
--   specified set of points.
polyInterp :: Fractional a => [(a, a)] -> a -> a
slidingFocus :: [a] -> [([a], a, [a])]

-- | A share of an encoded byte.
data ByteShare
ByteShare :: !Int -> !Int -> !Int -> ByteShare

-- | the index of this share
[shareId] :: ByteShare -> !Int

-- | number of shares required for reconstruction
[reconstructionThreshold] :: ByteShare -> !Int

-- | the value of p(shareId) where p(x) is the generated (secret)
--   polynomial
[shareValue] :: ByteShare -> !Int

-- | A share of the encoded secret.
data Share
Share :: ![ByteShare] -> Share
[theShare] :: Share -> ![ByteShare]

-- | Encodes a <a>ByteString</a> as a list of n shares, m of which are
--   required for reconstruction. Lives in the <a>IO</a> to access a random
--   source.
encode :: Int -> Int -> ByteString -> IO [Share]

-- | Reconstructs a (secret) bytestring from a list of (at least
--   <tt>m</tt>) shares. Throws <a>AssertionFailed</a> if the number of
--   shares is too small.
decode :: [Share] -> ByteString
encodeByte :: Int -> Int -> Polyn -> FField -> Vector ByteShare
decodeByte :: [ByteShare] -> FField

-- | Groups a list into blocks of certain size. Running time: <i>O(n)</i>
groupInto :: Int -> [a] -> [[a]]

-- | A finite prime field. All computations are performed in this field.
newtype FField
FField :: (PrimeField 1021) -> FField
[number] :: FField -> (PrimeField 1021)

-- | The size of the finite field
prime :: Int

-- | A polynomial over the finite field given as a list of coefficients.
type Polyn = [FField]

-- | Evaluates the polynomial at a given point.
evalPolynomial :: Polyn -> FField -> FField
instance GHC.Generics.Generic Crypto.SecretSharing.Internal.ByteShare
instance GHC.Classes.Eq Crypto.SecretSharing.Internal.ByteShare
instance GHC.Generics.Generic Crypto.SecretSharing.Internal.Share
instance GHC.Classes.Eq Crypto.SecretSharing.Internal.Share
instance Data.FiniteField.Base.FiniteField Crypto.SecretSharing.Internal.FField
instance GHC.Generics.Generic Crypto.SecretSharing.Internal.FField
instance GHC.Real.Fractional Crypto.SecretSharing.Internal.FField
instance GHC.Num.Num Crypto.SecretSharing.Internal.FField
instance GHC.Classes.Eq Crypto.SecretSharing.Internal.FField
instance GHC.Classes.Ord Crypto.SecretSharing.Internal.FField
instance GHC.Read.Read Crypto.SecretSharing.Internal.FField
instance GHC.Show.Show Crypto.SecretSharing.Internal.FField
instance GHC.Show.Show Crypto.SecretSharing.Internal.Share
instance Data.Binary.Class.Binary Crypto.SecretSharing.Internal.Share
instance GHC.Show.Show Crypto.SecretSharing.Internal.ByteShare
instance Data.Binary.Class.Binary Crypto.SecretSharing.Internal.ByteShare


-- | Implementation of an (<tt>m</tt>,<tt>n</tt>)-threshold secret sharing
--   scheme. A given ByteString <tt>b</tt> (the secret) is split into
--   <tt>n</tt> shares, and any <tt>m</tt> shares are sufficient to
--   reconstruct <tt>b</tt>. The scheme preserves perfect secrecy in the
--   sense that the knowledge of up to <tt>m-1</tt> shares does not reveal
--   any information about the secret <tt>b</tt>.
--   
--   Typically, there are <tt>n</tt> parties and we would like to give the
--   <tt>i</tt>-th party the <tt>i</tt>-share of each byte. For example, to
--   encode a bytestring <tt>secret</tt> as <tt>10</tt> shares, any
--   <tt>5</tt> of which are sufficient for reconstruction we could write:
--   
--   <pre>
--   shares &lt;- encode 5 10 secret
--   </pre>
--   
--   Note that each byte is encoded separately using a fresh set of random
--   coefficients.
--   
--   The mathematics behind the secret sharing scheme is described in: "How
--   to share a secret." by Shamir, Adi. In Communications of the ACM 22
--   (11): 612–613, 1979.
module Crypto.SecretSharing

-- | Encodes a <a>ByteString</a> as a list of n shares, m of which are
--   required for reconstruction. Lives in the <a>IO</a> to access a random
--   source.
encode :: Int -> Int -> ByteString -> IO [Share]

-- | Reconstructs a (secret) bytestring from a list of (at least
--   <tt>m</tt>) shares. Throws <a>AssertionFailed</a> if the number of
--   shares is too small.
decode :: [Share] -> ByteString

-- | A share of the encoded secret.
data Share
