Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class (Field (BaseFieldOf point), Eq (BaseFieldOf point), Planar (BaseFieldOf point) point, AdditiveGroup point) => EllipticCurve point where
- type CurveOf point :: Symbol
- type BaseFieldOf point :: Type
- isOnCurve :: point -> BooleanOf (BaseFieldOf point)
- class (AdditiveGroup g, FiniteField (ScalarFieldOf g), Scale (ScalarFieldOf g) g) => CyclicGroup g where
- type ScalarFieldOf g :: Type
- pointGen :: g
- type CycleOfCurves g1 g2 = (EllipticCurve g1, EllipticCurve g2, CyclicGroup g1, CyclicGroup g2, ScalarFieldOf g1 ~ BaseFieldOf g2, BaseFieldOf g1 ~ ScalarFieldOf g2)
- class Field field => WeierstrassCurve (curve :: Symbol) field where
- weierstrassB :: field
- class Field field => TwistedEdwardsCurve (curve :: Symbol) field where
- twistedEdwardsA :: field
- twistedEdwardsD :: field
- class Eq (BaseFieldOf point) => Compressible point where
- type Compressed point :: Type
- pointCompressed :: BaseFieldOf point -> BooleanOf (BaseFieldOf point) -> Compressed point
- compress :: point -> Compressed point
- decompress :: Compressed point -> point
- class (CyclicGroup g1, CyclicGroup g2, ScalarFieldOf g1 ~ ScalarFieldOf g2, MultiplicativeGroup gt, Exponent gt (ScalarFieldOf g1)) => Pairing g1 g2 gt | g1 g2 -> gt where
- pairing :: g1 -> g2 -> gt
- class Planar field point | point -> field where
- pointXY :: field -> field -> point
- class HasPointInf point where
- pointInf :: point
- newtype Weierstrass curve point = Weierstrass {
- pointWeierstrass :: point
- newtype TwistedEdwards curve point = TwistedEdwards {
- pointTwistedEdwards :: point
- data Point field = Point {}
- data CompressedPoint field = CompressedPoint {}
- data AffinePoint field = AffinePoint {}
curve classes
class (Field (BaseFieldOf point), Eq (BaseFieldOf point), Planar (BaseFieldOf point) point, AdditiveGroup point) => EllipticCurve point where Source #
Elliptic curves are plane algebraic curves that form AdditiveGroup
s.
Elliptic curves always have genus 1
and are birationally equivalent
to a projective curve of degree 3
. As such, elliptic curves are
the simplest curves after conic sections, curves of degree 2
,
and lines, curves of degree 1
. Bézout's theorem implies
that a line in general position will intersect with an
elliptic curve at 3 points counting multiplicity;
point0
, point1
and point2
.
The geometric group law of the elliptic curve is:
point0 + point1 + point2 = zero
isOnCurve :: point -> BooleanOf (BaseFieldOf point) Source #
isOnCurve
validates an equation for a plane algebraic curve
which has degree 3 up to some birational equivalence.
Instances
(TwistedEdwardsCurve curve field, Field field, Eq field) => EllipticCurve (TwistedEdwards curve (AffinePoint field)) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class type CurveOf (TwistedEdwards curve (AffinePoint field)) :: Symbol Source # type BaseFieldOf (TwistedEdwards curve (AffinePoint field)) Source # isOnCurve :: TwistedEdwards curve (AffinePoint field) -> BooleanOf (BaseFieldOf (TwistedEdwards curve (AffinePoint field))) Source # | |
(WeierstrassCurve curve field, Conditional (BooleanOf field) (BooleanOf field), Conditional (BooleanOf field) field, Eq field, Field field) => EllipticCurve (Weierstrass curve (Point field)) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class type CurveOf (Weierstrass curve (Point field)) :: Symbol Source # type BaseFieldOf (Weierstrass curve (Point field)) Source # isOnCurve :: Weierstrass curve (Point field) -> BooleanOf (BaseFieldOf (Weierstrass curve (Point field))) Source # |
class (AdditiveGroup g, FiniteField (ScalarFieldOf g), Scale (ScalarFieldOf g) g) => CyclicGroup g where Source #
Both the ECDSA and ECDH algorithms make use of
the elliptic curve discrete logarithm problem, ECDLP.
There may be a discrete "exponential" function
from a PrimeField
of scalars
into the AdditiveGroup
of points on an elliptic curve.
It's given naturally by scaling a point of prime order,
if there is one on the curve.
scale order pointGen = zero
>>>
let discreteExp scalar = scale scalar pointGen
Then the inverse of discreteExp
is hard to compute.
type ScalarFieldOf g :: Type Source #
generator of a cyclic subgroup
scale (order @(ScalarFieldOf g)) pointGen = zero
Instances
type CycleOfCurves g1 g2 = (EllipticCurve g1, EllipticCurve g2, CyclicGroup g1, CyclicGroup g2, ScalarFieldOf g1 ~ BaseFieldOf g2, BaseFieldOf g1 ~ ScalarFieldOf g2) Source #
A cycle of two curves elliptic curves over finite fields such that the number of points on one curve is equal to the size of the field of definition of the next, in a cyclic way.
class Field field => WeierstrassCurve (curve :: Symbol) field where Source #
The standard form of an elliptic curve is the Weierstrass equation:
y^2 = x^3 + a*x + b
- Weierstrass curves have x-axis symmetry.
- The characteristic of the field must not be
2
or3
. - The curve must have nonzero discriminant
Δ = -16 * (4*a^3 + 27*b^3)
. - When
a = 0
some computations can be simplified so all the public Weierstrass curves havea = zero
and nonzerob
and we do too.
weierstrassB :: field Source #
Instances
class Field field => TwistedEdwardsCurve (curve :: Symbol) field where Source #
A twisted Edwards curve is defined by the equation:
a*x^2 + y^2 = 1 + d*x^2*y^2
- Twisted Edwards curves have y-axis symmetry.
- The characteristic of the field must not be
2
. a
andd
must be nonzero.
twistedEdwardsA :: field Source #
twistedEdwardsD :: field Source #
Instances
Field field => TwistedEdwardsCurve "ed25519" field Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Ed25519 twistedEdwardsA :: field Source # twistedEdwardsD :: field Source # |
class Eq (BaseFieldOf point) => Compressible point where Source #
type Compressed point :: Type Source #
pointCompressed :: BaseFieldOf point -> BooleanOf (BaseFieldOf point) -> Compressed point Source #
compress :: point -> Compressed point Source #
decompress :: Compressed point -> point Source #
Instances
class (CyclicGroup g1, CyclicGroup g2, ScalarFieldOf g1 ~ ScalarFieldOf g2, MultiplicativeGroup gt, Exponent gt (ScalarFieldOf g1)) => Pairing g1 g2 gt | g1 g2 -> gt where Source #
point classes
class Planar field point | point -> field where Source #
A class for smart constructor method
pointXY
for constructing points from an x
and y
coordinate.
Instances
Planar field (AffinePoint field) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class pointXY :: field -> field -> AffinePoint field Source # | |
Eq field => Planar field (Point field) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class | |
Planar field point => Planar field (TwistedEdwards curve point) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class pointXY :: field -> field -> TwistedEdwards curve point Source # | |
Planar field point => Planar field (Weierstrass curve point) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class pointXY :: field -> field -> Weierstrass curve point Source # |
class HasPointInf point where Source #
A class for smart constructor method
pointInf
for constructing the point at infinity.
Instances
(BoolType (BooleanOf field), AdditiveMonoid field) => HasPointInf (CompressedPoint field) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class pointInf :: CompressedPoint field Source # | |
(Semiring field, Eq field) => HasPointInf (Point field) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class | |
HasPointInf point => HasPointInf (TwistedEdwards curve point) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class pointInf :: TwistedEdwards curve point Source # | |
HasPointInf point => HasPointInf (Weierstrass curve point) Source # | |
Defined in ZkFold.Base.Algebra.EllipticCurve.Class pointInf :: Weierstrass curve point Source # |
point types
newtype Weierstrass curve point Source #
Weierstrass
tags a ProjectivePlanar
point
, over a Field
field
,
with a phantom WeierstrassCurve
curve
.
Weierstrass | |
|
Instances
newtype TwistedEdwards curve point Source #
TwistedEdwards
tags a Planar
point
, over a Field
field
,
with a phantom TwistedEdwardsCurve
curve
.
TwistedEdwards | |
|
Instances
A type of points in the projective plane.
Instances
data CompressedPoint field Source #
Instances
data AffinePoint field Source #