Documentation ¶
Index ¶
- Variables
- type Account
- type Entry
- type Key
- type Master
- type Store
- func (s *Store) AddEntry(raw []byte) (primitive.ObjectID, error)
- func (s *Store) DecryptAccount(password, encryptedAccount []byte) (Account, error)
- func (s *Store) GetEntries(password []byte) ([]Entry, error)
- func (s *Store) Init(db *mongo.Database) error
- func (s *Store) RemoveEntry(id primitive.ObjectID) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrIndex is thrown on an out of bounds index ErrIndex = errors.New("invalid account index") //ErrDuplicate is thrown on inserting a duplicate account ErrDuplicate = errors.New("duplicate account insert") )
View Source
var ( // ErrDelete is thrown on an unsuccessful account delete ErrDelete = errors.New("unsuccessful delete") // ErrAccount is thrown on an unsupported account type ErrAccount = errors.New("invalid account type") )
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account interface { Gen() error Export([]byte) ([]byte, error) Import([]byte, []byte) error String() string }
Account represents a generic account
type Key ¶
type Key struct { ID primitive.ObjectID `bson:"_id,omitempty"` CreatedAt time.Time `bson:"created_at,omitempty"` UpdatedAt time.Time `bson:"updated_at,omitempty"` Raw []byte `bson:"raw"` }
Key represents an encrypted member of the account store
type Master ¶
Master holds a chain's master key This Key:
- Is responsible for encrypting/decrypting an account store
- Is user-provided and loaded into memory at runtime
- Should never touch disk
func (*Master) InsertAccount ¶
InsertAccount inserts a unique account into the store
func (*Master) NewAccount ¶
NewAccount generates a new account conditioned on the chain type
func (*Master) RemoveAccount ¶
RemoveAccount removes an account from the store by index
type Store ¶
type Store struct { AccountType chain.Type // the account type Ctx ctx.Context // calling context Accounts *mongo.Collection // collection of encrypted accounts for this chain }
Store wraps a mongo connection to an account store
func (*Store) DecryptAccount ¶
DecryptAccount decrypts a single account conditioned on the account type
func (*Store) GetEntries ¶
GetEntries decrypts the account store
Click to show internal directories.
Click to hide internal directories.