Documentation ¶
Index ¶
- Constants
- func BytesToPrivateKey(key []byte, curve elliptic.Curve) *ecdsa.PrivateKey
- func BytesToPublicKey(curve elliptic.Curve, buff []byte) *ecdsa.PublicKey
- func CompressedPublicKeyBytes(pub *ecdsa.PublicKey) []byte
- func IsCompressedPubKey(pubKey []byte) bool
- func PrivKeyFromBytes(curve elliptic.Curve, pk []byte) (*PrivateKey, *PublicKey)
- func PrivateKeyBytes(priv *ecdsa.PrivateKey) (b []byte)
- func PublicKeyBytes(pub *ecdsa.PublicKey) []byte
- type PrivateKey
- type PublicKey
Constants ¶
const ( PubKeyBytesLenCompressed = 33 PubKeyBytesLenUncompressed = 65 PubKeyBytesLenHybrid = 65 )
These constants define the lengths of serialized public keys.
const PrivKeyBytesLen = 32
PrivKeyBytesLen defines the length in bytes of a serialized private key.
Variables ¶
This section is empty.
Functions ¶
func BytesToPrivateKey ¶
func BytesToPrivateKey(key []byte, curve elliptic.Curve) *ecdsa.PrivateKey
BytesToPrivateKey 。
func BytesToPublicKey ¶
BytesToPublicKey .
func CompressedPublicKeyBytes ¶
CompressedPublicKeyBytes .
func IsCompressedPubKey ¶
IsCompressedPubKey returns true the the passed serialized public key has been encoded in compressed format, and false otherwise.
func PrivKeyFromBytes ¶
func PrivKeyFromBytes(curve elliptic.Curve, pk []byte) (*PrivateKey, *PublicKey)
PrivKeyFromBytes returns a private and public key for `curve' based on the private key passed as an argument as a byte slice.
Types ¶
type PrivateKey ¶
type PrivateKey ecdsa.PrivateKey
PrivateKey wraps an ecdsa.PrivateKey as a convenience mainly for signing things with the the private key without having to directly import the ecdsa package.
func NewPrivateKey ¶
func NewPrivateKey(curve elliptic.Curve) (*PrivateKey, error)
NewPrivateKey is a wrapper for ecdsa.GenerateKey that returns a PrivateKey instead of the normal ecdsa.PrivateKey.
func (*PrivateKey) PubKey ¶
func (p *PrivateKey) PubKey() *PublicKey
PubKey returns the PublicKey corresponding to this private key.
func (*PrivateKey) Serialize ¶
func (p *PrivateKey) Serialize() []byte
Serialize returns the private key number d as a big-endian binary-encoded number, padded to a length of 32 bytes.
func (*PrivateKey) Sign ¶
func (p *PrivateKey) Sign(hash []byte) (*sign.Signature, error)
Sign generates an ECDSA signature for the provided hash (which should be the result of hashing a larger message) using the private key. Produced signature is deterministic (same message and same key yield the same signature) and canonical in accordance with RFC6979 and BIP0062.
func (*PrivateKey) ToECDSA ¶
func (p *PrivateKey) ToECDSA() *ecdsa.PrivateKey
ToECDSA returns the private key as a *ecdsa.PrivateKey.
type PublicKey ¶
PublicKey is an ecdsa.PublicKey with additional functions to serialize in uncompressed, compressed, and hybrid formats.
func (*PublicKey) IsEqual ¶
IsEqual compares this PublicKey instance to the one passed, returning true if both PublicKeys are equivalent. A PublicKey is equivalent to another, if they both have the same X and Y coordinate.
func (*PublicKey) SerializeCompressed ¶
SerializeCompressed serializes a public key in a 33-byte compressed format.
func (*PublicKey) SerializeHybrid ¶
SerializeHybrid serializes a public key in a 65-byte hybrid format.
func (*PublicKey) SerializeUncompressed ¶
SerializeUncompressed serializes a public key in a 65-byte uncompressed format.