Documentation
¶
Overview ¶
Package crypto provides crypto for chestnut.
Package crypto provides the crypto utils to the program.
Package crypto provides the crypto utils to the program.
Package crypto provides the crypto utils to the program.
Package crypto provides the crypto utils to the program.
Package crypto provides the crypto utils to the program.
Package crypto provides the crypto utils to the program.
Package crypto provides crypto for chestnut.
Index ¶
- func AesDecode(data, key []byte) ([]byte, error)
- func AesEncrypt(data, key []byte) ([]byte, error)
- func AgeDecryptIdentityWithPassword(in io.Reader, out io.Writer, password string) (*age.X25519Identity, error)
- func AgeEncrypt(recipients []age.Recipient, in io.Reader, out io.Writer) error
- func CreateAesKey() ([]byte, error)
- func Hash(data []byte) []byte
- func InitKeystore(KeyStoreName, KeyStoreDir string) (int, error)
- func JoinKeyStorePath(keysDirPath, filename string) string
- func LoadEncodeKeyFrom(dir, keyname, filetype string) (string, error)
- func PassphrasePromptForEncryption() (string, error)
- func PassphrasePromptForUnlock() (string, error)
- type DirKeyStore
- func (ks *DirKeyStore) Backup(groupSeeds []byte) (string, string, string, error)
- func (ks *DirKeyStore) Decrypt(keyname string, data []byte) ([]byte, error)
- func (ks *DirKeyStore) EncryptTo(to []string, data []byte) ([]byte, error)
- func (ks *DirKeyStore) GetEncodedPubkey(keyname string, keytype KeyType) (string, error)
- func (ks *DirKeyStore) GetKeyFromUnlocked(keyname string) (interface{}, error)
- func (ks *DirKeyStore) GetPeerInfo(keyname string) (peerid peer.ID, ethaddr string, err error)
- func (ks *DirKeyStore) IfKeyExist(keyname string) (bool, error)
- func (ks *DirKeyStore) Import(keyname string, encodedkey string, keytype KeyType, password string) (string, error)
- func (ks *DirKeyStore) ImportEcdsaPrivKey(keyname string, privkey *ecdsa.PrivateKey, password string) (string, error)
- func (ks *DirKeyStore) LoadEncryptKey(filename, password string) (*age.X25519Identity, error)
- func (ks *DirKeyStore) LoadSignKey(filename string, addr common.Address, password string) (*ethkeystore.Key, error)
- func (ks *DirKeyStore) Lock() error
- func (ks *DirKeyStore) NewKey(keyname string, keytype KeyType, password string) (string, error)
- func (ks *DirKeyStore) NewKeyWithDefaultPassword(keyname string, keytype KeyType) (string, error)
- func (ks *DirKeyStore) Restore(groupSeedStr string, keystoreStr string, configStr string, path string, ...) error
- func (ks *DirKeyStore) Sign(data []byte, privKey p2pcrypto.PrivKey) ([]byte, error)
- func (ks *DirKeyStore) SignByKeyName(keyname string, data []byte, opts ...string) ([]byte, error)
- func (ks *DirKeyStore) StoreEncryptKey(filename string, key *age.X25519Identity, password string) error
- func (ks *DirKeyStore) StoreSignKey(filename string, key *ethkeystore.Key, password string) error
- func (ks *DirKeyStore) Unlock(signkeymap map[string]string, password string) error
- func (ks *DirKeyStore) UnlockedKeyCount(keytype KeyType) int
- func (ks *DirKeyStore) VerifySign(data, sig []byte, pubKey p2pcrypto.PubKey) (bool, error)
- func (ks *DirKeyStore) VerifySignByKeyName(keyname string, data []byte, sig []byte, opts ...string) (bool, error)
- type Key
- type KeyType
- type Keystore
- type LazyScryptIdentity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AesEncrypt ¶
func CreateAesKey ¶
func InitKeystore ¶
func JoinKeyStorePath ¶
func LoadEncodeKeyFrom ¶
Types ¶
type DirKeyStore ¶
type DirKeyStore struct { Name string KeystorePath string // contains filtered or unexported fields }
func InitDirKeyStore ¶
func InitDirKeyStore(name, keydir string) (*DirKeyStore, int, error)
InitDirKeyStore creates a new keystore at the given directory.
func (*DirKeyStore) Backup ¶
Backup the group seeds, key store and config directory, and return base64Encode(ageEncrypt(zip(keystore_dir))), base64Encode(ageEncrypt(zip(config_dir))) and error
func (*DirKeyStore) Decrypt ¶
func (ks *DirKeyStore) Decrypt(keyname string, data []byte) ([]byte, error)
func (*DirKeyStore) EncryptTo ¶
func (ks *DirKeyStore) EncryptTo(to []string, data []byte) ([]byte, error)
func (*DirKeyStore) GetEncodedPubkey ¶
func (ks *DirKeyStore) GetEncodedPubkey(keyname string, keytype KeyType) (string, error)
func (*DirKeyStore) GetKeyFromUnlocked ¶
func (ks *DirKeyStore) GetKeyFromUnlocked(keyname string) (interface{}, error)
func (*DirKeyStore) GetPeerInfo ¶
func (*DirKeyStore) IfKeyExist ¶
func (ks *DirKeyStore) IfKeyExist(keyname string) (bool, error)
func (*DirKeyStore) ImportEcdsaPrivKey ¶
func (ks *DirKeyStore) ImportEcdsaPrivKey(keyname string, privkey *ecdsa.PrivateKey, password string) (string, error)
func (*DirKeyStore) LoadEncryptKey ¶
func (ks *DirKeyStore) LoadEncryptKey(filename, password string) (*age.X25519Identity, error)
func (*DirKeyStore) LoadSignKey ¶
func (ks *DirKeyStore) LoadSignKey(filename string, addr common.Address, password string) (*ethkeystore.Key, error)
func (*DirKeyStore) Lock ¶
func (ks *DirKeyStore) Lock() error
func (*DirKeyStore) NewKeyWithDefaultPassword ¶
func (ks *DirKeyStore) NewKeyWithDefaultPassword(keyname string, keytype KeyType) (string, error)
func (*DirKeyStore) Restore ¶
func (ks *DirKeyStore) Restore(groupSeedStr string, keystoreStr string, configStr string, path string, password string) error
Restore restores the keystore and config from backup data
func (*DirKeyStore) SignByKeyName ¶
func (*DirKeyStore) StoreEncryptKey ¶
func (ks *DirKeyStore) StoreEncryptKey(filename string, key *age.X25519Identity, password string) error
func (*DirKeyStore) StoreSignKey ¶
func (ks *DirKeyStore) StoreSignKey(filename string, key *ethkeystore.Key, password string) error
func (*DirKeyStore) Unlock ¶
func (ks *DirKeyStore) Unlock(signkeymap map[string]string, password string) error
func (*DirKeyStore) UnlockedKeyCount ¶
func (ks *DirKeyStore) UnlockedKeyCount(keytype KeyType) int
func (*DirKeyStore) VerifySign ¶
func (*DirKeyStore) VerifySignByKeyName ¶
type Key ¶
type Key struct { PrivKey p2pcrypto.PrivKey PubKey p2pcrypto.PubKey EthAddr string // contains filtered or unexported fields }
func SignKeytoPeerKeys ¶
func SignKeytoPeerKeys(key *ethkeystore.Key) (*Key, error)
type Keystore ¶
type Keystore interface { Unlock(signkeymap map[string]string, password string) error Lock() error NewKey(keyname string, keytype KeyType, password string) (string, error) NewKeyWithDefaultPassword(keyname string, keytype KeyType) (string, error) Import(keyname string, encodedkey string, keytype KeyType, password string) (string, error) Sign(data []byte, privKey p2pcrypto.PrivKey) ([]byte, error) VerifySign(data, signature []byte, pubKey p2pcrypto.PubKey) (bool, error) SignByKeyName(keyname string, data []byte, opts ...string) ([]byte, error) VerifySignByKeyName(keyname string, data []byte, sig []byte, opts ...string) (bool, error) EncryptTo(to []string, data []byte) ([]byte, error) Decrypt(keyname string, data []byte) ([]byte, error) GetEncodedPubkey(keyname string, keytype KeyType) (string, error) GetPeerInfo(keyname string) (peerid peer.ID, ethaddr string, err error) }
func GetKeystore ¶
func GetKeystore() Keystore
type LazyScryptIdentity ¶
type LazyScryptIdentity struct {
Password string
}