Documentation ¶
Index ¶
- Constants
- Variables
- func AccessModeToString(m AccessMode) string
- func IsKeyDerivationVersionSupported(v uint32) bool
- func NewRecoveryPhrase() (string, error)
- type AccessMode
- type Algorithm
- type Event
- func NewLockedWalletUpdateEvent(walletName string) Event
- func NewUnlockedWalletUpdatedEvent(w Wallet) Event
- func NewWalletCreatedEvent(walletName string) Event
- func NewWalletHasBeenLockedEvent(name string) Event
- func NewWalletRemovedEvent(walletName string) Event
- func NewWalletRenamedEvent(previousWalletName, newWalletName string) Event
- type EventData
- type EventType
- 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) Metadata() []Metadata
- func (k *HDKeyPair) Name() string
- 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) UpdateMetadata(meta []Metadata) []Metadata
- func (k *HDKeyPair) VerifyAny(data, sig []byte) (bool, error)
- type HDKeyRing
- type HDMasterKeyPair
- func (k *HDMasterKeyPair) AlgorithmName() string
- func (k *HDMasterKeyPair) AlgorithmVersion() uint32
- func (k *HDMasterKeyPair) PrivateKey() string
- func (k *HDMasterKeyPair) PublicKey() string
- func (k *HDMasterKeyPair) Sign(data []byte) (*Signature, error)
- func (k *HDMasterKeyPair) SignAny(data []byte) ([]byte, error)
- type HDPublicKey
- func (k *HDPublicKey) AlgorithmName() string
- func (k *HDPublicKey) AlgorithmVersion() uint32
- func (k *HDPublicKey) Hash() (string, error)
- func (k *HDPublicKey) Index() uint32
- func (k *HDPublicKey) IsTainted() bool
- func (k *HDPublicKey) Key() string
- func (k *HDPublicKey) MarshalJSON() ([]byte, error)
- func (k *HDPublicKey) Metadata() []Metadata
- func (k *HDPublicKey) Name() string
- func (k *HDPublicKey) UnmarshalJSON(data []byte) error
- type HDWallet
- func (w *HDWallet) AnnotateKey(pubKey string, meta []Metadata) ([]Metadata, error)
- func (w *HDWallet) Clone() Wallet
- func (w *HDWallet) DescribeKeyPair(pubKey string) (KeyPair, error)
- func (w *HDWallet) DescribePublicKey(pubKey string) (PublicKey, error)
- func (w *HDWallet) GenerateKeyPair(meta []Metadata) (KeyPair, error)
- func (w *HDWallet) HasPublicKey(pubKey string) bool
- func (w *HDWallet) ID() string
- func (w *HDWallet) IsIsolated() bool
- func (w *HDWallet) IsolateWithKey(pubKey string) (Wallet, error)
- func (w *HDWallet) KeyDerivationVersion() uint32
- func (w *HDWallet) ListKeyPairs() []KeyPair
- func (w *HDWallet) ListPublicKeys() []PublicKey
- func (w *HDWallet) MarshalJSON() ([]byte, error)
- func (w *HDWallet) MasterKey() (MasterKeyPair, error)
- func (w *HDWallet) Name() string
- func (w *HDWallet) Permissions(hostname string) Permissions
- func (w *HDWallet) PermittedHostnames() []string
- func (w *HDWallet) PurgePermissions()
- func (w *HDWallet) RevokePermissions(hostname 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) UpdatePermissions(hostname string, perms Permissions) error
- func (w *HDWallet) VerifyAny(pubKey string, data, sig []byte) (bool, error)
- type Info
- type KeyPair
- type LockedWalletUpdatedEventData
- type MasterKeyPair
- type Metadata
- type Permissions
- type PermissionsSummary
- type PublicKey
- type PublicKeysPermission
- type Signature
- type UnlockedWalletUpdatedEventData
- type UnsupportedWalletVersionError
- type Wallet
- type WalletCreatedEventData
- type WalletHasBeenLockedEventData
- type WalletRemovedEventData
- type WalletRenamedEventData
Constants ¶
const ( // WalletCreatedEventType is raised when a wallet has been created. WalletCreatedEventType EventType = "WALLET_CREATED" // UnlockedWalletUpdatedEventType is raised when a wallet, that is already // unlocked, has been updated. UnlockedWalletUpdatedEventType = "UNLOCKED_WALLET_UPDATED" // LockedWalletUpdatedEventType is raised when a wallet that has not been // unlocked, has been updated. LockedWalletUpdatedEventType = "LOCKED_WALLET_UPDATED" // WalletRemovedEventType is raised when a wallet has been removed. WalletRemovedEventType = "WALLET_REMOVED" // WalletRenamedEventType is raised when a wallet has been renamed. WalletRenamedEventType = "WALLET_RENAMED" // WalletHasBeenLockedEventType is raised when the wallet has been locked, // either by an external passphrase update, or a timeout. WalletHasBeenLockedEventType = "WALLET_HAS_BEEN_LOCKED" )
const ( // MaxEntropyByteSize is the entropy bytes size used for recovery phrase // 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 identifies HD wallet with a key derivation version 1. Version1 = uint32(1) // Version2 identifies HD wallet with a key derivation version 2. Version2 = uint32(2) // LatestVersion is the latest version of Vega's HD wallet. Created wallets // are always pointing to the latest version. LatestVersion = Version2 )
const KeyNameMeta = "name"
Variables ¶
var ( ErrAllKeysInWalletAreTainted = errors.New("all the keys in this wallet are tainted") ErrInvalidRecoveryPhrase = errors.New("the recovery phrase is not valid") ErrIsolatedWalletCantGenerateKeys = errors.New("an isolated wallet can't generate keys") ErrIsolatedWalletDoesNotHaveMasterKey = errors.New("an isolated wallet doesn't have a master key") ErrPubKeyAlreadyTainted = errors.New("the public key is already tainted") ErrPubKeyDoesNotExist = errors.New("the public key does not exist") ErrPubKeyIsTainted = errors.New("the public key is tainted") ErrPubKeyNotTainted = errors.New("the public key is not tainted") ErrWalletAlreadyExists = errors.New("a wallet with the same name already exists") ErrWalletDoesNotExist = errors.New("the wallet does not exist") ErrWalletDoesNotHaveKeys = errors.New("the wallet does not have keys") ErrWalletNotLoggedIn = errors.New("the wallet is not logged in") ErrWrongPassphrase = errors.New("wrong passphrase") )
var ErrCannotSetAllowedKeysWithNoAccess = errors.New("can't set allowed keys with \"none\" access")
var PublicKeysPermissionLabel = "public_keys"
var SupportedKeyDerivationVersions = []uint32{Version1, Version2}
SupportedKeyDerivationVersions list of key derivation versions supported by Vega's HD wallet.
Functions ¶
func AccessModeToString ¶
func AccessModeToString(m AccessMode) string
func IsKeyDerivationVersionSupported ¶ added in v0.65.0
func NewRecoveryPhrase ¶
NewRecoveryPhrase generates a recovery phrase with an entropy of 256 bits.
Types ¶
type AccessMode ¶
type AccessMode string
var ( NoAccess AccessMode = "none" ReadAccess AccessMode = "read" )
func ToAccessMode ¶
func ToAccessMode(mode string) (AccessMode, error)
type Event ¶ added in v0.68.0
func NewLockedWalletUpdateEvent ¶ added in v0.68.0
func NewUnlockedWalletUpdatedEvent ¶ added in v0.68.0
func NewWalletCreatedEvent ¶ added in v0.68.0
func NewWalletHasBeenLockedEvent ¶ added in v0.68.0
func NewWalletRemovedEvent ¶ added in v0.68.0
func NewWalletRenamedEvent ¶ added in v0.68.0
type EventData ¶ added in v0.68.0
type EventData interface {
// contains filtered or unexported methods
}
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 ¶
func (*HDKeyPair) UpdateMetadata ¶ added in v0.55.0
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 HDMasterKeyPair ¶
type HDMasterKeyPair struct {
// contains filtered or unexported fields
}
func NewHDMasterKeyPair ¶
func NewHDMasterKeyPair( publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey, ) (*HDMasterKeyPair, error)
func (*HDMasterKeyPair) AlgorithmName ¶
func (k *HDMasterKeyPair) AlgorithmName() string
func (*HDMasterKeyPair) AlgorithmVersion ¶
func (k *HDMasterKeyPair) AlgorithmVersion() uint32
func (*HDMasterKeyPair) PrivateKey ¶
func (k *HDMasterKeyPair) PrivateKey() string
func (*HDMasterKeyPair) PublicKey ¶
func (k *HDMasterKeyPair) PublicKey() string
type HDPublicKey ¶
type HDPublicKey struct { Idx uint32 `json:"index"` PublicKey string `json:"key"` KeyName string `json:"name"` Algorithm Algorithm `json:"algorithm"` Tainted bool `json:"tainted"` MetadataList []Metadata `json:"metadata"` }
func (*HDPublicKey) AlgorithmName ¶
func (k *HDPublicKey) AlgorithmName() string
func (*HDPublicKey) AlgorithmVersion ¶
func (k *HDPublicKey) AlgorithmVersion() uint32
func (*HDPublicKey) Hash ¶
func (k *HDPublicKey) Hash() (string, error)
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) Metadata ¶ added in v0.55.0
func (k *HDPublicKey) Metadata() []Metadata
func (*HDPublicKey) Name ¶ added in v0.55.0
func (k *HDPublicKey) Name() string
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 recovery phrase in input. This is useful import or retrieve a wallet.
func NewHDWallet ¶
NewHDWallet creates a wallet with auto-generated recovery phrase. This is useful to create a brand-new wallet, without having to take care of the recovery phrase generation. The generated recovery phrase is returned alongside the created wallet.
func (*HDWallet) AnnotateKey ¶ added in v0.55.0
AnnotateKey replaces the key's metadata by the new ones. If the `name` metadata is missing it's added automatically with a default.
func (*HDWallet) DescribeKeyPair ¶
DescribeKeyPair returns all the information associated with a public key.
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) HasPublicKey ¶ added in v0.55.0
func (*HDWallet) IsIsolated ¶
func (*HDWallet) KeyDerivationVersion ¶ added in v0.65.0
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) MasterKey ¶ added in v0.55.0
func (w *HDWallet) MasterKey() (MasterKeyPair, error)
MasterKey returns all the information associated to a master key pair.
func (*HDWallet) Permissions ¶
func (w *HDWallet) Permissions(hostname string) Permissions
func (*HDWallet) PermittedHostnames ¶
func (*HDWallet) PurgePermissions ¶
func (w *HDWallet) PurgePermissions()
func (*HDWallet) RevokePermissions ¶
func (*HDWallet) UnmarshalJSON ¶
func (*HDWallet) UntaintKey ¶
UntaintKey remove the taint on a key.
func (*HDWallet) UpdatePermissions ¶
func (w *HDWallet) UpdatePermissions(hostname string, perms Permissions) error
type KeyPair ¶
type KeyPair interface { PublicKey() string PrivateKey() string Name() string IsTainted() bool Metadata() []Metadata UpdateMetadata([]Metadata) []Metadata Index() uint32 AlgorithmVersion() uint32 AlgorithmName() string SignAny(data []byte) ([]byte, error) VerifyAny(data, sig []byte) (bool, error) Sign(data []byte) (*Signature, error) }
nolint: interfacebloat
type LockedWalletUpdatedEventData ¶ added in v0.68.0
type LockedWalletUpdatedEventData struct {
Name string `json:"name"`
}
type MasterKeyPair ¶
type Permissions ¶
type Permissions struct {
PublicKeys PublicKeysPermission `json:"publicKeys"`
}
Permissions describes the permissions set on a given hostname.
func DefaultPermissions ¶
func DefaultPermissions() Permissions
func PermissionsWithoutRestrictions ¶ added in v0.63.0
func PermissionsWithoutRestrictions() Permissions
func (Permissions) CanListKeys ¶
func (p Permissions) CanListKeys() bool
func (Permissions) CanUseKey ¶
func (p Permissions) CanUseKey(pubKey string) bool
func (Permissions) Summary ¶
func (p Permissions) Summary() PermissionsSummary
type PermissionsSummary ¶
type PublicKeysPermission ¶
type PublicKeysPermission struct { Access AccessMode `json:"access"` // AllowedKeys lists all the keys a third-party application has access to. // All keys are valid and usable (no tainted key). AllowedKeys []string `json:"allowedKeys"` }
PublicKeysPermission defines what the third-party application can do with the public keys of the wallet.
Methods requiring read access:
- list_keys
func NoPublicKeysPermission ¶
func NoPublicKeysPermission() PublicKeysPermission
NoPublicKeysPermission returns a revoked access for public keys.
func PublicKeysPermissionWithoutRestrictions ¶ added in v0.63.0
func PublicKeysPermissionWithoutRestrictions() PublicKeysPermission
func (PublicKeysPermission) Enabled ¶
func (p PublicKeysPermission) Enabled() bool
func (PublicKeysPermission) HasAllowedKeys ¶ added in v0.67.0
func (p PublicKeysPermission) HasAllowedKeys() bool
type UnlockedWalletUpdatedEventData ¶ added in v0.68.0
type UnlockedWalletUpdatedEventData struct {
UpdatedWallet Wallet `json:"updateWallet"`
}
type UnsupportedWalletVersionError ¶
type UnsupportedWalletVersionError struct {
UnsupportedVersion uint32
}
func NewUnsupportedWalletVersionError ¶
func NewUnsupportedWalletVersionError(v uint32) UnsupportedWalletVersionError
func (UnsupportedWalletVersionError) Error ¶
func (e UnsupportedWalletVersionError) Error() string
type Wallet ¶
type Wallet interface { KeyDerivationVersion() uint32 Name() string SetName(newName string) ID() string Type() string HasPublicKey(pubKey string) bool DescribePublicKey(pubKey string) (PublicKey, error) DescribeKeyPair(pubKey string) (KeyPair, error) ListPublicKeys() []PublicKey ListKeyPairs() []KeyPair MasterKey() (MasterKeyPair, error) GenerateKeyPair(meta []Metadata) (KeyPair, error) TaintKey(pubKey string) error UntaintKey(pubKey string) error AnnotateKey(pubKey string, meta []Metadata) ([]Metadata, error) SignAny(pubKey string, data []byte) ([]byte, error) VerifyAny(pubKey string, data, sig []byte) (bool, error) SignTx(pubKey string, data []byte) (*Signature, error) IsIsolated() bool IsolateWithKey(pubKey string) (Wallet, error) Permissions(hostname string) Permissions PermittedHostnames() []string RevokePermissions(hostname string) PurgePermissions() UpdatePermissions(hostname string, perms Permissions) error Clone() Wallet }
nolint: interfacebloat
type WalletCreatedEventData ¶ added in v0.68.0
type WalletCreatedEventData struct {
Name string `json:"name"`
}
type WalletHasBeenLockedEventData ¶ added in v0.68.0
type WalletHasBeenLockedEventData struct {
Name string `json:"name"`
}
type WalletRemovedEventData ¶ added in v0.68.0
type WalletRemovedEventData struct {
Name string `json:"name"`
}