id

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright 2017-2018 OneLedger

Identities management for any of the associated chains

Group Mechanics

Current state of a given user, assembled from persistence

Key Management

Group Mechanics

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Armour

func Armour(privateKey PrivateKey, passphrase string, salt []byte) ([]byte, error)

salt := cytpo.CRandBytes(16)

func GenerateKeys

func GenerateKeys(secret []byte) (PublicKey, PrivateKey)

func Matches

func Matches(account Account, name string, chain data.ChainType) bool

func ParseAccountType

func ParseAccountType(typeName string) data.ChainType

Map type to string

Types

type Account

type Account interface {
	Name() string
	Chain() data.ChainType

	AccountKey() AccountKey
	PublicKey() PublicKey
	PrivateKey() PrivateKey

	Export() AccountExport

	AsString() string
}

Polymorphism

func NewAccount

func NewAccount(newType data.ChainType, name string, key PublicKey, priv PrivateKey) Account

Create a new account for a given chain

type AccountBase

type AccountBase struct {
	Type data.ChainType

	Key AccountKey

	Name       string
	PublicKey  PublicKey
	PrivateKey PrivateKey
}

type AccountBitcoin

type AccountBitcoin struct {
	AccountBase
}

Information we need for a Bitcoin account

func (*AccountBitcoin) AccountKey

func (account *AccountBitcoin) AccountKey() AccountKey

func (*AccountBitcoin) AsString

func (account *AccountBitcoin) AsString() string

func (*AccountBitcoin) Chain

func (account *AccountBitcoin) Chain() data.ChainType

func (*AccountBitcoin) Export

func (account *AccountBitcoin) Export() AccountExport

func (*AccountBitcoin) Name

func (account *AccountBitcoin) Name() string

func (*AccountBitcoin) PrivateKey

func (account *AccountBitcoin) PrivateKey() PrivateKey

func (*AccountBitcoin) PublicKey

func (account *AccountBitcoin) PublicKey() PublicKey

type AccountEthereum

type AccountEthereum struct {
	AccountBase
}

Information we need for an Ethereum account

func (*AccountEthereum) AccountKey

func (account *AccountEthereum) AccountKey() AccountKey

func (*AccountEthereum) AsString

func (account *AccountEthereum) AsString() string

func (*AccountEthereum) Chain

func (account *AccountEthereum) Chain() data.ChainType

func (*AccountEthereum) Export

func (account *AccountEthereum) Export() AccountExport

func (*AccountEthereum) Name

func (account *AccountEthereum) Name() string

func (*AccountEthereum) PrivateKey

func (account *AccountEthereum) PrivateKey() PrivateKey

func (*AccountEthereum) PublicKey

func (account *AccountEthereum) PublicKey() PublicKey

type AccountExport

type AccountExport struct {
	Type       string
	AccountKey string
	Name       string
	// Balance must come from utxo database, fill when needed
	Balance  string
	NodeName string
}

AccountExport struct holds important account info in a

type AccountKey

type AccountKey = wdata.Bytes // OneLedger address, like Tendermint the hash of the associated PubKey

Aliases to hide some of the basic underlying types.

func NewAccountKey

func NewAccountKey(key PublicKey) AccountKey

Hash the public key to get a unqiue hash that can act as a key

type AccountOneLedger

type AccountOneLedger struct {
	AccountBase
}

Information we need about our own fullnode identities

func (*AccountOneLedger) AccountKey

func (account *AccountOneLedger) AccountKey() AccountKey

func (*AccountOneLedger) AsString

func (account *AccountOneLedger) AsString() string

func (*AccountOneLedger) Chain

func (account *AccountOneLedger) Chain() data.ChainType

func (*AccountOneLedger) Export

func (account *AccountOneLedger) Export() AccountExport

func (*AccountOneLedger) Name

func (account *AccountOneLedger) Name() string

func (*AccountOneLedger) PrivateKey

func (account *AccountOneLedger) PrivateKey() PrivateKey

func (*AccountOneLedger) PublicKey

func (account *AccountOneLedger) PublicKey() PublicKey

type Accounts

type Accounts struct {
	// contains filtered or unexported fields
}

The persistent collection of all accounts known by this node

func NewAccounts

func NewAccounts(name string) *Accounts

func (*Accounts) Add

func (acc *Accounts) Add(account Account)

func (*Accounts) Delete

func (acc *Accounts) Delete(account Account)

func (*Accounts) Dump

func (acc *Accounts) Dump()

List out all of the accounts

func (*Accounts) Exists

func (acc *Accounts) Exists(newType data.ChainType, name string) bool

func (*Accounts) Find

func (acc *Accounts) Find(account Account) (Account, err.Code)

func (*Accounts) FindAll

func (acc *Accounts) FindAll() []Account

func (*Accounts) FindIdentity

func (acc *Accounts) FindIdentity(identity Identity) (Account, err.Code)

func (*Accounts) FindKey

func (acc *Accounts) FindKey(key AccountKey) (Account, err.Code)

func (*Accounts) FindName

func (acc *Accounts) FindName(name string) (Account, err.Code)

func (*Accounts) FindNameOnChain

func (acc *Accounts) FindNameOnChain(name string, chain data.ChainType) (Account, err.Code)

type DataPrivledge

type DataPrivledge struct {
	Name string
}

The ability to use a specific peice of data

type Group

type Group struct {
	Name  string
	Roles []RolePrivledge
	Data  []DataPrivledge

	Identities []*Identity
	Groups     []*Group
}

A Group of users or groups.

type Identities

type Identities struct {
	// contains filtered or unexported fields
}

The persistent collection of all accounts known by this node

func NewIdentities

func NewIdentities(name string) *Identities

Initialize or reconnect to the database

func (*Identities) Add

func (ids *Identities) Add(identity *Identity)

func (*Identities) Close

func (ids *Identities) Close()

func (*Identities) Delete

func (ids *Identities) Delete()

func (*Identities) Dump

func (ids *Identities) Dump()

func (*Identities) Exists

func (ids *Identities) Exists(name string) bool

func (*Identities) FindAll

func (ids *Identities) FindAll() []*Identity

func (*Identities) FindName

func (ids *Identities) FindName(name string) (*Identity, err.Code)

type Identity

type Identity struct {
	Name string // A unique name for the identity

	NodeName    string // The origin of this account
	ContactInfo string

	AccountKey AccountKey // A key

	External bool
	Chain    map[data.ChainType]AccountKey // TODO: Should be more than one account per chain

	Nodes map[string]data.ChainNode
}

A user of a OneLedger node, but not necessarily the chain itself.

func NewIdentity

func NewIdentity(name string, contactInfo string, external bool, nodeName string, accountKey AccountKey) *Identity

func (*Identity) AsString

func (id *Identity) AsString() string

func (*Identity) Export

func (id *Identity) Export() IdentityExport

Export returns an easily printable struct

func (*Identity) IsExternal

func (id *Identity) IsExternal() bool

func (*Identity) Key

func (id *Identity) Key() data.DatabaseKey

func (*Identity) SetAccount

func (id *Identity) SetAccount(chain data.ChainType, account Account)

type IdentityExport

type IdentityExport struct {
	Name       string
	External   bool
	AccountKey string
}

type KeyAlgorithm

type KeyAlgorithm int
const (
	ED25519 KeyAlgorithm = iota
	SECP256K1
)

type PrivateKey

type PrivateKey = crypto.PrivKey

func Dearmour

func Dearmour(buffer []byte, passphrase string, salt []byte) (PrivateKey, error)

func Generate

func Generate(secret []byte, algorithm KeyAlgorithm) (PrivateKey, error)

type PublicKey

type PublicKey = crypto.PubKey

type RolePrivledge

type RolePrivledge struct {
	Name string
}

The ability to execute a specific peice of code

type Signature

type Signature = crypto.Signature

type Wallet

type Wallet struct {
	Description string
	Accounts    []*Account
}

A Group of users or groups.

Jump to

Keyboard shortcuts

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