Documentation ¶
Overview ¶
The keystore package is used to load keys from keystore files, both for live use and for testing.
The Keystore ¶
The keystore file is used as a file representation of a key. It contains 4 parts: - The key type (secp256k1, sr25519) - The PublicKey - The Address - The ciphertext
This keystore also requires a password to decrypt into a usable key. The keystore library can be used to both encrypt keys into keystores, and decrypt keystore into keys. For more information on how to encrypt and decrypt from the command line, reference the README: https://github.com/elastos/Elastos.ELA.SideChain.ESC/ChainBridge
The Keyring ¶
The keyring provides predefined secp256k1 and srr25519 keys to use in testing. These keys are automatically provided during runtime and stored in memory rather than being stored on disk. There are 5 keys currenty supported: Alice, Bob, Charlie, Dave, and Eve.
Index ¶
- Constants
- Variables
- func DecodeKeypair(in []byte, keytype crypto.KeyType) (kp crypto.Keypair, err error)
- func Decrypt(data, password []byte) ([]byte, error)
- func DecryptKeypair(expectedPubK string, data, password []byte, keytype string) (crypto.Keypair, error)
- func Encrypt(msg, password []byte) ([]byte, error)
- func EncryptAndWriteToFile(file *os.File, kp crypto.Keypair, password []byte) error
- func EncryptKeypair(kp crypto.Keypair, password []byte) ([]byte, error)
- func GetPassword(msg string) []byte
- func KeypairFromAddress(chainType, path string, password []byte, insecure bool) (crypto.Keypair, error)
- func ReadFromFileAndDecrypt(filename string, password []byte, keytype string) (crypto.Keypair, error)
- type EncryptedKeystore
- type TestKeyRingHolder
Constants ¶
const AliceKey = "alice"
The Constant "keys". These are the name that the keys are based on. This can be expanded, but any additions must be added to Keys and to insecureKeyFromAddress
const BobKey = "bob"
const CharlieKey = "charlie"
const DaveKey = "dave"
const EnvPassword = "KEYSTORE_PASSWORD"
const EthChain = "ethereum"
The Chain type Constants
const EveKey = "eve"
const SubChain = "substrate"
Variables ¶
var Keys = []string{AliceKey, BobKey, CharlieKey, DaveKey, EveKey}
Functions ¶
func DecodeKeypair ¶
DecodeKeypair turns input bytes into a keypair based on the specified key type
func Decrypt ¶
Decrypt uses AES to decrypt ciphertext with the symmetric key deterministically created from `password`
func DecryptKeypair ¶
func DecryptKeypair(expectedPubK string, data, password []byte, keytype string) (crypto.Keypair, error)
DecryptPrivateKey uses AES to decrypt the ciphertext into a `crypto.PrivateKey` with a symmetric key deterministically created from `password`
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 EncryptKeypair ¶
EncryptKeypair uses AES to encrypt an encoded `crypto.Keypair` with a symmetric key deterministically created from `password`
func GetPassword ¶
prompt user to enter password for encrypted keystore
Types ¶
type EncryptedKeystore ¶
type TestKeyRingHolder ¶
type TestKeyRingHolder struct { EthereumKeys map[string]*secp256k1.Keypair SubstrateKeys map[string]*secp256k1.Keypair }
TestKeyStore is a struct that holds a Keystore of all the test keys
var TestKeyRing *TestKeyRingHolder