keystore

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: LGPL-3.0 Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePrivateKey

func DecodePrivateKey(in []byte, keytype crypto.KeyType) (priv crypto.PrivateKey, err error)

DecodePrivateKey turns input bytes into a private key based on the specified key type

func Decrypt

func Decrypt(data, password []byte) ([]byte, error)

Decrypt uses AES to decrypt ciphertext with the symmetric key deterministically created from `password`

func DecryptPrivateKey

func DecryptPrivateKey(data, password []byte, keytype string) (crypto.PrivateKey, error)

DecryptPrivateKey uses AES to decrypt the ciphertext into a `crypto.PrivateKey` with a symmetric key deterministically created from `password`

func DetermineKeyType

func DetermineKeyType(t string) crypto.KeyType

DetermineKeyType takes string as defined in https://github.com/w3f/PSPs/blob/psp-rpc-api/psp-002.md#Key-types

and returns the crypto.KeyType

func Encrypt

func Encrypt(msg, password []byte) ([]byte, error)

Encrypt uses AES to encrypt `msg` with the symmetric key deterministically created from `password`

func EncryptAndWriteToFile

func EncryptAndWriteToFile(file *os.File, pk crypto.PrivateKey, password []byte) error

EncryptAndWriteToFile encrypts the `crypto.PrivateKey` using the password and saves it to the specified file

func EncryptPrivateKey

func EncryptPrivateKey(pk crypto.PrivateKey, password []byte) ([]byte, error)

EncryptPrivateKey uses AES to encrypt an encoded `crypto.PrivateKey` with a symmetric key deterministically created from `password`

func GenerateKeypair

func GenerateKeypair(keytype string, basepath string, password []byte) (string, error)

GenerateKeypair create a new keypair with the corresponding type and saves it to basepath/keystore/[public key].key in json format encrypted using the specified password and returns the resulting filepath of the new key

func HasKey

func HasKey(pubKeyStr string, keyType string, keystore *Keystore) (bool, error)

HasKey returns true if given hex encoded public key string is found in keystore, false otherwise, error if there

are issues decoding string

func ImportKeypair

func ImportKeypair(fp string, dir string) (string, error)

ImportKeypair imports a key specified by its filename into a subdirectory by the name "keystore" and saves it under the filename "[publickey].key", returns the absolute path of the imported key file

func PrivateKeyToKeypair

func PrivateKeyToKeypair(priv crypto.PrivateKey) (kp crypto.Keypair, err error)

PrivateKeyToKeypair returns a public, private keypair given a private key

func ReadFromFileAndDecrypt

func ReadFromFileAndDecrypt(filename string, password []byte) (crypto.PrivateKey, error)

ReadFromFileAndDecrypt reads ciphertext from a file and decrypts it using the password into a `crypto.PrivateKey`

func UnlockKeys

func UnlockKeys(ks *Keystore, dir string, unlock string, password string) error

UnlockKeys unlocks keys specified by the --unlock flag with the passwords given by --password and places them into the keystore

Types

type Ed25519Keyring

type Ed25519Keyring struct {
	Alice   *ed25519.Keypair
	Bob     *ed25519.Keypair
	Charlie *ed25519.Keypair
	Dave    *ed25519.Keypair
	Eve     *ed25519.Keypair
	Fred    *ed25519.Keypair
	George  *ed25519.Keypair
	Heather *ed25519.Keypair
	Ian     *ed25519.Keypair

	Keys []*ed25519.Keypair
}

Ed25519Keyring represents a test ed25519 keyring

func NewEd25519Keyring

func NewEd25519Keyring() (*Ed25519Keyring, error)

NewEd25519Keyring returns an initialized ed25519 Keyring

type EncryptedKeystore

type EncryptedKeystore struct {
	Type       string
	PublicKey  string
	Ciphertext []byte
}

EncryptedKeystore holds Type PublicKey and Ciphertext

type Keystore

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

Keystore holds keys and lock

func LoadKeystore

func LoadKeystore(key string) (*Keystore, error)

LoadKeystore loads a new keystore and inserts the test key into the keystore

func NewKeystore

func NewKeystore() *Keystore

NewKeystore create and returns Keystore

func (*Keystore) Ed25519Keypairs

func (ks *Keystore) Ed25519Keypairs() []crypto.Keypair

Ed25519Keypairs Keypair

func (*Keystore) Ed25519PublicKeys

func (ks *Keystore) Ed25519PublicKeys() []crypto.PublicKey

Ed25519PublicKeys keys

func (*Keystore) Get

func (ks *Keystore) Get(pub common.Address) crypto.Keypair

Get crypto.Keypai from Keystore

func (*Keystore) GetKeypair

func (ks *Keystore) GetKeypair(pub crypto.PublicKey) crypto.Keypair

GetKeypair Keypair

func (*Keystore) Insert

func (ks *Keystore) Insert(kp crypto.Keypair)

Insert crypto.Keypai into Keystore

func (*Keystore) NumSr25519Keys

func (ks *Keystore) NumSr25519Keys() int

NumSr25519Keys returns the number of sr25519 keys in the keystore

func (*Keystore) Secp256k1Keypairs

func (ks *Keystore) Secp256k1Keypairs() []crypto.Keypair

Secp256k1Keypairs Keypair

func (*Keystore) Secp256k1PublicKeys

func (ks *Keystore) Secp256k1PublicKeys() []crypto.PublicKey

Secp256k1PublicKeys PublicKey

func (*Keystore) Sr25519Keypairs

func (ks *Keystore) Sr25519Keypairs() []crypto.Keypair

Sr25519Keypairs Keypair

func (*Keystore) Sr25519PublicKeys

func (ks *Keystore) Sr25519PublicKeys() []crypto.PublicKey

Sr25519PublicKeys PublicKey

type Sr25519Keyring

type Sr25519Keyring struct {
	Alice   *sr25519.Keypair
	Bob     *sr25519.Keypair
	Charlie *sr25519.Keypair
	Dave    *sr25519.Keypair
	Eve     *sr25519.Keypair
	Fred    *sr25519.Keypair
	George  *sr25519.Keypair
	Heather *sr25519.Keypair
	Ian     *sr25519.Keypair
}

Sr25519Keyring represents a test keyring

func NewSr25519Keyring

func NewSr25519Keyring() (*Sr25519Keyring, error)

NewSr25519Keyring returns an initialized sr25519 Keyring

Jump to

Keyboard shortcuts

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