secret-sharing-1.0.0.3: Information-theoretic secure secret sharing

Copyright | Peter Robinson 2014
License | LGPL
Maintainer | Peter Robinson <peter.robinson@monoid.at>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell98

Crypto.SecretSharing.Internal

Description

Synopsis

- data ByteShare = ByteShare {
  - shareId :: !Int
  - reconstructionThreshold :: !Int
  - shareValue :: !Int
  }
- data Share = Share {
  - theShare :: ![ByteShare]
  }
- encode :: Int -> Int -> ByteString -> IO [Share]
- decode :: [Share] -> ByteString
- encodeByte :: Int -> Int -> Polyn -> FField -> Vector ByteShare
- decodeByte :: [ByteShare] -> FField
- groupInto :: Int -> [a] -> [[a]]
- newtype FField = FField {
  - number :: PrimeField (I (O (I (I (I (I (I (I (I (I Z))))))))))
  }
- prime :: Int
- type Polyn = [FField]
- evalPolynomial :: Polyn -> FField -> FField

# Documentation

data ByteShare Source #

A share of an encoded byte.

Constructors

ByteShare |

Fields

- shareId :: !Int

  the index of this share

- reconstructionThreshold :: !Int

  number of shares required for reconstruction

- shareValue :: !Int

  the value of p(shareId) where p(x) is the generated (secret) polynomial

Instances

Eq ByteShare Source # |
Methods (==) :: ByteShare -> ByteShare -> Bool # (/=) :: ByteShare -> ByteShare -> Bool #
Show ByteShare Source # |
Methods showsPrec :: Int -> ByteShare -> ShowS # show :: ByteShare -> String # showList :: [ByteShare] -> ShowS #
Generic ByteShare Source # |
Associated Types type Rep ByteShare :: * -> * # Methods from :: ByteShare -> Rep ByteShare x # to :: Rep ByteShare x -> ByteShare #
Binary ByteShare Source # |
Methods put :: ByteShare -> Put # get :: Get ByteShare # putList :: [ByteShare] -> Put #
type Rep ByteShare Source # |

type Rep ByteShare = D1 (MetaData "ByteShare" "Crypto.SecretSharing.Internal" "secret-sharing-1.0.0.3-7IF3ya8wajQEapyY2aT18Z" False) (C1 (MetaCons "ByteShare" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "shareId") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int)) ((:*:) (S1 (MetaSel (Just Symbol "reconstructionThreshold") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int)) (S1 (MetaSel (Just Symbol "shareValue") NoSourceUnpackedness SourceStrict DecidedUnpack) (Rec0 Int)))))

data Share Source #

A share of the encoded secret.

Constructors

Share |

Fields

- theShare :: ![ByteShare]

Instances

Eq Share Source # |
Methods (==) :: Share -> Share -> Bool # (/=) :: Share -> Share -> Bool #
Show Share Source # |
Methods showsPrec :: Int -> Share -> ShowS # show :: Share -> String # showList :: [Share] -> ShowS #
Generic Share Source # |
Associated Types type Rep Share :: * -> * # Methods from :: Share -> Rep Share x # to :: Rep Share x -> Share #
Binary Share Source # |
Methods put :: Share -> Put # get :: Get Share # putList :: [Share] -> Put #
type Rep Share Source # |
type Rep Share = D1 (MetaData "Share" "Crypto.SecretSharing.Internal" "secret-sharing-1.0.0.3-7IF3ya8wajQEapyY2aT18Z" False) (C1 (MetaCons "Share" PrefixI True) (S1 (MetaSel (Just Symbol "theShare") NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 [ByteShare])))

encode Source #

Arguments

:: Int | m
-> Int | n
-> ByteString | the secret that we want to share
-> IO [Share] |

Encodes a `ByteString` as a list of n shares, m of which are required for reconstruction. Lives in the `IO` to access a random source.

decode Source #

Arguments

:: [Share] | list of at least `m` shares
-> ByteString | reconstructed secret

Reconstructs a (secret) bytestring from a list of (at least `m`) shares. Throws `AssertionFailed` if the number of shares is too small.

encodeByte :: Int -> Int -> Polyn -> FField -> Vector ByteShare Source #

decodeByte :: [ByteShare] -> FField Source #

groupInto :: Int -> [a] -> [[a]] Source #

Groups a list into blocks of certain size. Running time: O(n)

newtype FField Source #

A finite prime field. All computations are performed in this field.

Constructors

FField |

Fields

- number :: PrimeField (I (O (I (I (I (I (I (I (I (I Z))))))))))

Instances

Eq FField Source # |
Methods (==) :: FField -> FField -> Bool # (/=) :: FField -> FField -> Bool #
Fractional FField Source # |
Methods (/) :: FField -> FField -> FField # recip :: FField -> FField # fromRational :: Rational -> FField #
Num FField Source # |
Methods (+) :: FField -> FField -> FField # (-) :: FField -> FField -> FField # (*) :: FField -> FField -> FField # negate :: FField -> FField # abs :: FField -> FField # signum :: FField -> FField # fromInteger :: Integer -> FField #
Ord FField Source # |
Methods compare :: FField -> FField -> Ordering # (<) :: FField -> FField -> Bool # (<=) :: FField -> FField -> Bool # (>) :: FField -> FField -> Bool # (>=) :: FField -> FField -> Bool # max :: FField -> FField -> FField # min :: FField -> FField -> FField #
Read FField Source # |
Methods readsPrec :: Int -> ReadS FField # readList :: ReadS [FField] # readPrec :: ReadPrec FField # readListPrec :: ReadPrec [FField] #
Show FField Source # |
Methods showsPrec :: Int -> FField -> ShowS # show :: FField -> String # showList :: [FField] -> ShowS #
Generic FField Source # |
Associated Types type Rep FField :: * -> * # Methods from :: FField -> Rep FField x # to :: Rep FField x -> FField #
FiniteField FField Source # |
Methods order :: FField -> Integer # char :: FField -> Integer # pthRoot :: FField -> FField # allValues :: [FField] #
type Rep FField Source # |
type Rep FField = D1 (MetaData "FField" "Crypto.SecretSharing.Internal" "secret-sharing-1.0.0.3-7IF3ya8wajQEapyY2aT18Z" True) (C1 (MetaCons "FField" PrefixI True) (S1 (MetaSel (Just Symbol "number") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (PrimeField (I (O (I (I (I (I (I (I (I (I Z))))))))))))))

prime :: Int Source #

The size of the finite field

type Polyn = [FField] Source #

A polynomial over the finite field given as a list of coefficients.

evalPolynomial :: Polyn -> FField -> FField Source #

Evaluates the polynomial at a given point.