Documentation ¶
Index ¶
- Variables
- func Base58Decode(s string) (data []byte, err error)
- func Base58Encode(in []byte) string
- func ConvertHash(hash []byte) *math.Int
- func ExportPrivateKey(k *PrivateKey, testnet bool) string
- func Hash160(data []byte) []byte
- func Hash256(data []byte) []byte
- func RipeMD160(data []byte) []byte
- func Sha1(data []byte) []byte
- func Sha256(data []byte) []byte
- func SignY(p *Point) (int, error)
- func Solve(x *math.Int) (*math.Int, bool)
- func Verify(key *PublicKey, hash []byte, sig *Signature) bool
- type Curve
- type Point
- func (p *Point) Add(q *Point) *Point
- func (p *Point) Bytes(compressed bool) []byte
- func (p *Point) Double() *Point
- func (p *Point) Equals(q *Point) bool
- func (p *Point) IsInf() bool
- func (p *Point) IsOnCurve() bool
- func (p *Point) Mult(k *math.Int) *Point
- func (p *Point) Neg() *Point
- func (p *Point) String() string
- func (p *Point) X() *math.Int
- func (p *Point) Y() *math.Int
- type PrivateKey
- type PublicKey
- type Signature
Constants ¶
This section is empty.
Variables ¶
var (
ErrBtcBase58Decoding = errors.New("base58 decoding error -- unknown character")
)
Error codes
var (
ErrSigInvalid = errors.New("invalid ECDSA signature")
)
Inf is the point at "infinity"
Functions ¶
func Base58Decode ¶
Base58Decode converts a base58 representation into byte array
func Base58Encode ¶
Base58Encode converts byte array to base58 string representation
func ConvertHash ¶ added in v1.2.30
convert hash value to integer [http://www.secg.org/download/aid-780/sec1-v2.pdf]
func ExportPrivateKey ¶
func ExportPrivateKey(k *PrivateKey, testnet bool) string
ExportPrivateKey returns a private key in SIPA format
Types ¶
type Curve ¶
type Curve struct { // P is the generator of the underlying field "F_p" // = 2^256 - 2^32 - 2^9 - 2^8 - 2^7 - 2^6 - 2^4 - 1 P *math.Int // Gx is the x-coord of the base point Gx *math.Int // Gy is the y-coord of the base point Gy *math.Int // N is the order of G N *math.Int // curve parameter (=7) B *math.Int }
Curve is the elliptic curve used for Bitcoin (Secp256k1)
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point (x,y) on the curve
func NewPointFromBytes ¶
NewPointFromBytes reconstructs a Point from binary representation.
func (*Point) Mult ¶
Mult multiplies a Point on the curve with a scalar value k using a Montgomery multiplication approach
type PrivateKey ¶
PrivateKey is a random factor 'd' for the base Point that yields the associated PublicKey (Point on the curve (x,y) = d*G)
func GenerateKeys ¶
func GenerateKeys(compr bool) *PrivateKey
GenerateKeys creates a new set of keys. [http://www.nsa.gov/ia/_files/ecdsa.pdf] page 19f but with a different range (value 1 and 2 for exponent are not allowed)
func ImportPrivateKey ¶
func ImportPrivateKey(keydata string, testnet bool) (*PrivateKey, error)
ImportPrivateKey imports a private key in SIPA format
func PrivateKeyFromBytes ¶
func PrivateKeyFromBytes(b []byte) (*PrivateKey, error)
PrivateKeyFromBytes returns a private key from a byte representation.
func (*PrivateKey) Bytes ¶
func (k *PrivateKey) Bytes() []byte
Bytes returns a byte representation of private key.
type PublicKey ¶
PublicKey is a Point on the elliptic curve: (x,y) = d*G, where 'G' is the base Point of the curve and 'd' is the secret private factor (private key)
func PublicKeyFromBytes ¶
PublicKeyFromBytes returns a public key from a byte representation.
type Signature ¶
Signature is a Bitcoin signature in scripts.
func NewSignatureFromASN1 ¶
NewSignatureFromASN1 returns a signature from an ASN.1-encoded sequence.
func NewSignatureFromBytes ¶ added in v1.2.30
func Sign ¶
func Sign(key *PrivateKey, hash []byte) *Signature
Sign a hash value with private key. [http://www.nsa.gov/ia/_files/ecdsa.pdf, page 13f]