ec

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 7 Imported by: 4

Documentation

Overview

Package address provides ...

Package ec provides ...

Package ec provides ...

Index

Constants

View Source
const (
	PubKeyBytesLenCompressed   = 33
	PubKeyBytesLenUncompressed = 65
	PubKeyBytesLenHybrid       = 65
)
View Source
const PrivKeyBytesLen = 32

Variables

This section is empty.

Functions

func PrivKeyFromBytes

func PrivKeyFromBytes(bytes []byte) (*PrivateKey, *PublicKey)

Types

type AddressPubKeyHash

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

AddressPubKeyHash pay-to-pubkey-hash (P2PKH)

func NewAddressPubKeyHash

func NewAddressPubKeyHash(pkHash []byte, version byte) (*AddressPubKeyHash, error)

func (*AddressPubKeyHash) EncodeAddress

func (a *AddressPubKeyHash) EncodeAddress() string

EncodeAddress return P2PKH address

func (*AddressPubKeyHash) Hash160

func (a *AddressPubKeyHash) Hash160() []byte

Hash160 return hash160

type KoblitzCurve

type KoblitzCurve struct {
	*elliptic.CurveParams
	// contains filtered or unexported fields
}

KoblitzCurve A Koblitz Curve with a=0.

func Secp265k1

func Secp265k1() *KoblitzCurve

Secp265k1 return Curve

func (*KoblitzCurve) Add

func (curve *KoblitzCurve) Add(x1 *big.Int, y1 *big.Int, x2 *big.Int, y2 *big.Int) (x *big.Int, y *big.Int)

Add returns the sum of (x1,y1) and (x2,y2)

func (*KoblitzCurve) Double

func (curve *KoblitzCurve) Double(x1 *big.Int, y1 *big.Int) (x *big.Int, y *big.Int)

Double returns 2*(x,y)

func (*KoblitzCurve) IsOnCurve

func (curve *KoblitzCurve) IsOnCurve(x *big.Int, y *big.Int) bool

IsOnCurve reports whether the given (x,y) lies on the curve.

func (*KoblitzCurve) Params

func (curve *KoblitzCurve) Params() *elliptic.CurveParams

Params returns the parameters for the curve

func (*KoblitzCurve) QPlus1Div4

func (curve *KoblitzCurve) QPlus1Div4() *big.Int

QPlus1Div4 returns the Q+1/4 constant for the curve for use in calculating square roots via exponention.

func (*KoblitzCurve) ScalarBaseMult

func (curve *KoblitzCurve) ScalarBaseMult(k []byte) (x *big.Int, y *big.Int)

ScalarBaseMult returns k*G, where G is the base point of the group and k is an integer in big-endian form.

func (*KoblitzCurve) ScalarMult

func (curve *KoblitzCurve) ScalarMult(x1 *big.Int, y1 *big.Int, k []byte) (*big.Int, *big.Int)

ScalarMult returns k*(Bx,By) where k is a number in big-endian form.

type PrivateKey

type PrivateKey struct {
	PubKey PublicKey
	D      *big.Int
}

func (*PrivateKey) Serialize

func (privKey *PrivateKey) Serialize() []byte

type PublicKey

type PublicKey struct {
	X, Y *big.Int
}

PublicKey struct

func ParsePubKey

func ParsePubKey(pubKeyStr []byte) (key *PublicKey, err error)

ParsePubKey parses a public key for a koblitz curve from a bytestring into a ecdsa.Publickey, verifying that it is valid. It supports compressed, uncompressed and hybrid signature formats.

func (*PublicKey) SerializeCompressed

func (key *PublicKey) SerializeCompressed() []byte

SerializeCompressed serializes a public key 33-byte compressed format

Jump to

Keyboard shortcuts

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