Documentation ¶
Index ¶
- Constants
- Variables
- func AccessModeToString(m AccessMode) string
- func AnnotateKey(store Store, req *AnnotateKeyRequest) error
- func GetKeyName(meta []Meta) string
- func IsVersionSupported(v uint32) bool
- func NewRecoveryPhrase() (string, error)
- func PurgePermissions(store Store, req *PurgePermissionsRequest) error
- func RevokePermissions(store Store, req *RevokePermissionsRequest) error
- func TaintKey(store Store, req *TaintKeyRequest) error
- func UntaintKey(store Store, req *UntaintKeyRequest) error
- type AccessMode
- type Algorithm
- type AnnotateKeyRequest
- type CreateWalletRequest
- type CreateWalletResponse
- type CreatedWallet
- type DescribeKeyRequest
- type DescribeKeyResponse
- type DescribePermissionsRequest
- type DescribePermissionsResponse
- type FirstPublicKey
- type GenerateKeyRequest
- type GenerateKeyResponse
- type GetWalletInfoRequest
- type GetWalletInfoResponse
- 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 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) Meta() []Meta
- func (k *HDPublicKey) UnmarshalJSON(data []byte) error
- type HDWallet
- func (w *HDWallet) DescribeKeyPair(pubKey string) (KeyPair, error)
- func (w *HDWallet) DescribePublicKey(pubKey string) (PublicKey, error)
- func (w *HDWallet) GenerateKeyPair(meta []Meta) (KeyPair, error)
- func (w *HDWallet) GetMasterKeyPair() (MasterKeyPair, 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) 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) UpdateMeta(pubKey string, meta []Meta) error
- func (w *HDWallet) UpdatePermissions(hostname string, perms Permissions) error
- func (w *HDWallet) VerifyAny(pubKey string, data, sig []byte) (bool, error)
- func (w *HDWallet) Version() uint32
- type ImportWalletRequest
- type ImportWalletResponse
- type ImportedWallet
- type Info
- type IsolateKeyRequest
- type IsolateKeyResponse
- type KeyPair
- type ListKeysRequest
- type ListKeysResponse
- type ListPermissionsRequest
- type ListPermissionsResponse
- type ListWalletsResponse
- type MasterKeyPair
- type Meta
- type NamedPubKey
- type Permissions
- type PermissionsSummary
- type PublicKey
- type PublicKeysPermission
- type PurgePermissionsRequest
- type RevokePermissionsRequest
- type RotateKeyRequest
- type RotateKeyResponse
- type SignCommandRequest
- type SignCommandResponse
- type SignMessageRequest
- type SignMessageResponse
- type Signature
- type Store
- type TaintKeyRequest
- type UnsupportedWalletVersionError
- type UntaintKeyRequest
- type Wallet
Constants ¶
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 = 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 )
const KeyNameMeta = "name"
Variables ¶
var ( ErrIsolatedWalletCantGenerateKeyPairs = errors.New("isolated wallet can't generate key pairs") ErrIsolatedWalletDoesNotHaveMasterKey = errors.New("isolated wallet doesn't have a master key") ErrCantRotateKeyInIsolatedWallet = errors.New("isolated wallet can't rotate key") ErrInvalidRecoveryPhrase = errors.New("recovery phrase 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") ErrWalletDoesNotExists = errors.New("wallet does not exist") ErrWalletNotLoggedIn = errors.New("wallet is not logged in") ErrWrongPassphrase = errors.New("wrong passphrase") )
var ErrCannotSetRestrictedKeysWithNoAccess = errors.New("can't set restricted keys with \"none\" access")
var PublicKeysPermissionLabel = "public_keys"
var SupportedVersions = []uint32{Version1, Version2}
SupportedVersions list versions supported by Vega's HD wallet.
Functions ¶
func AccessModeToString ¶
func AccessModeToString(m AccessMode) string
func AnnotateKey ¶
func AnnotateKey(store Store, req *AnnotateKeyRequest) error
func GetKeyName ¶
func IsVersionSupported ¶
func NewRecoveryPhrase ¶
NewRecoveryPhrase generates a recovery phrase with an entropy of 256 bits.
func PurgePermissions ¶
func PurgePermissions(store Store, req *PurgePermissionsRequest) error
func RevokePermissions ¶
func RevokePermissions(store Store, req *RevokePermissionsRequest) error
func TaintKey ¶
func TaintKey(store Store, req *TaintKeyRequest) error
func UntaintKey ¶
func UntaintKey(store Store, req *UntaintKeyRequest) error
Types ¶
type AccessMode ¶
type AccessMode string
var ( NoAccess AccessMode = "none" ReadAccess AccessMode = "read" WriteAccess AccessMode = "write" )
func ToAccessMode ¶
func ToAccessMode(mode string) (AccessMode, error)
type AnnotateKeyRequest ¶
type CreateWalletRequest ¶
type CreateWalletResponse ¶
type CreateWalletResponse struct { Wallet CreatedWallet `json:"wallet"` Key FirstPublicKey `json:"key"` }
func CreateWallet ¶
func CreateWallet(store Store, req *CreateWalletRequest) (*CreateWalletResponse, error)
type CreatedWallet ¶
type DescribeKeyRequest ¶
type DescribeKeyResponse ¶
type DescribeKeyResponse struct { PublicKey string `json:"publicKey"` Algorithm Algorithm `json:"algorithm"` Meta []Meta `json:"meta"` IsTainted bool `json:"isTainted"` }
func DescribeKey ¶
func DescribeKey(store Store, req *DescribeKeyRequest) (*DescribeKeyResponse, error)
type DescribePermissionsResponse ¶
type DescribePermissionsResponse struct {
Permissions Permissions `json:"permissions"`
}
func DescribePermissions ¶
func DescribePermissions(store Store, req *DescribePermissionsRequest) (*DescribePermissionsResponse, error)
type FirstPublicKey ¶
type GenerateKeyRequest ¶
type GenerateKeyResponse ¶
type GenerateKeyResponse struct { PublicKey string `json:"publicKey"` Algorithm Algorithm `json:"algorithm"` Meta []Meta `json:"meta"` }
func GenerateKey ¶
func GenerateKey(store Store, req *GenerateKeyRequest) (*GenerateKeyResponse, error)
type GetWalletInfoRequest ¶
type GetWalletInfoResponse ¶
type GetWalletInfoResponse struct { Type string `json:"type"` Version uint32 `json:"version"` ID string `json:"id"` }
func GetWalletInfo ¶
func GetWalletInfo(store Store, req *GetWalletInfoRequest) (*GetWalletInfoResponse, error)
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 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:"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) 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) 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 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) 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) GetMasterKeyPair ¶
func (w *HDWallet) GetMasterKeyPair() (MasterKeyPair, error)
GetMasterKeyPair returns all the information associated to a master key pair.
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) 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) UpdateMeta ¶
UpdateMeta replaces the key's metadata by the new ones.
func (*HDWallet) UpdatePermissions ¶
func (w *HDWallet) UpdatePermissions(hostname string, perms Permissions) error
type ImportWalletRequest ¶
type ImportWalletResponse ¶
type ImportWalletResponse struct { Wallet ImportedWallet `json:"wallet"` Key FirstPublicKey `json:"key"` }
func ImportWallet ¶
func ImportWallet(store Store, req *ImportWalletRequest) (*ImportWalletResponse, error)
type ImportedWallet ¶
type IsolateKeyRequest ¶
type IsolateKeyResponse ¶
func IsolateKey ¶
func IsolateKey(store Store, req *IsolateKeyRequest) (*IsolateKeyResponse, error)
type ListKeysRequest ¶
type ListKeysResponse ¶
type ListKeysResponse struct {
Keys []NamedPubKey `json:"keys"`
}
func ListKeys ¶
func ListKeys(store Store, req *ListKeysRequest) (*ListKeysResponse, error)
type ListPermissionsRequest ¶
type ListPermissionsResponse ¶
type ListPermissionsResponse struct {
Hostnames []string `json:"hostnames"`
}
func ListPermissions ¶
func ListPermissions(store Store, req *ListPermissionsRequest) (*ListPermissionsResponse, error)
type ListWalletsResponse ¶
type ListWalletsResponse struct {
Wallets []string `json:"wallets"`
}
func ListWallets ¶
func ListWallets(store Store) (*ListWalletsResponse, error)
type MasterKeyPair ¶
type NamedPubKey ¶
type Permissions ¶
type Permissions struct {
PublicKeys PublicKeysPermission `json:"publicKeys"`
}
Permissions describes the permissions set on a given hostname.
func DefaultPermissions ¶
func DefaultPermissions() 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"` RestrictedKeys []string `json:"restrictedKeys"` }
PublicKeysPermission defines what the third-party application can do with the public keys of the wallet.
Methods requiring read access:
- list_keys
Methods requiring write access:
Nothing requires this type of access for now.
func NoPublicKeysPermission ¶
func NoPublicKeysPermission() PublicKeysPermission
NoPublicKeysPermission returns a revoked access for public keys.
func (PublicKeysPermission) Enabled ¶
func (p PublicKeysPermission) Enabled() bool
func (PublicKeysPermission) HasRestrictedKeys ¶
func (p PublicKeysPermission) HasRestrictedKeys() bool
type PurgePermissionsRequest ¶
type RotateKeyRequest ¶
type RotateKeyRequest struct { Wallet string `json:"wallet"` Passphrase string `json:"passphrase"` NewPublicKey string `json:"newPublicKey"` ChainID string `json:"chainId"` CurrentPublicKey string `json:"currentPublicKey"` TxBlockHeight uint64 `json:"txBlockHeight"` TargetBlockHeight uint64 `json:"targetBlockHeight"` }
type RotateKeyResponse ¶
type RotateKeyResponse struct { MasterPublicKey string `json:"masterPublicKey"` Base64Transaction string `json:"base64Transaction"` }
func RotateKey ¶
func RotateKey(store Store, req *RotateKeyRequest) (*RotateKeyResponse, error)
type SignCommandRequest ¶
type SignCommandResponse ¶
type SignCommandResponse struct {
Base64Transaction string `json:"base64Transaction"`
}
func SignCommand ¶
func SignCommand(store Store, req *SignCommandRequest) (*SignCommandResponse, error)
type SignMessageRequest ¶
type SignMessageResponse ¶
type SignMessageResponse struct { Base64 string `json:"hexSignature"` Bytes []byte `json:"bytesSignature"` }
func SignMessage ¶
func SignMessage(store Store, req *SignMessageRequest) (*SignMessageResponse, error)
type Store ¶
type Store interface { WalletExists(ctx context.Context, name string) (bool, error) SaveWallet(ctx context.Context, w Wallet, passphrase string) error GetWallet(ctx context.Context, name, passphrase string) (Wallet, error) GetWalletPath(name string) string ListWallets(ctx context.Context) ([]string, error) }
type TaintKeyRequest ¶
type UnsupportedWalletVersionError ¶
type UnsupportedWalletVersionError struct {
UnsupportedVersion uint32
}
func NewUnsupportedWalletVersionError ¶
func NewUnsupportedWalletVersionError(v uint32) UnsupportedWalletVersionError
func (UnsupportedWalletVersionError) Error ¶
func (e UnsupportedWalletVersionError) Error() string
type UntaintKeyRequest ¶
type Wallet ¶
type Wallet interface { Version() uint32 Name() string SetName(newName string) ID() string Type() string DescribePublicKey(pubKey string) (PublicKey, error) DescribeKeyPair(pubKey string) (KeyPair, error) ListPublicKeys() []PublicKey ListKeyPairs() []KeyPair GetMasterKeyPair() (MasterKeyPair, error) 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) Permissions(hostname string) Permissions PermittedHostnames() []string RevokePermissions(hostname string) PurgePermissions() UpdatePermissions(hostname string, perms Permissions) error }