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, 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 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 Ed25519Keyring
- type EncryptedKeystore
- type Keystore
- func (ks *Keystore) Ed25519Keypairs() []crypto.Keypair
- func (ks *Keystore) Ed25519PublicKeys() []crypto.PublicKey
- func (ks *Keystore) Get(pub common.Address) crypto.Keypair
- func (ks *Keystore) GetKeypair(pub crypto.PublicKey) crypto.Keypair
- func (ks *Keystore) Insert(kp crypto.Keypair)
- func (ks *Keystore) NumSr25519Keys() int
- func (ks *Keystore) Secp256k1Keypairs() []crypto.Keypair
- func (ks *Keystore) Secp256k1PublicKeys() []crypto.PublicKey
- func (ks *Keystore) Sr25519Keypairs() []crypto.Keypair
- func (ks *Keystore) Sr25519PublicKeys() []crypto.PublicKey
- type Sr25519Keyring
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 ¶
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 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 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 ¶
EncryptedKeystore holds Type PublicKey and Ciphertext
type Keystore ¶
type Keystore struct {
// contains filtered or unexported fields
}
Keystore holds keys and lock
func LoadKeystore ¶
LoadKeystore loads a new keystore and inserts the test key into the keystore
func (*Keystore) Ed25519Keypairs ¶
Ed25519Keypairs Keypair
func (*Keystore) Ed25519PublicKeys ¶
Ed25519PublicKeys keys
func (*Keystore) GetKeypair ¶
GetKeypair Keypair
func (*Keystore) NumSr25519Keys ¶
NumSr25519Keys returns the number of sr25519 keys in the keystore
func (*Keystore) Secp256k1Keypairs ¶
Secp256k1Keypairs Keypair
func (*Keystore) Secp256k1PublicKeys ¶
Secp256k1PublicKeys PublicKey
func (*Keystore) Sr25519Keypairs ¶
Sr25519Keypairs Keypair
func (*Keystore) Sr25519PublicKeys ¶
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