Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptContainer(container *EncryptedContainer, pass string) ([]byte, error)
- func EncryptContainer(data interface{}, pass, containerType string, version int) ([]byte, error)
- func Exists(p string) bool
- type AccountInfo
- type AccountInfoV1
- type EncryptedContainer
- type KeyPair
- type OrganisationInfo
- type OrganisationInfoV1
- type StoreType
- type StoreTypeV1
- type Vault
- func (v *Vault) AddAccount(account AccountInfo)
- func (v *Vault) AddOrganisation(organisation OrganisationInfo)
- func (v *Vault) DecryptContainer(container *EncryptedContainer) error
- func (v *Vault) EncryptContainer() ([]byte, error)
- func (v *Vault) FindShortRoutingID(id string) string
- func (v *Vault) GetAccountInfo(addr address.Address) (*AccountInfo, error)
- func (v *Vault) GetOrganisationInfo(orgHash hash.Hash) (*OrganisationInfo, error)
- func (v *Vault) HasAccount(addr address.Address) bool
- func (v *Vault) HasOrganisation(org hash.Hash) bool
- func (v *Vault) Persist() error
- func (v *Vault) RemoveAccount(addr address.Address)
- func (v *Vault) SetPassword(pass string)
- func (v *Vault) SetPath(p string)
Constants ¶
const ( VersionV0 = iota // Only accounts VersionV1 // Accounts + organisations VersionV2 // Multi key )
Vault versions
const LatestVaultVersion = VersionV2
LatestVaultVersion Everything below this version will be automatically migrated to this version
Variables ¶
var ( // VaultPassword is the given password through the commandline for opening the vault VaultPassword string // VaultPath is the default vault path VaultPath string )
Functions ¶
func DecryptContainer ¶
func DecryptContainer(container *EncryptedContainer, pass string) ([]byte, error)
DecryptContainer decrypts an encrypted data container
func EncryptContainer ¶
EncryptContainer encrypts bytes into a data container
Types ¶
type AccountInfo ¶
type AccountInfo struct { // Default bool `json:"default"` // Is this the default account Address *address.Address `json:"address"` // The address of the account Name string `json:"name"` // Full name of the user Settings map[string]string `json:"settings"` // Additional settings that can be user-defined Keys []KeyPair // Actual keys // Communication and encryption information Pow *proofofwork.ProofOfWork `json:"proof,omitempty"` // Proof of work RoutingID string `json:"routing_id"` // ID of the routing used StoreKey *bmcrypto.KeyPair `json:"store_key,omitempty"` // Keypair for the store }
AccountInfo represents client account information
func GetAccount ¶
func GetAccount(vault *Vault, a string) (*AccountInfo, error)
GetAccount returns the given account, or nil when not found
func (AccountInfo) FindKey ¶
func (info AccountInfo) FindKey(fp string) (*KeyPair, error)
FindKey will try and retrieve a key based on the fingerprint
func (AccountInfo) GetActiveKey ¶
func (info AccountInfo) GetActiveKey() KeyPair
GetActiveKey will return the currently active key from the list of keys in the info structure
func (AccountInfo) SetActiveKey ¶
func (info AccountInfo) SetActiveKey(kp *bmcrypto.KeyPair)
SetActiveKey sets the active key in the info
type AccountInfoV1 ¶
type AccountInfoV1 struct { Address *address.Address `json:"address"` // The address of the account Name string `json:"name"` // Full name of the user Settings map[string]string `json:"settings"` // Additional settings that can be user-defined PrivKey bmcrypto.PrivKey `json:"priv_key"` // PEM encoded private key PubKey bmcrypto.PubKey `json:"pub_key"` // PEM encoded public key Pow *proofofwork.ProofOfWork `json:"proof,omitempty"` // Proof of work RoutingID string `json:"routing_id"` // ID of the routing used }
AccountInfoV1 represents client account information
type EncryptedContainer ¶
type EncryptedContainer struct { Type string `json:"type"` // Type of the data Version int `json:"version"` // Version of the data Data []byte `json:"data"` // Actual data Salt []byte `json:"salt"` // Salt Iv []byte `json:"iv"` // IV for encryption Hmac []byte `json:"hmac"` // Hash MAC }
EncryptedContainer is the on-disk structure for an encrypted blob.
type KeyPair ¶
type KeyPair struct { bmcrypto.KeyPair Active bool `json:"active"` // This is the currently active key }
KeyPair is a structure with key information
type OrganisationInfo ¶
type OrganisationInfo struct { Addr string `json:"addr"` // org part from the bitmaelum address FullName string `json:"name"` // Full name of the organisation Keys []KeyPair `json:"keys"` // Organisation keys Pow *proofofwork.ProofOfWork `json:"pow,omitempty"` // Proof of work Validations []organisation.ValidationType `json:"validations"` // Validations }
OrganisationInfo represents a organisation configuration for a server
func (OrganisationInfo) GetActiveKey ¶
func (info OrganisationInfo) GetActiveKey() KeyPair
GetActiveKey will return the currently active key from the list of keys in the info structure
func (OrganisationInfo) SetActiveKey ¶
func (info OrganisationInfo) SetActiveKey(kp *KeyPair)
SetActiveKey sets the active key in the info
func (OrganisationInfo) ToOrg ¶
func (info OrganisationInfo) ToOrg() *organisation.Organisation
ToOrg converts organisation info to an actual organisation structure
type OrganisationInfoV1 ¶
type OrganisationInfoV1 struct { Addr string `json:"addr"` // org part from the bitmaelum address FullName string `json:"name"` // Full name of the organisation PrivKey bmcrypto.PrivKey `json:"priv_key"` // PEM encoded private key PubKey bmcrypto.PubKey `json:"pub_key"` // PEM encoded public key Pow *proofofwork.ProofOfWork `json:"pow,omitempty"` // Proof of work Validations []organisation.ValidationType `json:"validations"` // Validations }
OrganisationInfoV1 is an older structure
type StoreType ¶
type StoreType struct { Accounts []AccountInfo `json:"accounts"` Organisations []OrganisationInfo `json:"organisations"` }
StoreType hold the actual data that is encrypted inside the vault
type StoreTypeV1 ¶
type StoreTypeV1 struct { Accounts []AccountInfoV1 `json:"accounts"` Organisations []OrganisationInfoV1 `json:"organisations"` }
StoreTypeV1 hold the actual data that is encrypted inside the vault
type Vault ¶
Vault defines our vault with path and password. Only the accounts should be exported
func NewPersistent ¶
NewPersistent instantiates a new vault and persists on disk
func OpenDefaultVault ¶
func OpenDefaultVault() *Vault
OpenDefaultVault returns an opened vault on vault.VaultPath and with password vault.VaultPath. Will die when incorrect vault or password
func (*Vault) AddAccount ¶
func (v *Vault) AddAccount(account AccountInfo)
AddAccount adds a new account to the vault
func (*Vault) AddOrganisation ¶
func (v *Vault) AddOrganisation(organisation OrganisationInfo)
AddOrganisation adds an organisation to the vault
func (*Vault) DecryptContainer ¶
func (v *Vault) DecryptContainer(container *EncryptedContainer) error
DecryptContainer decrypts a container and fills the values in v.Store
func (*Vault) EncryptContainer ¶
EncryptContainer encrypts v.Store and returns the vault as encrypted JSON container
func (*Vault) FindShortRoutingID ¶
FindShortRoutingID will find a short routing ID in the vault and expand it to the full routing ID. So we can use "12345" instead of "1234567890123456789012345678901234567890". Will not return anything when multiple candidates are found.
func (*Vault) GetAccountInfo ¶
func (v *Vault) GetAccountInfo(addr address.Address) (*AccountInfo, error)
GetAccountInfo tries to find the given address and returns the account from the vault
func (*Vault) GetOrganisationInfo ¶
func (v *Vault) GetOrganisationInfo(orgHash hash.Hash) (*OrganisationInfo, error)
GetOrganisationInfo tries to find the given organisation and returns the organisation from the vault
func (*Vault) HasAccount ¶
HasAccount returns true when the vault has an account for the given address
func (*Vault) HasOrganisation ¶
HasOrganisation returns true when the vault has an organisation for the given address
func (*Vault) RemoveAccount ¶
RemoveAccount removes the given account from the vault
func (*Vault) SetPassword ¶
SetPassword allows us to change the vault password. Will take effect on writing to disk