Documentation ¶
Index ¶
- Constants
- Variables
- type Address
- type AddressScope
- type Backend
- type Cid
- type CryptoJSON
- type DSBackend
- func (backend *DSBackend) Addresses() []address.Address
- func (backend *DSBackend) GetKeyInfo(addr address.Address) (*crypto.KeyInfo, error)
- func (backend *DSBackend) GetKeyInfoPassphrase(addr address.Address, password []byte) (*crypto.KeyInfo, error)
- func (backend *DSBackend) HasAddress(addr address.Address) bool
- func (backend *DSBackend) HasPassword() bool
- func (backend *DSBackend) ImportKey(ki *crypto.KeyInfo) error
- func (backend *DSBackend) LockWallet() error
- func (backend *DSBackend) NewAddress(protocol address.Protocol) (address.Address, error)
- func (backend *DSBackend) SetPassword(password string) error
- func (backend *DSBackend) SignBytes(data []byte, addr address.Address) (*crypto.Signature, error)
- func (backend *DSBackend) UnLockWallet(password string) error
- func (backend *DSBackend) WalletState() int
- type Importer
- type KeccakState
- type Key
- type KeyInfo
- type KeyType
- type MethodNum
- type MsgMeta
- type MsgType
- type SigType
- type Signature
- type TokenAmount
- type Wallet
- func (w *Wallet) Addresses() []address.Address
- func (w *Wallet) Backends(typ reflect.Type) []Backend
- func (w *Wallet) DSBacked() (*DSBackend, error)
- func (w *Wallet) Export(addr address.Address, password string) (*crypto.KeyInfo, error)
- func (w *Wallet) Find(addr address.Address) (Backend, error)
- func (w *Wallet) GetPubKeyForAddress(addr address.Address) ([]byte, error)
- func (w *Wallet) HasAddress(a address.Address) bool
- func (w *Wallet) HasPassword() bool
- func (w *Wallet) Import(ki *crypto.KeyInfo) (address.Address, error)
- func (w *Wallet) LockWallet() error
- func (w *Wallet) NewAddress(p address.Protocol) (address.Address, error)
- func (w *Wallet) NewKeyInfo() (*crypto.KeyInfo, error)
- func (w *Wallet) SetPassword(password string) error
- func (w *Wallet) SignBytes(data []byte, addr address.Address) (*crypto.Signature, error)
- func (w *Wallet) UnLockWallet(password string) error
- func (w *Wallet) WalletSign(addr address.Address, msg []byte, meta MsgMeta) (*crypto.Signature, error)
- func (w *Wallet) WalletState() int
- type WalletIntersection
Constants ¶
const ( Lock Unlock )
const ( MTUnknown = MsgType("unknown") // Signing message CID. MsgMeta.Extra contains raw cbor message bytes MTChainMsg = MsgType("message") // Signing a blockheader. signing raw cbor block bytes (MsgMeta.Extra is empty) MTBlock = MsgType("block") // Signing a deal proposal. signing raw cbor proposal bytes (MsgMeta.Extra is empty) MTDealProposal = MsgType("dealproposal") // extra is nil, 'toSign' is cbor raw bytes of 'DrawRandomParams' // following types follow above rule MTDrawRandomParam = MsgType("drawrandomparam") MTSignedVoucher = MsgType("signedvoucher") MTStorageAsk = MsgType("storageask") MTAskResponse = MsgType("askresponse") MTNetWorkResponse = MsgType("networkresposne") // reference : storagemarket/impl/remotecli.go:330 // sign storagemarket.ClientDeal.ProposalCid, // MsgMeta.Extra is nil, 'toSign' is market.ClientDealProposal // storagemarket.ClientDeal.ProposalCid equals cborutil.AsIpld(market.ClientDealProposal).Cid() MTClientDeal = MsgType("clientdeal") MTProviderDealState = MsgType("providerdealstate") )
const ( SigTypeUnknown = SigType(math.MaxUint8) SigTypeSecp256k1 = SigType(iota) SigTypeBLS )
const StringEmpty = ""
const TestPassword = "test-password"
Variables ¶
var DSBackendType = reflect.TypeOf(&DSBackend{})
DSBackendType is the reflect type of the DSBackend.
var ErrDecrypt = errors.New("could not decrypt key with given password")
var ErrInvalidPassword = errors.New("password matching failed")
var ErrKeyInfoNotFound = fmt.Errorf("key info not found")
var ErrRepeatPassword = errors.New("set password more than once")
var (
NilAddress = Address{}
)
Functions ¶
This section is empty.
Types ¶
type AddressScope ¶ added in v0.9.7
type Backend ¶
type Backend interface { // Addresses returns a list of all accounts currently stored in this backend. Addresses() []address.Address // Contains returns true if this backend stores the passed in address. HasAddress(address.Address) bool // Sign cryptographically signs data with the private key associated with an address. SignBytes([]byte, address.Address) (*crypto.Signature, error) // GetKeyInfo will return the keyinfo associated with address `addr` // iff backend contains the addr. GetKeyInfo(address.Address) (*crypto.KeyInfo, error) GetKeyInfoPassphrase(address.Address, []byte) (*crypto.KeyInfo, error) LockWallet() error UnLockWallet(string) error WalletState() int }
Backend is the interface to represent different storage backends that can contain many addresses.
type CryptoJSON ¶ added in v0.9.1
type DSBackend ¶
type DSBackend struct { PassphraseConf config.PassphraseConfig // contains filtered or unexported fields }
DSBackend is a wallet backend implementation for storing addresses in a datastore.
func NewDSBackend ¶
func NewDSBackend(ds repo.Datastore, passphraseCfg config.PassphraseConfig, password string) (*DSBackend, error)
NewDSBackend constructs a new backend using the passed in datastore.
func (*DSBackend) Addresses ¶
func (backend *DSBackend) Addresses() []address.Address
Addresses returns a list of all addresses that are stored in this backend.
func (*DSBackend) GetKeyInfo ¶
GetKeyInfo will return the private & public keys associated with address `addr` iff backend contains the addr.
func (*DSBackend) GetKeyInfoPassphrase ¶ added in v0.9.1
func (*DSBackend) HasAddress ¶
HasAddress checks if the passed in address is stored in this backend. Safe for concurrent access.
func (*DSBackend) HasPassword ¶ added in v0.9.4
func (*DSBackend) LockWallet ¶ added in v0.9.7
func (*DSBackend) NewAddress ¶
NewAddress creates a new address and stores it. Safe for concurrent access.
func (*DSBackend) SetPassword ¶ added in v0.9.1
func (*DSBackend) SignBytes ¶
SignBytes cryptographically signs `data` using the private key `priv`.
func (*DSBackend) UnLockWallet ¶ added in v0.9.7
func (*DSBackend) WalletState ¶ added in v0.9.4
type Importer ¶
type Importer interface { // ImportKey imports the key described by the given keyinfo // into the backend ImportKey(*crypto.KeyInfo) error }
Importer is a specialization of a wallet backend that can import new keys into its permanent storage. Disk backed wallets can do this, hardware wallets generally cannot.
type KeccakState ¶ added in v0.9.1
KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.
type Key ¶ added in v0.9.1
type Key struct { ID uuid.UUID // Version 4 "random" for unique id not derived from key data // to simplify lookups we also store the address Address address.Address KeyInfo *crypto.KeyInfo }
func (*Key) MarshalJSON ¶ added in v0.9.1
func (*Key) UnmarshalJSON ¶ added in v0.9.1
type KeyType ¶ added in v0.9.7
type KeyType string
KeyType defines a type of a key
func SignType2Key ¶ added in v0.9.7
func (*KeyType) UnmarshalJSON ¶ added in v0.9.7
type SigType ¶ added in v0.9.7
func KeyType2Sign ¶ added in v0.9.7
type TokenAmount ¶ added in v0.9.7
type TokenAmount = abi.TokenAmount
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
wallet manages the locally stored addresses.
func (*Wallet) Addresses ¶
func (w *Wallet) Addresses() []address.Address
Addresses retrieves all stored addresses. Safe for concurrent access. Always sorted in the same order.
func (*Wallet) Find ¶
Find searches through all backends and returns the one storing the passed in address. Safe for concurrent access.
func (*Wallet) GetPubKeyForAddress ¶
GetPubKeyForAddress returns the public key in the keystore associated with the given address.
func (*Wallet) HasAddress ¶
HasAddress checks if the given address is stored. Safe for concurrent access.
func (*Wallet) HasPassword ¶ added in v0.9.4
func (*Wallet) LockWallet ¶ added in v0.9.7
func (*Wallet) NewAddress ¶ added in v0.9.1
NewAddress creates a new account address on the default wallet backend.
func (*Wallet) NewKeyInfo ¶
NewKeyInfo creates a new KeyInfo struct in the wallet backend and returns it
func (*Wallet) SetPassword ¶ added in v0.9.1
func (*Wallet) SignBytes ¶
SignBytes cryptographically signs `data` using the private key corresponding to address `addr`
func (*Wallet) UnLockWallet ¶ added in v0.9.7
func (*Wallet) WalletSign ¶
func (*Wallet) WalletState ¶ added in v0.9.4
type WalletIntersection ¶ added in v0.9.4
type WalletIntersection interface { HasAddress(a address.Address) bool Addresses() []address.Address NewAddress(p address.Protocol) (address.Address, error) Import(ki *crypto.KeyInfo) (address.Address, error) Export(addr address.Address, password string) (*crypto.KeyInfo, error) WalletSign(keyAddr address.Address, msg []byte, meta MsgMeta) (*crypto.Signature, error) HasPassword() bool }
WalletIntersection nolint