ssi

package
v0.30.38 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: Apache-2.0 Imports: 32 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 ErrNoData = fmt.Errorf("no data")

Functions

func AgentStorage added in v0.30.8

func AgentStorage(h int) api.AgentStorage

func NewDoc added in v0.30.15

func NewDoc(did core.DID, ae service.Addr) *sov.Doc

NewDoc creates a new DIDDoc for the DID. Uses our legacy Doc.

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)
	ManagedWallet() (managed.Wallet, managed.Wallet)
	RootDid() core.DID
	// CreateDID(seed string) (agentDid core.DID)
	NewDID(m method.Type, args ...string) (_ core.DID, err error)
	NewOutDID(didInfo ...string) (id core.DID, err error)
	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 *async.Future) (ad *DID)

func NewDIDWithRouting added in v0.30.9

func NewDIDWithRouting(_ string, verkey ...string) (d *DID)

func NewDid

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

func NewDidWithKeyFuture

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

func NewOutDid added in v0.25.27

func NewOutDid(verkey string, route []string) (d *DID)

func (*DID) AEndp

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

func (*DID) DOC added in v0.30.15

func (d *DID) DOC() core.DIDDoc

func (*DID) Did

func (d *DID) Did() string

func (*DID) Endpoint

func (d *DID) Endpoint() string

func (*DID) KID added in v0.30.4

func (d *DID) KID() string

KID returns a KMS specific key ID that can be used to Get KH from KMS.

func (*DID) KMS added in v0.30.8

func (d *DID) KMS() *indy.KMS

func (*DID) NewDoc added in v0.30.15

func (d *DID) NewDoc(ae service.Addr) core.DIDDoc

func (*DID) Packager added in v0.30.8

func (d *DID) Packager() api.Packager

func (*DID) RecipientKeys added in v0.30.15

func (d *DID) RecipientKeys() []string

func (*DID) Route added in v0.25.27

func (d *DID) Route() []string

Route returns only routing keys not the actual receiver key.

func (*DID) SavePairwiseForDID added in v0.25.26

func (d *DID) SavePairwiseForDID(mStorage managed.Wallet, tDID core.DID, pw core.PairwiseMeta)

func (*DID) SetAEndp

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

func (*DID) SetWallet

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

func (*DID) SignKey added in v0.30.4

func (d *DID) SignKey() any

SignKey return a indy.Handle including wallet SDK handle (int) and a VerKey TODO: Let's think if wee need a KID for there as well

func (*DID) StartEndp

func (d *DID) StartEndp(storageH managed.Wallet, connectionID string)

func (*DID) Storage added in v0.30.4

func (d *DID) Storage() managed.Wallet

func (*DID) Store

func (d *DID) Store(mgdWallet, mgdStorage managed.Wallet)

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) String added in v0.30.4

func (d *DID) String() string

String returns a string in DID format e.g. 'did:sov:xxx..'

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
	StorageH managed.Wallet

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

	// the Root DID which gives us rights to write ledger
	Root core.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) ConnectionStorage added in v0.30.4

func (a *DIDAgent) ConnectionStorage() storage.ConnectionStorage

func (*DIDAgent) DIDStorage added in v0.30.4

func (a *DIDAgent) DIDStorage() storage.DIDStorage

func (*DIDAgent) FindPWByID added in v0.30.14

func (a *DIDAgent) FindPWByID(id string) (pw *storage.Connection, err error)

FindPWByID finds pairwise by id. This is a ReceiverEndp interface method.

func (*DIDAgent) FindPWByName added in v0.25.26

func (a *DIDAgent) FindPWByName(name string) (pw *storage.Connection, err error)

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) KMS added in v0.30.4

func (a *DIDAgent) KMS() kms.KeyManager

func (*DIDAgent) LoadDID

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

func (*DIDAgent) LoadTheirDID added in v0.25.27

func (a *DIDAgent) LoadTheirDID(connection storage.Connection) core.DID

func (*DIDAgent) ManagedStorage added in v0.30.7

func (a *DIDAgent) ManagedStorage() managed.Wallet

func (*DIDAgent) ManagedWallet added in v0.30.0

func (a *DIDAgent) ManagedWallet() (managed.Wallet, managed.Wallet)

func (*DIDAgent) NewDID added in v0.30.4

func (a *DIDAgent) NewDID(didMethod method.Type, args ...string) (_ core.DID, err error)

func (*DIDAgent) NewOutDID added in v0.30.4

func (a *DIDAgent) NewOutDID(didInfo ...string) (id core.DID, err error)

func (*DIDAgent) OpenDID

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

OpenDID NOTE! Used by steward only.

func (*DIDAgent) OpenPool

func (a *DIDAgent) OpenPool(name string)

func (*DIDAgent) OpenWallet

func (a *DIDAgent) OpenWallet(aw Wallet)

func (*DIDAgent) Pool

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

func (*DIDAgent) RootDid

func (a *DIDAgent) RootDid() core.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 core.DID)

func (*DIDAgent) SetSAImplID added in v0.25.3

func (a *DIDAgent) SetSAImplID(id string)

func (*DIDAgent) Storage added in v0.30.7

func (a *DIDAgent) Storage() storage.AgentStorage

Storage returns TEMPORARY agent storage object pointer. Note!! You should newer store it, only use by once, even in every single line of code.

func (*DIDAgent) VDR added in v0.30.4

func (a *DIDAgent) VDR() *vdr.VDR

func (*DIDAgent) Wallet

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

type DidComm

type DidComm interface {
	Did() string
	Storage() managed.Wallet
}

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.

func (*Handle) Storage added in v0.30.0

func (h *Handle) Storage() api.AgentStorage

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 managed.WalletCfg) 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
	Route() []string
	Endpoint() string                    // refactor
	AEndp() (ae service.Addr, err error) // refactor
}

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 *async.Future)

func (*Wallet) CloseWallet added in v0.30.7

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

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 *async.Future)

func (*Wallet) OpenWallet added in v0.30.7

func (w *Wallet) OpenWallet() (h int, err error)

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) UniqueID

func (w *Wallet) UniqueID() string

func (*Wallet) WantsBackup added in v0.30.7

func (w *Wallet) WantsBackup() bool

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