Documentation ¶
Index ¶
- Variables
- func DecodePrivateKey(in []byte, keytype crypto.KeyType) (priv crypto.PrivateKey, err error)
- func Decrypt(data, password []byte) ([]byte, error)
- func DecryptPrivateKey(data, password []byte, keytype string) (crypto.PrivateKey, error)
- func DetermineKeyType(t string) crypto.KeyType
- func Encrypt(msg, password []byte) ([]byte, error)
- func EncryptAndWriteToFile(path string, pk crypto.PrivateKey, password []byte) error
- func EncryptPrivateKey(pk crypto.PrivateKey, password []byte) ([]byte, error)
- func GenerateKeypair(keytype string, kp PublicPrivater, basepath string, password []byte) (string, error)
- func HasKey(pubKeyStr, keyType string, keystore AddressKeypairGetter) (bool, error)
- func ImportKeypair(fp, dir string) (string, error)
- func ImportRawPrivateKey(key, keytype, basepath string, password []byte) (string, error)
- func LoadKeystore(key string, keyStore TyperInserter, keyRing KeyRing) (err error)
- func ReadFromFileAndDecrypt(filename string, password []byte) (crypto.PrivateKey, error)
- func UnlockKeys(ks Inserter, dir, unlock, password string) error
- type AddressKeypairGetter
- type BasicKeystore
- func (ks *BasicKeystore) GetKeypair(pub crypto.PublicKey) KeyPair
- func (ks *BasicKeystore) GetKeypairFromAddress(pub common.Address) KeyPair
- func (ks *BasicKeystore) Insert(kp KeyPair) error
- func (ks *BasicKeystore) Keypairs() (srkeys []KeyPair)
- func (ks *BasicKeystore) Name() Name
- func (ks *BasicKeystore) PublicKeys() (srkeys []crypto.PublicKey)
- func (ks *BasicKeystore) Size() int
- func (ks *BasicKeystore) Type() crypto.KeyType
- type Ed25519Keyring
- func (kr *Ed25519Keyring) Alice() KeyPair
- func (kr *Ed25519Keyring) Bob() KeyPair
- func (kr *Ed25519Keyring) Charlie() KeyPair
- func (kr *Ed25519Keyring) Dave() KeyPair
- func (kr *Ed25519Keyring) Eve() KeyPair
- func (kr *Ed25519Keyring) Ferdie() KeyPair
- func (kr *Ed25519Keyring) George() KeyPair
- func (kr *Ed25519Keyring) Heather() KeyPair
- func (kr *Ed25519Keyring) Ian() KeyPair
- type EncryptedKeystore
- type GenericKeystore
- func (ks *GenericKeystore) Ed25519Keypairs() (edkeys []KeyPair)
- func (ks *GenericKeystore) Ed25519PublicKeys() (edkeys []crypto.PublicKey)
- func (ks *GenericKeystore) GetKeypair(pub crypto.PublicKey) KeyPair
- func (ks *GenericKeystore) GetKeypairFromAddress(pub common.Address) KeyPair
- func (ks *GenericKeystore) Insert(kp KeyPair) error
- func (ks *GenericKeystore) Keypairs() (srkeys []KeyPair)
- func (ks *GenericKeystore) Name() Name
- func (ks *GenericKeystore) NumEd25519Keys() int
- func (ks *GenericKeystore) NumSr25519Keys() int
- func (ks *GenericKeystore) PublicKeys() (srkeys []crypto.PublicKey)
- func (ks *GenericKeystore) Secp256k1Keypairs() (sckeys []KeyPair)
- func (ks *GenericKeystore) Secp256k1PublicKeys() (sckeys []crypto.PublicKey)
- func (ks *GenericKeystore) Size() int
- func (ks *GenericKeystore) Sr25519Keypairs() (srkeys []KeyPair)
- func (ks *GenericKeystore) Sr25519PublicKeys() (srkeys []crypto.PublicKey)
- func (*GenericKeystore) Type() crypto.KeyType
- type GlobalKeystore
- type Inserter
- type KeyPair
- type KeyRing
- type Keystore
- type Name
- type Privater
- type PublicPrivater
- type Publicer
- type Sr25519Keyring
- func (kr *Sr25519Keyring) Alice() KeyPair
- func (kr *Sr25519Keyring) Bob() KeyPair
- func (kr *Sr25519Keyring) Charlie() KeyPair
- func (kr *Sr25519Keyring) Dave() KeyPair
- func (kr *Sr25519Keyring) Eve() KeyPair
- func (kr *Sr25519Keyring) Ferdie() KeyPair
- func (kr *Sr25519Keyring) George() KeyPair
- func (kr *Sr25519Keyring) Heather() KeyPair
- func (kr *Sr25519Keyring) Ian() KeyPair
- type Typer
- type TyperInserter
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidKeystoreName = errors.New("invalid keystore name")
)
var (
ErrKeyTypeNotSupported = errors.New("given key type is not supported by this keystore")
)
Functions ¶
func DecodePrivateKey ¶
DecodePrivateKey turns input bytes into a private key based on the specified key type
func Decrypt ¶
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 ¶
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 ¶
Encrypt uses AES to encrypt `msg` with the symmetric key deterministically created from `password`
func EncryptAndWriteToFile ¶
func EncryptAndWriteToFile(path string, 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, kp PublicPrivater, 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, keyType string, keystore AddressKeypairGetter) (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 ¶
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 ImportRawPrivateKey ¶ added in v0.2.0
ImportRawPrivateKey imports a raw private key and saves it to the keystore directory
func LoadKeystore ¶
func LoadKeystore(key string, keyStore TyperInserter, keyRing KeyRing) (err error)
LoadKeystore loads a new keystore and inserts the test key into the keystore
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 ¶
UnlockKeys unlocks keys specified by the --unlock flag with the passwords given by --password and places them into the keystore
Types ¶
type AddressKeypairGetter ¶ added in v0.8.0
AddressKeypairGetter gets a keypair from an address.
type BasicKeystore ¶ added in v0.2.0
type BasicKeystore struct {
// contains filtered or unexported fields
}
BasicKeystore holds keys of a certain type
func NewBasicKeystore ¶ added in v0.2.0
func NewBasicKeystore(name Name, typ crypto.KeyType) *BasicKeystore
NewBasicKeystore creates a new BasicKeystore with the given key type
func (*BasicKeystore) GetKeypair ¶ added in v0.2.0
func (ks *BasicKeystore) GetKeypair(pub crypto.PublicKey) KeyPair
GetKeypair returns a keypair corresponding to the given public key, or nil if it doesn't exist
func (*BasicKeystore) GetKeypairFromAddress ¶ added in v0.2.0
func (ks *BasicKeystore) GetKeypairFromAddress(pub common.Address) KeyPair
GetKeypairFromAddress returns a keypair corresponding to the given address, or nil if it doesn't exist
func (*BasicKeystore) Insert ¶ added in v0.2.0
func (ks *BasicKeystore) Insert(kp KeyPair) error
Insert adds a keypair to the keystore
func (*BasicKeystore) Keypairs ¶ added in v0.2.0
func (ks *BasicKeystore) Keypairs() (srkeys []KeyPair)
Keypairs returns all keypairs in the keystore
func (*BasicKeystore) Name ¶ added in v0.2.0
func (ks *BasicKeystore) Name() Name
Name returns the keystore's name
func (*BasicKeystore) PublicKeys ¶ added in v0.2.0
func (ks *BasicKeystore) PublicKeys() (srkeys []crypto.PublicKey)
PublicKeys returns all public keys in the keystore
func (*BasicKeystore) Size ¶ added in v0.2.0
func (ks *BasicKeystore) Size() int
Size returns the number of keys in the keystore
func (*BasicKeystore) Type ¶ added in v0.2.0
func (ks *BasicKeystore) Type() crypto.KeyType
Type returns the keystore's key type
type Ed25519Keyring ¶
type Ed25519Keyring struct { KeyAlice *ed25519.Keypair KeyBob *ed25519.Keypair KeyCharlie *ed25519.Keypair KeyDave *ed25519.Keypair KeyEve *ed25519.Keypair KeyFerdie *ed25519.Keypair KeyGeorge *ed25519.Keypair KeyHeather *ed25519.Keypair KeyIan *ed25519.Keypair Keys []*ed25519.Keypair }
Ed25519Keyring represents a test ed25519 keyring
func NewEd25519Keyring ¶
func NewEd25519Keyring() (*Ed25519Keyring, error)
NewEd25519Keyring returns an initialised ed25519 Keyring
func (*Ed25519Keyring) Charlie ¶
func (kr *Ed25519Keyring) Charlie() KeyPair
Charlie returns Charlie's key
func (*Ed25519Keyring) Ferdie ¶ added in v0.2.0
func (kr *Ed25519Keyring) Ferdie() KeyPair
Ferdie returns Ferdie's key
func (*Ed25519Keyring) George ¶
func (kr *Ed25519Keyring) George() KeyPair
George returns George's key
func (*Ed25519Keyring) Heather ¶
func (kr *Ed25519Keyring) Heather() KeyPair
Heather returns Heather's key
type EncryptedKeystore ¶
EncryptedKeystore holds Type PublicKey and Ciphertext
type GenericKeystore ¶ added in v0.2.0
type GenericKeystore struct {
// contains filtered or unexported fields
}
GenericKeystore holds keys of any type
func NewGenericKeystore ¶ added in v0.2.0
func NewGenericKeystore(name Name) *GenericKeystore
NewGenericKeystore creates a new GenericKeystore
func (*GenericKeystore) Ed25519Keypairs ¶ added in v0.2.0
func (ks *GenericKeystore) Ed25519Keypairs() (edkeys []KeyPair)
Ed25519Keypairs Keypair
func (*GenericKeystore) Ed25519PublicKeys ¶ added in v0.2.0
func (ks *GenericKeystore) Ed25519PublicKeys() (edkeys []crypto.PublicKey)
Ed25519PublicKeys keys
func (*GenericKeystore) GetKeypair ¶ added in v0.2.0
func (ks *GenericKeystore) GetKeypair(pub crypto.PublicKey) KeyPair
GetKeypair returns a keypair corresponding to the given public key, or nil if it doesn't exist
func (*GenericKeystore) GetKeypairFromAddress ¶ added in v0.2.0
func (ks *GenericKeystore) GetKeypairFromAddress(pub common.Address) KeyPair
GetKeypairFromAddress returns a keypair corresponding to the given address, or nil if it doesn't exist
func (*GenericKeystore) Insert ¶ added in v0.2.0
func (ks *GenericKeystore) Insert(kp KeyPair) error
Insert adds a keypair to the keystore
func (*GenericKeystore) Keypairs ¶ added in v0.2.0
func (ks *GenericKeystore) Keypairs() (srkeys []KeyPair)
Keypairs returns all keypairs in the keystore
func (*GenericKeystore) Name ¶ added in v0.2.0
func (ks *GenericKeystore) Name() Name
Name returns the keystore's name
func (*GenericKeystore) NumEd25519Keys ¶ added in v0.2.0
func (ks *GenericKeystore) NumEd25519Keys() int
NumEd25519Keys returns the number of ed25519 keys in the keystore
func (*GenericKeystore) NumSr25519Keys ¶ added in v0.2.0
func (ks *GenericKeystore) NumSr25519Keys() int
NumSr25519Keys returns the number of sr25519 keys in the keystore
func (*GenericKeystore) PublicKeys ¶ added in v0.2.0
func (ks *GenericKeystore) PublicKeys() (srkeys []crypto.PublicKey)
PublicKeys returns all public keys in the keystore
func (*GenericKeystore) Secp256k1Keypairs ¶ added in v0.2.0
func (ks *GenericKeystore) Secp256k1Keypairs() (sckeys []KeyPair)
Secp256k1Keypairs Keypair
func (*GenericKeystore) Secp256k1PublicKeys ¶ added in v0.2.0
func (ks *GenericKeystore) Secp256k1PublicKeys() (sckeys []crypto.PublicKey)
Secp256k1PublicKeys PublicKey
func (*GenericKeystore) Size ¶ added in v0.2.0
func (ks *GenericKeystore) Size() int
Size returns the number of keys in the keystore
func (*GenericKeystore) Sr25519Keypairs ¶ added in v0.2.0
func (ks *GenericKeystore) Sr25519Keypairs() (srkeys []KeyPair)
Sr25519Keypairs Keypair
func (*GenericKeystore) Sr25519PublicKeys ¶ added in v0.2.0
func (ks *GenericKeystore) Sr25519PublicKeys() (srkeys []crypto.PublicKey)
Sr25519PublicKeys PublicKey
func (*GenericKeystore) Type ¶ added in v0.2.0
func (*GenericKeystore) Type() crypto.KeyType
Type returns UnknownType since the keystore may contain keys of any type
type GlobalKeystore ¶ added in v0.2.0
type GlobalKeystore struct { Babe Keystore Gran Keystore Acco Keystore Aura Keystore Para Keystore Asgn Keystore Imon Keystore Audi Keystore Dumy Keystore }
GlobalKeystore defines the various keystores used by the node
func NewGlobalKeystore ¶ added in v0.2.0
func NewGlobalKeystore() *GlobalKeystore
NewGlobalKeystore returns a new GlobalKeystore
func (*GlobalKeystore) GetKeystore ¶ added in v0.3.1
func (k *GlobalKeystore) GetKeystore(name []byte) (Keystore, error)
GetKeystore returns a keystore given its name
type KeyPair ¶ added in v0.8.0
KeyPair is a key pair to sign messages and from which the public key and key type can be obtained.
func DecodeKeyPairFromHex ¶ added in v0.7.0
DecodeKeyPairFromHex turns an hex-encoded private key into a keypair
func PrivateKeyToKeypair ¶
func PrivateKeyToKeypair(priv crypto.PrivateKey) (kp KeyPair, err error)
PrivateKeyToKeypair returns a public, private keypair given a private key
type KeyRing ¶ added in v0.8.0
type KeyRing interface { Alice() KeyPair Bob() KeyPair Charlie() KeyPair Dave() KeyPair Eve() KeyPair Ferdie() KeyPair George() KeyPair Heather() KeyPair Ian() KeyPair }
KeyRing is the key ring with multiple named keypairs.
type Keystore ¶
type Keystore interface { Name() Name Typer Inserter AddressKeypairGetter Keypairs() []KeyPair GetKeypair(pub crypto.PublicKey) KeyPair PublicKeys() []crypto.PublicKey Size() int }
Keystore provides key management functionality
type Privater ¶ added in v0.8.0
type Privater interface {
Private() crypto.PrivateKey
}
Privater returns the private key of the keypair.
type PublicPrivater ¶ added in v0.8.0
PublicPrivater can return the private or public key from the keypair.
type Sr25519Keyring ¶
type Sr25519Keyring struct { KeyAlice *sr25519.Keypair KeyBob *sr25519.Keypair KeyCharlie *sr25519.Keypair KeyDave *sr25519.Keypair KeyEve *sr25519.Keypair KeyFerdie *sr25519.Keypair KeyGeorge *sr25519.Keypair KeyHeather *sr25519.Keypair KeyIan *sr25519.Keypair Keys []*sr25519.Keypair }
Sr25519Keyring represents a test keyring
func NewSr25519Keyring ¶
func NewSr25519Keyring() (*Sr25519Keyring, error)
NewSr25519Keyring returns an initialised sr25519 Keyring
func (*Sr25519Keyring) Charlie ¶
func (kr *Sr25519Keyring) Charlie() KeyPair
Charlie returns Charlie's key
func (*Sr25519Keyring) Ferdie ¶ added in v0.2.0
func (kr *Sr25519Keyring) Ferdie() KeyPair
Ferdie returns Ferdie's key
func (*Sr25519Keyring) George ¶
func (kr *Sr25519Keyring) George() KeyPair
George returns George's key
func (*Sr25519Keyring) Heather ¶
func (kr *Sr25519Keyring) Heather() KeyPair
Heather returns Heather's key
type TyperInserter ¶ added in v0.8.0
TyperInserter has the Type and Insert methods.