ecdsa

package
v0.0.0-...-ebe581b Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 25

Documentation

Index

Constants

View Source
const (
	PublicKeyLength  = 64
	PrivateKeyLength = 32
	SignatureLength  = 64
)

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair() (privkey PrivateKey, pubkey PublicKey, err error)

GenerateKeyPair generate a key pair

func ParsePrivateKey

func ParsePrivateKey(privkey PrivateKey) ecdsa.PrivateKey

ParsePrivateKey parse from local type to EC private key

func ParsePublicKey

func ParsePublicKey(pubkey PublicKey) (ecdsa.PublicKey, error)

ParsePublicKey parse from local type to EC public key

func Verify

func Verify(pubkey PublicKey, digest []byte, signature Signature) error

Verify verify a signature

Types

type PrivateKey

type PrivateKey [PrivateKeyLength]byte

func DecodePrivateKeyFromString

func DecodePrivateKeyFromString(s string) (PrivateKey, error)

DecodePrivateKeyFromString decode ec private key from string

func MarshalPrivateKey

func MarshalPrivateKey(privkey *ecdsa.PrivateKey) PrivateKey

MarshalPrivateKey marshal private key to local types

func (PrivateKey) String

func (sk PrivateKey) String() string

type PublicKey

type PublicKey [PublicKeyLength]byte

func DecodePublicKeyFromString

func DecodePublicKeyFromString(s string) (PublicKey, error)

DecodePublicKeyFromString decode ec public key from string

func MarshalPublicKey

func MarshalPublicKey(pubkey *ecdsa.PublicKey) PublicKey

MarshalPublicKey marshal public key to local types

func PublicKeyFromPrivateKey

func PublicKeyFromPrivateKey(privkey PrivateKey) PublicKey

PublicKeyFromPrivateKey

func (PublicKey) String

func (pk PublicKey) String() string

type Signature

type Signature [SignatureLength]byte

func DecodeSignatureFromString

func DecodeSignatureFromString(s string) (Signature, error)

DecodeSignatureFromString decode ec signature from string

func Sign

func Sign(privkey PrivateKey, digest []byte) (Signature, error)

Sign sign a digest

func (Signature) String

func (s Signature) String() string

Jump to

Keyboard shortcuts

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