id

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: Apache-2.0 Imports: 18 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

Easy Access to Persistent App Data, if the data isn't accessible stop immediately

Group Mechanics

Index

Constants

View Source
const (
	ED25519 KeyAlgorithm = iota
	SECP256K1
	ED25519_PUB_SIZE   int = ed25519.PubKeyEd25519Size
	SECP256K1_PUB_SIZE int = secp256k1.PubKeySecp256k1Size
)

Variables

This section is empty.

Functions

func GenerateKeys

func GenerateKeys(secret []byte, random bool) (PrivateKeyED25519, PublicKeyED25519)

func GetAdmin added in v0.8.0

func GetAdmin(app interface{}) data.Datastore

func GetBalances added in v0.8.0

func GetBalances(app interface{}) *data.ChainState

func GetChainID added in v0.8.0

func GetChainID(app interface{}) string

func GetContracts added in v0.8.0

func GetContracts(app interface{}) data.Datastore

func GetEvent added in v0.8.0

func GetEvent(app interface{}) data.Datastore

func GetSequence added in v0.8.0

func GetSequence(app interface{}) data.Datastore

func GetSmartContracts added in v0.8.0

func GetSmartContracts(app interface{}) data.Datastore

func GetStatus added in v0.8.0

func GetStatus(app interface{}) data.Datastore

func GetTendermintValidator added in v0.8.0

func GetTendermintValidator(address string, pubkey string, power int64) *types.Validator

func HasValidatorToken added in v0.8.0

func HasValidatorToken(app interface{}, validator types.Validator) bool

func IsByzantine added in v0.8.0

func IsByzantine(validator types.Validator, badValidators []types.Evidence) (result bool)

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

	String() string
}

Polymorphism

func NewAccount

func NewAccount(newType data.ChainType, name string, key PublicKeyED25519, priv PrivateKeyED25519) Account

Create a new account for a given chain

type AccountBase

type AccountBase struct {
	Type data.ChainType `json:"type"`
	Key  AccountKey     `json:"key"`
	Name string         `json:"name"`

	// TODO: Should handle key polymorphism properly..
	PublicKey  PublicKeyED25519  `json:"publicKey"`
	PrivateKey PrivateKeyED25519 `json:"privateKey"`
}

type AccountBitcoin

type AccountBitcoin struct {
	AccountBase
}

Information we need for a Bitcoin account

func (*AccountBitcoin) AccountKey

func (account *AccountBitcoin) AccountKey() AccountKey

func (*AccountBitcoin) Chain

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

func (*AccountBitcoin) Name

func (account *AccountBitcoin) Name() string

func (*AccountBitcoin) PrivateKey

func (account *AccountBitcoin) PrivateKey() PrivateKey

func (*AccountBitcoin) PublicKey

func (account *AccountBitcoin) PublicKey() PublicKey

func (*AccountBitcoin) String added in v0.7.1

func (account *AccountBitcoin) String() string

String used in fmt and Dump

type AccountEthereum

type AccountEthereum struct {
	AccountBase
}

Information we need for an Ethereum account

func (*AccountEthereum) AccountKey

func (account *AccountEthereum) AccountKey() AccountKey

func (*AccountEthereum) Chain

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

func (*AccountEthereum) Name

func (account *AccountEthereum) Name() string

func (*AccountEthereum) PrivateKey

func (account *AccountEthereum) PrivateKey() PrivateKey

func (*AccountEthereum) PublicKey

func (account *AccountEthereum) PublicKey() PublicKey

func (*AccountEthereum) String added in v0.7.1

func (account *AccountEthereum) String() string

String used in fmt and Dump

type AccountKey

type AccountKey []byte // OneLedger address, like Tendermint the hash of the associated PubKey

Aliases to hide some of the basic underlying types.

func NewAccountKey

func NewAccountKey(key PublicKeyED25519) AccountKey

NewAccountKey hashes the public key to get a unique hash that can act as a key

func (AccountKey) Bytes added in v0.6.0

func (accountKey AccountKey) Bytes() []byte

func (AccountKey) String added in v0.6.0

func (accountKey AccountKey) String() string

type AccountOneLedger

type AccountOneLedger struct {
	AccountBase
}

Information we need about our own olfullnode identities

func (*AccountOneLedger) AccountKey

func (account *AccountOneLedger) AccountKey() AccountKey

func (*AccountOneLedger) Chain

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

func (*AccountOneLedger) Name

func (account *AccountOneLedger) Name() string

func (*AccountOneLedger) PrivateKey

func (account *AccountOneLedger) PrivateKey() PrivateKey

func (*AccountOneLedger) PublicKey

func (account *AccountOneLedger) PublicKey() PublicKey

func (*AccountOneLedger) String added in v0.7.1

func (account *AccountOneLedger) String() string

String used in fmt and Dump

type Accounts

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

The persistent collection of all accounts known by this node

func GetAccounts added in v0.8.0

func GetAccounts(app interface{}) *Accounts

func NewAccounts

func NewAccounts(name string) *Accounts

func (*Accounts) Add

func (acc *Accounts) Add(account Account)

func (*Accounts) Close added in v0.7.0

func (acc *Accounts) Close()

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, status.Code)

func (*Accounts) FindAll

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

func (*Accounts) FindIdentity

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

func (*Accounts) FindKey

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

func (*Accounts) FindName

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

func (*Accounts) FindNameOnChain

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

type ApplyValidator added in v0.8.1

type ApplyValidator struct {
	Validator types.Validator
	Stake     data.Coin
}

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 GetIdentities added in v0.8.0

func GetIdentities(app interface{}) *Identities

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) FindKey added in v0.8.0

func (ids *Identities) FindKey(accountKey AccountKey) Identity

func (*Identities) FindName

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

func (*Identities) FindTendermint added in v0.7.0

func (ids *Identities) FindTendermint(tendermintAddress string) Identity

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

	TendermintAddress string
	TendermintPubKey  string
}

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, tendermintAddress string, tendermintPubKey string) *Identity

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)

func (*Identity) String added in v0.7.1

func (id *Identity) String() string

String used in fmt and Dump

type KeyAlgorithm

type KeyAlgorithm int

func (KeyAlgorithm) Size added in v0.7.0

func (algo KeyAlgorithm) Size() int

func (KeyAlgorithm) String added in v0.7.0

func (algo KeyAlgorithm) String() string

type PrivateKey

type PrivateKey interface {
	Bytes() []byte
	Sign([]byte) ([]byte, error)
	PubKey() PublicKey
	Equals(PrivateKey) bool
}

type PrivateKeyED25519 added in v0.6.2

type PrivateKeyED25519 ed25519.PrivKeyEd25519

func NilPrivateKey added in v0.6.0

func NilPrivateKey() PrivateKeyED25519

func OnePrivateKey added in v0.7.0

func OnePrivateKey() PrivateKeyED25519

func (PrivateKeyED25519) Bytes added in v0.6.2

func (k PrivateKeyED25519) Bytes() []byte

Private keys --------------------------------------------------

func (PrivateKeyED25519) Equals added in v0.6.2

func (k PrivateKeyED25519) Equals(key PrivateKey) bool

func (PrivateKeyED25519) PubKey added in v0.6.2

func (k PrivateKeyED25519) PubKey() PublicKey

func (PrivateKeyED25519) Sign added in v0.6.2

func (k PrivateKeyED25519) Sign(msg []byte) ([]byte, error)

type PrivateKeySECP256K1 added in v0.6.2

type PrivateKeySECP256K1 secp256k1.PrivKeySecp256k1

func (PrivateKeySECP256K1) Bytes added in v0.6.2

func (k PrivateKeySECP256K1) Bytes() []byte

func (PrivateKeySECP256K1) Equals added in v0.6.2

func (k PrivateKeySECP256K1) Equals(key PrivateKey) bool

func (PrivateKeySECP256K1) PubKey added in v0.6.2

func (k PrivateKeySECP256K1) PubKey() PublicKey

func (PrivateKeySECP256K1) Sign added in v0.6.2

func (k PrivateKeySECP256K1) Sign(msg []byte) ([]byte, error)

type PublicKey

type PublicKey interface {
	Address() []byte
	Bytes() []byte
	VerifyBytes(msg []byte, sig []byte) bool
	Equals(PublicKey) bool
	Hex() string
}

func ImportBytesKey added in v0.7.0

func ImportBytesKey(bz []byte, k KeyAlgorithm) (PublicKey, error)

ImportBytesKey takes a byteslice and returns a PublicKey

func ImportHexKey added in v0.7.0

func ImportHexKey(h string, k KeyAlgorithm) (PublicKey, error)

ImportHexKey returns a PublicKey given a hex-encoded string

type PublicKeyED25519 added in v0.6.2

type PublicKeyED25519 struct {
	Key ed25519.PubKeyEd25519
}

func NilPublicKey added in v0.6.0

func NilPublicKey() PublicKeyED25519

func OnePublicKey added in v0.7.0

func OnePublicKey() PublicKeyED25519

func (PublicKeyED25519) Address added in v0.6.2

func (k PublicKeyED25519) Address() []byte

Address hashes the key with a RIPEMD-160 hash

func (PublicKeyED25519) Bytes added in v0.6.2

func (k PublicKeyED25519) Bytes() []byte

func (PublicKeyED25519) Equals added in v0.6.2

func (k PublicKeyED25519) Equals(key PublicKey) bool

func (PublicKeyED25519) Hex added in v0.7.0

func (k PublicKeyED25519) Hex() string

func (PublicKeyED25519) VerifyBytes added in v0.6.2

func (k PublicKeyED25519) VerifyBytes(msg []byte, sig []byte) bool

type PublicKeySECP256K1 added in v0.6.2

type PublicKeySECP256K1 struct {
	Key secp256k1.PubKeySecp256k1
}

func (PublicKeySECP256K1) Address added in v0.6.2

func (k PublicKeySECP256K1) Address() []byte

func (PublicKeySECP256K1) Bytes added in v0.6.2

func (k PublicKeySECP256K1) Bytes() []byte

func (PublicKeySECP256K1) Equals added in v0.6.2

func (k PublicKeySECP256K1) Equals(key PublicKey) bool

func (PublicKeySECP256K1) Hex added in v0.7.0

func (k PublicKeySECP256K1) Hex() string

func (PublicKeySECP256K1) VerifyBytes added in v0.6.2

func (k PublicKeySECP256K1) VerifyBytes(msg []byte, sig []byte) bool

type RolePrivledge

type RolePrivledge struct {
	Name string
}

The ability to execute a specific peice of code

type SequenceRecord added in v0.8.0

type SequenceRecord struct {
	Sequence int64
}

func NextSequence added in v0.8.0

func NextSequence(app interface{}, accountkey AccountKey) SequenceRecord

type Signature

type Signature = []byte

Temporary typing for signatures

type ValidatorInfo added in v0.8.0

type ValidatorInfo struct {
	Address string
	PubKey  string
}

func NewValidatorInfo added in v0.8.0

func NewValidatorInfo(address []byte, pubkey types.PubKey) *ValidatorInfo

type Validators added in v0.8.0

type Validators struct {
	Signers            []types.SigningValidator
	Byzantines         []types.Evidence
	Approved           []Identity
	ApprovedValidators []types.Validator
	SelectedValidator  Identity
	NewValidators      []ApplyValidator
	ToBeRemoved        []ApplyValidator
}

func GetValidators added in v0.8.0

func GetValidators(app interface{}) *Validators

func NewValidatorList added in v0.8.0

func NewValidatorList() *Validators

func (*Validators) FindApproved added in v0.8.0

func (list *Validators) FindApproved(app interface{}) []Identity

func (*Validators) FindSelectedValidator added in v0.8.0

func (list *Validators) FindSelectedValidator(app interface{}, hash []byte) Identity

func (Validators) IsValidAccountKey added in v0.8.0

func (list Validators) IsValidAccountKey(key AccountKey, index int) bool

func (*Validators) Set added in v0.8.0

func (list *Validators) Set(app interface{}, validators []types.SigningValidator, badValidators []types.Evidence, hash []byte)

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