secret-sharing-1.0.1.2: Information-theoretic secure secret sharing

Copyright | Peter Robinson 2014
License | LGPL
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Crypto.SecretSharing.Internal

Description

Synopsis

- polyInterp :: Fractional a => [(a, a)] -> a -> a
- slidingFocus :: [a] -> [([a], a, [a])]
- 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 1021
  }
- prime :: Int
- type Polyn = [FField]
- evalPolynomial :: Polyn -> FField -> FField

# Documentation

polyInterp :: Fractional a => [(a, a)] -> a -> a Source #

Evaluate a Lagrange interpolation polynomial passing through the specified set of points.

slidingFocus :: [a] -> [([a], a, [a])] Source #

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

Instances details

Generic ByteShare Source # |
Instance details Defined in Crypto.SecretSharing.Internal Associated Types type Rep ByteShare :: Type -> Type Source # Methods from :: ByteShare -> Rep ByteShare x Source # to :: Rep ByteShare x -> ByteShare Source #
Show ByteShare Source # |
Instance details Defined in Crypto.SecretSharing.Internal Methods showsPrec :: Int -> ByteShare -> ShowS Source # show :: ByteShare -> String Source # showList :: [ByteShare] -> ShowS Source #
Binary ByteShare Source # |
Instance details Defined in Crypto.SecretSharing.Internal Methods put :: ByteShare -> Put Source # get :: Get ByteShare Source # putList :: [ByteShare] -> Put Source #
Eq ByteShare Source # |
Instance details Defined in Crypto.SecretSharing.Internal Methods (==) :: ByteShare -> ByteShare -> Bool Source # (/=) :: ByteShare -> ByteShare -> Bool Source #
type Rep ByteShare Source # |

Instance details

Defined in Crypto.SecretSharing.Internal

type Rep ByteShare = D1 ('MetaData "ByteShare" "Crypto.SecretSharing.Internal" "secret-sharing-1.0.1.2-LnVHOwF7Z8vLpey1R202CX" 'False) (C1 ('MetaCons "ByteShare" 'PrefixI 'True) (S1 ('MetaSel ('Just "shareId") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: (S1 ('MetaSel ('Just "reconstructionThreshold") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "shareValue") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int))))

data Share Source #

A share of the encoded secret.

Constructors

Share |

Fields

- theShare :: ![ByteShare]

#### Instances

Instances details

Generic Share Source # |
Instance details Defined in Crypto.SecretSharing.Internal Associated Types type Rep Share :: Type -> Type Source # Methods from :: Share -> Rep Share x Source # to :: Rep Share x -> Share Source #
Show Share Source # |
Instance details Defined in Crypto.SecretSharing.Internal Methods showsPrec :: Int -> Share -> ShowS Source # show :: Share -> String Source # showList :: [Share] -> ShowS Source #
Binary Share Source # |
Instance details Defined in Crypto.SecretSharing.Internal Methods put :: Share -> Put Source # get :: Get Share Source # putList :: [Share] -> Put Source #
Eq Share Source # |
Instance details Defined in Crypto.SecretSharing.Internal Methods (==) :: Share -> Share -> Bool Source # (/=) :: Share -> Share -> Bool Source #
type Rep Share Source # |
Instance details Defined in Crypto.SecretSharing.Internal type Rep Share = D1 ('MetaData "Share" "Crypto.SecretSharing.Internal" "secret-sharing-1.0.1.2-LnVHOwF7Z8vLpey1R202CX" 'False) (C1 ('MetaCons "Share" 'PrefixI 'True) (S1 ('MetaSel ('Just "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 1021

#### Instances

Instances details

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

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.