secp256k1

package
v0.0.0-...-61197bd Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrivKeyFromBytes

func PrivKeyFromBytes(curve elliptic.Curve, secret string) (*btcec.PrivateKey,
	*btcec.PublicKey)

PrivKeyFromBytes PrivKeyFromBytes

Types

type EllipticCurve

type EllipticCurve struct {
	A *big.Int
	B *big.Int
	P *big.Int
	G Point
	N *big.Int
	H *big.Int
}

EllipticCurve y**2 = x**3 + a*x + b % p EllipticCurve represents the parameters of a short Weierstrass equation elliptic curve.

func (*EllipticCurve) Add

func (ec *EllipticCurve) Add(P, Q Point) (R Point)

Add computes R = P + Q on EllipticCurve ec.

func (*EllipticCurve) IsInfinity

func (ec *EllipticCurve) IsInfinity(P Point) bool

IsInfinity checks if point P is infinity on EllipticCurve ec.

func (*EllipticCurve) IsOnCurve

func (ec *EllipticCurve) IsOnCurve(P Point) bool

IsOnCurve checks if point P is on EllipticCurve ec.

func (*EllipticCurve) ScalarBaseMult

func (ec *EllipticCurve) ScalarBaseMult(k *big.Int) (Q Point)

ScalarBaseMult computes Q = k * G on EllipticCurve ec.

func (*EllipticCurve) ScalarMult

func (ec *EllipticCurve) ScalarMult(k *big.Int, P Point) (Q Point)

ScalarMult computes Q = k * P on EllipticCurve ec.

type Point

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

Point represents a point on an EllipticCurve.

func (Point) Compression

func (p Point) Compression() (b []byte)

Compression Compression

type PrivateKey

type PrivateKey struct {
	PublicKey
	D *big.Int
}

PrivateKey represents a Bitcoin private key.

func (*PrivateKey) ToBytes

func (priv *PrivateKey) ToBytes() (b []byte)

ToBytes 私钥转成32字节

type PublicKey

type PublicKey struct {
	Point
}

PublicKey represents a Bitcoin public key.

func (*PublicKey) BytesToHex

func (pub *PublicKey) BytesToHex() string

BytesToHex BytesToHex

func (*PublicKey) ToAddress

func (pub *PublicKey) ToAddress() (address string)

ToAddress 公钥转成钱包地址

func (*PublicKey) ToBytes

func (pub *PublicKey) ToBytes() (b []byte)

ToBytes 将椭圆点压缩成(02+X 如Y 偶), 或(03+X 如Y奇),得到 33 字节的 public key

type Secp256KeyPair

type Secp256KeyPair struct{}

Secp256KeyPair Secp256KeyPair

func (*Secp256KeyPair) CheckAddress

func (*Secp256KeyPair) CheckAddress(address string) bool

CheckAddress 验证地址

func (*Secp256KeyPair) DeriveKeyPair

func (*Secp256KeyPair) DeriveKeyPair(secret string) (*PrivateKey, error)

DeriveKeyPair 根据私钥生成秘钥对

func (*Secp256KeyPair) GenerateSeed

func (*Secp256KeyPair) GenerateSeed() (string, error)

GenerateSeed 生成私钥

Jump to

Keyboard shortcuts

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