Documentation ¶
Index ¶
- 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(file *os.File, pk crypto.PrivateKey, password []byte) error
- func EncryptPrivateKey(pk crypto.PrivateKey, password []byte) ([]byte, error)
- func GenerateKeypair(keytype string, kp crypto.Keypair, basepath string, password []byte) (string, error)
- func HasKey(pubKeyStr string, keyType string, keystore Keystore) (bool, error)
- func ImportKeypair(fp string, dir string) (string, error)
- func ImportRawPrivateKey(key, keytype, basepath string, password []byte) (string, error)
- func LoadKeystore(key string, ks Keystore) error
- func PrivateKeyToKeypair(priv crypto.PrivateKey) (kp crypto.Keypair, err error)
- func ReadFromFileAndDecrypt(filename string, password []byte) (crypto.PrivateKey, error)
- func UnlockKeys(ks Keystore, dir string, unlock string, password string) error
- type BasicKeystore
- func (ks *BasicKeystore) GetKeypair(pub crypto.PublicKey) crypto.Keypair
- func (ks *BasicKeystore) GetKeypairFromAddress(pub common.Address) crypto.Keypair
- func (ks *BasicKeystore) Insert(kp crypto.Keypair)
- func (ks *BasicKeystore) Keypairs() []crypto.Keypair
- func (ks *BasicKeystore) Name() Name
- func (ks *BasicKeystore) PublicKeys() []crypto.PublicKey
- func (ks *BasicKeystore) Size() int
- func (ks *BasicKeystore) Type() crypto.KeyType
- type Ed25519Keyring
- func (kr *Ed25519Keyring) Alice() crypto.Keypair
- func (kr *Ed25519Keyring) Bob() crypto.Keypair
- func (kr *Ed25519Keyring) Charlie() crypto.Keypair
- func (kr *Ed25519Keyring) Dave() crypto.Keypair
- func (kr *Ed25519Keyring) Eve() crypto.Keypair
- func (kr *Ed25519Keyring) Ferdie() crypto.Keypair
- func (kr *Ed25519Keyring) George() crypto.Keypair
- func (kr *Ed25519Keyring) Heather() crypto.Keypair
- func (kr *Ed25519Keyring) Ian() crypto.Keypair
- type EncryptedKeystore
- type GenericKeystore
- func (ks *GenericKeystore) Ed25519Keypairs() []crypto.Keypair
- func (ks *GenericKeystore) Ed25519PublicKeys() []crypto.PublicKey
- func (ks *GenericKeystore) GetKeypair(pub crypto.PublicKey) crypto.Keypair
- func (ks *GenericKeystore) GetKeypairFromAddress(pub common.Address) crypto.Keypair
- func (ks *GenericKeystore) Insert(kp crypto.Keypair)
- func (ks *GenericKeystore) Keypairs() []crypto.Keypair
- func (ks *GenericKeystore) Name() Name
- func (ks *GenericKeystore) NumEd25519Keys() int
- func (ks *GenericKeystore) NumSr25519Keys() int
- func (ks *GenericKeystore) PublicKeys() []crypto.PublicKey
- func (ks *GenericKeystore) Secp256k1Keypairs() []crypto.Keypair
- func (ks *GenericKeystore) Secp256k1PublicKeys() []crypto.PublicKey
- func (ks *GenericKeystore) Size() int
- func (ks *GenericKeystore) Sr25519Keypairs() []crypto.Keypair
- func (ks *GenericKeystore) Sr25519PublicKeys() []crypto.PublicKey
- func (ks *GenericKeystore) Type() crypto.KeyType
- type GlobalKeystore
- type Keyring
- type Keystore
- type Name
- type Sr25519Keyring
- func (kr *Sr25519Keyring) Alice() crypto.Keypair
- func (kr *Sr25519Keyring) Bob() crypto.Keypair
- func (kr *Sr25519Keyring) Charlie() crypto.Keypair
- func (kr *Sr25519Keyring) Dave() crypto.Keypair
- func (kr *Sr25519Keyring) Eve() crypto.Keypair
- func (kr *Sr25519Keyring) Ferdie() crypto.Keypair
- func (kr *Sr25519Keyring) George() crypto.Keypair
- func (kr *Sr25519Keyring) Heather() crypto.Keypair
- func (kr *Sr25519Keyring) Ian() crypto.Keypair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 ¶
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 crypto.Keypair, 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 ¶
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 ¶
LoadKeystore loads a new keystore and inserts the test key into the keystore
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`
Types ¶
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) crypto.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) crypto.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 crypto.Keypair)
Insert adds a keypair to the keystore
func (*BasicKeystore) Keypairs ¶ added in v0.2.0
func (ks *BasicKeystore) Keypairs() []crypto.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() []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 initialized ed25519 Keyring
func (*Ed25519Keyring) Alice ¶
func (kr *Ed25519Keyring) Alice() crypto.Keypair
Alice returns Alice's key
func (*Ed25519Keyring) Charlie ¶
func (kr *Ed25519Keyring) Charlie() crypto.Keypair
Charlie returns Charlie's key
func (*Ed25519Keyring) Dave ¶
func (kr *Ed25519Keyring) Dave() crypto.Keypair
Dave returns Dave's key
func (*Ed25519Keyring) Ferdie ¶ added in v0.2.0
func (kr *Ed25519Keyring) Ferdie() crypto.Keypair
Ferdie returns Ferdie's key
func (*Ed25519Keyring) George ¶
func (kr *Ed25519Keyring) George() crypto.Keypair
George returns George's key
func (*Ed25519Keyring) Heather ¶
func (kr *Ed25519Keyring) Heather() crypto.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() []crypto.Keypair
Ed25519Keypairs Keypair
func (*GenericKeystore) Ed25519PublicKeys ¶ added in v0.2.0
func (ks *GenericKeystore) Ed25519PublicKeys() []crypto.PublicKey
Ed25519PublicKeys keys
func (*GenericKeystore) GetKeypair ¶ added in v0.2.0
func (ks *GenericKeystore) GetKeypair(pub crypto.PublicKey) crypto.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) crypto.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 crypto.Keypair)
Insert adds a keypair to the keystore
func (*GenericKeystore) Keypairs ¶ added in v0.2.0
func (ks *GenericKeystore) Keypairs() []crypto.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() []crypto.PublicKey
PublicKeys returns all public keys in the keystore
func (*GenericKeystore) Secp256k1Keypairs ¶ added in v0.2.0
func (ks *GenericKeystore) Secp256k1Keypairs() []crypto.Keypair
Secp256k1Keypairs Keypair
func (*GenericKeystore) Secp256k1PublicKeys ¶ added in v0.2.0
func (ks *GenericKeystore) Secp256k1PublicKeys() []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() []crypto.Keypair
Sr25519Keypairs Keypair
func (*GenericKeystore) Sr25519PublicKeys ¶ added in v0.2.0
func (ks *GenericKeystore) Sr25519PublicKeys() []crypto.PublicKey
Sr25519PublicKeys PublicKey
func (*GenericKeystore) Type ¶ added in v0.2.0
func (ks *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 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 Keyring ¶ added in v0.2.0
type Keyring interface { Alice() crypto.Keypair Bob() crypto.Keypair Charlie() crypto.Keypair Dave() crypto.Keypair Eve() crypto.Keypair Ferdie() crypto.Keypair George() crypto.Keypair Heather() crypto.Keypair Ian() crypto.Keypair }
Keyring represents a test keyring
type Keystore ¶
type Keystore interface { Name() Name Type() crypto.KeyType Insert(kp crypto.Keypair) GetKeypairFromAddress(pub common.Address) crypto.Keypair GetKeypair(pub crypto.PublicKey) crypto.Keypair PublicKeys() []crypto.PublicKey Keypairs() []crypto.Keypair Size() int }
Keystore provides key management functionality
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 initialized sr25519 Keyring
func (*Sr25519Keyring) Alice ¶
func (kr *Sr25519Keyring) Alice() crypto.Keypair
Alice returns Alice's key
func (*Sr25519Keyring) Charlie ¶
func (kr *Sr25519Keyring) Charlie() crypto.Keypair
Charlie returns Charlie's key
func (*Sr25519Keyring) Dave ¶
func (kr *Sr25519Keyring) Dave() crypto.Keypair
Dave returns Dave's key
func (*Sr25519Keyring) Ferdie ¶ added in v0.2.0
func (kr *Sr25519Keyring) Ferdie() crypto.Keypair
Ferdie returns Ferdie's key
func (*Sr25519Keyring) George ¶
func (kr *Sr25519Keyring) George() crypto.Keypair
George returns George's key
func (*Sr25519Keyring) Heather ¶
func (kr *Sr25519Keyring) Heather() crypto.Keypair
Heather returns Heather's key