entropystore

package
v2.10.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: GPL-3.0 Imports: 20 Imported by: 8

Documentation

Index

Constants

View Source
const (
	// StandardScryptN is the N parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on chain modern processor.
	StandardScryptN = 1 << 18

	// StandardScryptP is the P parameter of Scrypt encryption algorithm, using 256MB
	// memory and taking approximately 1s CPU time on chain modern processor.
	StandardScryptP = 1
)
View Source
const (
	Locked   = "Locked"
	UnLocked = "Unlocked"

	DefaultMaxIndex = uint32(100)
)

Variables

This section is empty.

Functions

func DecryptEntropy

func DecryptEntropy(entropyJson []byte, passphrase string) ([]byte, error)

func EncryptEntropy

func EncryptEntropy(seed []byte, addr types.Address, passphrase string) ([]byte, error)

func FindAddrFromSeed

func FindAddrFromSeed(seed []byte, addr types.Address, maxSearchIndex uint32) (key *derivation.Key, index uint32, e error)

it is very fast(in my mac 2.8GHZ intel cpu 10Ks search cost 728ms) so we dont need cache the relation

func FullKeyFileName

func FullKeyFileName(keysDirPath string, keyAddr types.Address) string

func IsMayValidEntropystoreFile

func IsMayValidEntropystoreFile(path string) (bool, *types.Address, error)

it it return false it must not be chain valid seedstore file if it return chain true it only means that might be true

func MnemonicToPrimaryAddr

func MnemonicToPrimaryAddr(mnemonic string) (primaryAddress *types.Address, e error)

func NewMnemonic

func NewMnemonic() (mnemonic string, err error)

Types

type CryptoStore

type CryptoStore struct {
	EntropyStoreFilename string
}

func (CryptoStore) ExtractEntropy

func (ks CryptoStore) ExtractEntropy(passphrase string) ([]byte, error)

func (CryptoStore) ExtractSeed

func (ks CryptoStore) ExtractSeed(passphrase string) (seed, entropy []byte, err error)

func (CryptoStore) StoreEntropy

func (ks CryptoStore) StoreEntropy(entropy []byte, primaryAddr types.Address, passphrase string) error

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(entropyStoreFilename string, primaryAddr types.Address, maxSearchIndex uint32) *Manager

func StoreNewEntropy

func StoreNewEntropy(storeDir string, mnemonic string, pwd string, maxSearchIndex uint32) (*Manager, error)

func (*Manager) DeriveForFullPath

func (km *Manager) DeriveForFullPath(path string) (fpath string, key *derivation.Key, err error)

func (*Manager) DeriveForFullPathWithPassphrase

func (km *Manager) DeriveForFullPathWithPassphrase(path, passphrase string) (fpath string, key *derivation.Key, err error)

func (*Manager) DeriveForIndexPath

func (km *Manager) DeriveForIndexPath(index uint32) (path string, key *derivation.Key, err error)

func (*Manager) DeriveForIndexPathWithPassphrase

func (km *Manager) DeriveForIndexPathWithPassphrase(index uint32, passphrase string) (path string, key *derivation.Key, err error)

func (Manager) ExtractMnemonic

func (km Manager) ExtractMnemonic(passphrase string) (string, error)

func (*Manager) FindAddr

func (km *Manager) FindAddr(addr types.Address) (key *derivation.Key, index uint32, e error)

func (*Manager) FindAddrWithPassphrase

func (km *Manager) FindAddrWithPassphrase(passphrase string, addr types.Address) (key *derivation.Key, index uint32, e error)

func (Manager) GetEntropyStoreFile

func (km Manager) GetEntropyStoreFile() string

func (Manager) GetPrimaryAddr

func (km Manager) GetPrimaryAddr() (primaryAddr types.Address)

func (*Manager) GetPrivateKey

func (km *Manager) GetPrivateKey(a types.Address) (ed25519.PrivateKey, error)

func (*Manager) IsAddrUnlocked

func (km *Manager) IsAddrUnlocked(addr types.Address) bool

func (*Manager) IsUnlocked

func (km *Manager) IsUnlocked() bool

func (*Manager) ListAddress

func (km *Manager) ListAddress(from, to uint32) ([]types.Address, error)

func (*Manager) Lock

func (km *Manager) Lock()

func (*Manager) RemoveUnlockChangeChannel

func (km *Manager) RemoveUnlockChangeChannel()

func (*Manager) SetLockEventListener

func (km *Manager) SetLockEventListener(lis func(event UnlockEvent))

func (*Manager) SignData

func (km *Manager) SignData(a types.Address, data []byte) (signedData, pubkey []byte, err error)

func (*Manager) SignDataWithPassphrase

func (km *Manager) SignDataWithPassphrase(addr types.Address, passphrase string, data []byte) (signedData, pubkey []byte, err error)

func (*Manager) Unlock

func (km *Manager) Unlock(passphrase string) error

type UnlockEvent

type UnlockEvent struct {
	EntropyStoreFile string
	PrimaryAddr      types.Address // represent which seed we use the seed`s PrimaryAddress represents the seed
	// contains filtered or unexported fields
}

func (UnlockEvent) String

func (ue UnlockEvent) String() string

func (UnlockEvent) Unlocked

func (ue UnlockEvent) Unlocked() bool

Jump to

Keyboard shortcuts

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