identity

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapWithType

func WrapWithType(idType Type, id driver.Identity) (driver.Identity, error)

Types

type Binder

type Binder interface {
	Bind(longTerm driver.Identity, ephemeral driver.Identity) error
}

type Deserializer

type Deserializer interface {
	// DeserializeSigner deserializes a signer from its bytes representation
	DeserializeSigner(raw []byte) (driver.Signer, error)
}

Deserializer is an interface for deserializing identities

type EnrollmentIDUnmarshaler

type EnrollmentIDUnmarshaler interface {
	// GetEnrollmentID returns the enrollment ID from the audit info
	GetEnrollmentID(identity driver.Identity, auditInfo []byte) (string, error)
	// GetRevocationHandler returns the revocation handle from the audit info
	GetRevocationHandler(identity driver.Identity, auditInfo []byte) (string, error)
	// GetEIDAndRH returns both enrollment ID and revocation handle
	GetEIDAndRH(identity driver.Identity, auditInfo []byte) (string, string, error)
}

EnrollmentIDUnmarshaler decodes an enrollment ID form an audit info

type Identity

type Identity = driver.Identity

type Keystore

type Keystore interface {
	Put(id string, state interface{}) error
	Get(id string, state interface{}) error
}

type Provider

type Provider struct {
	SigService sigService
	Binder     Binder
	Storage    Storage
	// contains filtered or unexported fields
}

Provider implements the driver.IdentityProvider interface. Provider handles the long-term identities on top of which wallets are defined.

func NewProvider

func NewProvider(Storage Storage, sigService sigService, binder Binder, enrollmentIDUnmarshaler EnrollmentIDUnmarshaler) *Provider

NewProvider creates a new identity provider implementing the driver.IdentityProvider interface. The Provider handles the long-term identities on top of which wallets are defined.

func (*Provider) Bind

func (p *Provider) Bind(longTerm driver.Identity, ephemeral driver.Identity, copyAll bool) error

func (*Provider) GetAuditInfo

func (p *Provider) GetAuditInfo(identity driver.Identity) ([]byte, error)

func (*Provider) GetEIDAndRH

func (p *Provider) GetEIDAndRH(identity driver.Identity, auditInfo []byte) (string, string, error)

func (*Provider) GetEnrollmentID

func (p *Provider) GetEnrollmentID(identity driver.Identity, auditInfo []byte) (string, error)

func (*Provider) GetRevocationHandler

func (p *Provider) GetRevocationHandler(identity driver.Identity, auditInfo []byte) (string, error)

func (*Provider) GetSigner

func (p *Provider) GetSigner(identity driver.Identity) (driver.Signer, error)

func (*Provider) IsMe

func (p *Provider) IsMe(identity driver.Identity) bool

func (*Provider) RegisterAuditInfo

func (p *Provider) RegisterAuditInfo(identity driver.Identity, info []byte) error

func (*Provider) RegisterRecipientData

func (p *Provider) RegisterRecipientData(data *driver.RecipientData) error

func (*Provider) RegisterRecipientIdentity

func (p *Provider) RegisterRecipientIdentity(id driver.Identity) error

func (*Provider) RegisterSigner

func (p *Provider) RegisterSigner(identity driver.Identity, signer driver.Signer, verifier driver.Verifier, signerInfo []byte) error

func (*Provider) RegisterVerifier

func (p *Provider) RegisterVerifier(identity driver.Identity, v driver.Verifier) error

type Role

type Role interface {
	// ID returns the identifier of this role
	ID() driver.IdentityRole
	// MapToID returns the long-term identity and its identifier for the given index.
	// The index can be an identity or a label (string).
	MapToID(v driver.WalletLookupID) (driver.Identity, string, error)
	// GetIdentityInfo returns the long-term identity info associated to the passed id
	GetIdentityInfo(id string) (driver.IdentityInfo, error)
	// RegisterIdentity registers the given identity
	RegisterIdentity(config driver.IdentityConfiguration) error
	// IdentityIDs returns the identifiers contained in this role
	IdentityIDs() ([]string, error)
}

Role is a container of long-term identities. A long-term identity is then used to construct a wallet.

type Roles

type Roles map[driver.IdentityRole]Role

Roles is a map of Role, one for each identity role

func NewRoles

func NewRoles() Roles

NewRoles returns a new Roles maps

func (Roles) Register

func (m Roles) Register(usage driver.IdentityRole, role Role)

Register associates an instance of Role to a given identifier

type Storage

type Storage interface {
	GetAuditInfo(id []byte) ([]byte, error)
	StoreIdentityData(id []byte, identityAudit []byte, tokenMetadata []byte, tokenMetadataAudit []byte) error
}

type StorageProvider

type StorageProvider interface {
	OpenWalletDB(tmsID token.TMSID) (driver.WalletDB, error)
	OpenIdentityDB(tmsID token.TMSID) (driver.IdentityDB, error)
	NewKeystore() (Keystore, error)
}

func GetStorageProvider

func GetStorageProvider(sp token.ServiceProvider) (StorageProvider, error)

GetStorageProvider returns the registered instance of StorageProvider from the passed service provider

type Type

type Type = string

type TypedIdentity

type TypedIdentity struct {
	// Type encodes the type of the identity
	Type Type `protobuf:"bytes,1,opt,name=type,json=type,proto3" json:"type,omitempty"`
	// Identity encodes the identity itself
	Identity Identity `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"`
}

TypedIdentity encodes an identity with a type.

func UnmarshalTypedIdentity

func UnmarshalTypedIdentity(id driver.Identity) (*TypedIdentity, error)

func (TypedIdentity) Bytes

func (i TypedIdentity) Bytes() ([]byte, error)

type WalletRegistry

type WalletRegistry struct {
	Role    Role
	Storage db.WalletDB

	Wallets map[string]driver.Wallet
}

WalletRegistry manages wallets whose long-term identities have a given role.

func NewWalletRegistry

func NewWalletRegistry(role Role, storage db.WalletDB) *WalletRegistry

NewWalletRegistry returns a new registry for the passed parameters. A registry is bound to a given role, and it is persistent. Long-term identities are provided by the passed identity provider

func (*WalletRegistry) BindIdentity

func (r *WalletRegistry) BindIdentity(identity driver.Identity, eID string, wID string, meta any) error

BindIdentity binds the passed identity to the passed wallet identifier. Additional metadata can be bound to the identity.

func (*WalletRegistry) ContainsIdentity

func (r *WalletRegistry) ContainsIdentity(identity driver.Identity, wID string) bool

ContainsIdentity returns true if the passed identity belongs to the passed wallet, false otherwise

func (*WalletRegistry) GetIdentityMetadata

func (r *WalletRegistry) GetIdentityMetadata(identity driver.Identity, wID string, meta any) error

GetIdentityMetadata loads metadata bound to the passed identity into the passed meta argument

func (*WalletRegistry) GetWalletID

func (r *WalletRegistry) GetWalletID(identity driver.Identity) (string, error)

GetWalletID returns the wallet identifier bound to the passed identity

func (*WalletRegistry) Lookup

Lookup searches the wallet corresponding to the passed id. If a wallet is found, Lookup returns the wallet and its identifier. If no wallet is found, Lookup returns the identity info and a potential wallet identifier for the passed id, if anything is found

func (*WalletRegistry) RegisterIdentity

func (r *WalletRegistry) RegisterIdentity(config driver.IdentityConfiguration) error

func (*WalletRegistry) RegisterWallet

func (r *WalletRegistry) RegisterWallet(id string, w driver.Wallet) error

RegisterWallet binds the passed wallet to the passed id

func (*WalletRegistry) WalletIDs

func (r *WalletRegistry) WalletIDs() ([]string, error)

WalletIDs returns the list of wallet identifiers

Directories

Path Synopsis
interop
msp
storage
kvs/hashicorp module

Jump to

Keyboard shortcuts

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