account

package
v0.0.0-...-19c2005 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2022 License: GPL-3.0 Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const AddressPrefix = "QBX"

Variables

View Source
var Groups map[string]*Group

Functions

func CreateNewAddress

func CreateNewAddress(network byte, key string) (string, error)

func Decrypt

func Decrypt(key, data []byte) ([]byte, error)

func DeriveKey

func DeriveKey(password, salt []byte) ([]byte, []byte, error)

func GenerateEd25519

func GenerateEd25519(id string, seed []byte) ed25519.PrivateKey

func NewDHKeys

func NewDHKeys() (dh.Key, dh.Key)

func NewKeyPair

func NewKeyPair(id string) (ed25519.PrivateKey, ed25519.PublicKey)

func WriteKeyForAccountID

func WriteKeyForAccountID(accountID string, data []byte, priv []byte)

Types

type ACL

type ACL interface {
	Guard() error
	Create() (*ACLManager, error)
	CreateNewGroup(name string) *Group
	AddItemsToGroup(gId string, gItem ...*GroupItem) error
	AddPermission(name string, gId string, r ResourceID, pt PermissionType) error
}

type ACLManager

type ACLManager struct {
	IsInitialized bool
	AclContext    context.Context
	// contains filtered or unexported fields
}

ACLManager implements ACL interface

func (ACLManager) AddItemsToGroup

func (A ACLManager) AddItemsToGroup(gName string, gItems ...*GroupItem) error

func (ACLManager) AddPermission

func (A ACLManager) AddPermission(name string, gId string, r ResourceID, pt PermissionType) error

func (ACLManager) Create

func (A ACLManager) Create() (*ACLManager, error)

func (ACLManager) CreateNewGroup

func (A ACLManager) CreateNewGroup(name string) *Group

func (ACLManager) Guard

func (A ACLManager) Guard() error

func (ACLManager) NewACLManager

func (A ACLManager) NewACLManager() *ACLManager

type Account

type Account struct {
	ID       string
	Nickname string
	Groups   map[string]*Group
	ACL      map[string]*Permission
}

func NewAccountFromKeys

func NewAccountFromKeys(id, ownerKey, activeKey string) *Account

func (*Account) Bytes

func (a *Account) Bytes() []byte

func (*Account) Dump

func (a *Account) Dump()

func (*Account) GetAddress

func (a *Account) GetAddress() string

func (Account) New

func (a Account) New(args map[string]any) *Account

func (Account) NewFromKeys

func (a Account) NewFromKeys(id, ownerKey, activeKey string) *Account

func (*Account) String

func (a *Account) String() string

func (*Account) VerifyAddress

func (a *Account) VerifyAddress(addr string) error

type Address

type Address []byte

func (Address) Bytes

func (a Address) Bytes() []byte

func (Address) String

func (a Address) String() string

type AddressFileFormat

type AddressFileFormat struct {
	EncryptedFile []byte
	Chksum        uint32
}

type AddressRepository

type AddressRepository struct {
	List map[string]bool
}

func (*AddressRepository) Add

func (ar *AddressRepository) Add(addr Address)

func (*AddressRepository) Disable

func (ar *AddressRepository) Disable(addr Address)

func (*AddressRepository) Has

func (ar *AddressRepository) Has(addr Address) bool

func (AddressRepository) New

type DecryptedAddressFormat

type DecryptedAddressFormat struct {
	Network   byte
	PrivKey   []byte
	PubKey    []byte
	Signature []byte
	Suite     string
}

func GetAddressFromStorage

func GetAddressFromStorage(pub string, key string) (*DecryptedAddressFormat, error)

type Group

type Group struct {
	Name  string
	Items []*GroupItem
}

type GroupItem

type GroupItem struct {
	ID           string //keypair id
	Permission   string
	PermissionID PermissionType
	Resource     ResourceID
	IsKeyPair    bool
	Weight       int
}

type IAccount

type IAccount interface {
	New(args map[string]any) *Account
	NewFromKeys(id, ownerKey, activeKey string) *Account
}

func NewAccountManager

func NewAccountManager() IAccount

type IAddress

type IAddress interface {
	GenerateNewAddress() *address
	GetAddressFromFile(pubStr string) *Address
}

type Keys

type Keys struct {
	PublicKey []byte

	Sig []byte
	// contains filtered or unexported fields
}

func (Keys) GetLoadedKeys

func (k Keys) GetLoadedKeys(accID string) *LoadedKeys

func (Keys) Shared

func (k Keys) Shared(with dh.Key)

type LoadedKeys

type LoadedKeys struct {
	Priv       ed25519.PrivateKey
	Pub        ed25519.PublicKey
	PubKeySign []byte
}

type Permission

type Permission struct {
	Name      string
	Groups    []string
	Items     []*GroupItem
	Threshold int
}

type PermissionType

type PermissionType uint32
const (
	PT_NONE PermissionType = iota
	PT_READ
	PT_DELETE
	PT_UPDATE
	PT_WRITE
	PT_SYSTEM_UPGRADE
	PT_VALIDATE
	PT_VERIFY
	PT_LEAD
	PT_MINTER
	PT_BURNER
	PT_ADMIN
	PT_SUPERADMIN
	PT_BAN
)

type ResourceID

type ResourceID uint32
const (
	// R_NONE ...
	R_NONE ResourceID = iota
	R_PROXY
	R_FILE
	R_URL
	R_CONTRACT
	R_SYSTEM
	R_FULLCHAIN
	R_BLOCK
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL