Documentation ¶
Overview ¶
Copyright 2017-2018 OneLedger
Identities management for any of the associated chains ¶
Copyright 2017 - 2018 OneLedger ¶
Group Mechanics ¶
Copyright 2017-2018 OneLedger ¶
Current state of a given user, assembled from persistence ¶
Copyright 2017 - 2018 OneLedger ¶
Key Management ¶
Copyright 2017 - 2018 OneLedger ¶
Easy Access to Persistent App Data, if the data isn't accessible stop immediately
Copyright 2017 - 2018 OneLedger ¶
Group Mechanics
Index ¶
- Constants
- func GenerateKeys(secret []byte, random bool) (PrivateKeyED25519, PublicKeyED25519)
- func GetAdmin(app interface{}) data.Datastore
- func GetBalances(app interface{}) *data.ChainState
- func GetChainID(app interface{}) string
- func GetContracts(app interface{}) data.Datastore
- func GetEvent(app interface{}) data.Datastore
- func GetSequence(app interface{}) data.Datastore
- func GetSmartContracts(app interface{}) data.Datastore
- func GetStatus(app interface{}) data.Datastore
- func GetTendermintValidator(address string, pubkey string, power int64) *types.Validator
- func HasValidatorToken(app interface{}, validator types.Validator) bool
- func IsByzantine(validator types.Validator, badValidators []types.Evidence) (result bool)
- func Matches(account Account, name string, chain data.ChainType) bool
- func ParseAccountType(typeName string) data.ChainType
- type Account
- type AccountBase
- type AccountBitcoin
- func (account *AccountBitcoin) AccountKey() AccountKey
- func (account *AccountBitcoin) Chain() data.ChainType
- func (account *AccountBitcoin) Name() string
- func (account *AccountBitcoin) PrivateKey() PrivateKey
- func (account *AccountBitcoin) PublicKey() PublicKey
- func (account *AccountBitcoin) String() string
- type AccountEthereum
- func (account *AccountEthereum) AccountKey() AccountKey
- func (account *AccountEthereum) Chain() data.ChainType
- func (account *AccountEthereum) Name() string
- func (account *AccountEthereum) PrivateKey() PrivateKey
- func (account *AccountEthereum) PublicKey() PublicKey
- func (account *AccountEthereum) String() string
- type AccountKey
- type AccountOneLedger
- func (account *AccountOneLedger) AccountKey() AccountKey
- func (account *AccountOneLedger) Chain() data.ChainType
- func (account *AccountOneLedger) Name() string
- func (account *AccountOneLedger) PrivateKey() PrivateKey
- func (account *AccountOneLedger) PublicKey() PublicKey
- func (account *AccountOneLedger) String() string
- type Accounts
- func (acc *Accounts) Add(account Account)
- func (acc *Accounts) Close()
- func (acc *Accounts) Delete(account Account)
- func (acc *Accounts) Dump()
- func (acc *Accounts) Exists(newType data.ChainType, name string) bool
- func (acc *Accounts) Find(account Account) (Account, status.Code)
- func (acc *Accounts) FindAll() []Account
- func (acc *Accounts) FindIdentity(identity Identity) (Account, status.Code)
- func (acc *Accounts) FindKey(key AccountKey) (Account, status.Code)
- func (acc *Accounts) FindName(name string) (Account, status.Code)
- func (acc *Accounts) FindNameOnChain(name string, chain data.ChainType) (Account, status.Code)
- type ApplyValidator
- type DataPrivledge
- type Group
- type Identities
- func (ids *Identities) Add(identity Identity)
- func (ids *Identities) Close()
- func (ids *Identities) Delete()
- func (ids *Identities) Dump()
- func (ids *Identities) Exists(name string) bool
- func (ids *Identities) FindAll() []Identity
- func (ids *Identities) FindKey(accountKey AccountKey) Identity
- func (ids *Identities) FindName(name string) (Identity, status.Code)
- func (ids *Identities) FindTendermint(tendermintAddress string) Identity
- type Identity
- type KeyAlgorithm
- type PrivateKey
- type PrivateKeyED25519
- type PrivateKeySECP256K1
- type PublicKey
- type PublicKeyED25519
- type PublicKeySECP256K1
- type RolePrivledge
- type SequenceRecord
- type Signature
- type ValidatorInfo
- type Validators
- func (list *Validators) FindApproved(app interface{}) []Identity
- func (list *Validators) FindSelectedValidator(app interface{}, hash []byte) Identity
- func (list Validators) IsValidAccountKey(key AccountKey, index int) bool
- func (list *Validators) Set(app interface{}, validators []types.SigningValidator, ...)
- type Wallet
Constants ¶
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 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 GetSequence ¶ added in v0.8.0
func GetSmartContracts ¶ added in v0.8.0
func GetTendermintValidator ¶ added in v0.8.0
func HasValidatorToken ¶ added in v0.8.0
func IsByzantine ¶ added in v0.8.0
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 (*Accounts) FindIdentity ¶
type ApplyValidator ¶ added in v0.8.1
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) 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 (*Identity) IsExternal ¶
func (*Identity) Key ¶
func (id *Identity) Key() data.DatabaseKey
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 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
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
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 ValidatorInfo ¶ added in v0.8.0
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)