driver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	// IssuerRole is the role of an issuer
	IssuerRole = iota
	// AuditorRole is the role of an auditor
	AuditorRole
	// OwnerRole is the role of an owner
	OwnerRole
	// CertifierRole is the role of a certifier
	CertifierRole
)

Variables

This section is empty.

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

func MarshalMeta

func MarshalMeta(v map[string][]byte) ([]byte, error)

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

func UnmarshalMeta

func UnmarshalMeta(raw []byte) (map[string][]byte, error)

Types

type AuditorService

type AuditorService interface {
	// AuditorCheck verifies the well-formedness of the passed request with the respect to the passed metadata and anchor
	AuditorCheck(request *TokenRequest, metadata *TokenRequestMetadata, anchor string) error
}

AuditorService models the auditor service

type AuditorWallet

type AuditorWallet interface {
	Wallet

	// GetAuditorIdentity returns an auditor identity.
	// Depending on the underlying wallet implementation, this can be a long-term or ephemeral identity.
	GetAuditorIdentity() (view.Identity, error)
}

AuditorWallet models the wallet of an auditor

type CertificationClient

type CertificationClient interface {
	IsCertified(id *token2.ID) bool
	RequestCertification(ids ...*token2.ID) error
}

type CertificationService

type CertificationService interface {
	NewCertificationRequest(ids []*token2.ID) ([]byte, error)
	Certify(wallet CertifierWallet, ids []*token2.ID, tokens [][]byte, request []byte) ([][]byte, error)
	VerifyCertifications(ids []*token2.ID, certifications [][]byte) error
}

type CertificationStorage

type CertificationStorage interface {
	Exists(id *token.ID) bool
	Store(certifications map[*token.ID][]byte) error
}

type CertifierWallet

type CertifierWallet interface {
	Wallet

	// GetCertifierIdentity returns a certifier identity.
	// Depending on the underlying wallet implementation, this can be a long-term or ephemeral identity.
	GetCertifierIdentity() (view.Identity, error)
}

CertifierWallet models the wallet of a certifier

type Deserializer

type Deserializer interface {
	// GetOwnerVerifier returns the verifier associated to the passed owner identity
	GetOwnerVerifier(id view.Identity) (Verifier, error)
	// GetIssuerVerifier returns the verifier associated to the passed issuer identity
	GetIssuerVerifier(id view.Identity) (Verifier, error)
	// GetAuditorVerifier returns the verifier associated to the passed auditor identity
	GetAuditorVerifier(id view.Identity) (Verifier, error)
	// GetOwnerMatcher returns an identity matcher for the passed identity audit data.
	GetOwnerMatcher(auditData []byte) (Matcher, error)
}

Deserializer models the deserializer of owner, issuer, and auditor identities to get signature verifiers

type Driver

type Driver interface {
	// PublicParametersFromBytes unmarshals the bytes to a PublicParameters instance.
	PublicParametersFromBytes(params []byte) (PublicParameters, error)
	// NewTokenService returns a new TokenManagerService instance.
	NewTokenService(sp view.ServiceProvider, publicParamsFetcher PublicParamsFetcher, network string, channel string, namespace string) (TokenManagerService, error)
	// NewPublicParametersManager returns a new PublicParametersManager instance from the passed public parameters
	NewPublicParametersManager(pp PublicParameters) (PublicParamsManager, error)
	// NewValidator returns a new Validator instance from the passed public parameters
	NewValidator(pp PublicParameters) (Validator, error)
}

Driver is the interface that must be implemented by a token driver.

type ExtendedDriver added in v0.3.0

type ExtendedDriver interface {
	NewWalletService(sp view.ServiceProvider, network string, channel string, namespace string, params PublicParameters) (WalletService, error)
}

type GetStateFnc

type GetStateFnc = func(key string) ([]byte, error)

GetStateFnc models a function that returns the value for the given key from the ledger

type IdentityInfo

type IdentityInfo interface {
	// ID returns the ID of the Identity
	ID() string
	// EnrollmentID returns the enrollment ID of the Identity
	EnrollmentID() string
	// Get returns the identity and it is audit info.
	// Get might return a different identity at each call depending on the implementation.
	Get() (view.Identity, []byte, error)
}

IdentityInfo models an Identity inside the Identity Provider

type IdentityProvider

type IdentityProvider interface {
	LookupIdentifier(role IdentityRole, v interface{}) (view.Identity, string, error)

	// GetIdentityInfo returns the long-term identity info associated to the passed id, nil if not found.
	GetIdentityInfo(role IdentityRole, id string) (IdentityInfo, error)

	// GetAuditInfo returns the audit information associated to the passed identity, nil otherwise
	GetAuditInfo(identity view.Identity) ([]byte, error)

	// GetSigner returns a Signer for passed identity.
	GetSigner(identity view.Identity) (Signer, error)

	// RegisterSigner registers a Signer and a Verifier for passed identity.
	RegisterSigner(identity view.Identity, signer Signer, verifier Verifier) error

	// IsMe returns true if a signer was ever registered for the passed identity
	IsMe(party view.Identity) bool

	// GetEnrollmentID extracts the enrollment ID from the passed audit info
	GetEnrollmentID(auditInfo []byte) (string, error)

	// GetRevocationHandler extracts the revocation handler from the passed audit info
	GetRevocationHandler(auditInfo []byte) (string, error)

	// Bind binds id to the passed identity long term identity. The same signer, verifier, and audit of the long term
	// identity is associated to id.
	Bind(id view.Identity, longTerm view.Identity) error

	// RegisterRecipientIdentity register the passed identity as a third-pary recipient identity.
	RegisterRecipientIdentity(id view.Identity) error

	// RegisterOwnerWallet registers the passed wallet as the owner wallet of the passed identity.
	RegisterOwnerWallet(id string, path string) error

	// RegisterIssuerWallet registers the passed wallet ad the issuer wallet of the passed identity.
	RegisterIssuerWallet(id string, path string) error

	WalletIDs(role IdentityRole) ([]string, error)
}

IdentityProvider handles the long-term identities on top of which wallets are defined.

type IdentityRole

type IdentityRole int

IdentityRole is the role of an identity

type IssueAction

type IssueAction interface {
	// Serialize returns the serialized version of the action
	Serialize() ([]byte, error)
	// NumOutputs returns the number of outputs of the action
	NumOutputs() int
	// GetSerializedOutputs returns the serialized outputs of the action
	GetSerializedOutputs() ([][]byte, error)
	// GetOutputs returns the outputs of the action
	GetOutputs() []Output
	// IsAnonymous returns true if the issuer is anonymous
	IsAnonymous() bool
	// GetIssuer returns the issuer of the action
	GetIssuer() []byte
	// GetMetadata returns the metadata of the action
	GetMetadata() map[string][]byte
}

IssueAction is the action used to issue tokens

type IssueMetadata

type IssueMetadata struct {
	// Issuer is the identity of the issuer
	Issuer view.Identity

	// Outputs is the list of outputs issued
	Outputs [][]byte
	// TokenInfo, for each output we have a TokenInfo entry that contains secrets to de-obfuscate the output
	TokenInfo [][]byte
	// Receivers, for each output we have a receiver
	Receivers []view.Identity
	// ReceiversAuditInfos, for each receiver we have audit info to recover the enrollment ID of the receiver
	ReceiversAuditInfos [][]byte

	// ExtraSigners is the list of extra identities that are not part of the issue action per se
	// but needs to sign the request
	ExtraSigners []view.Identity
}

IssueMetadata contains the metadata of an issue action. In more details, there is an issuer and a list of outputs. For each output, there is a token info and a list of receivers with their audit info to recover their enrollment ID.

type IssueOptions

type IssueOptions struct {
	// Attributes is a container of generic options that might be driver specific
	Attributes map[interface{}]interface{}
}

IssueOptions models the options that can be passed to the issue command

type IssueService

type IssueService interface {
	// Issue generates an IssuerAction whose tokens are issued by the passed identity.
	// The tokens to be issued are passed as pairs (value, owner).
	// In addition, a set of options can be specified to further customize the issue command.
	// The function returns an IssuerAction, the associated metadata, and the identity of the issuer (depending on the implementation, it can be different from
	// the one passed in input).
	// The metadata is an array with an entry for each output created by the action.
	Issue(issuerIdentity view.Identity, tokenType string, values []uint64, owners [][]byte, opts *IssueOptions) (IssueAction, *IssueMetadata, error)

	// VerifyIssue checks the well-formedness of the passed IssuerAction with the respect to the passed metadata
	VerifyIssue(tr IssueAction, metadata [][]byte) error

	// DeserializeIssueAction deserializes the passed bytes into an IssuerAction
	DeserializeIssueAction(raw []byte) (IssueAction, error)
}

IssueService models the token issue service

type IssuerWallet

type IssuerWallet interface {
	Wallet

	// GetIssuerIdentity returns an issuer identity for the passed token type.
	// Depending on the underlying wallet implementation, this can be a long-term or ephemeral identity.
	GetIssuerIdentity(tokenType string) (view.Identity, error)

	// HistoryTokens returns the list of tokens issued by this wallet filtered using the passed options.
	HistoryTokens(opts *ListTokensOptions) (*token.IssuedTokens, error)
}

IssuerWallet models the wallet of an issuer

type Ledger

type Ledger interface {
	// GetState returns the value for the given key
	GetState(key string) ([]byte, error)
}

Ledger models a read-only ledger

type ListTokensOptions

type ListTokensOptions struct {
	// TokenType is the type of token to list
	TokenType string
}

ListTokensOptions contains options that can be used to list tokens from a wallet

type Matcher

type Matcher interface {
	// Match returns true if the passed identity matches this matcher
	Match([]byte) error
}

Matcher models a matcher that can be used to match identities

type Output

type Output interface {
	// Serialize returns the serialized version of the output
	Serialize() ([]byte, error)
	// IsRedeem returns true if the output is a redeem output
	IsRedeem() bool
}

Output models an output of an action

type OwnerWallet

type OwnerWallet interface {
	Wallet

	// GetRecipientIdentity returns a recipient identity.
	// Depending on the underlying wallet implementation, this can be a long-term or ephemeral identity.
	GetRecipientIdentity() (view.Identity, error)

	// GetAuditInfo returns auditing information for the passed identity
	GetAuditInfo(id view.Identity) ([]byte, error)

	// ListTokens returns the list of unspent tokens owned by this wallet filtered using the passed options.
	ListTokens(opts *ListTokensOptions) (*token.UnspentTokens, error)

	// ListTokensIterator returns an iterator of unspent tokens owned by this wallet filtered using the passed options.
	ListTokensIterator(opts *ListTokensOptions) (UnspentTokensIterator, error)

	// GetTokenMetadata returns any information needed to implement the transfer
	GetTokenMetadata(id view.Identity) ([]byte, error)

	// EnrollmentID returns the enrollment ID of the owner wallet
	EnrollmentID() string

	// RegisterRecipient TODO
	RegisterRecipient(identity view.Identity, info []byte, metadata []byte) error
}

OwnerWallet models the wallet of a token recipient.

type PublicParameters

type PublicParameters interface {
	// Identifier returns the unique identifier of this public parameters.
	Identifier() string
	// TokenDataHiding returns true if the token data is hidden
	TokenDataHiding() bool
	// GraphHiding returns true if the token graph is hidden
	GraphHiding() bool
	// MaxTokenValue returns the maximum token value
	MaxTokenValue() uint64
	// CertificationDriver returns the certification driver identifier
	CertificationDriver() string
	// Bytes returns the marshalled version of the public parameters.
	Bytes() ([]byte, error)
	// Auditors returns the list of auditors.
	Auditors() []view.Identity
	// Precision returns the precision used to represent the token value.
	Precision() uint64
	// String returns a readable version of the public parameters
	String() string
}

PublicParameters is the interface that must be implemented by the driver public parameters.

type PublicParamsFetcher

type PublicParamsFetcher interface {
	// Fetch fetches the public parameters from a repository.
	Fetch() ([]byte, error)
}

PublicParamsFetcher models a public parameters fetcher.

type PublicParamsManager

type PublicParamsManager interface {
	// Load loads the public parameters either from the local storage, if available
	Load() error
	// Fetch fetches the public parameters
	Fetch() ([]byte, error)
	// PublicParameters returns the public parameters.
	PublicParameters() PublicParameters
	// SetPublicParameters updates the public parameters with the passed value
	SetPublicParameters(raw []byte) error
	// NewCertifierKeyPair generates a new key pair for the certifier, if supported
	NewCertifierKeyPair() ([]byte, []byte, error)
	// SerializePublicParameters returns the public params in a serialized form
	SerializePublicParameters() ([]byte, error)
	// Validate validates the public parameters
	Validate() error
}

PublicParamsManager is the interface that must be implemented by the driver public parameters manager.

type QueryCallback2Func

type QueryCallback2Func func(*token.ID, string, []byte, []byte) error

type QueryCallbackFunc

type QueryCallbackFunc func(*token.ID, []byte) error

type QueryEngine

type QueryEngine interface {
	// IsPending returns true if the transaction the passed id refers to is still pending, false otherwise
	IsPending(id *token.ID) (bool, error)
	// IsMine returns true if the passed id is owned by any known wallet
	IsMine(id *token.ID) (bool, error)
	// UnspentTokensIterator returns an iterator over all unspent tokens
	UnspentTokensIterator() (UnspentTokensIterator, error)
	// UnspentTokensIteratorBy returns an iterator of unspent tokens owned by the passed id and whose type is the passed on.
	// The token type can be empty. In that case, tokens of any type are returned.
	UnspentTokensIteratorBy(id, typ string) (UnspentTokensIterator, error)
	// ListUnspentTokens returns the list of unspent tokens
	ListUnspentTokens() (*token.UnspentTokens, error)
	// ListAuditTokens returns the audited tokens associated to the passed ids
	ListAuditTokens(ids ...*token.ID) ([]*token.Token, error)
	// ListHistoryIssuedTokens returns the list of issues tokens
	ListHistoryIssuedTokens() (*token.IssuedTokens, error)
	// PublicParams returns the public parameters
	PublicParams() ([]byte, error)
	// GetTokenInfos retrieves the token information for the passed ids.
	// For each id, the callback is invoked to unmarshal the token information
	GetTokenInfos(ids []*token.ID, callback QueryCallbackFunc) error
	// GetTokenOutputs retrieves the token output as stored on the ledger for the passed ids.
	// For each id, the callback is invoked to unmarshal the output
	GetTokenOutputs(ids []*token.ID, callback QueryCallbackFunc) error
	// GetTokenInfoAndOutputs retrieves both the token output and information for the passed ids.
	GetTokenInfoAndOutputs(ids []*token.ID, callback QueryCallback2Func) error
	// GetTokens returns the list of tokens with their respective vault keys
	GetTokens(inputs ...*token.ID) ([]string, []*token.Token, error)
	// WhoDeletedTokens returns info about who deleted the passed tokens.
	// The bool array is an indicator used to tell if the token at a given position has been deleted or not
	WhoDeletedTokens(inputs ...*token.ID) ([]string, []bool, error)
}

type SerializedPublicParameters

type SerializedPublicParameters struct {
	// Identifier is the unique identifier of this public parameters.
	Identifier string
	// Raw is marshalled version of the public parameters.
	Raw []byte
}

SerializedPublicParameters is the serialized form of PublicParameters.

func (*SerializedPublicParameters) Deserialize

func (pp *SerializedPublicParameters) Deserialize(raw []byte) error

Deserialize deserializes the serialized public parameters.

type Serializer

type Serializer interface {
	// MarshalTokenRequestToSign marshals the to token request to a byte array representation on which a signature must be produced
	MarshalTokenRequestToSign(request *TokenRequest, meta *TokenRequestMetadata) ([]byte, error)
}

Serializer models the serialization needs of the Token Service

type SetupAction

type SetupAction interface {
	GetSetupParameters() ([]byte, error)
}

SetupAction is the action used to update the public parameters

type SignatureProvider

type SignatureProvider interface {
	// HasBeenSignedBy returns true and the verified signature if the provider contains a valid signature for the passed identity and verifier
	HasBeenSignedBy(id view.Identity, verifier Verifier) ([]byte, error)
	// Signatures returns the signatures inside this provider
	Signatures() [][]byte
}

type Signer

type Signer interface {
	// Sign signs message bytes and returns the signature or an error on failure.
	Sign(message []byte) ([]byte, error)
}

Signer is an interface which wraps the Sign method.

type SigningIdentity

type SigningIdentity interface {
	// Sign signs message bytes and returns the signature or an error on failure.
	Sign(raw []byte) ([]byte, error)

	// Serialize serializes the signing identity
	Serialize() ([]byte, error)
}

SigningIdentity models a signing identity

type TokenIDSer

type TokenIDSer struct {
	TxId  string
	Index int
}

type TokenManagerService

type TokenManagerService interface {
	IssueService
	TransferService
	TokenService
	AuditorService
	WalletService
	CertificationService
	Deserializer
	Serializer

	IdentityProvider() IdentityProvider
	Validator() (Validator, error)
	PublicParamsManager() PublicParamsManager
	ConfigManager() config.Manager
}

TokenManagerService is the entry point of the Driver API and gives access to the rest of the API

type TokenManagerServiceProvider

type TokenManagerServiceProvider interface {
	// GetTokenManagerService returns a TokenManagerService instance for the passed parameters
	// If a TokenManagerService is not available, it creates one.
	GetTokenManagerService(network string, channel string, namespace string, publicParamsFetcher PublicParamsFetcher) (TokenManagerService, error)
}

type TokenRequest

type TokenRequest struct {
	Issues            [][]byte
	Transfers         [][]byte
	Signatures        [][]byte
	AuditorSignatures [][]byte
}

TokenRequest is a collection of Token Action: Issues, to create new Tokens; Transfers, to manipulate Tokens (e.g., transfer ownership or redeem) The actions in the collection are independent. An action cannot spend tokens created by another action in the same Token Request. In addition, actions comes with a set of Witnesses to verify the right to spend or the right to issue a given token

func (*TokenRequest) Bytes

func (r *TokenRequest) Bytes() ([]byte, error)

func (*TokenRequest) FromBytes

func (r *TokenRequest) FromBytes(raw []byte) error

type TokenRequestMetadata

type TokenRequestMetadata struct {
	// Issues is the list of issue actions metadata
	Issues []IssueMetadata
	// Transfers is the list of transfer actions metadata
	Transfers []TransferMetadata
	// Application enables attaching more info to the TokenRequestMetadata
	Application map[string][]byte
}

TokenRequestMetadata is a collection of actions metadata

func (*TokenRequestMetadata) Bytes

func (m *TokenRequestMetadata) Bytes() ([]byte, error)

func (*TokenRequestMetadata) FromBytes

func (m *TokenRequestMetadata) FromBytes(raw []byte) error

func (*TokenRequestMetadata) GetTokenInfo

func (m *TokenRequestMetadata) GetTokenInfo(tokenRaw []byte) []byte

GetTokenInfo returns the TokenInfo that matches the given token

type TokenService

type TokenService interface {
	// DeserializeToken unmarshals the passed output and uses the passed metadata to derive a token and its issuer (if any).
	DeserializeToken(output []byte, outputMetadata []byte) (*token2.Token, view.Identity, error)

	// GetTokenInfo extracts from the given metadata the token info entry corresponding to the given target
	GetTokenInfo(meta *TokenRequestMetadata, target []byte) ([]byte, error)
}

type TransferAction

type TransferAction interface {
	// Serialize returns the serialized version of the action
	Serialize() ([]byte, error)
	// NumOutputs returns the number of outputs of the action
	NumOutputs() int
	// GetSerializedOutputs returns the serialized outputs of the action
	GetSerializedOutputs() ([][]byte, error)
	// GetOutputs returns the outputs of the action
	GetOutputs() []Output
	// IsRedeemAt returns true if the output is a redeem output at the passed index
	IsRedeemAt(index int) bool
	// SerializeOutputAt returns the serialized output at the passed index
	SerializeOutputAt(index int) ([]byte, error)
	// GetInputs returns the identifiers of the inputs in the action.
	GetInputs() ([]string, error)
	// IsGraphHiding returns true if the action is graph hiding
	IsGraphHiding() bool
	// GetMetadata returns the action's metadata
	GetMetadata() map[string][]byte
}

TransferAction is the action used to transfer tokens

type TransferMetadata

type TransferMetadata struct {
	// TokenIDs is the list of TokenIDs spent by this action
	TokenIDs []*token.ID
	// Senders is the list of senders
	Senders []view.Identity
	// SendersAuditInfos, for each sender we have audit info to recover the enrollment ID of the sender
	SenderAuditInfos [][]byte

	// Outputs is the list of outputs created by this transfer action
	Outputs [][]byte
	// OutputsMetadata, for each output we have an OutputsMetadata entry that contains secrets to de-obfuscate the output
	OutputsMetadata [][]byte
	// Receivers is the list of receivers
	Receivers []view.Identity
	// ReceiversAuditInfos, for each receiver we have audit info to recover the enrollment ID of the receiver
	ReceiverAuditInfos [][]byte
	// ReceiverIsSender indicates if the receiver is a sender in this very same action
	ReceiverIsSender []bool

	// ExtraSigners is the list of extra identities that are not part of the transfer action per se
	// but needs to sign the request
	ExtraSigners []view.Identity
}

TransferMetadata contains the metadata of a transfer action For each TokenID there is a sender with its audit info to recover its enrollment ID, For each Output there is: - A OutputsMetadata entry to de-obfuscate the output; - A Receiver identity; - A ReceiverAuditInfo entry to recover the enrollment ID of the receiver - A Flag to indicate if the receiver is a sender in this very same action

func (*TransferMetadata) TokenIDAt

func (tm *TransferMetadata) TokenIDAt(index int) *token.ID

TokenIDAt returns the TokenID at the given index. It returns nil if the index is out of bounds.

type TransferMetadataSer

type TransferMetadataSer struct {
	TokenIDs           []TokenIDSer
	Outputs            [][]byte
	TokenInfo          [][]byte
	Senders            []view.Identity
	SenderAuditInfos   [][]byte
	Receivers          []view.Identity
	ReceiverIsSender   []bool
	ReceiverAuditInfos [][]byte
	ExtraSigners       []view.Identity
}

type TransferOptions

type TransferOptions struct {
	// Attributes is a container of generic options that might be driver specific
	Attributes map[interface{}]interface{}
}

TransferOptions models the options that can be passed to the transfer command

type TransferService

type TransferService interface {
	// Transfer generates a TransferAction that spend the passed token ids and created the passed outputs.
	// In addition, a set of options can be specified to further customize the transfer command.
	// The function returns an TransferAction and the associated metadata.
	Transfer(txID string, wallet OwnerWallet, ids []*token2.ID, Outputs []*token2.Token, opts *TransferOptions) (TransferAction, *TransferMetadata, error)

	// VerifyTransfer checks the well-formedness of the passed TransferAction with the respect to the passed output metadata
	VerifyTransfer(tr TransferAction, tokenInfos [][]byte) error

	// DeserializeTransferAction deserializes the passed bytes into an TransferAction
	DeserializeTransferAction(raw []byte) (TransferAction, error)
}

TransferService models the token transfer service

type UnspentTokensIterator

type UnspentTokensIterator interface {
	Close()
	Next() (*token.UnspentToken, error)
}

type Validator

type Validator interface {
	// UnmarshalActions returns the actions contained in the serialized token request
	UnmarshalActions(raw []byte) ([]interface{}, error)
	// VerifyTokenRequestFromRaw verifies the passed marshalled token request against the passed ledger and anchor.
	// The function returns additionally a map that contains information about the token request. The content of this map
	// is driver-dependant
	VerifyTokenRequestFromRaw(getState GetStateFnc, anchor string, raw []byte) ([]interface{}, map[string][]byte, error)
}

Validator models a token request validator

type Vault

type Vault interface {
	QueryEngine() QueryEngine
}

type Verifier

type Verifier interface {
	// Verify verifies the signature over the message bytes and returns nil if the signature is valid and an error otherwise.
	Verify(message, sigma []byte) error
}

Verifier is an interface which wraps the Verify method.

type Wallet

type Wallet interface {
	// ID returns the ID of this wallet
	ID() string

	// Contains returns true if the passed identity belongs to this wallet
	Contains(identity view.Identity) bool

	// ContainsToken returns true if the passed token is owned by this wallet
	ContainsToken(token *token.UnspentToken) bool

	// GetSigner returns the Signer bound to the passed identity
	GetSigner(identity view.Identity) (Signer, error)
}

Wallet models a generic wallet

type WalletService

type WalletService interface {
	// RegisterRecipientIdentity registers the passed recipient identity together with the associated audit information
	RegisterRecipientIdentity(id view.Identity, auditInfo []byte, metadata []byte) error

	// GetAuditInfo retrieves the audit information for the passed identity
	GetAuditInfo(id view.Identity) ([]byte, error)

	// GetEnrollmentID extracts the enrollment id from the passed audit information
	GetEnrollmentID(auditInfo []byte) (string, error)

	// GetRevocationHandler extracts the revocation handler from the passed audit information
	GetRevocationHandler(auditInfo []byte) (string, error)

	// Wallet returns the wallet bound to the passed identity, if any is available
	Wallet(identity view.Identity) Wallet

	// RegisterOwnerWallet registers an owner wallet
	RegisterOwnerWallet(id string, path string) error

	// RegisterIssuerWallet registers an issuer wallet
	RegisterIssuerWallet(id string, path string) error

	// OwnerWalletIDs returns the list of owner wallet identifiers
	OwnerWalletIDs() ([]string, error)

	// OwnerWallet returns an instance of the OwnerWallet interface bound to the passed id.
	// The id can be: the wallet identifier or a unique id of a view identity belonging to the wallet.
	OwnerWallet(id string) (OwnerWallet, error)

	// OwnerWalletByIdentity returns the OwnerWallet the passed identity belongs to.
	OwnerWalletByIdentity(identity view.Identity) (OwnerWallet, error)

	// IssuerWallet returns an instance of the IssuerWallet interface bound to the passed id.
	// The id can be: the wallet identifier or a unique id of a view identity belonging to the wallet.
	IssuerWallet(id string) (IssuerWallet, error)

	// IssuerWalletByIdentity returns an instance of the IssuerWallet interface that contains the passed identity.
	IssuerWalletByIdentity(identity view.Identity) (IssuerWallet, error)

	// AuditorWalletByIdentity returns an instance of the AuditorWallet interface that contains the passed identity.
	AuditorWalletByIdentity(identity view.Identity) (AuditorWallet, error)

	// AuditorWallet returns an instance of the AuditorWallet interface bound to the passed id.
	// The id can be: the wallet identifier or a unique id of a view identity belonging to the wallet.
	AuditorWallet(id string) (AuditorWallet, error)

	// CertifierWallet returns an instance of the CertifierWallet interface bound to the passed id.
	// The id can be: the wallet identifier or a unique id of a view identity belonging to the wallet.
	CertifierWallet(id string) (CertifierWallet, error)

	// CertifierWalletByIdentity returns an instance of the CertifierWallet interface that contains the passed identity.
	CertifierWalletByIdentity(identity view.Identity) (CertifierWallet, error)

	// SpentIDs returns the spend ids for the passed token ids
	SpentIDs(ids ...*token.ID) ([]string, error)
}

WalletService models the wallet service that handles issuer, recipient, auditor and certifier wallets

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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