zkfold-base-0.1.0.0: ZkFold Symbolic compiler and zero-knowledge proof protocols
Safe HaskellSafe-Inferred
LanguageHaskell2010

ZkFold.Base.Algebra.Basic.Class

Synopsis

Documentation

class FromConstant a b where Source #

Every algebraic structure has a handful of "constant types" related with it: natural numbers, integers, field of constants etc. This typeclass captures this relation.

Methods

fromConstant :: a -> b Source #

Builds an element of an algebraic structure from a constant.

fromConstant should preserve algebraic structure, e.g. if both the structure and the type of constants are additive monoids, the following should hold:

Homomorphism
fromConstant (c + d) == fromConstant c + fromConstant d

Instances

Instances details
FromConstant Integer Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

FromConstant Natural Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

FromConstant Natural Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

FromConstant a a Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

fromConstant :: a -> a Source #

KnownNat p => FromConstant Integer (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

fromConstant :: Integer -> Zp p Source #

KnownNat p => FromConstant Natural (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

fromConstant :: Natural -> Zp p Source #

(Arithmetic a, FromConstant b a) => FromConstant b (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

FromConstant b a => FromConstant b [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

fromConstant :: b -> [a] Source #

(FromConstant Natural a, KnownNat n) => FromConstant Integer (ByteString n a) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.ByteString

(FromConstant Natural a, Finite a, AdditiveMonoid a, KnownNat n) => FromConstant Integer (UInt n a) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

fromConstant :: Integer -> UInt n a Source #

(FromConstant Natural a, KnownNat n) => FromConstant Natural (ByteString n a) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.ByteString

(FromConstant Natural a, Finite a, AdditiveMonoid a, KnownNat n) => FromConstant Natural (UInt n a) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

fromConstant :: Natural -> UInt n a Source #

FromConstant b a => FromConstant b (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

fromConstant :: b -> p -> a Source #

(FromConstant f f', Field f') => FromConstant f (Ext2 f' e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

fromConstant :: f -> Ext2 f' e Source #

(FromConstant f f', Field f') => FromConstant f (Ext3 f' ip) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

fromConstant :: f -> Ext3 f' ip Source #

Ord i => FromConstant c (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

fromConstant :: c -> Sources a i Source #

class ToConstant a b where Source #

Methods

toConstant :: a -> b Source #

Instances

Instances details
ToConstant a a Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

toConstant :: a -> a Source #

ToConstant (Zp p) Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

toConstant :: Zp p -> Natural Source #

ToConstant a Natural => ToConstant (ByteString n a) Natural Source # 
Instance details

Defined in ZkFold.Symbolic.Data.ByteString

(Finite (Zp p), KnownNat n) => ToConstant (UInt n (Zp p)) Integer Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

toConstant :: UInt n (Zp p) -> Integer Source #

(Finite (Zp p), KnownNat n) => ToConstant (UInt n (Zp p)) Natural Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

toConstant :: UInt n (Zp p) -> Natural Source #

class MultiplicativeSemigroup a where Source #

A class of types with a binary associative operation with a multiplicative feel to it. Not necessarily commutative.

Methods

(*) :: a -> a -> a infixl 7 Source #

A binary associative operation. The following should hold:

Associativity
x * (y * z) == (x * y) * z

Instances

Instances details
MultiplicativeSemigroup BLS12_381_GT Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.BLS12_381

MultiplicativeSemigroup Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(*) :: Integer -> Integer -> Integer Source #

MultiplicativeSemigroup Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(*) :: Natural -> Natural -> Natural Source #

MultiplicativeSemigroup Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(*) :: Bool -> Bool -> Bool Source #

MultiplicativeSemigroup a => MultiplicativeSemigroup (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(*) :: NonZero a -> NonZero a -> NonZero a Source #

KnownNat p => MultiplicativeSemigroup (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(*) :: Zp p -> Zp p -> Zp p Source #

(Field c, Eq c) => MultiplicativeSemigroup (Poly c) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

(*) :: Poly c -> Poly c -> Poly c Source #

Arithmetic a => MultiplicativeSemigroup (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

MultiplicativeSemigroup a => MultiplicativeSemigroup [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(*) :: [a] -> [a] -> [a] Source #

(Field f, Eq f, IrreduciblePoly f e) => MultiplicativeSemigroup (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(*) :: Ext2 f e -> Ext2 f e -> Ext2 f e Source #

(Field f, Eq f, IrreduciblePoly f e) => MultiplicativeSemigroup (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(*) :: Ext3 f e -> Ext3 f e -> Ext3 f e Source #

(Field c, KnownNat size, Eq c) => MultiplicativeSemigroup (PolyVec c size) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

(*) :: PolyVec c size -> PolyVec c size -> PolyVec c size Source #

(Finite (Zp p), KnownNat n) => MultiplicativeSemigroup (UInt n (Zp p)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

(*) :: UInt n (Zp p) -> UInt n (Zp p) -> UInt n (Zp p) Source #

(Arithmetic a, KnownNat n) => MultiplicativeSemigroup (UInt n (ArithmeticCircuit a)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

(Eq c, FiniteField c, Ord a, AdditiveGroup a, MultiplicativeMonoid a) => MultiplicativeSemigroup (Polynom a c) Source # 
Instance details

Defined in ZkFold.Symbolic.GroebnerBasis.Internal.Types

Methods

(*) :: Polynom a c -> Polynom a c -> Polynom a c Source #

MultiplicativeSemigroup a => MultiplicativeSemigroup (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(*) :: (p -> a) -> (p -> a) -> p -> a Source #

Ord i => MultiplicativeSemigroup (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

(*) :: Sources a i -> Sources a i -> Sources a i Source #

Monomial i j => MultiplicativeSemigroup (M i j (Map i j)) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Multivariate.Monomial

Methods

(*) :: M i j (Map i j) -> M i j (Map i j) -> M i j (Map i j) Source #

class MultiplicativeSemigroup b => Exponent a b where Source #

A class for semigroup (and monoid) actions on types where exponential notation is the most natural (including an exponentiation itself).

Methods

(^) :: a -> b -> a Source #

A right semigroup action on a type. The following should hold:

Compatibility
a ^ (m * n) == (a ^ m) ^ n

If exponents form a monoid, the following should also hold:

Right identity
a ^ one == a

NOTE, however, that even if exponents form a semigroup, left distributivity (that a ^ (m + n) == (a ^ m) * (a ^ n)) is desirable but not required: otherwise instance for Bool as exponent could not be made lawful.

Instances

Instances details
Exponent BLS12_381_GT Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.BLS12_381

Exponent BLS12_381_GT Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.BLS12_381

Exponent Integer Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(^) :: Integer -> Natural -> Integer Source #

Exponent Natural Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(^) :: Natural -> Natural -> Natural Source #

(Semiring a, Eq a) => Exponent Bool a Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(^) :: Bool -> a -> Bool Source #

MultiplicativeMonoid a => Exponent a Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(^) :: a -> Bool -> a Source #

(KnownNat p, MultiplicativeGroup a, Order a ~ p) => Exponent a (Zp p) Source #

Exponentiation by an element of a finite field is well-defined (and lawful) if and only if the base is a finite multiplicative group of a matching order.

Note that left distributivity is satisfied, meaning a ^ (m + n) = (a ^ m) * (a ^ n).

Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(^) :: a -> Zp p -> a Source #

Exponent a b => Exponent (NonZero a) b Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(^) :: NonZero a -> b -> NonZero a Source #

Prime p => Exponent (Zp p) Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(^) :: Zp p -> Integer -> Zp p Source #

KnownNat p => Exponent (Zp p) Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(^) :: Zp p -> Natural -> Zp p Source #

(Field c, Eq c) => Exponent (Poly c) Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

(^) :: Poly c -> Natural -> Poly c Source #

Arithmetic a => Exponent (ArithmeticCircuit a) Integer Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

Arithmetic a => Exponent (ArithmeticCircuit a) Natural Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

Exponent a b => Exponent [a] b Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(^) :: [a] -> b -> [a] Source #

Field (Ext2 f e) => Exponent (Ext2 f e) Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(^) :: Ext2 f e -> Integer -> Ext2 f e Source #

MultiplicativeMonoid (Ext2 f e) => Exponent (Ext2 f e) Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(^) :: Ext2 f e -> Natural -> Ext2 f e Source #

Field (Ext3 f e) => Exponent (Ext3 f e) Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(^) :: Ext3 f e -> Integer -> Ext3 f e Source #

MultiplicativeMonoid (Ext3 f e) => Exponent (Ext3 f e) Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(^) :: Ext3 f e -> Natural -> Ext3 f e Source #

(Field c, KnownNat size, Eq c) => Exponent (PolyVec c size) Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

(^) :: PolyVec c size -> Natural -> PolyVec c size Source #

MultiplicativeMonoid (UInt n a) => Exponent (UInt n a) Natural Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

(^) :: UInt n a -> Natural -> UInt n a Source #

MultiplicativeMonoid (Polynom a c) => Exponent (Polynom a c) Natural Source # 
Instance details

Defined in ZkFold.Symbolic.GroebnerBasis.Internal.Types

Methods

(^) :: Polynom a c -> Natural -> Polynom a c Source #

Exponent a b => Exponent (p -> a) b Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(^) :: (p -> a) -> b -> p -> a Source #

MultiplicativeSemigroup c => Exponent (Sources a i) c Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

(^) :: Sources a i -> c -> Sources a i Source #

(Monomial i j, Ring j) => Exponent (M i j (Map i j)) Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Multivariate.Monomial

Methods

(^) :: M i j (Map i j) -> Integer -> M i j (Map i j) Source #

Monomial i j => Exponent (M i j (Map i j)) Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Multivariate.Monomial

Methods

(^) :: M i j (Map i j) -> Natural -> M i j (Map i j) Source #

class (MultiplicativeSemigroup a, Exponent a Natural) => MultiplicativeMonoid a where Source #

A class of types with a binary associative operation with a multiplicative feel to it and an identity element. Not necessarily commutative.

While exponentiation by a natural is specified as a constraint, a default implementation is provided as a natPow function. You can provide a faster alternative, but do not forget to check that it satisfies the following (in addition to the properties already stated in Exponent documentation):

Left identity
one ^ n == one
Absorption
a ^ 0 == one
Left distributivity
a ^ (m + n) == (a ^ m) * (a ^ n)

Finally, if the base monoid operation is commutative, power should distribute over (MultiplicativeSemigroup):

Right distributivity
(a * b) ^ n == (a ^ n) * (b ^ n)

Methods

one :: a Source #

An identity with respect to multiplication:

Left identity
one * x == x
Right identity
x * one == x

Instances

Instances details
MultiplicativeMonoid BLS12_381_GT Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.BLS12_381

MultiplicativeMonoid Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

one :: Integer Source #

MultiplicativeMonoid Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

one :: Natural Source #

MultiplicativeMonoid Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

one :: Bool Source #

MultiplicativeMonoid a => MultiplicativeMonoid (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

one :: NonZero a Source #

KnownNat p => MultiplicativeMonoid (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

one :: Zp p Source #

(Field c, Eq c) => MultiplicativeMonoid (Poly c) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

one :: Poly c Source #

Arithmetic a => MultiplicativeMonoid (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

MultiplicativeMonoid a => MultiplicativeMonoid [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

one :: [a] Source #

(Field f, Eq f, IrreduciblePoly f e) => MultiplicativeMonoid (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

one :: Ext2 f e Source #

(Field f, Eq f, IrreduciblePoly f e) => MultiplicativeMonoid (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

one :: Ext3 f e Source #

(Field c, KnownNat size, Eq c) => MultiplicativeMonoid (PolyVec c size) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

one :: PolyVec c size Source #

(Finite (Zp p), KnownNat n) => MultiplicativeMonoid (UInt n (Zp p)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

one :: UInt n (Zp p) Source #

(Arithmetic a, KnownNat n) => MultiplicativeMonoid (UInt n (ArithmeticCircuit a)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

(Eq c, FiniteField c, Ord a, AdditiveGroup a, MultiplicativeMonoid a) => MultiplicativeMonoid (Polynom a c) Source # 
Instance details

Defined in ZkFold.Symbolic.GroebnerBasis.Internal.Types

Methods

one :: Polynom a c Source #

MultiplicativeMonoid a => MultiplicativeMonoid (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

one :: p -> a Source #

Ord i => MultiplicativeMonoid (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

one :: Sources a i Source #

Monomial i j => MultiplicativeMonoid (M i j (Map i j)) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Multivariate.Monomial

Methods

one :: M i j (Map i j) Source #

natPow :: MultiplicativeMonoid a => a -> Natural -> a Source #

A default implementation for natural exponentiation. Uses only (MultiplicativeSemigroup) and one so doesn't loop via an Exponent Natural a instance.

multiExp :: (MultiplicativeMonoid a, Exponent a b, Foldable t) => a -> t b -> a Source #

class MultiplicativeMonoid b => Scale b a where Source #

A class for monoid actions where multiplicative notation is the most natural (including multiplication by constant itself).

Minimal complete definition

Nothing

Methods

scale :: b -> a -> a Source #

A left monoid action on a type. Should satisfy the following:

Compatibility
scale (c * d) a == scale c (scale d a)
Left identity
scale one a == a

If, in addition, a cast from constant is defined, they should agree:

Scale agrees
scale c a == fromConstant c * a
Cast agrees
fromConstant c == scale c one

If the action is on an abelian structure, scaling should respect it:

Left distributivity
scale c (a + b) == scale c a + scale c b
Right absorption
scale c zero == zero

If, in addition, the scaling itself is abelian, this structure should propagate:

Right distributivity
scale (c + d) a == scale c a + scale d a
Left absorption
scale zero a == zero

The default implementation is the multiplication by a constant.

default scale :: (FromConstant b a, MultiplicativeSemigroup a) => b -> a -> a Source #

Instances

Instances details
Scale Integer Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

scale :: Integer -> Bool -> Bool Source #

Scale Natural Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Scale Natural Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

scale :: Natural -> Bool -> Bool Source #

MultiplicativeMonoid a => Scale a a Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

scale :: a -> a -> a Source #

KnownNat p => Scale Integer (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

scale :: Integer -> Zp p -> Zp p Source #

KnownNat p => Scale Natural (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

scale :: Natural -> Zp p -> Zp p Source #

(Scale b a, Functor f) => Scale b (f a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

scale :: b -> f a -> f a Source #

(Arithmetic a, Scale c a) => Scale c (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

(EllipticCurve curve, AdditiveGroup (BaseField curve)) => Scale Integer (Point curve) Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.Class

Methods

scale :: Integer -> Point curve -> Point curve Source #

(FromConstant Natural a, Finite a, AdditiveMonoid a, KnownNat n, MultiplicativeSemigroup (UInt n a)) => Scale Integer (UInt n a) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

scale :: Integer -> UInt n a -> UInt n a Source #

EllipticCurve curve => Scale Natural (Point curve) Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.Class

Methods

scale :: Natural -> Point curve -> Point curve Source #

(FromConstant Natural a, Finite a, AdditiveMonoid a, KnownNat n, MultiplicativeSemigroup (UInt n a)) => Scale Natural (UInt n a) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

scale :: Natural -> UInt n a -> UInt n a Source #

Scale c f => Scale c (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

scale :: c -> Ext2 f e -> Ext2 f e Source #

Scale c f => Scale c (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

scale :: c -> Ext3 f e -> Ext3 f e Source #

Scale c a => Scale c (SVector size a) Source # 
Instance details

Defined in ZkFold.Base.Data.Sparse.Vector

Methods

scale :: c -> SVector size a -> SVector size a Source #

Scale c' c => Scale c' (PolyVec c size) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

scale :: c' -> PolyVec c size -> PolyVec c size Source #

MultiplicativeMonoid c => Scale c (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

scale :: c -> Sources a i -> Sources a i Source #

class (MultiplicativeMonoid a, Exponent a Integer) => MultiplicativeGroup a where Source #

A class of groups in a multiplicative notation.

While exponentiation by an integer is specified in a constraint, a default implementation is provided as an intPow function. You can provide a faster alternative yourself, but do not forget to check that your implementation computes the same results on all inputs.

Minimal complete definition

(invert | (/))

Methods

(/) :: a -> a -> a infixl 7 Source #

Division in a group. The following should hold:

Division
x / x == one
Cancellation
(y / x) * x == y
Agreement
x / y == x * invert y

invert :: a -> a Source #

Inverse in a group. The following should hold:

Left inverse
invert x * x == one
Right inverse
x * invert x == one
Agreement
invert x == one / x

Instances

Instances details
MultiplicativeGroup BLS12_381_GT Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.BLS12_381

MultiplicativeGroup Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(/) :: Bool -> Bool -> Bool Source #

invert :: Bool -> Bool Source #

Field a => MultiplicativeGroup (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(/) :: NonZero a -> NonZero a -> NonZero a Source #

invert :: NonZero a -> NonZero a Source #

MultiplicativeGroup a => MultiplicativeGroup [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(/) :: [a] -> [a] -> [a] Source #

invert :: [a] -> [a] Source #

MultiplicativeGroup a => MultiplicativeGroup (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(/) :: (p -> a) -> (p -> a) -> p -> a Source #

invert :: (p -> a) -> p -> a Source #

Ord i => MultiplicativeGroup (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

(/) :: Sources a i -> Sources a i -> Sources a i Source #

invert :: Sources a i -> Sources a i Source #

(Monomial i j, Ring j) => MultiplicativeGroup (M i j (Map i j)) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Multivariate.Monomial

Methods

(/) :: M i j (Map i j) -> M i j (Map i j) -> M i j (Map i j) Source #

invert :: M i j (Map i j) -> M i j (Map i j) Source #

intPow :: MultiplicativeGroup a => a -> Integer -> a Source #

A default implementation for integer exponentiation. Uses only natural exponentiation and invert so doesn't loop via an Exponent Integer a instance.

class AdditiveSemigroup a where Source #

A class of types with a binary associative, commutative operation.

Methods

(+) :: a -> a -> a infixl 6 Source #

A binary associative commutative operation. The following should hold:

Associativity
x + (y + z) == (x + y) + z
Commutativity
x + y == y + x

Instances

Instances details
AdditiveSemigroup Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(+) :: Integer -> Integer -> Integer Source #

AdditiveSemigroup Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(+) :: Natural -> Natural -> Natural Source #

AdditiveSemigroup Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(+) :: Bool -> Bool -> Bool Source #

KnownNat p => AdditiveSemigroup (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(+) :: Zp p -> Zp p -> Zp p Source #

(Ring c, Eq c) => AdditiveSemigroup (Poly c) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

(+) :: Poly c -> Poly c -> Poly c Source #

Arithmetic a => AdditiveSemigroup (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

AdditiveSemigroup a => AdditiveSemigroup [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(+) :: [a] -> [a] -> [a] Source #

Field f => AdditiveSemigroup (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(+) :: Ext2 f e -> Ext2 f e -> Ext2 f e Source #

Field f => AdditiveSemigroup (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(+) :: Ext3 f e -> Ext3 f e -> Ext3 f e Source #

EllipticCurve curve => AdditiveSemigroup (Point curve) Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.Class

Methods

(+) :: Point curve -> Point curve -> Point curve Source #

Ring c => AdditiveSemigroup (PolyVec c size) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

(+) :: PolyVec c size -> PolyVec c size -> PolyVec c size Source #

(KnownNat size, AdditiveMonoid a, Eq a) => AdditiveSemigroup (SVector size a) Source # 
Instance details

Defined in ZkFold.Base.Data.Sparse.Vector

Methods

(+) :: SVector size a -> SVector size a -> SVector size a Source #

(Finite (Zp p), KnownNat n) => AdditiveSemigroup (UInt n (Zp p)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

(+) :: UInt n (Zp p) -> UInt n (Zp p) -> UInt n (Zp p) Source #

(Arithmetic a, KnownNat n) => AdditiveSemigroup (UInt n (ArithmeticCircuit a)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

(Eq c, FiniteField c, Ord a, MultiplicativeMonoid a) => AdditiveSemigroup (Polynom a c) Source # 
Instance details

Defined in ZkFold.Symbolic.GroebnerBasis.Internal.Types

Methods

(+) :: Polynom a c -> Polynom a c -> Polynom a c Source #

AdditiveSemigroup a => AdditiveSemigroup (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(+) :: (p -> a) -> (p -> a) -> p -> a Source #

Ord i => AdditiveSemigroup (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

(+) :: Sources a i -> Sources a i -> Sources a i Source #

class (AdditiveSemigroup a, Scale Natural a) => AdditiveMonoid a where Source #

A class of types with a binary associative, commutative operation and with an identity element.

While scaling by a natural is specified as a constraint, a default implementation is provided as a natScale function.

Methods

zero :: a Source #

An identity with respect to addition:

Identity
x + zero == x

Instances

Instances details
AdditiveMonoid Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

zero :: Integer Source #

AdditiveMonoid Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

zero :: Natural Source #

AdditiveMonoid Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

zero :: Bool Source #

KnownNat p => AdditiveMonoid (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

zero :: Zp p Source #

(Ring c, Eq c) => AdditiveMonoid (Poly c) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

zero :: Poly c Source #

Arithmetic a => AdditiveMonoid (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

AdditiveMonoid a => AdditiveMonoid [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

zero :: [a] Source #

Field f => AdditiveMonoid (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

zero :: Ext2 f e Source #

Field f => AdditiveMonoid (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

zero :: Ext3 f e Source #

EllipticCurve curve => AdditiveMonoid (Point curve) Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.Class

Methods

zero :: Point curve Source #

(Ring c, KnownNat size) => AdditiveMonoid (PolyVec c size) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

zero :: PolyVec c size Source #

(KnownNat size, AdditiveMonoid a, Eq a) => AdditiveMonoid (SVector size a) Source # 
Instance details

Defined in ZkFold.Base.Data.Sparse.Vector

Methods

zero :: SVector size a Source #

(Finite (Zp p), KnownNat n) => AdditiveMonoid (UInt n (Zp p)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

zero :: UInt n (Zp p) Source #

(Arithmetic a, KnownNat n) => AdditiveMonoid (UInt n (ArithmeticCircuit a)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

(Eq c, FiniteField c, Ord a, MultiplicativeMonoid a) => AdditiveMonoid (Polynom a c) Source # 
Instance details

Defined in ZkFold.Symbolic.GroebnerBasis.Internal.Types

Methods

zero :: Polynom a c Source #

AdditiveMonoid a => AdditiveMonoid (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

zero :: p -> a Source #

Ord i => AdditiveMonoid (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

zero :: Sources a i Source #

natScale :: AdditiveMonoid a => Natural -> a -> a Source #

A default implementation for natural scaling. Uses only (AdditiveSemigroup) and zero so doesn't loop via a Scale Natural a instance.

sum :: (Foldable t, AdditiveMonoid a) => t a -> a Source #

class (AdditiveMonoid a, Scale Integer a) => AdditiveGroup a where Source #

A class of abelian groups.

While scaling by an integer is specified in a constraint, a default implementation is provided as an intScale function.

Minimal complete definition

(negate | (-))

Methods

(-) :: a -> a -> a infixl 6 Source #

Subtraction in an abelian group. The following should hold:

Subtraction
x - x == zero
Agreement
x - y == x + negate y

negate :: a -> a Source #

Inverse in an abelian group. The following should hold:

Negative
x + negate x == zero
Agreement
negate x == zero - x

Instances

Instances details
AdditiveGroup Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

AdditiveGroup Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(-) :: Bool -> Bool -> Bool Source #

negate :: Bool -> Bool Source #

KnownNat p => AdditiveGroup (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(-) :: Zp p -> Zp p -> Zp p Source #

negate :: Zp p -> Zp p Source #

(Ring c, Eq c) => AdditiveGroup (Poly c) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

(-) :: Poly c -> Poly c -> Poly c Source #

negate :: Poly c -> Poly c Source #

Arithmetic a => AdditiveGroup (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

AdditiveGroup a => AdditiveGroup [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

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

negate :: [a] -> [a] Source #

Field f => AdditiveGroup (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(-) :: Ext2 f e -> Ext2 f e -> Ext2 f e Source #

negate :: Ext2 f e -> Ext2 f e Source #

Field f => AdditiveGroup (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(-) :: Ext3 f e -> Ext3 f e -> Ext3 f e Source #

negate :: Ext3 f e -> Ext3 f e Source #

(EllipticCurve curve, AdditiveGroup (BaseField curve)) => AdditiveGroup (Point curve) Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.Class

Methods

(-) :: Point curve -> Point curve -> Point curve Source #

negate :: Point curve -> Point curve Source #

(Ring c, KnownNat size) => AdditiveGroup (PolyVec c size) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Polynomials.Univariate

Methods

(-) :: PolyVec c size -> PolyVec c size -> PolyVec c size Source #

negate :: PolyVec c size -> PolyVec c size Source #

(KnownNat size, AdditiveGroup a, Eq a) => AdditiveGroup (SVector size a) Source # 
Instance details

Defined in ZkFold.Base.Data.Sparse.Vector

Methods

(-) :: SVector size a -> SVector size a -> SVector size a Source #

negate :: SVector size a -> SVector size a Source #

(Finite (Zp p), KnownNat n) => AdditiveGroup (UInt n (Zp p)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

(-) :: UInt n (Zp p) -> UInt n (Zp p) -> UInt n (Zp p) Source #

negate :: UInt n (Zp p) -> UInt n (Zp p) Source #

(Arithmetic a, KnownNat n) => AdditiveGroup (UInt n (ArithmeticCircuit a)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

(Eq c, FiniteField c, Ord a, MultiplicativeMonoid a) => AdditiveGroup (Polynom a c) Source # 
Instance details

Defined in ZkFold.Symbolic.GroebnerBasis.Internal.Types

Methods

(-) :: Polynom a c -> Polynom a c -> Polynom a c Source #

negate :: Polynom a c -> Polynom a c Source #

AdditiveGroup a => AdditiveGroup (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(-) :: (p -> a) -> (p -> a) -> p -> a Source #

negate :: (p -> a) -> p -> a Source #

Ord i => AdditiveGroup (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

(-) :: Sources a i -> Sources a i -> Sources a i Source #

negate :: Sources a i -> Sources a i Source #

intScale :: AdditiveGroup a => Integer -> a -> a Source #

A default implementation for integer scaling. Uses only natural scaling and negate so doesn't loop via a Scale Integer a instance.

class (AdditiveMonoid a, MultiplicativeMonoid a, FromConstant Natural a) => Semiring a Source #

Class of semirings with both 0 and 1. The following should hold:

Left distributivity
a * (b + c) == a * b + a * c
Right distributivity
(a + b) * c == a * c + b * c

Instances

Instances details
Semiring Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Semiring Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Semiring Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

KnownNat p => Semiring (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Arithmetic a => Semiring (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

Semiring a => Semiring [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

(Field f, Eq f, IrreduciblePoly f e) => Semiring (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

(Field f, Eq f, IrreduciblePoly f e) => Semiring (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

(Finite (Zp p), KnownNat n) => Semiring (UInt n (Zp p)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

(Arithmetic a, KnownNat n) => Semiring (UInt n (ArithmeticCircuit a)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Semiring a => Semiring (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Ord i => Semiring (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

class Semiring a => EuclideanDomain a where Source #

A Euclidean domain R is an integral domain which can be endowed with at least one function f : R{0} -> R+ s.t. If a and b are in R and b is nonzero, then there exist q and r in R such that a = bq + r and either r = 0 or f(r) < f(b).

q and r are called respectively a quotient and a remainder of the division (or Euclidean division) of a by b.

The function divMod associated with this class produces q and r given a and b.

Minimal complete definition

divMod

Methods

divMod :: a -> a -> (a, a) Source #

div :: a -> a -> a Source #

mod :: a -> a -> a Source #

Instances

Instances details
EuclideanDomain Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

EuclideanDomain Natural Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

KnownNat p => EuclideanDomain (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

divMod :: Zp p -> Zp p -> (Zp p, Zp p) Source #

div :: Zp p -> Zp p -> Zp p Source #

mod :: Zp p -> Zp p -> Zp p Source #

(Finite (Zp p), KnownNat n) => EuclideanDomain (UInt n (Zp p)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Methods

divMod :: UInt n (Zp p) -> UInt n (Zp p) -> (UInt n (Zp p), UInt n (Zp p)) Source #

div :: UInt n (Zp p) -> UInt n (Zp p) -> UInt n (Zp p) Source #

mod :: UInt n (Zp p) -> UInt n (Zp p) -> UInt n (Zp p) Source #

(Arithmetic a, KnownNat n) => EuclideanDomain (UInt n (ArithmeticCircuit a)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

class (Semiring a, AdditiveGroup a, FromConstant Integer a) => Ring a Source #

Class of rings with both 0, 1 and additive inverses. The following should hold:

Left distributivity
a * (b - c) == a * b - a * c
Right distributivity
(a - b) * c == a * c - b * c

Instances

Instances details
Ring Integer Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Ring Bool Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

KnownNat p => Ring (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Arithmetic a => Ring (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

Ring a => Ring [a] Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

(Field f, Eq f, IrreduciblePoly f e) => Ring (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

(Field f, Eq f, IrreduciblePoly f e) => Ring (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

(Finite (Zp p), KnownNat n) => Ring (UInt n (Zp p)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

(Arithmetic a, KnownNat n) => Ring (UInt n (ArithmeticCircuit a)) Source # 
Instance details

Defined in ZkFold.Symbolic.Data.UInt

Ring a => Ring (p -> a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Ord i => Ring (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

type Algebra b a = (Ring a, Scale b a, FromConstant b a) Source #

Type of modules/algebras over the base type of constants b. As all the required laws are implied by the constraints, this is simply an alias rather than a typeclass in its own right.

Note the following useful facts:

  • every Ring is an algebra over natural numbers and over integers;
  • every Ring is an algebra over itself. However, due to the possible overlapping instances of Scale a a and FromConstant a a you might need to defer the resolution of these constraints until a is specified.

class (Ring a, Exponent a Integer) => Field a where Source #

Class of fields. As a ring, each field is commutative, that is:

Commutativity
x * y == y * x

While exponentiation by an integer is specified in a constraint, a default implementation is provided as an intPowF function. You can provide a faster alternative yourself, but do not forget to check that your implementation computes the same results on all inputs.

Minimal complete definition

(finv | (//))

Methods

(//) :: a -> a -> a Source #

Division in a field. The following should hold:

Division
If x /= 0, x // x == one
Div by 0
x // zero == zero
Agreement
x // y == x * finv y

finv :: a -> a Source #

Inverse in a field. The following should hold:

Inverse
If x /= 0, x * inverse x == one
Inv of 0
inverse zero == zero
Agreement
finv x == one // x

rootOfUnity :: Natural -> Maybe a Source #

rootOfUnity n is an element of a characteristic 2^n, that is,

Root of 0
rootOfUnity 0 == Just one
Root property
If rootOfUnity n == Just x, x ^ (2 ^ n) == one
Smallest root
If rootOfUnity n == Just x and m < n, x ^ (2 ^ m) /= one
All roots
If rootOfUnity n == Just x and m < n, rootOfUnity m /= Nothing

Instances

Instances details
Prime p => Field (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(//) :: Zp p -> Zp p -> Zp p Source #

finv :: Zp p -> Zp p Source #

rootOfUnity :: Natural -> Maybe (Zp p) Source #

Arithmetic a => Field (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

(Field f, Eq f, IrreduciblePoly f e) => Field (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(//) :: Ext2 f e -> Ext2 f e -> Ext2 f e Source #

finv :: Ext2 f e -> Ext2 f e Source #

rootOfUnity :: Natural -> Maybe (Ext2 f e) Source #

(Field f, Eq f, IrreduciblePoly f e) => Field (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

(//) :: Ext3 f e -> Ext3 f e -> Ext3 f e Source #

finv :: Ext3 f e -> Ext3 f e Source #

rootOfUnity :: Natural -> Maybe (Ext3 f e) Source #

Ord i => Field (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Methods

(//) :: Sources a i -> Sources a i -> Sources a i Source #

finv :: Sources a i -> Sources a i Source #

rootOfUnity :: Natural -> Maybe (Sources a i) Source #

intPowF :: Field a => a -> Integer -> a Source #

A default implementation for integer exponentiation. Uses only natural exponentiation and finv so doesn't loop via an Exponent Integer a instance.

class (KnownNat (Order a), KnownNat (NumberOfBits a)) => Finite (a :: Type) Source #

Class of finite structures. Order a should be the actual number of elements in the type, identified up to the associated equality relation.

Associated Types

type Order a :: Natural Source #

Instances

Instances details
Finite BLS12_381_GT Source # 
Instance details

Defined in ZkFold.Base.Algebra.EllipticCurve.BLS12_381

Associated Types

type Order BLS12_381_GT :: Natural Source #

(KnownNat (Order (NonZero a)), KnownNat (NumberOfBits (NonZero a))) => Finite (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Associated Types

type Order (NonZero a) :: Natural Source #

(KnownNat p, KnownNat (NumberOfBits (Zp p))) => Finite (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Associated Types

type Order (Zp p) :: Natural Source #

FiniteField a => Finite (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

Associated Types

type Order (ArithmeticCircuit a) :: Natural Source #

(KnownNat (Order (Ext2 f e)), KnownNat (NumberOfBits (Ext2 f e))) => Finite (Ext2 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Associated Types

type Order (Ext2 f e) :: Natural Source #

(KnownNat (Order (Ext3 f e)), KnownNat (NumberOfBits (Ext3 f e))) => Finite (Ext3 f e) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Associated Types

type Order (Ext3 f e) :: Natural Source #

Finite a => Finite (Sources a i) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Sources

Associated Types

type Order (Sources a i) :: Natural Source #

order :: forall a. Finite a => Natural Source #

type NumberOfBits a = Log2 (Order a - 1) + 1 Source #

type FiniteField a = (Finite a, Field a) Source #

class Field a => DiscreteField' a where Source #

A field is a commutative ring in which an element is invertible if and only if it is nonzero. In a discrete field an element is invertible xor it equals zero. That is equivalent in classical logic but stronger in constructive logic. Every element is either 0 or invertible, and 0 ≠ 1.

We represent a discrete field as a field with an internal equality function which returns one for equal field elements and zero for distinct field elements.

Minimal complete definition

Nothing

Methods

equal :: a -> a -> a Source #

default equal :: Eq a => a -> a -> a Source #

Instances

Instances details
Prime p => DiscreteField' (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

equal :: Zp p -> Zp p -> Zp p Source #

Arithmetic a => DiscreteField' (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

class DiscreteField' a => TrichotomyField a where Source #

An ordering of a field is usually required to have compatibility laws with respect to addition and multiplication. However, we can drop that requirement and define a trichotomy field as one with an internal total ordering. We represent a trichotomy field as a discrete field with an internal comparison of field elements returning negate one for <, zero for =, and one for >. The law of trichotomy is that for any two field elements, exactly one of the relations =, or holds. Thus we require that -1, 0 and 1 are distinct field elements.

equal a b = one - (trichotomy a b)^2

Minimal complete definition

Nothing

Methods

trichotomy :: a -> a -> a Source #

default trichotomy :: Ord a => a -> a -> a Source #

Instances

Instances details
Prime p => TrichotomyField (Zp p) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Field

Methods

trichotomy :: Zp p -> Zp p -> Zp p Source #

Arithmetic a => TrichotomyField (ArithmeticCircuit a) Source # 
Instance details

Defined in ZkFold.Symbolic.Compiler.ArithmeticCircuit.Instance

class Semiring a => BinaryExpansion a where Source #

Class of semirings where a binary expansion of elements can be computed. Note: numbers should convert to Little-endian bit representation.

The following should hold:

  • fromBinary . binaryExpansion == id
  • fromBinary xs == foldr (x y -> x + y + y) zero xs

Minimal complete definition

binaryExpansion

Methods

binaryExpansion :: a -> [a] Source #

fromBinary :: [a] -> a Source #

padBits :: forall a. BinaryExpansion a => Natural -> [a] -> [a] Source #

castBits :: (Semiring a, Eq a, Semiring b) => [a] -> [b] Source #

newtype NonZero a Source #

A multiplicative subgroup of nonzero elements of a field. TODO: hide constructor

Constructors

NonZero a 

Instances

Instances details
(KnownNat (Order (NonZero a)), KnownNat (NumberOfBits (NonZero a))) => Finite (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Associated Types

type Order (NonZero a) :: Natural Source #

Field a => MultiplicativeGroup (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(/) :: NonZero a -> NonZero a -> NonZero a Source #

invert :: NonZero a -> NonZero a Source #

MultiplicativeMonoid a => MultiplicativeMonoid (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

one :: NonZero a Source #

MultiplicativeSemigroup a => MultiplicativeSemigroup (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(*) :: NonZero a -> NonZero a -> NonZero a Source #

Exponent a b => Exponent (NonZero a) b Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

Methods

(^) :: NonZero a -> b -> NonZero a Source #

type Order (NonZero a) Source # 
Instance details

Defined in ZkFold.Base.Algebra.Basic.Class

type Order (NonZero a) = Order a - 1

(-!) :: Natural -> Natural -> Natural infixl 6 Source #