Documentation
¶
Overview ¶
pkg/accounts/ethereum.go
pkg/accounts/rbac.go
Index ¶
- func ComputeAccountID(signerType types.SignerType, pubKeyBytes []byte) string
- func PublicKeyToAddress(pubKeyBytes []byte) (types.Address, error)
- type Account
- func (a *Account) Address() types.Address
- func (a *Account) AssignRole(role types.Role, permissions ...types.Permission) error
- func (a *Account) Authorize(permission types.Permission) error
- func (a *Account) Comment() string
- func (a *Account) ExtraPermissions() map[types.Role][]types.Permission
- func (a *Account) HasPermission(permission types.Permission) bool
- func (a *Account) ID() string
- func (a *Account) MarshalPublicKey() ([]byte, error)
- func (a *Account) MasterKeyToECDSA() (*ecdsa.PrivateKey, error)
- func (a *Account) MasterPrivateKey() libp2pCrypto.PrivKey
- func (a *Account) MasterPublicKey() libp2pCrypto.PubKey
- func (a *Account) Name() string
- func (a *Account) PeerID() peer.ID
- func (a *Account) RemoveRole(role types.Role) error
- func (a *Account) Roles() []types.Role
- func (a *Account) Sign(data []byte) ([]byte, error)
- func (a *Account) SupportedProtocols() []types.ProtocolType
- func (a *Account) SupportedTransports() []types.TransportType
- func (a *Account) Verify(data []byte, signature []byte) (bool, error)
- type Store
- func (s *Store) Create(name, comment string, signer types.SignerType, persist bool, ...) (*Account, error)
- func (s *Store) Delete(peerID libp2pPeer.ID) error
- func (s *Store) GetByAddress(addr types.Address) (*Account, error)
- func (s *Store) GetByName(name string) (*Account, error)
- func (s *Store) GetByPeerID(peerID libp2pPeer.ID) (*Account, error)
- func (s *Store) GetByRole(role types.Role) (*Account, error)
- func (s *Store) List() ([]*Account, error)
- func (s *Store) Load() error
- func (s *Store) Save(account *Account) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeAccountID ¶
func ComputeAccountID(signerType types.SignerType, pubKeyBytes []byte) string
ComputeAccountID computes the account ID using SignerType and public key bytes.
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account represents a Decentralized Identifier with associated cryptographic keys and permissions.
func NewAccount ¶
func NewAccount( logger logger.Logger, peerID peer.ID, peerSk libp2pCrypto.PrivKey, peerPk libp2pCrypto.PubKey, signerType types.SignerType, name, comment string, roles []types.Role, extraPermissions map[types.Role][]types.Permission, rbacMgr *rbac.Manager, ) (*Account, error)
NewAccount initializes a new Account with all the cryptographic keys and metadata.
func NewConsensusAccount ¶
func NewConsensusAccount(logger logger.Logger, peerId peer.ID, address types.Address, pubKey libp2pCrypto.PubKey, roles []types.Role) (*Account, error)
NewConsensusAccount initializes Account used by the validators. TODO: This needs to be extended with roles and many more things but for now it's this
func (*Account) AssignRole ¶
AssignRole assigns a new role to the account.
func (*Account) Authorize ¶
func (a *Account) Authorize(permission types.Permission) error
Authorize ensures the account has the required permission.
func (*Account) ExtraPermissions ¶
func (a *Account) ExtraPermissions() map[types.Role][]types.Permission
ExtraPermissions returns the additional permissions associated with each role.
func (*Account) HasPermission ¶
func (a *Account) HasPermission(permission types.Permission) bool
HasPermission checks if the account has the specified permission.
func (*Account) MarshalPublicKey ¶
func (*Account) MasterKeyToECDSA ¶
func (a *Account) MasterKeyToECDSA() (*ecdsa.PrivateKey, error)
func (*Account) MasterPrivateKey ¶
func (a *Account) MasterPrivateKey() libp2pCrypto.PrivKey
MasterPrivateKey returns the master private key associated with the account.
func (*Account) MasterPublicKey ¶
func (a *Account) MasterPublicKey() libp2pCrypto.PubKey
MasterPublicKey returns the master public key associated with the account.
func (*Account) RemoveRole ¶
RemoveRole removes a role from the account.
func (*Account) SupportedProtocols ¶
func (a *Account) SupportedProtocols() []types.ProtocolType
TODO: Not even sure how to do this... And is this even how it should be done... Perhaps based on node type and configuration instead of anything else...
func (*Account) SupportedTransports ¶
func (a *Account) SupportedTransports() []types.TransportType
TODO: Not even sure how to do this... And is this even how it should be done... Perhaps based on node type and configuration instead of anything else...
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the persistence of Accounts using YAML files.
func (*Store) Create ¶
func (s *Store) Create(name, comment string, signer types.SignerType, persist bool, roles ...types.Role) (*Account, error)
Create generates a new Account and stores it as a YAML file.
func (*Store) Delete ¶
func (s *Store) Delete(peerID libp2pPeer.ID) error
Delete removes an Account from the storage by deleting its corresponding YAML file and removing it from memory.
func (*Store) GetByAddress ¶
GetByAddress returns an Account by its Address if it exists in memory.
func (*Store) GetByPeerID ¶
func (s *Store) GetByPeerID(peerID libp2pPeer.ID) (*Account, error)
GetByPeerID returns an Account by its peer.ID if it exists in memory.