go-ethereum: github.com/axiomzen/go-ethereum/accounts/scwallet Index | Files

package scwallet

import "github.com/axiomzen/go-ethereum/accounts/scwallet"

Index

Package Files

apdu.go hub.go securechannel.go wallet.go

Constants

const (
    P1DeriveKeyFromMaster  = uint8(0x00)
    P1DeriveKeyFromParent  = uint8(0x01)
    P1DeriveKeyFromCurrent = uint8(0x10)
)

List of ADPU command parameters

const Scheme = "keycard"

Scheme is the URI prefix for smartcard wallets.

Variables

var (

    // DerivationSignatureHash is used to derive the public key from the signature of this hash
    DerivationSignatureHash = sha256.Sum256(common.Hash{}.Bytes())
)
var ErrAlreadyOpen = errors.New("smartcard: already open")

ErrAlreadyOpen is returned if the smart card is attempted to be opened, but there is already a paired and unlocked session.

var ErrPINNeeded = errors.New("smartcard: pin needed")

ErrPINNeeded is returned if opening the smart card requires a PIN code. In this case, the calling application should request user input to enter the PIN and send it back.

var ErrPINUnblockNeeded = errors.New("smartcard: pin unblock needed")

ErrPINUnblockNeeded is returned if opening the smart card requires a PIN code, but all PIN attempts have already been exhausted. In this case the calling application should request user input for the PUK and a new PIN code to set fo the card.

var ErrPairingPasswordNeeded = errors.New("smartcard: pairing password needed")

ErrPairingPasswordNeeded is returned if opening the smart card requires pairing with a pairing password. In this case, the calling application should request user input to enter the pairing password and send it back.

var ErrPubkeyMismatch = errors.New("smartcard: recovered public key mismatch")

ErrPubkeyMismatch is returned if the public key recovered from a signature does not match the one expected by the user.

type Hub Uses

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

Hub is a accounts.Backend that can find and handle generic PC/SC hardware wallets.

func NewHub Uses

func NewHub(daemonPath string, scheme string, datadir string) (*Hub, error)

NewHub creates a new hardware wallet manager for smartcards.

func (*Hub) Subscribe Uses

func (hub *Hub) Subscribe(sink chan<- accounts.WalletEvent) event.Subscription

Subscribe implements accounts.Backend, creating an async subscription to receive notifications on the addition or removal of smart card wallets.

func (*Hub) Wallets Uses

func (hub *Hub) Wallets() []accounts.Wallet

Wallets implements accounts.Backend, returning all the currently tracked smart cards that appear to be hardware wallets.

type SecureChannelSession Uses

type SecureChannelSession struct {
    PairingKey []byte // A permanent shared secret for a pairing, if present

    PairingIndex uint8 // The pairing index
    // contains filtered or unexported fields
}

SecureChannelSession enables secure communication with a hardware wallet.

func NewSecureChannelSession Uses

func NewSecureChannelSession(card *pcsc.Card, keyData []byte) (*SecureChannelSession, error)

NewSecureChannelSession creates a new secure channel for the given card and public key.

func (*SecureChannelSession) Open Uses

func (s *SecureChannelSession) Open() error

Open initializes the secure channel.

func (*SecureChannelSession) Pair Uses

func (s *SecureChannelSession) Pair(pairingPassword []byte) error

Pair establishes a new pairing with the smartcard.

func (*SecureChannelSession) Unpair Uses

func (s *SecureChannelSession) Unpair() error

Unpair disestablishes an existing pairing.

type Session Uses

type Session struct {
    Wallet  *Wallet               // A handle to the wallet that opened the session
    Channel *SecureChannelSession // A secure channel for encrypted messages
    // contains filtered or unexported fields
}

Session represents a secured communication session with the wallet.

type Wallet Uses

type Wallet struct {
    Hub       *Hub   // A handle to the Hub that instantiated this wallet.
    PublicKey []byte // The wallet's public key (used for communication and identification, not signing!)
    // contains filtered or unexported fields
}

Wallet represents a smartcard wallet instance.

func NewWallet Uses

func NewWallet(hub *Hub, card *pcsc.Card) *Wallet

NewWallet constructs and returns a new Wallet instance.

func (*Wallet) Accounts Uses

func (w *Wallet) Accounts() []accounts.Account

Accounts retrieves the list of signing accounts the wallet is currently aware of. For hierarchical deterministic wallets, the list will not be exhaustive, rather only contain the accounts explicitly pinned during account derivation.

func (*Wallet) Close Uses

func (w *Wallet) Close() error

Close stops and closes the wallet, freeing any resources.

func (*Wallet) Contains Uses

func (w *Wallet) Contains(account accounts.Account) bool

Contains returns whether an account is part of this particular wallet or not.

func (*Wallet) Derive Uses

func (w *Wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Account, error)

Derive attempts to explicitly derive a hierarchical deterministic account at the specified derivation path. If requested, the derived account will be added to the wallet's tracked account list.

func (*Wallet) Initialize Uses

func (w *Wallet) Initialize(seed []byte) error

Initialize installs a keypair generated from the provided key into the wallet.

func (*Wallet) Open Uses

func (w *Wallet) Open(passphrase string) error

Open initializes access to a wallet instance. It is not meant to unlock or decrypt account keys, rather simply to establish a connection to hardware wallets and/or to access derivation seeds.

The passphrase parameter may or may not be used by the implementation of a particular wallet instance. The reason there is no passwordless open method is to strive towards a uniform wallet handling, oblivious to the different backend providers.

Please note, if you open a wallet, you must close it to release any allocated resources (especially important when working with hardware wallets).

func (*Wallet) SelfDerive Uses

func (w *Wallet) SelfDerive(bases []accounts.DerivationPath, chain ethereum.ChainStateReader)

SelfDerive sets a base account derivation path from which the wallet attempts to discover non zero accounts and automatically add them to list of tracked accounts.

Note, self derivaton will increment the last component of the specified path opposed to decending into a child path to allow discovering accounts starting from non zero components.

Some hardware wallets switched derivation paths through their evolution, so this method supports providing multiple bases to discover old user accounts too. Only the last base will be used to derive the next empty account.

You can disable automatic account discovery by calling SelfDerive with a nil chain state reader.

func (*Wallet) SignData Uses

func (w *Wallet) SignData(account accounts.Account, mimeType string, data []byte) ([]byte, error)

SignData requests the wallet to sign the hash of the given data.

It looks up the account specified either solely via its address contained within, or optionally with the aid of any location metadata from the embedded URL field.

If the wallet requires additional authentication to sign the request (e.g. a password to decrypt the account, or a PIN code o verify the transaction), an AuthNeededError instance will be returned, containing infos for the user about which fields or actions are needed. The user may retry by providing the needed details via SignDataWithPassphrase, or by other means (e.g. unlock the account in a keystore).

func (*Wallet) SignDataWithPassphrase Uses

func (w *Wallet) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error)

SignDataWithPassphrase requests the wallet to sign the given hash with the given passphrase as extra authentication information.

It looks up the account specified either solely via its address contained within, or optionally with the aid of any location metadata from the embedded URL field.

func (*Wallet) SignText Uses

func (w *Wallet) SignText(account accounts.Account, text []byte) ([]byte, error)

SignText requests the wallet to sign the hash of a given piece of data, prefixed by the Ethereum prefix scheme It looks up the account specified either solely via its address contained within, or optionally with the aid of any location metadata from the embedded URL field.

If the wallet requires additional authentication to sign the request (e.g. a password to decrypt the account, or a PIN code o verify the transaction), an AuthNeededError instance will be returned, containing infos for the user about which fields or actions are needed. The user may retry by providing the needed details via SignHashWithPassphrase, or by other means (e.g. unlock the account in a keystore).

func (*Wallet) SignTextWithPassphrase Uses

func (w *Wallet) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error)

SignTextWithPassphrase implements accounts.Wallet, attempting to sign the given hash with the given account using passphrase as extra authentication

func (*Wallet) SignTx Uses

func (w *Wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

SignTx requests the wallet to sign the given transaction.

It looks up the account specified either solely via its address contained within, or optionally with the aid of any location metadata from the embedded URL field.

If the wallet requires additional authentication to sign the request (e.g. a password to decrypt the account, or a PIN code o verify the transaction), an AuthNeededError instance will be returned, containing infos for the user about which fields or actions are needed. The user may retry by providing the needed details via SignTxWithPassphrase, or by other means (e.g. unlock the account in a keystore).

func (*Wallet) SignTxWithPassphrase Uses

func (w *Wallet) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

SignTxWithPassphrase requests the wallet to sign the given transaction, with the given passphrase as extra authentication information.

It looks up the account specified either solely via its address contained within, or optionally with the aid of any location metadata from the embedded URL field.

func (*Wallet) Status Uses

func (w *Wallet) Status() (string, error)

Status returns a textual status to aid the user in the current state of the wallet. It also returns an error indicating any failure the wallet might have encountered.

func (*Wallet) URL Uses

func (w *Wallet) URL() accounts.URL

URL retrieves the canonical path under which this wallet is reachable. It is user by upper layers to define a sorting order over all wallets from multiple backends.

func (*Wallet) Unpair Uses

func (w *Wallet) Unpair(pin []byte) error

Unpair deletes an existing wallet pairing.

Package scwallet imports 34 packages (graph). Updated 2019-07-06. Refresh now. Tools for package owners.