Copyright | (c) Chris Peikert 2018- |
---|---|
License | GPL-3 |
Maintainer | ecrockett0@gmail.com |
Stability | experimental |
Portability | POSIX \( \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 Haskell | None |
Language | Haskell2010 |
Synopsis
- data Basis
- class Cyclotomic cmr where
- class GSqNormCyc cm r where
- gSqNorm :: cm r -> r
- class GaussianCyc cmq where
- tweakedGaussian :: (ToRational v, MonadRandom rnd) => v -> rnd cmq
- class RoundedGaussianCyc cmz where
- roundedGaussian :: (ToRational v, MonadRandom rnd) => v -> rnd cmz
- class CosetGaussianCyc rp where
- cosetGaussian :: (ToRational v, MonadRandom rnd) => v -> rp -> rnd (LiftOf rp)
- class ExtensionCyc c r where
- coeffsPow :: (ExtensionCyc c r, m `Divides` m') => c m' r -> [c m r]
- coeffsDec :: (ExtensionCyc c r, m `Divides` m') => c m' r -> [c m r]
- class ExtensionCyc c r => CRTSetCyc c r where
- class FunctorCyc cm a b where
- fmapAny :: FunctorCyc cm a b => (a -> b) -> cm a -> cm b
- fmapPow :: FunctorCyc cm a b => (a -> b) -> cm a -> cm b
- fmapDec :: FunctorCyc cm a b => (a -> b) -> cm a -> cm b
- class FoldableCyc cm a where
- foldrAny :: FoldableCyc cm a => (a -> b -> b) -> b -> cm a -> b
- foldrPow :: FoldableCyc cm a => (a -> b -> b) -> b -> cm a -> b
- foldrDec :: FoldableCyc cm a => (a -> b -> b) -> b -> cm a -> b
- reduceCyc :: (FunctorCyc cm a b, Reduce a b) => cm a -> cm b
- class LiftCyc cmr where
- liftAny :: LiftCyc cmr => cmr -> LiftOf cmr
- liftPow :: LiftCyc cmr => cmr -> LiftOf cmr
- liftDec :: LiftCyc cmr => cmr -> LiftOf cmr
- class RescaleCyc cm a b where
- rescaleCyc :: Basis -> cm a -> cm b
- rescalePow :: RescaleCyc cm a b => cm a -> cm b
- rescaleDec :: RescaleCyc cm a b => cm a -> cm b
Documentation
class Cyclotomic cmr where Source #
Operations on cyclotomics.
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 # | |
Defined in Crypto.Lol.Cyclotomic.Cyc | |
Cyclotomic (CycG t m (ZqBasic q z)) => Cyclotomic (Cyc t m (ZqBasic q z)) Source # | |
Defined in Crypto.Lol.Cyclotomic.Cyc 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 # | |
Cyclotomic (CycG t m Double) => Cyclotomic (Cyc t m Double) Source # | |
Defined in Crypto.Lol.Cyclotomic.Cyc |
class GSqNormCyc cm r where 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 # | |
(Fact m, TensorGSqNorm t Double, CRTElt t Double) => GSqNormCyc (Cyc t m) Double Source # | |
class GaussianCyc cmq where Source #
Sampling from tweaked Gaussian distributions over cyclotomic number fields.
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 # | |
Defined in Crypto.Lol.Cyclotomic.Cyc 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.
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 |
Defined in Crypto.Lol.Cyclotomic.Cyc 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.
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 |
Defined in Crypto.Lol.Cyclotomic.Cyc 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 \).
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
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.
class FunctorCyc cm a b where Source #
Map over coefficients in a specified basis.
Instances
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.
Instances
Foldable (t m) => FoldableCyc (Cyc t m) Integer Source # | |
FoldableCyc (CycG t m) Int64 => FoldableCyc (Cyc t m) Int64 Source # | |
FoldableCyc (CycG t m) Double => FoldableCyc (Cyc t m) Double Source # | |
(Fact m, TensorPowDec t (RRq q r), Foldable (t m)) => FoldableCyc (Cyc t m) (RRq q r) Source # | |
FoldableCyc (CycG t m) (ZqBasic q z) => FoldableCyc (Cyc t m) (ZqBasic q z) 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 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
.)
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 |
Defined in Crypto.Lol.Cyclotomic.Cyc | |
(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 |
Defined in Crypto.Lol.Cyclotomic.Cyc | |
(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 |
Defined in Crypto.Lol.Cyclotomic.Cyc | |
(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 |
Defined in Crypto.Lol.Cyclotomic.Cyc | |
(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\) |
Defined in Crypto.Lol.Cyclotomic.Cyc | |
RescaleCyc (Cyc t m) (a, b) (a, b) Source # | no-op rescale for Cyc over pairs |
Defined in Crypto.Lol.Cyclotomic.Cyc | |
(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 |
Defined in Crypto.Lol.Cyclotomic.Cyc | |
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 |
Defined in Crypto.Lol.Cyclotomic.Cyc |
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.