lol-0.5.0.0: A library for lattice cryptography.

Safe HaskellNone
LanguageHaskell2010

Crypto.Lol.Gadget

Description

Interfaces for "gadgets," decomposition, and error correction.

Synopsis

Documentation

class Ring u => Gadget gad u where Source #

Gadget vectors, parameterized by an index type.

Minimal complete definition

gadget

Methods

gadget :: Tagged gad [u] Source #

The gadget vector over u.

encode :: u -> Tagged gad [u] Source #

Yield an error-tolerant encoding of an element with respect to the gadget. (Mathematically, this should just be the product of the input with the gadget, but it is a class method to allow for optimized implementations.)

Instances

(Gadget k gad a, Gadget k gad b) => Gadget k gad (a, b) Source #

Product ring: concatenate gadgets over component rings

Methods

gadget :: Tagged gad (a, b) [u] Source #

encode :: u -> Tagged gad (a, b) [u] Source #

(Gadget k gad zq, Fact m, CElt t zq) => Gadget k gad (Cyc t m zq) Source #

promoted from base ring

Methods

gadget :: Tagged gad (Cyc t m zq) [u] Source #

encode :: u -> Tagged gad (Cyc t m zq) [u] Source #

(Reflects k q z, ToInteger z) => Gadget * TrivGad (ZqBasic k q z) Source # 

Methods

gadget :: Tagged TrivGad (ZqBasic k q z) [u] Source #

encode :: u -> Tagged TrivGad (ZqBasic k q z) [u] Source #

(Reflects k1 q z, ToInteger z, RealIntegral z, Reflects k b z) => Gadget * (BaseBGad k b) (ZqBasic k1 q z) Source # 

Methods

gadget :: Tagged (BaseBGad k b) (ZqBasic k1 q z) [u] Source #

encode :: u -> Tagged (BaseBGad k b) (ZqBasic k1 q z) [u] Source #

class (Gadget gad u, Reduce (DecompOf u) u) => Decompose gad u where Source #

Decomposition relative to a gadget.

Minimal complete definition

decompose

Associated Types

type DecompOf u Source #

The ring that u decomposes over.

Methods

decompose :: u -> Tagged gad [DecompOf u] Source #

Yield a short vector \( x \) such that \( \langle g, x\rangle = u \).

Instances

(Decompose k gad a, Decompose k gad b, (~) * (DecompOf a) (DecompOf b)) => Decompose k gad (a, b) Source #

Product ring: concatenate decompositions for component rings

Associated Types

type DecompOf u :: * Source #

Methods

decompose :: u -> Tagged gad (a, b) [DecompOf u] Source #

(Decompose k gad zq, Fact m, CElt t zq, CElt t (DecompOf zq)) => Decompose k gad (Cyc t m zq) Source #

promoted from base ring, using the powerful basis for best geometry

Associated Types

type DecompOf u :: * Source #

Methods

decompose :: u -> Tagged gad (Cyc t m zq) [DecompOf u] Source #

(Reflects k q z, ToInteger z) => Decompose * TrivGad (ZqBasic k q z) Source # 

Associated Types

type DecompOf u :: * Source #

Methods

decompose :: u -> Tagged TrivGad (ZqBasic k q z) [DecompOf u] Source #

(Reflects k1 q z, ToInteger z, Reflects k b z) => Decompose * (BaseBGad k b) (ZqBasic k1 q z) Source # 

Associated Types

type DecompOf u :: * Source #

Methods

decompose :: u -> Tagged (BaseBGad k b) (ZqBasic k1 q z) [DecompOf u] Source #

class Gadget gad u => Correct gad u where Source #

Error correction relative to a gadget.

Minimal complete definition

correct

Methods

correct :: Tagged gad [u] -> (u, [LiftOf u]) Source #

Error-correct a "noisy" encoding of an element (see encode), returning the encoded element and the error vector.

Instances

(Correct k gad a, Correct k gad b, Mod a, Mod b, Field a, Field b, Lift' a, Lift' b, ToInteger (LiftOf a), ToInteger (LiftOf b)) => Correct k gad (a, b) Source #

Product ring

Methods

correct :: Tagged gad (a, b) [u] -> (u, [LiftOf u]) Source #

(Correct k gad zq, Fact m, CElt t zq) => Correct k gad (Cyc t m zq) Source #

promoted from base ring, using the decoding basis for best geometry

Methods

correct :: Tagged gad (Cyc t m zq) [u] -> (u, [LiftOf u]) Source #

(Reflects k q z, ToInteger z, Ring z) => Correct * TrivGad (ZqBasic k q z) Source # 

Methods

correct :: Tagged TrivGad (ZqBasic k q z) [u] -> (u, [LiftOf u]) Source #

(Reflects k1 q z, ToInteger z, Reflects k b z) => Correct * (BaseBGad k b) (ZqBasic k1 q z) Source # 

Methods

correct :: Tagged (BaseBGad k b) (ZqBasic k1 q z) [u] -> (u, [LiftOf u]) Source #

decomposeT :: Decompose gad u => u -> TaggedT gad [] (DecompOf u) Source #

Alternative to decompose.

decomposeList :: Decompose gad u => [u] -> Tagged gad [DecompOf u] Source #

Decompose a list entry-wise.

decomposeMatrix :: forall gad u. Decompose gad u => Matrix u -> Tagged gad (Matrix (DecompOf u)) Source #

Decompose a matrix entry-wise.

data TrivGad Source #

Dummy type representing the gadget \( [1] \).

Instances

(Reflects k q z, ToInteger z, Ring z) => Correct * TrivGad (ZqBasic k q z) Source # 

Methods

correct :: Tagged TrivGad (ZqBasic k q z) [u] -> (u, [LiftOf u]) Source #

(Reflects k q z, ToInteger z) => Decompose * TrivGad (ZqBasic k q z) Source # 

Associated Types

type DecompOf u :: * Source #

Methods

decompose :: u -> Tagged TrivGad (ZqBasic k q z) [DecompOf u] Source #

(Reflects k q z, ToInteger z) => Gadget * TrivGad (ZqBasic k q z) Source # 

Methods

gadget :: Tagged TrivGad (ZqBasic k q z) [u] Source #

encode :: u -> Tagged TrivGad (ZqBasic k q z) [u] Source #

data BaseBGad b Source #

Dummy type representing the gadget \( [1,b,b^2,\ldots] \).

Instances

(Reflects k1 q z, ToInteger z, Reflects k b z) => Correct * (BaseBGad k b) (ZqBasic k1 q z) Source # 

Methods

correct :: Tagged (BaseBGad k b) (ZqBasic k1 q z) [u] -> (u, [LiftOf u]) Source #

(Reflects k1 q z, ToInteger z, Reflects k b z) => Decompose * (BaseBGad k b) (ZqBasic k1 q z) Source # 

Associated Types

type DecompOf u :: * Source #

Methods

decompose :: u -> Tagged (BaseBGad k b) (ZqBasic k1 q z) [DecompOf u] Source #

(Reflects k1 q z, ToInteger z, RealIntegral z, Reflects k b z) => Gadget * (BaseBGad k b) (ZqBasic k1 q z) Source # 

Methods

gadget :: Tagged (BaseBGad k b) (ZqBasic k1 q z) [u] Source #

encode :: u -> Tagged (BaseBGad k b) (ZqBasic k1 q z) [u] Source #