Documentation ¶
Index ¶
- Variables
- func FromECDSAPrivateKey(priv *ecdsa.PrivateKey) ([]byte, error)
- func FromECDSAPublicKey(pub *ecdsa.PublicKey) ([]byte, error)
- func HexToECDSAPrivateKey(hexkey string) (*ecdsa.PrivateKey, error)
- func NewECDSAPrivateKey() *ecdsa.PrivateKey
- func RecoverECDSAPublicKey(msg []byte, signature []byte) (*ecdsa.PublicKey, error)
- func S256() elliptic.Curve
- func SeckeyVerify(priv *ecdsa.PrivateKey) bool
- func Sign(msg []byte, priv *ecdsa.PrivateKey) ([]byte, error)
- func ToECDSAPrivateKey(d []byte) (*ecdsa.PrivateKey, error)
- func ToECDSAPublicKey(pub []byte) (*ecdsa.PublicKey, error)
- func Verify(msg []byte, signature []byte, pub *ecdsa.PublicKey) (bool, error)
- type PrivateKey
- type PublicKey
- type Signature
- func (s *Signature) Algorithm() keystore.Algorithm
- func (s *Signature) InitSign(priv keystore.PrivateKey) error
- func (s *Signature) InitVerify(pub keystore.PublicKey) error
- func (s *Signature) RecoverPublic(data []byte, signature []byte) (keystore.PublicKey, error)
- func (s *Signature) Sign(data []byte) (out []byte, err error)
- func (s *Signature) Verify(data []byte, signature []byte) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidMsgLen invalid message length ErrInvalidMsgLen = errors.New("invalid message length, need 32 bytes") // ErrInvalidSignature invalid signature length ErrInvalidSignature = errors.New("invalid signature") // ErrInvalidPrivateKey invalid private key ErrInvalidPrivateKey = errors.New("invalid private key") // ErrInvalidPublicKey invalid public key ErrInvalidPublicKey = errors.New("invalid public key") // ErrSignFailed sign failed ErrSignFailed = errors.New("sign failed") // ErrRecoverFailed recover failed ErrRecoverFailed = errors.New("recovery failed") )
Functions ¶
func FromECDSAPrivateKey ¶
func FromECDSAPrivateKey(priv *ecdsa.PrivateKey) ([]byte, error)
FromECDSAPrivateKey exports a private key into a binary dump.
func FromECDSAPublicKey ¶
FromECDSAPublicKey exports a public key into a binary dump.
func HexToECDSAPrivateKey ¶
func HexToECDSAPrivateKey(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSAPrivateKey parses a secp256k1 private key.
func NewECDSAPrivateKey ¶
func NewECDSAPrivateKey() *ecdsa.PrivateKey
NewECDSAPrivateKey generate a ecdsa private key
func RecoverECDSAPublicKey ¶
RecoverECDSAPublicKey recover verifies the compact signature "signature" of "hash"
func SeckeyVerify ¶ added in v1.0.0
func SeckeyVerify(priv *ecdsa.PrivateKey) bool
SeckeyVerify check private is ok for secp256k1
func Sign ¶
func Sign(msg []byte, priv *ecdsa.PrivateKey) ([]byte, error)
Sign sign hash with private key
func ToECDSAPrivateKey ¶
func ToECDSAPrivateKey(d []byte) (*ecdsa.PrivateKey, error)
ToECDSAPrivateKey creates a private key with the given data value.
func ToECDSAPublicKey ¶
ToECDSAPublicKey creates a public key with the given data value.
Types ¶
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey ecdsa privatekey
func GeneratePrivateKey ¶
func GeneratePrivateKey() *PrivateKey
GeneratePrivateKey generate a new private key
func NewPrivateKey ¶ added in v1.0.0
func NewPrivateKey(key *ecdsa.PrivateKey) *PrivateKey
NewPrivateKey new a private key with ecdsa.PrivateKey
func (*PrivateKey) Algorithm ¶
func (k *PrivateKey) Algorithm() keystore.Algorithm
Algorithm algorithm name
func (*PrivateKey) Decode ¶
func (k *PrivateKey) Decode(data []byte) error
Decode decode data to key
func (*PrivateKey) PublicKey ¶
func (k *PrivateKey) PublicKey() keystore.PublicKey
PublicKey returns publickey
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey ecdsa publickey
func NewPublicKey ¶
NewPublicKey generate PublicKey
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
Signature signature ecdsa
func (*Signature) InitSign ¶
func (s *Signature) InitSign(priv keystore.PrivateKey) error
InitSign ecdsa init sign
func (*Signature) InitVerify ¶
InitVerify ecdsa verify init
func (*Signature) RecoverPublic ¶
RecoverPublic returns a public key