lol-0.7.0.0: A library for lattice cryptography.

Copyright(c) Eric Crockett 2011-2017
Chris Peikert 2011-2017
LicenseGPL-3
Maintainerecrockett0@gmail.com
Stabilityexperimental
PortabilityPOSIX \( \def\lcm{\text{lcm}} \)
Safe HaskellNone
LanguageHaskell2010

Crypto.Lol.Factored

Contents

Description

This module defines types and operations for type-level representation and manipulation of natural numbers, as represented by their prime-power factorizations. It relies on Template Haskell, so parts of the documentation may be difficult to read. See source-level comments for further details.

Synopsis

Factored natural numbers

data Factored Source #

Instances
Eq Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Show Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

PShow Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Associated Types

type ShowsPrec arg arg1 arg2 :: Symbol #

type Show_ arg :: Symbol #

type ShowList arg arg1 :: Symbol #

SShow [PrimePower] => SShow Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

sShowsPrec :: Sing t1 -> Sing t2 -> Sing t3 -> Sing (Apply (Apply (Apply ShowsPrecSym0 t1) t2) t3) #

sShow_ :: Sing t -> Sing (Apply Show_Sym0 t) #

sShowList :: Sing t1 -> Sing t2 -> Sing (Apply (Apply ShowListSym0 t1) t2) #

SEq [PrimePower] => SEq Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

(%==) :: Sing a -> Sing b -> Sing (a == b) #

(%/=) :: Sing a -> Sing b -> Sing (a /= b) #

PEq Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Associated Types

type x == y :: Bool #

type x /= y :: Bool #

SDecide [PrimePower] => SDecide Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

(%~) :: Sing a -> Sing b -> Decision (a :~: b) #

SingKind Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Associated Types

type Demote Factored = (r :: Type) #

(Fact m, C i) => Reflects (m :: Factored) i Source # 
Instance details

Defined in Crypto.Lol.Reflects

Methods

value :: i Source #

ShowSing [PrimePower] => Show (Sing z) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

showsPrec :: Int -> Sing z -> ShowS #

show :: Sing z -> String #

showList :: [Sing z] -> ShowS #

Fact m => Show (ArgType m) Source # 
Instance details

Defined in Crypto.Lol.Utils.ShowType

Methods

showsPrec :: Int -> ArgType m -> ShowS #

show :: ArgType m -> String #

showList :: [ArgType m] -> ShowS #

data Sing (a :: Factored) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

data Sing (a :: Factored) where
type Demote Factored Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type Show_ (arg :: Factored) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type Show_ (arg :: Factored) = Apply (Show__6989586621680262717Sym0 :: TyFun Factored Symbol -> Type) arg
type ShowList (arg :: [Factored]) arg1 Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type ShowList (arg :: [Factored]) arg1 = Apply (Apply (ShowList_6989586621680262728Sym0 :: TyFun [Factored] (Symbol ~> Symbol) -> Type) arg) arg1
type (x :: Factored) /= (y :: Factored) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type (x :: Factored) /= (y :: Factored) = Not (x == y)
type (a :: Factored) == (b :: Factored) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type (a :: Factored) == (b :: Factored)
type ShowsPrec a1 (a2 :: Factored) a3 Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type ShowsPrec a1 (a2 :: Factored) a3

type Fact (m :: Factored) = SingI m Source #

Kind-restricted synonym for SingI.

fType :: Int -> TypeQ Source #

Template Haskell splice for the Factored type corresponding to a given positive integer. Factors its argument using a naive trial-division algorithm with primes, so should only be used on small-to-moderate-sized arguments (any reasonable cyclotomic index should be OK).

fDec :: Int -> DecQ Source #

Template Haskell splice that defines the Factored type synonym F\(n\) for a positive integer \(n\).

reifyFact :: Int -> (forall m. SFactored m -> a) -> a Source #

Reify a Factored as a singleton.

reifyFactI :: Int -> (forall m proxy. Fact m => proxy m -> a) -> a Source #

Reify a Factored for a Fact constraint.

intToFact :: Int -> Factored Source #

Converts input to its data-level Factored representation.

Prime powers

newtype PrimePower Source #

Constructors

PP (PrimeBin, Pos) 
Instances
Eq PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Show PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

PShow PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Associated Types

type ShowsPrec arg arg1 arg2 :: Symbol #

type Show_ arg :: Symbol #

type ShowList arg arg1 :: Symbol #

SShow (PrimeBin, Pos) => SShow PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

sShowsPrec :: Sing t1 -> Sing t2 -> Sing t3 -> Sing (Apply (Apply (Apply ShowsPrecSym0 t1) t2) t3) #

sShow_ :: Sing t -> Sing (Apply Show_Sym0 t) #

sShowList :: Sing t1 -> Sing t2 -> Sing (Apply (Apply ShowListSym0 t1) t2) #

SEq (PrimeBin, Pos) => SEq PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

(%==) :: Sing a -> Sing b -> Sing (a == b) #

(%/=) :: Sing a -> Sing b -> Sing (a /= b) #

PEq PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Associated Types

type x == y :: Bool #

type x /= y :: Bool #

SDecide (PrimeBin, Pos) => SDecide PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

(%~) :: Sing a -> Sing b -> Decision (a :~: b) #

SingKind PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Associated Types

type Demote PrimePower = (r :: Type) #

(PPow pp, C i) => Reflects (pp :: PrimePower) i Source # 
Instance details

Defined in Crypto.Lol.Reflects

Methods

value :: i Source #

SingI n => SingI (PP n :: PrimePower) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

sing :: Sing (PP n) #

ShowSing (PrimeBin, Pos) => Show (Sing z) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

showsPrec :: Int -> Sing z -> ShowS #

show :: Sing z -> String #

showList :: [Sing z] -> ShowS #

SingI (TyCon1 PP) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

sing :: Sing (TyCon1 PP) #

data Sing (a :: PrimePower) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

data Sing (a :: PrimePower) where
type Demote PrimePower Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type Show_ (arg :: PrimePower) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type Show_ (arg :: PrimePower) = Apply (Show__6989586621680262717Sym0 :: TyFun PrimePower Symbol -> Type) arg
type ShowList (arg :: [PrimePower]) arg1 Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type ShowList (arg :: [PrimePower]) arg1 = Apply (Apply (ShowList_6989586621680262728Sym0 :: TyFun [PrimePower] (Symbol ~> Symbol) -> Type) arg) arg1
type (x :: PrimePower) /= (y :: PrimePower) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type (x :: PrimePower) /= (y :: PrimePower) = Not (x == y)
type (a :: PrimePower) == (b :: PrimePower) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type (a :: PrimePower) == (b :: PrimePower)
type ShowsPrec a1 (a2 :: PrimePower) a3 Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

type ShowsPrec a1 (a2 :: PrimePower) a3

data family Sing (a :: k) :: Type #

The singleton kind-indexed data family.

Instances
ShowSing Pos => Show (Sing z) Source # 
Instance details

Defined in Crypto.Lol.PosBinDefs

Methods

showsPrec :: Int -> Sing z -> ShowS #

show :: Sing z -> String #

showList :: [Sing z] -> ShowS #

ShowSing Bin => Show (Sing z) Source # 
Instance details

Defined in Crypto.Lol.PosBinDefs

Methods

showsPrec :: Int -> Sing z -> ShowS #

show :: Sing z -> String #

showList :: [Sing z] -> ShowS #

ShowSing Bin => Show (Sing z) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

showsPrec :: Int -> Sing z -> ShowS #

show :: Sing z -> String #

showList :: [Sing z] -> ShowS #

ShowSing (PrimeBin, Pos) => Show (Sing z) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

showsPrec :: Int -> Sing z -> ShowS #

show :: Sing z -> String #

showList :: [Sing z] -> ShowS #

ShowSing [PrimePower] => Show (Sing z) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

Methods

showsPrec :: Int -> Sing z -> ShowS #

show :: Sing z -> String #

showList :: [Sing z] -> ShowS #

data Sing (a :: Bool) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (a :: Bool) where
data Sing (a :: Ordering) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (a :: Ordering) where
data Sing (n :: Nat) 
Instance details

Defined in Data.Singletons.TypeLits.Internal

data Sing (n :: Nat) where
data Sing (n :: Symbol) 
Instance details

Defined in Data.Singletons.TypeLits.Internal

data Sing (n :: Symbol) where
data Sing (a :: ()) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (a :: ()) where
data Sing (a :: Pos) Source # 
Instance details

Defined in Crypto.Lol.PosBinDefs

data Sing (a :: Pos) where
data Sing (a :: Bin) Source # 
Instance details

Defined in Crypto.Lol.PosBinDefs

data Sing (a :: Bin) where
data Sing (a :: PrimeBin) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

data Sing (a :: PrimeBin) where
data Sing (a :: PrimePower) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

data Sing (a :: PrimePower) where
data Sing (a :: Factored) Source # 
Instance details

Defined in Crypto.Lol.FactoredDefs

data Sing (a :: Factored) where
data Sing (a :: Void) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (a :: Void)
data Sing (a :: All) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (a :: All) where
data Sing (a :: Any) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (a :: Any) where
data Sing (b :: [a]) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (b :: [a]) where
  • SNil :: forall a (b :: [a]). Sing ([] :: [a])
  • SCons :: forall a (b :: [a]) (n1 :: a) (n2 :: [a]). Sing n1 -> Sing n2 -> Sing (n1 ': n2)
data Sing (b :: Maybe a) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (b :: Maybe a) where
data Sing (b :: Min a) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (b :: Min a) where
data Sing (b :: Max a) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (b :: Max a) where
data Sing (b :: First a) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (b :: First a) where
data Sing (b :: Last a) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (b :: Last a) where
data Sing (a :: WrappedMonoid m) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (a :: WrappedMonoid m) where
data Sing (b :: Option a) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (b :: Option a) where
data Sing (b :: Identity a) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (b :: Identity a) where
data Sing (b :: First a) 
Instance details

Defined in Data.Singletons.Prelude.Monoid

data Sing (b :: First a) where
data Sing (b :: Last a) 
Instance details

Defined in Data.Singletons.Prelude.Monoid

data Sing (b :: Last a) where
data Sing (b :: Dual a) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (b :: Dual a) where
data Sing (b :: Sum a) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (b :: Sum a) where
data Sing (b :: Product a) 
Instance details

Defined in Data.Singletons.Prelude.Semigroup.Internal

data Sing (b :: Product a) where
data Sing (b :: Down a) 
Instance details

Defined in Data.Singletons.Prelude.Ord

data Sing (b :: Down a) where
data Sing (b :: NonEmpty a) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (b :: NonEmpty a) where
data Sing (b :: Endo a) 
Instance details

Defined in Data.Singletons.Prelude.Foldable

data Sing (b :: Endo a) where
data Sing (b :: MaxInternal a) 
Instance details

Defined in Data.Singletons.Prelude.Foldable

data Sing (b :: MaxInternal a) where
data Sing (b :: MinInternal a) 
Instance details

Defined in Data.Singletons.Prelude.Foldable

data Sing (b :: MinInternal a) where
data Sing (c :: Either a b) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (c :: Either a b) where
data Sing (c :: (a, b)) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (c :: (a, b)) where
data Sing (c :: Arg a b) 
Instance details

Defined in Dat