lol-0.7.0.0: A library for lattice cryptography.

Copyright(c) Chris Peikert 2018-
LicenseGPL-3
Maintainerecrockett0@gmail.com
Stabilityexperimental
PortabilityPOSIX \( \def\Z{\mathbb{Z}} \) \( \def\F{\mathbb{F}} \) \( \def\Q{\mathbb{Q}} \) \( \def\Tw{\text{Tw}} \) \( \def\Tr{\text{Tr}} \) \( \def\O{\mathcal{O}} \)
Safe HaskellNone
LanguageHaskell2010

Crypto.Lol.Cyclotomic.Language

Description

 
Synopsis

Documentation

data Basis Source #

Used to specify a basis for cyclotomic operations

Constructors

Pow 
Dec 

class Cyclotomic cmr where Source #

Operations on cyclotomics.

Methods

mulG :: cmr -> cmr Source #

Multiply by the special element \( g \).

divG :: cmr -> Maybe cmr Source #

Divide by the special element \( g \), returning Nothing if the input is not evenly divisible.

advisePow :: cmr -> cmr Source #

Yield an equivalent element that may be in powerful/decoding/CRT representation. This can serve as an optimization hint. E.g., call adviseCRT prior to multiplying a value by many other values.

adviseDec :: cmr -> cmr Source #

Yield an equivalent element that may be in powerful/decoding/CRT representation. This can serve as an optimization hint. E.g., call adviseCRT prior to multiplying a value by many other values.

adviseCRT :: cmr -> cmr Source #

Yield an equivalent element that may be in powerful/decoding/CRT representation. This can serve as an optimization hint. E.g., call adviseCRT prior to multiplying a value by many other values.

Instances
(Cyclotomic (Cyc t m a), Cyclotomic (Cyc t m b)) => Cyclotomic (Cyc t m (a, b)) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

mulG :: Cyc t m (a, b) -> Cyc t m (a, b) Source #

divG :: Cyc t m (a, b) -> Maybe (Cyc t m (a, b)) Source #

advisePow :: Cyc t m (a, b) -> Cyc t m (a, b) Source #

adviseDec :: Cyc t m (a, b) -> Cyc t m (a, b) Source #

adviseCRT :: Cyc t m (a, b) -> Cyc t m (a, b) Source #

Cyclotomic (CycG t m (ZqBasic q z)) => Cyclotomic (Cyc t m (ZqBasic q z)) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

mulG :: Cyc t m (ZqBasic q z) -> Cyc t m (ZqBasic q z) Source #

divG :: Cyc t m (ZqBasic q z) -> Maybe (Cyc t m (ZqBasic q z)) Source #

advisePow :: Cyc t m (ZqBasic q z) -> Cyc t m (ZqBasic q z) Source #

adviseDec :: Cyc t m (ZqBasic q z) -> Cyc t m (ZqBasic q z) Source #

adviseCRT :: Cyc t m (ZqBasic q z) -> Cyc t m (ZqBasic q z) Source #

Cyclotomic (CycG t m Int64) => Cyclotomic (Cyc t m Int64) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

mulG :: Cyc t m Int64 -> Cyc t m Int64 Source #

divG :: Cyc t m Int64 -> Maybe (Cyc t m Int64) Source #

advisePow :: Cyc t m Int64 -> Cyc t m Int64 Source #

adviseDec :: Cyc t m Int64 -> Cyc t m Int64 Source #

adviseCRT :: Cyc t m Int64 -> Cyc t m Int64 Source #

Cyclotomic (CycG t m Double) => Cyclotomic (Cyc t m Double) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

mulG :: Cyc t m Double -> Cyc t m Double Source #

divG :: Cyc t m Double -> Maybe (Cyc t m Double) Source #

advisePow :: Cyc t m Double -> Cyc t m Double Source #

adviseDec :: Cyc t m Double -> Cyc t m Double Source #

adviseCRT :: Cyc t m Double -> Cyc t m Double Source #

class GSqNormCyc cm r where Source #

Methods

gSqNorm :: cm r -> r Source #

Yield the scaled squared norm of \( g_m \cdot e \) under the canonical embedding, namely, ( hat{m}^{-1} cdot | sigma(g_m cdot e) |^2 ).

Instances
(Fact m, TensorGSqNorm t Int64, CRTElt t Int64) => GSqNormCyc (Cyc t m) Int64 Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

gSqNorm :: Cyc t m Int64 -> Int64 Source #

(Fact m, TensorGSqNorm t Double, CRTElt t Double) => GSqNormCyc (Cyc t m) Double Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

gSqNorm :: Cyc t m Double -> Double Source #

class GaussianCyc cmq where Source #

Sampling from tweaked Gaussian distributions over cyclotomic number fields.

Methods

tweakedGaussian :: (ToRational v, MonadRandom rnd) => v -> rnd cmq Source #

Sample from the "tweaked" Gaussian distribution ( t cdot D ), where \( D \) has scaled variance \( v \).

Instances
(Fact m, TensorGaussian t Double) => GaussianCyc (Cyc t m Double) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

tweakedGaussian :: (ToRational v, MonadRandom rnd) => v -> rnd (Cyc t m Double) Source #

class RoundedGaussianCyc cmz where Source #

Sampling from discretized tweaked Gaussian distributions over cyclotomic number rings.

Methods

roundedGaussian :: (ToRational v, MonadRandom rnd) => v -> rnd cmz Source #

Sample from the tweaked Gaussian with given scaled variance, deterministically rounded using the decoding basis.

Instances
(Fact m, TensorGaussian t Double, FunctorCyc (Cyc t m) Double Int64) => RoundedGaussianCyc (Cyc t m Int64) Source #

uses Double for the intermediate Gaussian sample

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

roundedGaussian :: (ToRational v, MonadRandom rnd) => v -> rnd (Cyc t m Int64) Source #

class CosetGaussianCyc rp where Source #

Sampling from tweaked Gaussian distributions, discretized to mod-p cosets of cyclotomic number rings.

Methods

cosetGaussian :: (ToRational v, MonadRandom rnd) => v -> rp -> rnd (LiftOf rp) Source #

Sample from the tweaked Gaussian with scaled variance ( v cdot p^2 ), deterministically rounded to the given coset of \( R_p \) using the decoding basis.

Instances
CosetGaussianCyc (CycG t m (ZqBasic q Int64)) => CosetGaussianCyc (Cyc t m (ZqBasic q Int64)) Source #

uses Double for the intermediate Gaussian samples

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

cosetGaussian :: (ToRational v, MonadRandom rnd) => v -> Cyc t m (ZqBasic q Int64) -> rnd (LiftOf (Cyc t m (ZqBasic q Int64))) Source #

class ExtensionCyc c r where Source #

Cyclotomic extensions \( \O_{m'}/\O_m \).

Methods

embed :: m `Divides` m' => c m r -> c m' r Source #

Embed into a cyclotomic extension.

twace :: m `Divides` m' => c m' r -> c m r Source #

The "tweaked trace" (twace) ( Tw(x) = (hat{m} / hat{m}') cdot Tr((g' / g) cdot x) ), which is the left-inverse of embed (i.e., twace . embed == id).

powBasis :: m `Divides` m' => Tagged m [c m' r] Source #

The relative powerful/decoding bases of the extension.

coeffsCyc :: m `Divides` m' => Basis -> c m' r -> [c m r] Source #

Yield the coefficient vector with respect to the given (relative) basis of the extension.

Instances
CRTElt t Int64 => ExtensionCyc (Cyc t) Int64 Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

embed :: Divides m m' => Cyc t m Int64 -> Cyc t m' Int64 Source #

twace :: Divides m m' => Cyc t m' Int64 -> Cyc t m Int64 Source #

powBasis :: Divides m m' => Tagged m [Cyc t m' Int64] Source #

coeffsCyc :: Divides m m' => Basis -> Cyc t m' Int64 -> [Cyc t m Int64] Source #

CRTElt t Double => ExtensionCyc (Cyc t) Double Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

embed :: Divides m m' => Cyc t m Double -> Cyc t m' Double Source #

twace :: Divides m m' => Cyc t m' Double -> Cyc t m Double Source #

powBasis :: Divides m m' => Tagged m [Cyc t m' Double] Source #

coeffsCyc :: Divides m m' => Basis -> Cyc t m' Double -> [Cyc t m Double] Source #

(ExtensionCyc (Cyc t) a, ExtensionCyc (Cyc t) b) => ExtensionCyc (Cyc t) (a, b) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

embed :: Divides m m' => Cyc t m (a, b) -> Cyc t m' (a, b) Source #

twace :: Divides m m' => Cyc t m' (a, b) -> Cyc t m (a, b) Source #

powBasis :: Divides m m' => Tagged m [Cyc t m' (a, b)] Source #

coeffsCyc :: Divides m m' => Basis -> Cyc t m' (a, b) -> [Cyc t m (a, b)] Source #

TensorPowDec t (RRq q r) => ExtensionCyc (Cyc t) (RRq q r) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

embed :: Divides m m' => Cyc t m (RRq q r) -> Cyc t m' (RRq q r) Source #

twace :: Divides m m' => Cyc t m' (RRq q r) -> Cyc t m (RRq q r) Source #

powBasis :: Divides m m' => Tagged m [Cyc t m' (RRq q r)] Source #

coeffsCyc :: Divides m m' => Basis -> Cyc t m' (RRq q r) -> [Cyc t m (RRq q r)] Source #

ExtensionCyc (CycG t) (ZqBasic q z) => ExtensionCyc (Cyc t) (ZqBasic q z) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

embed :: Divides m m' => Cyc t m (ZqBasic q z) -> Cyc t m' (ZqBasic q z) Source #

twace :: Divides m m' => Cyc t m' (ZqBasic q z) -> Cyc t m (ZqBasic q z) Source #

powBasis :: Divides m m' => Tagged m [Cyc t m' (ZqBasic q z)] Source #

coeffsCyc :: Divides m m' => Basis -> Cyc t m' (ZqBasic q z) -> [Cyc t m (ZqBasic q z)] Source #

coeffsPow :: (ExtensionCyc c r, m `Divides` m') => c m' r -> [c m r] Source #

coeffsCyc specialized to the powerful basis.

coeffsDec :: (ExtensionCyc c r, m `Divides` m') => c m' r -> [c m r] Source #

coeffsCyc specialized to the decoding basis.

class ExtensionCyc c r => CRTSetCyc c r where Source #

Relative CRT sets of cyclotomic extensions.

Methods

crtSet :: m `Divides` m' => Tagged m [c m' r] Source #

The relative mod-r CRT set of the extension.

Instances
CRTSetCyc (CycG t) (ZqBasic q z) => CRTSetCyc (Cyc t) (ZqBasic q z) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

crtSet :: Divides m m' => Tagged m [Cyc t m' (ZqBasic q z)] Source #

class FunctorCyc cm a b where Source #

Map over coefficients in a specified basis.

Methods

fmapCyc :: Maybe Basis -> (a -> b) -> cm a -> cm b Source #

Map in the specified basis (where Nothing indicates that any Basis may be used).

Instances
Functor (t m) => FunctorCyc (Cyc t m) Integer Integer Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Integer -> Integer) -> Cyc t m Integer -> Cyc t m Integer Source #

(Fact m, UnCyc t Int64, UnCyc t Int64, IFunctor t, IFElt t Int64, IFElt t Int64) => FunctorCyc (Cyc t m) Int64 Int64 Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Int64 -> Int64) -> Cyc t m Int64 -> Cyc t m Int64 Source #

(Fact m, UnCyc t Int64, UnCyc t Double, IFunctor t, IFElt t Int64, IFElt t Double) => FunctorCyc (Cyc t m) Int64 Double Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Int64 -> Double) -> Cyc t m Int64 -> Cyc t m Double Source #

(Fact m, UnCyc t Double, UnCyc t Int64, IFunctor t, IFElt t Double, IFElt t Int64) => FunctorCyc (Cyc t m) Double Int64 Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Double -> Int64) -> Cyc t m Double -> Cyc t m Int64 Source #

(Fact m, UnCyc t Double, UnCyc t Double, IFunctor t, IFElt t Double, IFElt t Double) => FunctorCyc (Cyc t m) Double Double Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Double -> Double) -> Cyc t m Double -> Cyc t m Double Source #

(Fact m, Functor (t m), UnCyc t Int64) => FunctorCyc (Cyc t m) Int64 Integer Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Int64 -> Integer) -> Cyc t m Int64 -> Cyc t m Integer Source #

(Fact m, Functor (t m), UnCyc t Double) => FunctorCyc (Cyc t m) Double Integer Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Double -> Integer) -> Cyc t m Double -> Cyc t m Integer Source #

(Fact m, UnCyc t Int64, UnCyc t (a, b), IFunctor t, IFElt t Int64, IFElt t (a, b)) => FunctorCyc (Cyc t m) Int64 (a, b) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Int64 -> (a, b)) -> Cyc t m Int64 -> Cyc t m (a, b) Source #

(Fact m, UnCyc t Double, UnCyc t (a, b), IFunctor t, IFElt t Double, IFElt t (a, b)) => FunctorCyc (Cyc t m) Double (a, b) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Double -> (a, b)) -> Cyc t m Double -> Cyc t m (a, b) Source #

(Fact m, UnCyc t Int64, UnCyc t (ZqBasic q z), IFunctor t, IFElt t Int64, IFElt t (ZqBasic q z)) => FunctorCyc (Cyc t m) Int64 (ZqBasic q z) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Int64 -> ZqBasic q z) -> Cyc t m Int64 -> Cyc t m (ZqBasic q z) Source #

(Fact m, UnCyc t Int64, UnCyc t (RRq q r), IFunctor t, IFElt t Int64, IFElt t (RRq q r)) => FunctorCyc (Cyc t m) Int64 (RRq q r) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Int64 -> RRq q r) -> Cyc t m Int64 -> Cyc t m (RRq q r) Source #

(Fact m, UnCyc t Double, UnCyc t (ZqBasic q z), IFunctor t, IFElt t Double, IFElt t (ZqBasic q z)) => FunctorCyc (Cyc t m) Double (ZqBasic q z) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Double -> ZqBasic q z) -> Cyc t m Double -> Cyc t m (ZqBasic q z) Source #

(Fact m, UnCyc t Double, UnCyc t (RRq q r), IFunctor t, IFElt t Double, IFElt t (RRq q r)) => FunctorCyc (Cyc t m) Double (RRq q r) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (Double -> RRq q r) -> Cyc t m Double -> Cyc t m (RRq q r) Source #

(Fact m, UnCyc t (a, b), UnCyc t Int64, IFunctor t, IFElt t (a, b), IFElt t Int64) => FunctorCyc (Cyc t m) (a, b) Int64 Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> ((a, b) -> Int64) -> Cyc t m (a, b) -> Cyc t m Int64 Source #

(Fact m, UnCyc t (a, b), UnCyc t Double, IFunctor t, IFElt t (a, b), IFElt t Double) => FunctorCyc (Cyc t m) (a, b) Double Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> ((a, b) -> Double) -> Cyc t m (a, b) -> Cyc t m Double Source #

(Fact m, Functor (t m), UnCyc t (a, b)) => FunctorCyc (Cyc t m) (a, b) Integer Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> ((a, b) -> Integer) -> Cyc t m (a, b) -> Cyc t m Integer Source #

(Fact m, UnCyc t (a, b), UnCyc t (a, b), IFunctor t, IFElt t (a, b), IFElt t (a, b)) => FunctorCyc (Cyc t m) (a, b) (a, b) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> ((a, b) -> (a, b)) -> Cyc t m (a, b) -> Cyc t m (a, b) Source #

(Fact m, UnCyc t (a, b), UnCyc t (ZqBasic q z), IFunctor t, IFElt t (a, b), IFElt t (ZqBasic q z)) => FunctorCyc (Cyc t m) (a, b) (ZqBasic q z) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> ((a, b) -> ZqBasic q z) -> Cyc t m (a, b) -> Cyc t m (ZqBasic q z) Source #

(Fact m, UnCyc t (a, b), UnCyc t (RRq q r), IFunctor t, IFElt t (a, b), IFElt t (RRq q r)) => FunctorCyc (Cyc t m) (a, b) (RRq q r) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> ((a, b) -> RRq q r) -> Cyc t m (a, b) -> Cyc t m (RRq q r) Source #

(Fact m, UnCyc t (ZqBasic q z), UnCyc t Int64, IFunctor t, IFElt t (ZqBasic q z), IFElt t Int64) => FunctorCyc (Cyc t m) (ZqBasic q z) Int64 Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (ZqBasic q z -> Int64) -> Cyc t m (ZqBasic q z) -> Cyc t m Int64 Source #

(Fact m, UnCyc t (ZqBasic q z), UnCyc t Double, IFunctor t, IFElt t (ZqBasic q z), IFElt t Double) => FunctorCyc (Cyc t m) (ZqBasic q z) Double Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (ZqBasic q z -> Double) -> Cyc t m (ZqBasic q z) -> Cyc t m Double Source #

(Fact m, UnCyc t (RRq q r), UnCyc t Int64, IFunctor t, IFElt t (RRq q r), IFElt t Int64) => FunctorCyc (Cyc t m) (RRq q r) Int64 Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (RRq q r -> Int64) -> Cyc t m (RRq q r) -> Cyc t m Int64 Source #

(Fact m, UnCyc t (RRq q r), UnCyc t Double, IFunctor t, IFElt t (RRq q r), IFElt t Double) => FunctorCyc (Cyc t m) (RRq q r) Double Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (RRq q r -> Double) -> Cyc t m (RRq q r) -> Cyc t m Double Source #

(Fact m, Functor (t m), UnCyc t (ZqBasic q z)) => FunctorCyc (Cyc t m) (ZqBasic q z) Integer Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (ZqBasic q z -> Integer) -> Cyc t m (ZqBasic q z) -> Cyc t m Integer Source #

(Fact m, Functor (t m), UnCyc t (RRq q r)) => FunctorCyc (Cyc t m) (RRq q r) Integer Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (RRq q r -> Integer) -> Cyc t m (RRq q r) -> Cyc t m Integer Source #

(Fact m, UnCyc t (ZqBasic q z), UnCyc t (a, b), IFunctor t, IFElt t (ZqBasic q z), IFElt t (a, b)) => FunctorCyc (Cyc t m) (ZqBasic q z) (a, b) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (ZqBasic q z -> (a, b)) -> Cyc t m (ZqBasic q z) -> Cyc t m (a, b) Source #

(Fact m, UnCyc t (RRq q r), UnCyc t (a, b), IFunctor t, IFElt t (RRq q r), IFElt t (a, b)) => FunctorCyc (Cyc t m) (RRq q r) (a, b) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (RRq q r -> (a, b)) -> Cyc t m (RRq q r) -> Cyc t m (a, b) Source #

(Fact m, UnCyc t (ZqBasic q z), UnCyc t (ZqBasic q z), IFunctor t, IFElt t (ZqBasic q z), IFElt t (ZqBasic q z)) => FunctorCyc (Cyc t m) (ZqBasic q z) (ZqBasic q z) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (ZqBasic q z -> ZqBasic q z) -> Cyc t m (ZqBasic q z) -> Cyc t m (ZqBasic q z) Source #

(Fact m, UnCyc t (ZqBasic q z), UnCyc t (RRq q r), IFunctor t, IFElt t (ZqBasic q z), IFElt t (RRq q r)) => FunctorCyc (Cyc t m) (ZqBasic q z) (RRq q r) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (ZqBasic q z -> RRq q r) -> Cyc t m (ZqBasic q z) -> Cyc t m (RRq q r) Source #

(Fact m, UnCyc t (RRq q r), UnCyc t (ZqBasic q z), IFunctor t, IFElt t (RRq q r), IFElt t (ZqBasic q z)) => FunctorCyc (Cyc t m) (RRq q r) (ZqBasic q z) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (RRq q r -> ZqBasic q z) -> Cyc t m (RRq q r) -> Cyc t m (ZqBasic q z) Source #

(Fact m, UnCyc t (RRq q r), UnCyc t (RRq q r), IFunctor t, IFElt t (RRq q r), IFElt t (RRq q r)) => FunctorCyc (Cyc t m) (RRq q r) (RRq q r) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

fmapCyc :: Maybe Basis -> (RRq q r -> RRq q r) -> Cyc t m (RRq q r) -> Cyc t m (RRq q r) Source #

fmapAny :: FunctorCyc cm a b => (a -> b) -> cm a -> cm b Source #

Convenient specializations of fmapCyc.

fmapPow :: FunctorCyc cm a b => (a -> b) -> cm a -> cm b Source #

Convenient specializations of fmapCyc.

fmapDec :: FunctorCyc cm a b => (a -> b) -> cm a -> cm b Source #

Convenient specializations of fmapCyc.

class FoldableCyc cm a where Source #

Fold over coefficients in a specified basis.

Methods

foldrCyc :: Maybe Basis -> (a -> b -> b) -> b -> cm a -> b Source #

Fold in the specified basis (where Nothing indicates that any Basis may be used).

Instances
Foldable (t m) => FoldableCyc (Cyc t m) Integer Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

foldrCyc :: Maybe Basis -> (Integer -> b -> b) -> b -> Cyc t m Integer -> b Source #

FoldableCyc (CycG t m) Int64 => FoldableCyc (Cyc t m) Int64 Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

foldrCyc :: Maybe Basis -> (Int64 -> b -> b) -> b -> Cyc t m Int64 -> b Source #

FoldableCyc (CycG t m) Double => FoldableCyc (Cyc t m) Double Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

foldrCyc :: Maybe Basis -> (Double -> b -> b) -> b -> Cyc t m Double -> b Source #

(Fact m, TensorPowDec t (RRq q r), Foldable (t m)) => FoldableCyc (Cyc t m) (RRq q r) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

foldrCyc :: Maybe Basis -> (RRq q r -> b -> b) -> b -> Cyc t m (RRq q r) -> b Source #

FoldableCyc (CycG t m) (ZqBasic q z) => FoldableCyc (Cyc t m) (ZqBasic q z) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

foldrCyc :: Maybe Basis -> (ZqBasic q z -> b -> b) -> b -> Cyc t m (ZqBasic q z) -> b Source #

foldrAny :: FoldableCyc cm a => (a -> b -> b) -> b -> cm a -> b Source #

Convenient specializations of foldrCyc.

foldrPow :: FoldableCyc cm a => (a -> b -> b) -> b -> cm a -> b Source #

Convenient specializations of foldrCyc.

foldrDec :: FoldableCyc cm a => (a -> b -> b) -> b -> cm a -> b Source #

Convenient specializations of foldrCyc.

reduceCyc :: (FunctorCyc cm a b, Reduce a b) => cm a -> cm b Source #

Reduce on a cyclotomic (in an arbitrary basis).

class LiftCyc cmr where Source #

Lift a cyclotomic in a specified basis.

Methods

liftCyc :: Maybe Basis -> cmr -> LiftOf cmr Source #

Lift in the specified basis (where Nothing indicates that any Basis may be used).

Instances
(Lift' r, FunctorCyc (Cyc t m) r (LiftOf r)) => LiftCyc (Cyc t m r) Source # 
Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

liftCyc :: Maybe Basis -> Cyc t m r -> LiftOf (Cyc t m r) Source #

liftAny :: LiftCyc cmr => cmr -> LiftOf cmr Source #

Convenient specializations of liftCyc.

liftPow :: LiftCyc cmr => cmr -> LiftOf cmr Source #

Convenient specializations of liftCyc.

liftDec :: LiftCyc cmr => cmr -> LiftOf cmr Source #

Convenient specializations of liftCyc.

class RescaleCyc cm a b where Source #

Rescaling on cyclotomics from one base ring to another. (This is a separate class because there are optimized rescaling algorithms that can't be implemented using FunctorCyc.)

Methods

rescaleCyc :: Basis -> cm a -> cm b Source #

Rescale in the given basis.

Instances
(Fact m, Reflects q z, Reduce z b, ZeroTestable z, CRTElt t (ZqBasic q z), C b (Cyc t m b)) => RescaleCyc (Cyc t m) b (ZqBasic q z, b) Source #

rescale up by one additional modulus

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

rescaleCyc :: Basis -> Cyc t m b -> Cyc t m (ZqBasic q z, b) Source #

(RescaleCyc (Cyc t m) (b, (c, (d, e))) e, RescaleCyc (Cyc t m) (a, (b, (c, (d, e)))) (b, (c, (d, e)))) => RescaleCyc (Cyc t m) (a, (b, (c, (d, e)))) e Source #

convenient rescale-down by multiple components at once

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

rescaleCyc :: Basis -> Cyc t m (a, (b, (c, (d, e)))) -> Cyc t m e Source #

(RescaleCyc (Cyc t m) (b, (c, d)) d, RescaleCyc (Cyc t m) (a, (b, (c, d))) (b, (c, d))) => RescaleCyc (Cyc t m) (a, (b, (c, d))) d Source #

convenient rescale-down by multiple components at once

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

rescaleCyc :: Basis -> Cyc t m (a, (b, (c, d))) -> Cyc t m d Source #

(RescaleCyc (Cyc t m) (b, c) c, RescaleCyc (Cyc t m) (a, (b, c)) (b, c)) => RescaleCyc (Cyc t m) (a, (b, c)) c Source #

convenient rescale-down by multiple components at once

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

rescaleCyc :: Basis -> Cyc t m (a, (b, c)) -> Cyc t m c Source #

(ToInteger z, Reflects q z, Reduce z b, Field b, FunctorCyc (Cyc t m) (ZqBasic q z) z, FunctorCyc (Cyc t m) z b, Additive (Cyc t m b), Module b (Cyc t m b)) => RescaleCyc (Cyc t m) (ZqBasic q z, b) b Source #

specialized (faster) rescale-down by a single \(\Z_q\)

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

rescaleCyc :: Basis -> Cyc t m (ZqBasic q z, b) -> Cyc t m b Source #

RescaleCyc (Cyc t m) (a, b) (a, b) Source #

no-op rescale for Cyc over pairs

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

rescaleCyc :: Basis -> Cyc t m (a, b) -> Cyc t m (a, b) Source #

(Fact m, Rescale (RRq q r) (RRq p r), TensorPowDec t (RRq q r), TensorPowDec t (RRq p r)) => RescaleCyc (Cyc t m) (RRq q r) (RRq p r) Source #

rescale from one modulus to another

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

rescaleCyc :: Basis -> Cyc t m (RRq q r) -> Cyc t m (RRq p r) Source #

RescaleCyc (CycG t m) (ZqBasic q z) (ZqBasic p z) => RescaleCyc (Cyc t m) (ZqBasic q z) (ZqBasic p z) Source #

rescale from one modulus to another

Instance details

Defined in Crypto.Lol.Cyclotomic.Cyc

Methods

rescaleCyc :: Basis -> Cyc t m (ZqBasic q z) -> Cyc t m (ZqBasic p z) Source #

rescalePow :: RescaleCyc cm a b => cm a -> cm b Source #

rescaleCyc specialized to the powerful basis.

rescaleDec :: RescaleCyc cm a b => cm a -> cm b Source #

rescaleCyc specialized to the decoding basis.