keychain

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const PrivateKeyStoreKey = "private_key"
View Source
const PublicKeyStoreKey = "public_key"

Variables

View Source
var (
	ErrKeyPairNotFound = errors.New("No key pair found in the local db.")
)

Functions

This section is empty.

Types

type Keychain

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

func New

func New(store db.Store) *Keychain

func (*Keychain) GenerateKeyPair

func (kc *Keychain) GenerateKeyPair() ([]byte, []byte, error)

Generates a public/private key pair using ed25519 algorithm. It stores it in the local db and returns the key pair key. If there's already a key pair stored, it returns an error. Use GenerateKeyPairWithForce if you want to override existing keys

func (*Keychain) GenerateKeyPairWithForce

func (kc *Keychain) GenerateKeyPairWithForce() ([]byte, []byte, error)

Generates a public/private key pair using ed25519 algorithm. It stores it in the local db and returns the key pair. Warning: If there's already a key pair stored, it overrides it.

func (*Keychain) GetStoredKeyPairInLibP2PFormat

func (kc *Keychain) GetStoredKeyPairInLibP2PFormat() (crypto.PrivKey, crypto.PubKey, error)

Returns the stored key pair using the same signature than libp2p's GenerateEd25519Key function

func (*Keychain) Sign

func (kc *Keychain) Sign(message []byte) ([]byte, error)

Signs a message using the stored private key. Returns an error if the private key cannot be found.

Jump to

Keyboard shortcuts

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