ec

package
v0.0.0-...-eab8366 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurve

func GetCurve(c Curve) elliptic.Curve

Types

type Curve

type Curve int
const (
	P224 Curve = 1 + iota
	P256
	P384
	P521
)

type Group

type Group struct {
	Curve elliptic.Curve
	Q     *big.Int
}

Group is a wrapper around elliptic.Curve. It is a cyclic group with generator (c.Params().Gx, c.Params().Gy) and order c.Params().N (which is exposed as Q in a wrapper).

func NewGroup

func NewGroup(curveType Curve) *Group

func (*Group) Exp

func (g *Group) Exp(base *GroupElement, exponent *big.Int) *GroupElement

Exp computes base^exponent in Group. This actually means exponent * base as this is additive group.

func (*Group) ExpBaseG

func (g *Group) ExpBaseG(exponent *big.Int) *GroupElement

Exp computes base^exponent in Group where base is the generator. This actually means exponent * G as this is additive group.

func (*Group) GetRandomElement

func (g *Group) GetRandomElement() *GroupElement

GetRandomElement returns a random element from this group.

func (*Group) Inv

func (g *Group) Inv(x *GroupElement) *GroupElement

Inv computes inverse of x in Group. This is done by computing x^(order-1) as: x * x^(order-1) = x^order = 1. Note that this actually means x * (order-1) as this is additive group.

func (*Group) Mul

func (g *Group) Mul(a, b *GroupElement) *GroupElement

Mul computes a * b in Group. This actually means a + b as this is additive group.

type GroupElement

type GroupElement struct {
	X *big.Int
	Y *big.Int
}

TODO Insert appropriate comment with description of this struct

func NewGroupElement

func NewGroupElement(x, y *big.Int) *GroupElement

func (*GroupElement) Equals

func (e *GroupElement) Equals(b *GroupElement) bool

Jump to

Keyboard shortcuts

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