ecpointgrouplaw

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDifferentLength is returned if the two slices has different lengths.
	ErrDifferentLength = errors.New("different lengths of slices")
	// ErrEmptySlice is returned if the length of slice is zero.
	ErrEmptySlice = errors.New("the length of slice is zero")
)
View Source
var (
	// ErrInvalidPoint is returned if the point is invalid.
	ErrInvalidPoint = errors.New("invalid point")
	// ErrDifferentCurve is returned if the two different elliptic curves.
	ErrDifferentCurve = errors.New("different elliptic curves")
	// ErrInvalidCurve is returned if the curve is invalid.
	ErrInvalidCurve = errors.New("invalid curve")
)
View Source
var (
	EcPointMessage_Curve_name = map[int32]string{
		0: "P224",
		1: "P256",
		2: "P384",
		3: "S256",
		4: "EDWARD25519",
	}
	EcPointMessage_Curve_value = map[string]int32{
		"P224":        0,
		"P256":        1,
		"P384":        2,
		"S256":        3,
		"EDWARD25519": 4,
	}
)

Enum value maps for EcPointMessage_Curve.

View Source
var File_github_com_getamis_alice_crypto_ecpointgrouplaw_point_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type ECPoint

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

ECPoint is the struct for an elliptic curve point.

func ComputeLinearCombinationPoint

func ComputeLinearCombinationPoint(scalar []*big.Int, points []*ECPoint) (*ECPoint, error)

ComputeLinearCombinationPoint returns the linear combination of points by multiplying scalar. Give two arrays: [a1,a2,a3] and points in secp256k1 [G1,G2,G3]. The outcome of this function is a1*G1+a2*G2+a3*G3. Ex: Give two arrays: [1,2,5] and points in secp256k1 [G1,G2,G3]. The outcome of this function is 1*G1+2*G2+5*G3.

func NewBase

func NewBase(curve elliptic.Curve) *ECPoint

NewBase returns the base point of the given elliptic curve.

func NewECPoint

func NewECPoint(curve elliptic.Curve, x *big.Int, y *big.Int) (*ECPoint, error)

NewECPoint creates an EC-Point and verifies that it should locate on the given elliptic curve. Note: when x = nil, y =nil, we set it to be the identity element in the elliptic curve group.

func NewIdentity

func NewIdentity(curve elliptic.Curve) *ECPoint

NewIdentity returns the identity element of the given elliptic curve.

func ScalarBaseMult

func ScalarBaseMult(c elliptic.Curve, k *big.Int) *ECPoint

ScalarBaseMult multiplies the base point k times.

func (*ECPoint) Add

func (p *ECPoint) Add(p1 *ECPoint) (*ECPoint, error)

Add sums up two arbitrary points located on the same elliptic curve.

func (*ECPoint) Copy

func (p *ECPoint) Copy() *ECPoint

Copy copies the point.

func (*ECPoint) Equal

func (p *ECPoint) Equal(p1 *ECPoint) bool

Equal checks if the point is the same with the given point.

func (*ECPoint) GetCurve

func (p *ECPoint) GetCurve() elliptic.Curve

GetCurve returns the elliptic curve of the point.

func (*ECPoint) GetX

func (p *ECPoint) GetX() *big.Int

GetX returns the x coordinate of the point.

func (*ECPoint) GetY

func (p *ECPoint) GetY() *big.Int

GetY returns the x coordinate of the point.

func (*ECPoint) IsEvenY added in v1.0.3

func (p *ECPoint) IsEvenY() bool

func (*ECPoint) IsIdentity

func (p *ECPoint) IsIdentity() bool

IsIdentity checks if the point is the identity element.

func (*ECPoint) IsSameCurve

func (p *ECPoint) IsSameCurve(p2 *ECPoint) bool

IsSameCurve checks if the point is on the same curve with the given point.

func (*ECPoint) Neg added in v1.0.2

func (p *ECPoint) Neg() *ECPoint

func (*ECPoint) ScalarMult

func (p *ECPoint) ScalarMult(k *big.Int) *ECPoint

ScalarMult multiplies the point k times. If the point is the identity element, do nothing.

func (*ECPoint) String

func (p *ECPoint) String() string

String returns the string format of the point.

func (*ECPoint) ToEcPointMessage

func (p *ECPoint) ToEcPointMessage() (*EcPointMessage, error)

ToEcPointMessage converts the point to proto message.

func (*ECPoint) ToPubKey added in v1.0.2

func (p *ECPoint) ToPubKey() *ecdsa.PublicKey

ToPubKey returns pubkey

type EcPointMessage

type EcPointMessage struct {
	Curve EcPointMessage_Curve `` /* 127-byte string literal not displayed */
	X     []byte               `protobuf:"bytes,2,opt,name=x,proto3" json:"x,omitempty"`
	Y     []byte               `protobuf:"bytes,3,opt,name=y,proto3" json:"y,omitempty"`
	// contains filtered or unexported fields
}

func (*EcPointMessage) Descriptor deprecated

func (*EcPointMessage) Descriptor() ([]byte, []int)

Deprecated: Use EcPointMessage.ProtoReflect.Descriptor instead.

func (*EcPointMessage) GetCurve

func (x *EcPointMessage) GetCurve() EcPointMessage_Curve

func (*EcPointMessage) GetX

func (x *EcPointMessage) GetX() []byte

func (*EcPointMessage) GetY

func (x *EcPointMessage) GetY() []byte

func (*EcPointMessage) ProtoMessage

func (*EcPointMessage) ProtoMessage()

func (*EcPointMessage) ProtoReflect added in v1.0.2

func (x *EcPointMessage) ProtoReflect() protoreflect.Message

func (*EcPointMessage) Reset

func (x *EcPointMessage) Reset()

func (*EcPointMessage) String

func (x *EcPointMessage) String() string

func (*EcPointMessage) ToPoint

func (p *EcPointMessage) ToPoint() (*ECPoint, error)

ToPoint converts the point from proto message.

type EcPointMessage_Curve

type EcPointMessage_Curve int32
const (
	EcPointMessage_P224 EcPointMessage_Curve = 0
	EcPointMessage_P256 EcPointMessage_Curve = 1
	EcPointMessage_P384 EcPointMessage_Curve = 2
	// Above curves are not implemented
	EcPointMessage_S256        EcPointMessage_Curve = 3
	EcPointMessage_EDWARD25519 EcPointMessage_Curve = 4
)

func (EcPointMessage_Curve) Descriptor added in v1.0.2

func (EcPointMessage_Curve) Enum added in v1.0.2

func (EcPointMessage_Curve) EnumDescriptor deprecated

func (EcPointMessage_Curve) EnumDescriptor() ([]byte, []int)

Deprecated: Use EcPointMessage_Curve.Descriptor instead.

func (EcPointMessage_Curve) GetEllipticCurve

func (c EcPointMessage_Curve) GetEllipticCurve() (elliptic.Curve, error)

func (EcPointMessage_Curve) Number added in v1.0.2

func (EcPointMessage_Curve) String

func (x EcPointMessage_Curve) String() string

func (EcPointMessage_Curve) Type added in v1.0.2

Jump to

Keyboard shortcuts

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