keys

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyPair

type KeyPair interface {
	fmt.Stringer
	Sign(message []byte) ([]byte, error)
	Verify(message, signature []byte) bool
	GetPublicKey() PublicKey
}

KeyPair represents a public/private key pair.

func NewKeyPairFromRandom

func NewKeyPairFromRandom(curve string) (KeyPair, error)

NewKeyPairFromRandom creates a random KeyPair using the specified curve.

func NewKeyPairFromString

func NewKeyPairFromString(secretKey string) (KeyPair, error)

NewKeyPairFromString creates a new KeyPair from a optionally curve-prefixed base58 string.

type KeyPairEd25519

type KeyPairEd25519 struct {
	// contains filtered or unexported fields
}

KeyPairEd25519 is an ed25519 implementation of KeyPair.

func (*KeyPairEd25519) GetPublicKey

func (k *KeyPairEd25519) GetPublicKey() PublicKey

GetPublicKey returns the PublicKey corresponding to the KeyPair's private key.

func (*KeyPairEd25519) Sign

func (k *KeyPairEd25519) Sign(message []byte) ([]byte, error)

Sign signs a message with the KeyPair's private key.

func (*KeyPairEd25519) String

func (k *KeyPairEd25519) String() string

func (*KeyPairEd25519) Verify

func (k *KeyPairEd25519) Verify(message, signature []byte) bool

Verify reports whether signature is a valid signature of message by the KeyPair's public key.

type KeyStore

type KeyStore interface {
	SetKey(networkID, accountID string, keyPair KeyPair)
}

KeyStore stores KeyPairs in association with network and account IDs.

type KeyType

type KeyType int

KeyType is the type of key.

const (
	// ED25519 represents an ed25519 key.
	ED25519 KeyType = iota
)

type PublicKey

type PublicKey struct {
	Type KeyType
	Data []byte
}

PublicKey represents a public key.

func NewPublicKeyFromString

func NewPublicKeyFromString(str string) (*PublicKey, error)

NewPublicKeyFromString creates a new public key from a base58 encoded string prefixed with the key type string.

func (*PublicKey) ToString

func (pk *PublicKey) ToString() (string, error)

ToString creates a string representation of the public key of the form <curve>:<base58 encoded key>.

Jump to

Keyboard shortcuts

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