curve

package
v0.0.0-...-3c8af55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package curve provides definitions of several models of elliptic curves defined over finite fields of large prime characteristic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CurveID

type CurveID int
const (
	Custom CurveID = iota
	P256
	P384
	P521
	Curve25519
	Curve448
	Edwards25519
	Edwards448
	SECP256K1
	SECP256K1_3ISO
	BLS12381G1
	BLS12381G1_11ISO
	BLS12381G2
)

func (CurveID) Get

func (id CurveID) Get() EllCurve

GetFromID is

type EllCurve

type EllCurve interface {
	Field() GF.Field
	Order() *big.Int
	Cofactor() *big.Int
	NewPoint(x, y GF.Elt) Point
	// Predicates
	IsOnCurve(Point) bool
	IsEqual(EllCurve) bool
	// Arithmetic operations
	Identity() Point
	Neg(Point) Point
	Add(Point, Point) Point
	Double(Point) Point
	ClearCofactor(Point) Point
}

EllCurve represents an elliptic curve group.

type Isogeny

type Isogeny interface {
	Domain() EllCurve
	Codomain() EllCurve
	Push(Point) Point
}

Isogeny represents an isogeny between two elliptic curves.

func GetBLS12381G1Isogeny

func GetBLS12381G1Isogeny() Isogeny

GetSECP256K1Isogeny returns an 11-degree isogeny from BLS12381G1_11ISO to the BLS12381G1 elliptic curve.

func GetSECP256K1Isogeny

func GetSECP256K1Isogeny() Isogeny

GetSECP256K1Isogeny returns a 3-degree isogeny from SECP256K1_3ISO to the SECP256K1 elliptic curve.

type M

type M = *MTCurve

type MTCurve

type MTCurve struct {
	// contains filtered or unexported fields
}

MTCurve is a Montgomery curve

func NewMontgomery

func NewMontgomery(id CurveID, f GF.Field, a, b GF.Elt, r, h *big.Int) *MTCurve

NewMontgomery returns a Montgomery curve

func (*MTCurve) Add

func (e *MTCurve) Add(p, q Point) Point

func (*MTCurve) ClearCofactor

func (e *MTCurve) ClearCofactor(p Point) Point

func (MTCurve) Cofactor

func (e MTCurve) Cofactor() *big.Int

func (*MTCurve) Double

func (e *MTCurve) Double(p Point) Point

func (MTCurve) Field

func (e MTCurve) Field() GF.Field

func (*MTCurve) Identity

func (e *MTCurve) Identity() Point

func (*MTCurve) IsEqual

func (e *MTCurve) IsEqual(ec EllCurve) bool

func (*MTCurve) IsOnCurve

func (e *MTCurve) IsOnCurve(p Point) bool

func (*MTCurve) IsValid

func (e *MTCurve) IsValid() bool

func (*MTCurve) Neg

func (e *MTCurve) Neg(p Point) Point

func (*MTCurve) NewPoint

func (e *MTCurve) NewPoint(x, y GF.Elt) (P Point)

func (MTCurve) Order

func (e MTCurve) Order() *big.Int

func (*MTCurve) ScalarMult

func (e *MTCurve) ScalarMult(p Point, k *big.Int) Point

func (*MTCurve) String

func (e *MTCurve) String() string

func (*MTCurve) ToWeierstrassC

func (e *MTCurve) ToWeierstrassC() RationalMap

type Point

type Point interface {
	Copy() Point
	IsIdentity() bool
	IsEqual(Point) bool
	IsTwoTorsion() bool
	X() GF.Elt
	Y() GF.Elt
}

Point represents an elliptic curve point.

type RationalMap

type RationalMap interface {
	Domain() EllCurve
	Codomain() EllCurve
	Push(Point) Point
	Pull(Point) Point
}

RationalMap represents a birational map between two elliptic curves.

func FromTe2Mt25519

func FromTe2Mt25519() RationalMap

FromTe2Mt25519 returns the birational map between Edwards25519 and Curve25519 curves.

func FromTe2Mt4ISO448

func FromTe2Mt4ISO448() RationalMap

FromTe2Mt4ISO448 returns the four-degree isogeny between Edwards448 and Curve448 curves.

type T

type T = *TECurve

type TECurve

type TECurve struct {
	// contains filtered or unexported fields
}

TECurve is a twisted Edwards curve

func NewEdwards

func NewEdwards(id CurveID, f GF.Field, a, d GF.Elt, r, h *big.Int) *TECurve

NewEdwards returns a twisted Edwards curve

func (*TECurve) Add

func (e *TECurve) Add(p, q Point) Point

func (*TECurve) ClearCofactor

func (e *TECurve) ClearCofactor(p Point) Point

func (TECurve) Cofactor

func (e TECurve) Cofactor() *big.Int

func (*TECurve) Double

func (e *TECurve) Double(p Point) Point

func (TECurve) Field

func (e TECurve) Field() GF.Field

func (*TECurve) Identity

func (e *TECurve) Identity() Point

func (*TECurve) IsComplete

func (e *TECurve) IsComplete() bool

func (*TECurve) IsEqual

func (e *TECurve) IsEqual(ec EllCurve) bool

func (*TECurve) IsOnCurve

func (e *TECurve) IsOnCurve(p Point) bool

func (*TECurve) IsValid

func (e *TECurve) IsValid() bool

func (*TECurve) Neg

func (e *TECurve) Neg(p Point) Point

func (*TECurve) NewPoint

func (e *TECurve) NewPoint(x, y GF.Elt) (P Point)

func (TECurve) Order

func (e TECurve) Order() *big.Int

func (*TECurve) ScalarMult

func (e *TECurve) ScalarMult(p Point, k *big.Int) Point

func (*TECurve) String

func (e *TECurve) String() string

func (*TECurve) ToWeierstrassC

func (e *TECurve) ToWeierstrassC() RationalMap

type W

type W = *WECurve

type WC

type WC = *WCCurve

type WCCurve

type WCCurve struct {
	RationalMap
	// contains filtered or unexported fields
}

WCCurve is a Weierstrass curve

func NewWeierstrassC

func NewWeierstrassC(id CurveID, f GF.Field, a, b GF.Elt, r, h *big.Int) *WCCurve

NewWeierstrassC returns a Weierstrass curve

func (*WCCurve) Add

func (e *WCCurve) Add(p, q Point) Point

func (*WCCurve) ClearCofactor

func (e *WCCurve) ClearCofactor(p Point) Point

func (WCCurve) Cofactor

func (e WCCurve) Cofactor() *big.Int

func (*WCCurve) Double

func (e *WCCurve) Double(p Point) Point

func (WCCurve) Field

func (e WCCurve) Field() GF.Field

func (*WCCurve) Identity

func (e *WCCurve) Identity() Point

func (*WCCurve) IsEqual

func (e *WCCurve) IsEqual(ec EllCurve) bool

func (*WCCurve) IsOnCurve

func (e *WCCurve) IsOnCurve(p Point) bool

func (*WCCurve) IsValid

func (e *WCCurve) IsValid() bool

func (*WCCurve) Neg

func (e *WCCurve) Neg(p Point) Point

func (*WCCurve) NewPoint

func (e *WCCurve) NewPoint(x, y GF.Elt) (P Point)

func (WCCurve) Order

func (e WCCurve) Order() *big.Int

func (*WCCurve) String

func (e *WCCurve) String() string

func (*WCCurve) ToWeierstrass

func (e *WCCurve) ToWeierstrass() RationalMap

type WECurve

type WECurve struct {
	// contains filtered or unexported fields
}

WECurve is a Weierstrass curve

func NewWeierstrass

func NewWeierstrass(id CurveID, f GF.Field, a, b GF.Elt, r, h *big.Int) *WECurve

NewWeierstrass returns a Weierstrass curve

func (*WECurve) Add

func (e *WECurve) Add(p, q Point) Point

func (*WECurve) ClearCofactor

func (e *WECurve) ClearCofactor(p Point) Point

func (WECurve) Cofactor

func (e WECurve) Cofactor() *big.Int

func (*WECurve) Double

func (e *WECurve) Double(p Point) Point

func (*WECurve) EvalRHS

func (e *WECurve) EvalRHS(x GF.Elt) GF.Elt

func (WECurve) Field

func (e WECurve) Field() GF.Field

func (*WECurve) Identity

func (e *WECurve) Identity() Point

func (*WECurve) IsEqual

func (e *WECurve) IsEqual(ec EllCurve) bool

func (*WECurve) IsOnCurve

func (e *WECurve) IsOnCurve(p Point) bool

func (*WECurve) IsValid

func (e *WECurve) IsValid() bool

func (*WECurve) Neg

func (e *WECurve) Neg(p Point) Point

func (*WECurve) NewPoint

func (e *WECurve) NewPoint(x, y GF.Elt) (P Point)

NewPoint generates

func (WECurve) Order

func (e WECurve) Order() *big.Int

func (*WECurve) ScalarMult

func (e *WECurve) ScalarMult(p Point, k *big.Int) Point

func (*WECurve) String

func (e *WECurve) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL