identity

package
v0.0.0-...-be0919c Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExtractor

func NewExtractor() *extractor

NewExtractor constructs Extractor instance

func NewIdentityManager

func NewIdentityManager(keystore Keystore) *identityManager

NewIdentityManager creates and returns new identityManager

func NewIdentityManagerFake

func NewIdentityManagerFake(existingIdentities []Identity, newIdentity Identity) *idmFake

func NewKeystoreFilesystem

func NewKeystoreFilesystem(directory string) *keystore.KeyStore

NewKeystoreFilesystem create new keystore, which keeps keys in filesystem

func NewVerifierIdentity

func NewVerifierIdentity(peerID Identity) *verifierIdentity

NewVerifierIdentity constructs Verifier which:

  • checks signature's sanity
  • checks if message was unchanged by middleman
  • checks if message is from exact identity

func NewVerifierSigned

func NewVerifierSigned() *verifierSigned

NewVerifierSigned constructs Verifier which:

  • checks signature's sanity
  • checks if message was unchanged by middleman

Types

type Extractor

type Extractor interface {
	Extract(message []byte, signature Signature) (Identity, error)
}

Extractor is able to message signer's identity

type Identity

type Identity struct {
	Address string `json:"address"`
}

Identity represents unique user network identity

func FromAddress

func FromAddress(address string) Identity

FromAddress converts address to identity

type IdentityCache

type IdentityCache struct {
	File string
}

IdentityCache saves identity to file

func (*IdentityCache) GetIdentity

func (ic *IdentityCache) GetIdentity() (identity Identity, err error)

GetIdentity retrieves identity from cache

func (*IdentityCache) StoreIdentity

func (ic *IdentityCache) StoreIdentity(identity Identity) error

StoreIdentity stores identity to cache

type IdentityCacheInterface

type IdentityCacheInterface interface {
	GetIdentity() (identity Identity, err error)
	StoreIdentity(identity Identity) error
}

IdentityCacheInterface allows caching single identity

func NewIdentityCache

func NewIdentityCache(dir string, jsonFile string) IdentityCacheInterface

NewIdentityCache creates and returns identityCache

func NewIdentityCacheFake

func NewIdentityCacheFake() IdentityCacheInterface

NewIdentityCacheFake creates and returns fake identity cache

type Keystore

type Keystore interface {
	Accounts() []accounts.Account
	NewAccount(passphrase string) (accounts.Account, error)
	Find(a accounts.Account) (accounts.Account, error)
	Unlock(a accounts.Account, passphrase string) error
	SignHash(a accounts.Account, hash []byte) ([]byte, error)
}

Keystore allows actions with accounts (listing, creating, unlocking, signing)

type Manager

type Manager interface {
	CreateNewIdentity(passphrase string) (Identity, error)
	GetIdentities() []Identity
	GetIdentity(address string) (Identity, error)
	HasIdentity(address string) bool
	Unlock(address string, passphrase string) error
}

type Signature

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

Signature structure

func SignatureBase64

func SignatureBase64(signature string) Signature

SignatureBase64 decodes base64 string signature into Signature

func SignatureBytes

func SignatureBytes(signatureBytes []byte) Signature

SignatureBytes constructs Signature structure instance from bytes

func SignatureHex

func SignatureHex(signature string) Signature

SignatureHex returns Signature struct from hex string

func (*Signature) Base64

func (signature *Signature) Base64() string

Base64 encodes signature into Base64 format

func (*Signature) Bytes

func (signature *Signature) Bytes() []byte

Bytes returns signature in raw bytes format

func (Signature) EqualsTo

func (signature Signature) EqualsTo(other Signature) bool

EqualsTo compares current signature with a given one

type Signer

type Signer interface {
	Sign(message []byte) (Signature, error)
}

Signer interface signifies an ability ti sign a message

func NewSigner

func NewSigner(keystore Keystore, identity Identity) Signer

NewSigner returns new instance of Signer

type SignerFactory

type SignerFactory func(id Identity) Signer

SignerFactory callback returning Signer

type SignerFake

type SignerFake struct {
	ErrorMock error
}

func (*SignerFake) Sign

func (signer *SignerFake) Sign(message []byte) (Signature, error)

type Verifier

type Verifier interface {
	Verify(message []byte, signature Signature) bool
}

Verifier checks message's sanity

type VerifierFake

type VerifierFake struct{}

func (*VerifierFake) Verify

func (verifier *VerifierFake) Verify(message []byte, signature Signature) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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