ecc

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckInterval

func CheckInterval(val, min, max *big.Int) bool

func Clone

func Clone(int2 *big.Int) *big.Int

func GetInt

func GetInt(val int64) *big.Int

func Hex2int

func Hex2int(hexStr string) *big.Int

Types

type Curve

type Curve struct {
	Name       string
	A, B, P, N *big.Int
	GX, GY     *big.Int
}

func (*Curve) AddPoint

func (c *Curve) AddPoint(P, Q *Point) (*Point, error)

func (*Curve) ComputeY

func (c *Curve) ComputeY(x *big.Int) *big.Int

func (*Curve) ConvertToMontgomeryCurve

func (c *Curve) ConvertToMontgomeryCurve() *MontgomeryCurve

func (*Curve) G

func (c *Curve) G() *Point

func (*Curve) INF

func (c *Curve) INF() *Point

func (*Curve) IsOnCurve

func (c *Curve) IsOnCurve(P *Point) bool

func (*Curve) MulPoint

func (c *Curve) MulPoint(d *big.Int, P *Point) (*Point, error)

func (*Curve) NegPoint

func (c *Curve) NegPoint(P *Point) (*Point, error)

func (*Curve) String

func (c *Curve) String() string

type ECDSA

type ECDSA struct {
	GenPoint *Point
	Curve    *MontgomeryCurve
}

func NewECDSA

func NewECDSA() *ECDSA

func (*ECDSA) Sign

func (ec *ECDSA) Sign(privateKey *big.Int, message string) (*big.Int, *big.Int)

func (*ECDSA) Verify

func (ec *ECDSA) Verify(publicKey Point, message string, r, s *big.Int) bool

type ICurve

type ICurve interface {
	String() string
	G() *Point
	INF() *Point
	IsOnCurve(P *Point) bool
	AddPoint(P, Q *Point) (*Point, error)
	MulPoint(d *big.Int, P *Point) (*Point, error)
	NegPoint(P *Point) (*Point, error)
	ComputeY(x *big.Int) *big.Int
}

type MontgomeryCurve

type MontgomeryCurve struct {
	Curve
}

MontgomeryCurve by^2 = x^3 + ax^2 + x https://en.wikipedia.org/wiki/Montgomery_curve

func NewCurve25519

func NewCurve25519() *MontgomeryCurve

func (*MontgomeryCurve) ComputeY

func (mc *MontgomeryCurve) ComputeY(x *big.Int) *big.Int

type Point

type Point struct {
	X     *big.Int
	Y     *big.Int
	Curve ICurve
}

func GetKeyPair

func GetKeyPair(curve *MontgomeryCurve) (*big.Int, *Point)

func (*Point) Add

func (p *Point) Add(other *Point) *Point

func (*Point) Copy

func (p *Point) Copy() *Point

func (*Point) Eq

func (p *Point) Eq(other *Point) bool

func (*Point) IsAtInfinity

func (p *Point) IsAtInfinity() bool

func (*Point) Mul

func (p *Point) Mul(scalar *big.Int) *Point

func (*Point) Neg

func (p *Point) Neg() *Point

func (*Point) String

func (p *Point) String() string

Jump to

Keyboard shortcuts

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