crypto

package
v0.0.0-...-6b2b62e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2022 License: GPL-3.0 Imports: 30 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecode

func AesDecode(data, key []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(data, key []byte) ([]byte, error)

func AgeDecryptIdentityWithPassword

func AgeDecryptIdentityWithPassword(in io.Reader, out io.Writer, password string) (*age.X25519Identity, error)

func AgeEncrypt

func AgeEncrypt(recipients []age.Recipient, in io.Reader, out io.Writer) error

func CreateAesKey

func CreateAesKey() ([]byte, error)

func Hash

func Hash(data []byte) []byte

func InitKeystore

func InitKeystore(KeyStoreName, KeyStoreDir string) (int, error)

func JoinKeyStorePath

func JoinKeyStorePath(keysDirPath, filename string) string

func LoadEncodeKeyFrom

func LoadEncodeKeyFrom(dir, keyname, filetype string) (string, error)

func PassphrasePromptForEncryption

func PassphrasePromptForEncryption() (string, error)

func PassphrasePromptForUnlock

func PassphrasePromptForUnlock() (string, error)

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

func (ks *DirKeyStore) Backup(groupSeeds []byte) (string, string, string, error)

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 (ks *DirKeyStore) GetPeerInfo(keyname string) (peerid peer.ID, ethaddr string, err error)

func (*DirKeyStore) IfKeyExist

func (ks *DirKeyStore) IfKeyExist(keyname string) (bool, error)

func (*DirKeyStore) Import

func (ks *DirKeyStore) Import(keyname string, encodedkey string, keytype KeyType, password string) (string, 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) NewKey

func (ks *DirKeyStore) NewKey(keyname string, keytype KeyType, password string) (string, 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) Sign

func (ks *DirKeyStore) Sign(data []byte, privKey p2pcrypto.PrivKey) ([]byte, error)

func (*DirKeyStore) SignByKeyName

func (ks *DirKeyStore) SignByKeyName(keyname string, data []byte, opts ...string) ([]byte, error)

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 (ks *DirKeyStore) VerifySign(data, sig []byte, pubKey p2pcrypto.PubKey) (bool, error)

func (*DirKeyStore) VerifySignByKeyName

func (ks *DirKeyStore) VerifySignByKeyName(keyname string, data []byte, sig []byte, opts ...string) (bool, error)

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 KeyType

type KeyType int
const (
	Encrypt KeyType = 0
	Sign    KeyType = 1
)

func (KeyType) NameString

func (kt KeyType) NameString(keyname string) string

func (KeyType) Prefix

func (kt KeyType) Prefix() string

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
}

func (*LazyScryptIdentity) Unwrap

func (i *LazyScryptIdentity) Unwrap(stanzas []*age.Stanza) (fileKey []byte, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL