Documentation ¶
Index ¶
- Constants
- Variables
- func IsVersionSupported(v uint32) bool
- func NewMnemonic() (string, error)
- type Algorithm
- type HDKeyPair
- func (k *HDKeyPair) AlgorithmName() string
- func (k *HDKeyPair) AlgorithmVersion() uint32
- func (k *HDKeyPair) DeepCopy() *HDKeyPair
- func (k *HDKeyPair) Index() uint32
- func (k *HDKeyPair) IsTainted() bool
- func (k *HDKeyPair) MarshalJSON() ([]byte, error)
- func (k *HDKeyPair) Meta() []Meta
- func (k *HDKeyPair) PrivateKey() string
- func (k *HDKeyPair) PublicKey() string
- func (k *HDKeyPair) Sign(data []byte) (*Signature, error)
- func (k *HDKeyPair) SignAny(data []byte) ([]byte, error)
- func (k *HDKeyPair) Taint() error
- func (k *HDKeyPair) ToPublicKey() HDPublicKey
- func (k *HDKeyPair) UnmarshalJSON(data []byte) error
- func (k *HDKeyPair) Untaint() error
- func (k *HDKeyPair) VerifyAny(data, sig []byte) (bool, error)
- type HDKeyRing
- type HDPublicKey
- func (k *HDPublicKey) AlgorithmName() string
- func (k *HDPublicKey) AlgorithmVersion() uint32
- func (k *HDPublicKey) Index() uint32
- func (k *HDPublicKey) IsTainted() bool
- func (k *HDPublicKey) Key() string
- func (k *HDPublicKey) MarshalJSON() ([]byte, error)
- func (k *HDPublicKey) Meta() []Meta
- func (k *HDPublicKey) UnmarshalJSON(data []byte) error
- type HDWallet
- func (w *HDWallet) DescribePublicKey(pubKey string) (PublicKey, error)
- func (w *HDWallet) GenerateKeyPair(meta []Meta) (KeyPair, error)
- func (w *HDWallet) ID() string
- func (w *HDWallet) IsIsolated() bool
- func (w *HDWallet) IsolateWithKey(pubKey string) (Wallet, error)
- func (w *HDWallet) ListKeyPairs() []KeyPair
- func (w *HDWallet) ListPublicKeys() []PublicKey
- func (w *HDWallet) MarshalJSON() ([]byte, error)
- func (w *HDWallet) Name() string
- func (w *HDWallet) SetName(newName string)
- func (w *HDWallet) SignAny(pubKey string, data []byte) ([]byte, error)
- func (w *HDWallet) SignTx(pubKey string, data []byte) (*Signature, error)
- func (w *HDWallet) TaintKey(pubKey string) error
- func (w *HDWallet) Type() string
- func (w *HDWallet) UnmarshalJSON(data []byte) error
- func (w *HDWallet) UntaintKey(pubKey string) error
- func (w *HDWallet) UpdateMeta(pubKey string, meta []Meta) error
- func (w *HDWallet) VerifyAny(pubKey string, data, sig []byte) (bool, error)
- func (w *HDWallet) Version() uint32
- type Info
- type KeyPair
- type Meta
- type PublicKey
- type Signature
- type UnsupportedWalletVersionError
- type Wallet
Constants ¶
const ( // MaxEntropyByteSize is the entropy bytes size used for mnemonic // generation. MaxEntropyByteSize = 256 // MagicIndex is the registered HD wallet index for Vega's wallets. MagicIndex = 1789 // OriginIndex is a constant index used to derive a node from the master // node. The resulting node will be used to generate the cryptographic keys. OriginIndex = slip10.FirstHardenedIndex + MagicIndex )
const ( Version1 = uint32(1) // Version2 identifies HD wallet v2. Version2 = uint32(2) // LatestVersion is the latest version of Vega's HD wallet. Created wallets // are always pointing to the latest version. LatestVersion = Version2 )
Variables ¶
var ( ErrIsolatedWalletCantGenerateKeyPairs = errors.New("isolated wallet can't generate key pairs") ErrInvalidMnemonic = errors.New("mnemonic is not valid") ErrPubKeyAlreadyTainted = errors.New("public key is already tainted") ErrPubKeyIsTainted = errors.New("public key is tainted") ErrPubKeyNotTainted = errors.New("public key is not tainted") ErrPubKeyDoesNotExist = errors.New("public key does not exist") ErrWalletAlreadyExists = errors.New("a wallet with the same name already exists") ErrWalletNotLoggedIn = errors.New("wallet is not logged in") )
var SupportedVersions = []uint32{Version1, Version2}
SupportedVersions list versions supported by Vega's HD wallet.
Functions ¶
func IsVersionSupported ¶ added in v0.9.2
func NewMnemonic ¶
NewMnemonic generates a mnemonic with an entropy of 256 bits.
Types ¶
type HDKeyPair ¶
type HDKeyPair struct {
// contains filtered or unexported fields
}
func NewHDKeyPair ¶
func (*HDKeyPair) AlgorithmName ¶
func (*HDKeyPair) AlgorithmVersion ¶
func (*HDKeyPair) MarshalJSON ¶
func (*HDKeyPair) PrivateKey ¶
func (*HDKeyPair) ToPublicKey ¶
func (k *HDKeyPair) ToPublicKey() HDPublicKey
ToPublicKey ensures the sensitive information doesn't leak outside.
func (*HDKeyPair) UnmarshalJSON ¶
type HDKeyRing ¶
type HDKeyRing struct {
// contains filtered or unexported fields
}
func LoadHDKeyRing ¶
func NewHDKeyRing ¶
func NewHDKeyRing() *HDKeyRing
func (*HDKeyRing) ListKeyPairs ¶
ListKeyPairs returns the list of key pairs sorted by key index.
func (*HDKeyRing) ListPublicKeys ¶
func (r *HDKeyRing) ListPublicKeys() []HDPublicKey
ListPublicKeys returns the list of public keys sorted by key index.
type HDPublicKey ¶
type HDPublicKey struct { Idx uint32 `json:"index"` PublicKey string `json:"pub"` Algorithm Algorithm `json:"algorithm"` Tainted bool `json:"tainted"` MetaList []Meta `json:"meta"` }
func (*HDPublicKey) AlgorithmName ¶
func (k *HDPublicKey) AlgorithmName() string
func (*HDPublicKey) AlgorithmVersion ¶
func (k *HDPublicKey) AlgorithmVersion() uint32
func (*HDPublicKey) Index ¶
func (k *HDPublicKey) Index() uint32
func (*HDPublicKey) IsTainted ¶
func (k *HDPublicKey) IsTainted() bool
func (*HDPublicKey) Key ¶
func (k *HDPublicKey) Key() string
func (*HDPublicKey) MarshalJSON ¶
func (k *HDPublicKey) MarshalJSON() ([]byte, error)
func (*HDPublicKey) Meta ¶
func (k *HDPublicKey) Meta() []Meta
func (*HDPublicKey) UnmarshalJSON ¶
func (k *HDPublicKey) UnmarshalJSON(data []byte) error
type HDWallet ¶
type HDWallet struct {
// contains filtered or unexported fields
}
func ImportHDWallet ¶
ImportHDWallet creates a wallet based on the mnemonic in input. This is useful import or retrieve a wallet.
func NewHDWallet ¶
NewHDWallet creates a wallet with auto-generated mnemonic. This is useful to create a brand-new wallet, without having to take care of the mnemonic generation. The generated mnemonic is returned alongside the created wallet.
func (*HDWallet) DescribePublicKey ¶
DescribePublicKey returns all the information associated to a public key, except the private key.
func (*HDWallet) GenerateKeyPair ¶
GenerateKeyPair generates a new key pair from a node, that is derived from the wallet node.
func (*HDWallet) IsIsolated ¶
func (*HDWallet) ListKeyPairs ¶
ListKeyPairs lists the key pairs. Be careful, it contains the private key.
func (*HDWallet) ListPublicKeys ¶
ListPublicKeys lists the public keys with their information. The private keys are not returned.
func (*HDWallet) MarshalJSON ¶
func (*HDWallet) UnmarshalJSON ¶
func (*HDWallet) UntaintKey ¶
UntaintKey remove the taint on a key.
func (*HDWallet) UpdateMeta ¶
UpdateMeta replaces the key's metadata by the new ones.
type UnsupportedWalletVersionError ¶ added in v0.9.2
type UnsupportedWalletVersionError struct {
UnsupportedVersion uint32
}
func NewUnsupportedWalletVersionError ¶ added in v0.9.2
func NewUnsupportedWalletVersionError(v uint32) UnsupportedWalletVersionError
func (UnsupportedWalletVersionError) Error ¶ added in v0.9.2
func (e UnsupportedWalletVersionError) Error() string
type Wallet ¶
type Wallet interface { Version() uint32 Name() string SetName(newName string) ID() string Type() string DescribePublicKey(pubKey string) (PublicKey, error) ListPublicKeys() []PublicKey ListKeyPairs() []KeyPair GenerateKeyPair(meta []Meta) (KeyPair, error) TaintKey(pubKey string) error UntaintKey(pubKey string) error UpdateMeta(pubKey string, meta []Meta) error SignAny(pubKey string, data []byte) ([]byte, error) VerifyAny(pubKey string, data, sig []byte) (bool, error) SignTx(pubKey string, data []byte) (*Signature, error) IsolateWithKey(pubKey string) (Wallet, error) }