ssi

package
v0.25.25 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Edge agents are the agents which are at the end of the agent route. They
	// are the final endpoint of the agent messages. In the agency we can have
	// pure EAs when CLI is used, or we can have Worker EAs which are working
	// together with their Cloud Agent.
	Edge = 0x01

	// Worker is an Edge Agent in the Cloud. Workers are used to allow EAs to
	// have endpoints inside to identity domain. Worker EAs can be always on,
	// and listen their endpoints. These cloud EAs have their own wallets,
	// which can be copied to actual EA's device if needed.
	Worker = 0x02
)

Please be noted that Cloud Agent is the default value.

View Source
const WalletAlreadyExistsError = 203

Variables

View Source
var Wallets = &Mgr{
	opened: make(WalletMap, maxOpened),
}

Functions

func ClosePool

func ClosePool()

func CredDefFromLedger

func CredDefFromLedger(DID, credDefID string) (cd string, err error)

func Pool

func Pool() (v int)

func SetWalletMgrPoolSize added in v0.25.24

func SetWalletMgrPoolSize(s int)

SetWalletMgrPoolSize sets pool size, i.e. how many wallets can kept open in the same time. This should be set at the startup of the application or service.

Types

type Agent

type Agent interface {
	AgentType
	Wallet() (h int)
	RootDid() *DID
	CreateDID(seed string) (agentDid *DID)
	SendNYM(targetDid *DID, submitterDid, alias, role string) error
	AddDIDCache(DID *DID)
}

type AgentType

type AgentType interface {
	IsCA() bool
	IsEA() bool
}

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cache is keeps DIDs in memory per agent because they are so slow to load from wallet. Cache is not thread safe because this is not a global cache but per Agent.

func (*Cache) Add

func (c *Cache) Add(d *DID)

Add is for the cases when DID is ready, like we know the DID`s name already.

func (*Cache) Clone added in v0.25.22

func (c *Cache) Clone() Cache

func (*Cache) Get

func (c *Cache) Get(s string, sure bool) *DID

Get to DID by name from cache. With sure we can tell to panic if DID not found. That's development time use case, and normal cases the caller should check the return value.

func (*Cache) LazyAdd

func (c *Cache) LazyAdd(s string, d *DID)

LazyAdd is for the cases when we know the DID's name but the key is not yet fetched i.e. DID is launched to get key.

type DID

type DID struct {
	sync.Mutex // when setting Future ptrs making sure that happens atomically
	// contains filtered or unexported fields
}

DID is an application framework level wrapper for findy.DID implementation. Uses Future to async processing of the findy.Channel results.

func NewAgentDid

func NewAgentDid(wallet managed.Wallet, f *Future) (ad *DID)

func NewDid

func NewDid(did, verkey string) (d *DID)

func NewDidWithKeyFuture

func NewDidWithKeyFuture(wallet managed.Wallet, did string, verkey *Future) (d *DID)

func (*DID) AEndp

func (d *DID) AEndp() (ae service.Addr, err error)

func (*DID) Did

func (d *DID) Did() string

func (*DID) Endpoint

func (d *DID) Endpoint() string

func (*DID) Pairwise

func (d *DID) Pairwise(wallet int, theirDID *DID, meta string)

func (*DID) SetAEndp

func (d *DID) SetAEndp(ae service.Addr)

func (*DID) SetWallet

func (d *DID) SetWallet(w managed.Wallet)

func (*DID) StartEndp

func (d *DID) StartEndp(wallet int)

func (*DID) Store

func (d *DID) Store(wallet int)

Store stores this DID as their DID to given wallet. Work is done thru futures so the call doesn't block. The meta data is set "pairwise". See StoreResult() for status.

func (*DID) StoreResult

func (d *DID) StoreResult() error

StoreResult returns error status of the Store() functions result. If storing their DID and related meta and pairwise data isn't ready, this call blocks.

func (*DID) URI

func (d *DID) URI() string

func (*DID) VerKey

func (d *DID) VerKey() (vk string)

func (*DID) Wallet

func (d *DID) Wallet() int

type DIDAgent

type DIDAgent struct {
	WalletH managed.Wallet

	// result future of the wallet export, one time attr, obsolete soon
	Export Future

	// the Root DID which gives us rights to write ledger
	Root *DID

	// keep 'all' DIDs for performance reasons as well as better usability of our APIs
	DidCache Cache

	// Agent type: CA, EA, Worker, etc.
	Type Type

	sync.Mutex // Currently saImplID makes the agent mutable

	EAEndp *service.Addr // EA endpoint if set, used for SA API and notifications
	// contains filtered or unexported fields
}

DIDAgent is the main abstraction of the package together with Agency. The agent started as a CA but has been later added support for EAs and worker/cloud-EA as well. This might be something we will change later. DIDAgent's most important task is/WAS to receive Payloads and process Messages inside them. And there are lots of stuff to support that. That part of code is heavily under construction.

More concrete parts of the DIDAgent are support for wallet, root DID, did cache. Web socket connections are more like old relic, and that will change in future for something else. It WAS part of the protocol STATE management.

Please be noted that DIDAgent or more precisely CA is singleton by its nature per EA it serves. So, Cloud DIDAgent is a gateway to world for EA it serves. EAs are mostly in mobile devices and handicapped by their nature. In our latest architecture CA serves EA by creating a worker EA which lives in the cloud as well. For now, in the most cases we have pair or agents serving each mobile EAs here in the cloud: CA and w-EA.

There is DIDAgent.Type where this DIDAgent can be EA only. That type is used for test and CLI Go clients.

func (*DIDAgent) AddDIDCache

func (a *DIDAgent) AddDIDCache(DID *DID)

func (*DIDAgent) AssertWallet

func (a *DIDAgent) AssertWallet()

func (*DIDAgent) CloseWallet

func (a *DIDAgent) CloseWallet()

func (*DIDAgent) CreateDID

func (a *DIDAgent) CreateDID(seed string) (agentDid *DID)

CreateDID creates a new DID thru the Future which means that returned *DID follows 'lazy fetch' principle. You should call this as early as possible for the performance reasons. Most cases seed should be empty string.

func (*DIDAgent) FindPW

func (a *DIDAgent) FindPW(my string) (their string, pwname string, err error)

FindPW finds pairwise by name. This is a ReceiverEndp interface method.

func (*DIDAgent) IsCA

func (a *DIDAgent) IsCA() bool

func (*DIDAgent) IsEA

func (a *DIDAgent) IsEA() bool

func (*DIDAgent) IsWorker

func (a *DIDAgent) IsWorker() bool

func (*DIDAgent) LoadDID

func (a *DIDAgent) LoadDID(did string) *DID

func (*DIDAgent) OpenDID

func (a *DIDAgent) OpenDID(name string) *DID

func (*DIDAgent) OpenPool

func (a *DIDAgent) OpenPool(name string)

func (*DIDAgent) OpenWallet

func (a *DIDAgent) OpenWallet(aw Wallet)

func (*DIDAgent) Pairwise

func (a *DIDAgent) Pairwise(name string) (my string, their string, err error)

func (*DIDAgent) Pool

func (a *DIDAgent) Pool() (v int)

func (*DIDAgent) RootDid

func (a *DIDAgent) RootDid() *DID

func (*DIDAgent) SAImplID

func (a *DIDAgent) SAImplID() string

func (*DIDAgent) SaveTheirDID

func (a *DIDAgent) SaveTheirDID(did, vk string) (err error)

func (*DIDAgent) SendNYM

func (a *DIDAgent) SendNYM(
	targetDid *DID,
	submitterDid,
	alias,
	role string,
) (err error)

func (*DIDAgent) SetRootDid

func (a *DIDAgent) SetRootDid(rootDid *DID)

func (*DIDAgent) SetSAImplID added in v0.25.3

func (a *DIDAgent) SetSAImplID(id string)

func (*DIDAgent) Wallet

func (a *DIDAgent) Wallet() (h int)

type DidComm

type DidComm interface {
	Did() string
}

type Future

type Future struct {
	On State
	V  interface{}
	// contains filtered or unexported fields
}

func NewFuture

func NewFuture(ch findy.Channel) *Future

NewFuture changes the existing findy.Channel to a Future.

func OpenPool

func OpenPool(name string) *Future

Open opens ledger connection first time called. After that returns previous handle without checking the pool name. If caller wants to reopen new pool it must call ClosePool() first.

Note! We could have unit tests working with out ledger by reserving certain ledger handle and name, but that should be done in the indy Go wrapper

func (*Future) Bytes

func (f *Future) Bytes() (b []byte)

func (*Future) Int

func (f *Future) Int() (i int)

func (*Future) IsEmpty

func (f *Future) IsEmpty() bool

func (*Future) Result

func (f *Future) Result() (dtoResult *dto.Result)

func (*Future) SetChan

func (f *Future) SetChan(ch findy.Channel)

SetChan sets the existing findy.Channel to this Future.

func (*Future) Str1

func (f *Future) Str1() string

func (*Future) Str2

func (f *Future) Str2() string

func (*Future) Strs

func (f *Future) Strs() (s1, s2, s3 string)

type Handle

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

Handle implements ManagedWallet interface. These types together offer an API to use SSI wallets conveniently. They hide closing and opening logic which is needed to reserve OS level file handles. Only limited amount of simultaneous wallet handles is kept open (MaxOpen). See more information from API function descriptions.

func (*Handle) Close

func (h *Handle) Close()

Close frees the wallet handle to reuse by WalletMgr. Please note that it's NOT important or desired to call this function during the agency process is running.

func (*Handle) Config

func (h *Handle) Config() managed.WalletCfg

Config returns managed wallet's associated indy wallet configuration.

func (*Handle) Handle

func (h *Handle) Handle() int

Handle returns the actual indy wallet handle which can be used with indy SDK API calls. The Handle function hides all the needed complexity behind it. For example, if the actual libindy wallet handle is already closed, it will be opened first. Please note that there is no performance penalty i.e. no optimization is needed.

type In

type In interface {
	Out
	Wallet() int
}

type Mgr

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

func (*Mgr) Open

func (m *Mgr) Open(cfg Wallet) managed.Wallet

Open opens a wallet configuration and returns a managed wallet.

func (*Mgr) Reset

func (m *Mgr) Reset()

Reset resets the managed wallet buffer which means that all the current wallet configurations must be registered again with ssi.Wallets.Open. Note! You should not need to use this!

type Out

type Out interface {
	DidComm
	VerKey() string
	Endpoint() string                      // refactor
	AEndp() (ae service.Addr, error error) // refactor
}

type Schema

type Schema struct {
	ID      string   `json:"id,omitempty"`      // ID from Indy/Ledger
	Name    string   `json:"name,omitempty"`    // name of the schema
	Version string   `json:"version,omitempty"` // version number in string
	Attrs   []string `json:"attrs,omitempty"`   // attribute string list
	Stored  *Future  `json:"-"`                 // info from ledger
}

func (*Schema) Create

func (s *Schema) Create(DID string) (err error)

func (*Schema) FromLedger

func (s *Schema) FromLedger(DID string) (err error)

func (*Schema) LazySchema

func (s *Schema) LazySchema() string

func (*Schema) ToLedger

func (s *Schema) ToLedger(wallet int, DID string) error

func (*Schema) ValidID

func (s *Schema) ValidID() string

type State

type State uint32
const (
	Consumed State
)

type Type

type Type int

Type of the agent instance. In most cases it's Cloud Agent (CA). Which is the the default value.

type Wallet

type Wallet struct {
	Config      wallet.Config
	Credentials wallet.Credentials
	// contains filtered or unexported fields
}

func NewRawWalletCfg

func NewRawWalletCfg(name, key string) (w *Wallet)

func NewWalletCfg

func NewWalletCfg(name, key string) (w *Wallet)

func (*Wallet) Close

func (w *Wallet) Close(handle int) (f *Future)

func (*Wallet) Create

func (w *Wallet) Create() (exist bool)

func (*Wallet) Exists

func (w *Wallet) Exists(worker bool) bool

func (*Wallet) ID

func (w *Wallet) ID() string

func (*Wallet) Key

func (w *Wallet) Key() string

func (*Wallet) Open

func (w *Wallet) Open() (f *Future)

func (*Wallet) SetID

func (w *Wallet) SetID(id string)

func (*Wallet) SetKey

func (w *Wallet) SetKey(key string)

func (*Wallet) SetKeyMethod

func (w *Wallet) SetKeyMethod(m string)

func (*Wallet) StartCreation

func (w *Wallet) StartCreation() (f *Future)

func (*Wallet) SyncClose

func (w *Wallet) SyncClose(handle int) (err error)

func (*Wallet) SyncOpen

func (w *Wallet) SyncOpen() int

func (*Wallet) UniqueID

func (w *Wallet) UniqueID() string

func (Wallet) WorkerWallet

func (w Wallet) WorkerWallet() *Wallet

WorkerWallet makes a copy of the wallet cfg, normally CA`s wallet

func (Wallet) WorkerWalletBy

func (w Wallet) WorkerWalletBy(suffix string) *Wallet

WorkerWalletBy makes a copy of the wallet cfg which name ends with suffix

type WalletMap

type WalletMap map[string]*Handle

Jump to

Keyboard shortcuts

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