Documentation ¶
Index ¶
- func B58checkdecode(s string) (ver uint8, b []byte, err error)
- func B58checkencodeNEO(ver uint8, b []byte) (s string)
- func CheckWIF(wif string) (valid bool, err error)
- func PrivateKeyFromHexString(key string) ecdsa.PrivateKey
- func Sign(data []byte, key string) ([]byte, error)
- func Verify(publicKey []byte, signature []byte, hash []byte) bool
- type EllipticCurve
- func (ec *EllipticCurve) Add(P, Q Point) (R Point)
- func (ec *EllipticCurve) Decompress(x *big.Int, ylsb uint) (P Point, err error)
- func (ec *EllipticCurve) IsInfinity(P Point) bool
- func (ec *EllipticCurve) IsOnCurve(P Point) bool
- func (ec *EllipticCurve) ScalarBaseMult(k *big.Int) (Q Point)
- func (ec *EllipticCurve) ScalarMult(k *big.Int, P Point) (Q Point)
- type Point
- type PrivateKey
- type PublicKey
- func (pub *PublicKey) FromBytes(b []byte) (err error)
- func (pub *PublicKey) ToAddress() (address string)
- func (pub *PublicKey) ToAddressUncompressed() (address string)
- func (pub *PublicKey) ToBytes() (b []byte)
- func (pub *PublicKey) ToBytesUncompressed() (b []byte)
- func (pub *PublicKey) ToNeoAddress() (address string)
- func (pub *PublicKey) ToNeoSignature() (signature []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func B58checkdecode ¶
B58checkdecode decodes base-58 check encoded string s into a version ver and byte slice b.
func B58checkencodeNEO ¶
b58checkencode encodes version ver and byte slice b into a base-58 check encoded string.
func CheckWIF ¶
CheckWIF checks that string wif is a valid Wallet Import Format or Wallet Import Format Compressed string. If it is not, err is populated with the reason.
func PrivateKeyFromHexString ¶
func PrivateKeyFromHexString(key string) ecdsa.PrivateKey
Types ¶
type 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) Decompress ¶
Decompress decompresses coordinate x and ylsb (y's least significant bit) into a Point P 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 PrivateKey ¶
PrivateKey represents a Bitcoin private key.
func GenerateKey ¶
func GenerateKey(rand io.Reader) (priv PrivateKey, err error)
GenerateKey generates a public and private key pair using random source rand.
func (*PrivateKey) FromBytes ¶
func (priv *PrivateKey) FromBytes(b []byte) (err error)
FromBytes converts a 32-byte byte slice to a Bitcoin private key and derives the corresponding Bitcoin public key.
func (*PrivateKey) FromWIF ¶
func (priv *PrivateKey) FromWIF(wif string) (err error)
FromWIF converts a Wallet Import Format string to a Bitcoin private key and derives the corresponding Bitcoin public key.
func (*PrivateKey) ToBytes ¶
func (priv *PrivateKey) ToBytes() (b []byte)
ToBytes converts a Bitcoin private key to a 32-byte byte slice.
func (*PrivateKey) ToWIF ¶
func (priv *PrivateKey) ToWIF() (wif string)
ToWIF converts a Bitcoin private key to a Wallet Import Format string.
func (*PrivateKey) ToWIFC ¶
func (priv *PrivateKey) ToWIFC() (wifc string)
ToWIFC converts a Bitcoin private key to a Wallet Import Format string with the public key compressed flag.
type PublicKey ¶
type PublicKey struct {
Point
}
PublicKey represents a Bitcoin public key.
func (*PublicKey) FromBytes ¶
FromBytes converts a byte slice (either with or without point compression) to a Bitcoin public key.
func (*PublicKey) ToAddress ¶
ToAddress converts a Bitcoin public key to a compressed Bitcoin address string.
func (*PublicKey) ToAddressUncompressed ¶
ToAddressUncompressed converts a Bitcoin public key to an uncompressed Bitcoin address string.
func (*PublicKey) ToBytes ¶
ToBytes converts a Bitcoin public key to a 33-byte byte slice with point compression.
func (*PublicKey) ToBytesUncompressed ¶
ToBytesUncompressed converts a Bitcoin public key to a 65-byte byte slice without point compression.
func (*PublicKey) ToNeoAddress ¶
ToAddress converts a Bitcoin public key to a compressed Bitcoin address string.