Documentation ¶
Overview ¶
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func CompileListTokensOption(opts ...ListTokensOption) (*driver.ListTokensOptions, error)
- func NewLedgerFromGetter(f driver.GetStateFnc) *stateGetter
- func NewTMSNormalizer(tmsProvider core.ConfigProvider, normalizer Normalizer) *tmsNormalizer
- type AuditRecord
- type AuditorWallet
- type Authorization
- type Binder
- type CertificationClient
- type CertificationClientProvider
- type CertificationManager
- func (c *CertificationManager) Certify(wallet *CertifierWallet, ids []*token2.ID, tokens [][]byte, request []byte) ([][]byte, error)
- func (c *CertificationManager) NewCertificationRequest(ids []*token2.ID) ([]byte, error)
- func (c *CertificationManager) VerifyCertifications(ids []*token2.ID, certifications [][]byte) ([][]byte, error)
- type CertificationStorage
- type CertifierWallet
- type Configuration
- type Hashable
- type Identity
- type IdentityConfiguration
- type Input
- type InputStream
- func (is *InputStream) At(i int) *Input
- func (is *InputStream) ByEnrollmentID(id string) *InputStream
- func (is *InputStream) ByType(tokenType token.Type) *InputStream
- func (is *InputStream) Count() int
- func (is *InputStream) EnrollmentIDs() []string
- func (is *InputStream) Filter(f func(t *Input) bool) *InputStream
- func (is *InputStream) IDs() []*token.ID
- func (is *InputStream) Inputs() []*Input
- func (is *InputStream) IsAnyMine() (bool, error)
- func (is *InputStream) Owners() *OwnerStream
- func (is *InputStream) RevocationHandles() []string
- func (is *InputStream) String() string
- func (is *InputStream) Sum() *big.Int
- func (is *InputStream) TokenTypes() []token.Type
- type Issue
- type IssueAction
- func (i *IssueAction) GetIssuer() []byte
- func (i *IssueAction) GetMetadata() map[string][]byte
- func (i *IssueAction) GetSerializedOutputs() ([][]byte, error)
- func (i *IssueAction) IsAnonymous() bool
- func (i *IssueAction) IsGraphHiding() bool
- func (i *IssueAction) NumOutputs() int
- func (i *IssueAction) Serialize() ([]byte, error)
- type IssueMetadata
- type IssueOption
- type IssueOptions
- type IssuerWallet
- type Ledger
- type ListTokensOption
- type ListTokensOptions
- type ManagementService
- func (t *ManagementService) Authorization() *Authorization
- func (t *ManagementService) CertificationClient() (*CertificationClient, error)
- func (t *ManagementService) CertificationManager() *CertificationManager
- func (t *ManagementService) Channel() string
- func (t *ManagementService) Configuration() *Configuration
- func (t *ManagementService) ID() TMSID
- func (t *ManagementService) Namespace() string
- func (t *ManagementService) Network() string
- func (t *ManagementService) NewFullRequestFromBytes(tr []byte) (*Request, error)
- func (t *ManagementService) NewMetadataFromBytes(raw []byte) (*Metadata, error)
- func (t *ManagementService) NewRequest(id string) (*Request, error)
- func (t *ManagementService) NewRequestFromBytes(anchor string, actions []byte, meta []byte) (*Request, error)
- func (t *ManagementService) PublicParametersManager() *PublicParametersManager
- func (t *ManagementService) SelectorManager() (SelectorManager, error)
- func (t *ManagementService) SigService() *SignatureService
- func (t *ManagementService) String() string
- func (t *ManagementService) Validator() (*Validator, error)
- func (t *ManagementService) Vault() *Vault
- func (t *ManagementService) WalletManager() *WalletManager
- type ManagementServiceProvider
- type Metadata
- func (m *Metadata) FilterBy(eIDs ...string) (*Metadata, error)
- func (m *Metadata) GetToken(raw []byte) (*token.Token, Identity, []byte, error)
- func (m *Metadata) Issue(i int) (*IssueMetadata, error)
- func (m *Metadata) SpentTokenID() []*token.ID
- func (m *Metadata) Transfer(i int) (*TransferMetadata, error)
- type Normalizer
- type Output
- type OutputStream
- func (o *OutputStream) At(i int) *Output
- func (o *OutputStream) ByEnrollmentID(id string) *OutputStream
- func (o *OutputStream) ByRecipient(id Identity) *OutputStream
- func (o *OutputStream) ByType(typ token.Type) *OutputStream
- func (o *OutputStream) Count() int
- func (o *OutputStream) EnrollmentIDs() []string
- func (o *OutputStream) Filter(f func(t *Output) bool) *OutputStream
- func (o *OutputStream) Outputs() []*Output
- func (o *OutputStream) RevocationHandles() []string
- func (o *OutputStream) String() string
- func (o *OutputStream) Sum() *big.Int
- func (o *OutputStream) TokenTypes() []token.Type
- type OwnerFilter
- type OwnerStream
- type OwnerWallet
- func (o *OwnerWallet) Balance(opts ...ListTokensOption) (uint64, error)
- func (o *OwnerWallet) EnrollmentID() string
- func (o *OwnerWallet) GetAuditInfo(id Identity) ([]byte, error)
- func (o *OwnerWallet) GetRecipientIdentity() (Identity, error)
- func (o *OwnerWallet) GetSigner(identity Identity) (driver.Signer, error)
- func (o *OwnerWallet) GetTokenMetadata(token []byte) ([]byte, error)
- func (o *OwnerWallet) GetTokenMetadataAuditInfo(token []byte) ([]byte, error)
- func (o *OwnerWallet) ListUnspentTokens(opts ...ListTokensOption) (*token.UnspentTokens, error)
- func (o *OwnerWallet) ListUnspentTokensIterator(opts ...ListTokensOption) (*UnspentTokensIterator, error)
- func (o *OwnerWallet) RegisterRecipient(data *RecipientData) error
- func (o *OwnerWallet) Remote() bool
- type PPHash
- type PublicParameters
- func (c *PublicParameters) Auditors() []Identity
- func (c *PublicParameters) CertificationDriver() string
- func (c *PublicParameters) GraphHiding() bool
- func (c *PublicParameters) Identifier() string
- func (c *PublicParameters) MaxTokenValue() uint64
- func (c *PublicParameters) Precision() uint64
- func (c *PublicParameters) Serialize() ([]byte, error)
- func (c *PublicParameters) TokenDataHiding() bool
- type PublicParametersManager
- type PublicParamsFetcher
- type QueryEngine
- func (q *QueryEngine) GetStatus(txID string) (TxStatus, string, error)
- func (q *QueryEngine) GetTokens(inputs ...*token.ID) ([]*token.Token, error)
- func (q *QueryEngine) IsMine(id *token.ID) (bool, error)
- func (q *QueryEngine) ListAuditTokens(ids ...*token.ID) ([]*token.Token, error)
- func (q *QueryEngine) ListHistoryIssuedTokens() (*token.IssuedTokens, error)
- func (q *QueryEngine) ListUnspentTokens() (*token.UnspentTokens, error)
- func (q *QueryEngine) PublicParams() ([]byte, error)
- func (q *QueryEngine) UnspentTokensIterator() (*UnspentTokensIterator, error)
- func (q *QueryEngine) UnspentTokensIteratorBy(ctx context.Context, id string, tokenType token.Type) (driver.UnspentTokensIterator, error)
- type QueryService
- type RecipientData
- type Request
- func (r *Request) AddAuditorSignature(sigma []byte)
- func (r *Request) ApplicationMetadata(k string) []byte
- func (r *Request) AuditCheck(ctx context.Context) error
- func (r *Request) AuditRecord() (*AuditRecord, error)
- func (r *Request) BindTo(binder Binder, identity Identity) error
- func (r *Request) Bytes() ([]byte, error)
- func (r *Request) FilterMetadataBy(eIDs ...string) (*Request, error)
- func (r *Request) FromBytes(request []byte) error
- func (r *Request) GetMetadata() (*Metadata, error)
- func (r *Request) ID() string
- func (r *Request) Inputs() (*InputStream, error)
- func (r *Request) InputsAndOutputs() (*InputStream, *OutputStream, error)
- func (r *Request) IsValid() error
- func (r *Request) Issue(ctx context.Context, wallet *IssuerWallet, receiver Identity, typ token.Type, ...) (*IssueAction, error)
- func (r *Request) IssueSigners() []Identity
- func (r *Request) Issues() []*Issue
- func (r *Request) MarshalToAudit() ([]byte, error)
- func (r *Request) MarshalToSign() ([]byte, error)
- func (r *Request) MetadataToBytes() ([]byte, error)
- func (r *Request) Outputs() (*OutputStream, error)
- func (r *Request) Redeem(ctx context.Context, wallet *OwnerWallet, typ token.Type, value uint64, ...) error
- func (r *Request) RequestToBytes() ([]byte, error)
- func (r *Request) SetApplicationMetadata(k string, v []byte)
- func (r *Request) SetSignatures(sigmas map[string][]byte)
- func (r *Request) SetTokenService(service *ManagementService)
- func (r *Request) Transfer(ctx context.Context, wallet *OwnerWallet, typ token.Type, values []uint64, ...) (*TransferAction, error)
- func (r *Request) TransferSigners() []Identity
- func (r *Request) Transfers() []*Transfer
- type Selector
- type SelectorManager
- type SelectorManagerProvider
- type ServiceOption
- func WithChannel(channel string) ServiceOption
- func WithNamespace(namespace string) ServiceOption
- func WithNetwork(network string) ServiceOption
- func WithPublicParameter(publicParams []byte) ServiceOption
- func WithPublicParameterFetcher(ppFetcher PublicParamsFetcher) ServiceOption
- func WithTMS(network, channel, namespace string) ServiceOption
- func WithTMSID(id TMSID) ServiceOption
- type ServiceOptions
- type ServiceProvider
- type SignatureService
- func (s *SignatureService) AuditorVerifier(id Identity) (Verifier, error)
- func (s *SignatureService) GetSigner(id Identity) (Signer, error)
- func (s *SignatureService) IsMe(party Identity) bool
- func (s *SignatureService) IssuerVerifier(id Identity) (Verifier, error)
- func (s *SignatureService) OwnerVerifier(id Identity) (Verifier, error)
- func (s *SignatureService) RegisterSigner(identity Identity, signer Signer, verifier Verifier) error
- type Signer
- type TMSID
- type TMSNormalizer
- type Transfer
- type TransferAction
- func (t *TransferAction) GetInputs() []*token.ID
- func (t *TransferAction) GetSerialNumbers() []string
- func (t *TransferAction) GetSerializedOutputs() ([][]byte, error)
- func (t *TransferAction) IsGraphHiding() bool
- func (t *TransferAction) IsRedeemAt(i int) bool
- func (t *TransferAction) NumOutputs() int
- func (t *TransferAction) Serialize() ([]byte, error)
- func (t *TransferAction) SerializeOutputAt(i int) ([]byte, error)
- type TransferMetadata
- type TransferOption
- func WithRestRecipientIdentity(recipientData *RecipientData) TransferOption
- func WithTokenIDs(ids ...*token.ID) TransferOption
- func WithTokenSelector(selector Selector) TransferOption
- func WithTransferAttribute(attr, value interface{}) TransferOption
- func WithTransferMetadata(key string, value []byte) TransferOption
- type TransferOptions
- type TxStatus
- type UnspentTokensIterator
- type Validator
- func (c *Validator) UnmarshalActions(raw []byte) ([]interface{}, error)
- func (c *Validator) UnmarshallAndVerify(ctx context.Context, ledger Ledger, anchor string, raw []byte) ([]interface{}, error)
- func (c *Validator) UnmarshallAndVerifyWithMetadata(ctx context.Context, ledger Ledger, anchor string, raw []byte) ([]interface{}, map[string][]byte, error)
- type Vault
- type VaultProvider
- type Verifier
- type Wallet
- type WalletLookupID
- type WalletManager
- func (wm *WalletManager) AuditorWallet(id WalletLookupID) *AuditorWallet
- func (wm *WalletManager) CertifierWallet(id WalletLookupID) *CertifierWallet
- func (wm *WalletManager) GetEnrollmentID(identity Identity) (string, error)
- func (wm *WalletManager) GetRevocationHandle(identity Identity) (string, error)
- func (wm *WalletManager) IssuerWallet(id WalletLookupID) *IssuerWallet
- func (wm *WalletManager) OwnerWallet(id WalletLookupID) *OwnerWallet
- func (wm *WalletManager) OwnerWalletIDs() ([]string, error)
- func (wm *WalletManager) RegisterIssuerIdentity(id string, url string) error
- func (wm *WalletManager) RegisterOwnerIdentity(id string, url string) error
- func (wm *WalletManager) RegisterOwnerIdentityConfiguration(conf IdentityConfiguration) error
- func (wm *WalletManager) RegisterRecipientIdentity(data *RecipientData) error
- func (wm *WalletManager) SpentIDs(ids []*token.ID) ([]string, error)
- func (wm *WalletManager) Wallet(identity Identity) *Wallet
Constants ¶
const ( // Unknown is the status of a transaction that is unknown Unknown = driver.Unknown // Pending is the status of a transaction that has been submitted to the ledger Pending = driver.Pending // Confirmed is the status of a transaction that has been confirmed by the ledger Confirmed = driver.Confirmed // Deleted is the status of a transaction that has been deleted due to a failure to commit Deleted = driver.Deleted )
const (
TransferMetadataPrefix = meta.TransferMetadataPrefix
)
Variables ¶
var ( // SelectorInsufficientFunds is returned when funds are not sufficient to cover the request SelectorInsufficientFunds = errors.New("insufficient funds") // SelectorSufficientButLockedFunds is returned when funds are sufficient to cover the request, but some tokens are locked // by other transactions SelectorSufficientButLockedFunds = errors.New("sufficient but partially locked funds") // SelectorSufficientButNotCertifiedFunds is returned when funds are sufficient to cover the request, but some tokens // are not yet certified and therefore cannot be used. SelectorSufficientButNotCertifiedFunds = errors.New("sufficient but partially not certified") // SelectorSufficientFundsButConcurrencyIssue is returned when funds are sufficient to cover the request, but // concurrency issues does not make some of the selected tokens available. SelectorSufficientFundsButConcurrencyIssue = errors.New("sufficient funds but concurrency issue") )
Functions ¶
func CompileListTokensOption ¶
func CompileListTokensOption(opts ...ListTokensOption) (*driver.ListTokensOptions, error)
func NewLedgerFromGetter ¶ added in v0.4.0
func NewLedgerFromGetter(f driver.GetStateFnc) *stateGetter
func NewTMSNormalizer ¶ added in v0.4.0
func NewTMSNormalizer(tmsProvider core.ConfigProvider, normalizer Normalizer) *tmsNormalizer
Types ¶
type AuditRecord ¶
type AuditRecord struct { Anchor string Inputs *InputStream Outputs *OutputStream }
AuditRecord models the audit record returned by the audit command It contains the token request's anchor, inputs (with Type and Quantity), and outputs
type AuditorWallet ¶
type AuditorWallet struct { *Wallet // contains filtered or unexported fields }
AuditorWallet models the wallet of an auditor
func (*AuditorWallet) GetAuditorIdentity ¶
func (a *AuditorWallet) GetAuditorIdentity() (Identity, error)
GetAuditorIdentity returns the auditor identity. This can be a long term identity or a pseudonym depending on the underlying token driver.
type Authorization ¶ added in v0.4.0
type Authorization struct {
driver.Authorization
}
Authorization defines method to check the relation between a token and wallets (owner, auditor, etc.)
type CertificationClient ¶
type CertificationClient struct {
// contains filtered or unexported fields
}
CertificationClient is the client side of the certification process
func (*CertificationClient) IsCertified ¶
func (c *CertificationClient) IsCertified(id *token2.ID) bool
IsCertified returns true if the passed token id has been already certified, otherwise false
func (*CertificationClient) RequestCertification ¶
func (c *CertificationClient) RequestCertification(ids ...*token2.ID) error
RequestCertification requests the certification of the passed token ids
type CertificationClientProvider ¶
type CertificationClientProvider interface { // New returns a new CertificationClient instance for the passed inputs New(tms *ManagementService) (driver.CertificationClient, error) }
CertificationClientProvider provides instances of CertificationClient
type CertificationManager ¶
type CertificationManager struct {
// contains filtered or unexported fields
}
CertificationManager manages token certifications as described by the paper [`Privacy-preserving auditable token payments in a permissioned blockchain system`]('https://eprint.iacr.org/2019/1058.pdf')
func (*CertificationManager) Certify ¶
func (c *CertificationManager) Certify(wallet *CertifierWallet, ids []*token2.ID, tokens [][]byte, request []byte) ([][]byte, error)
Certify uses the passed wallet to certify the passed token ids. Certify takes in input the certification request and the token representations as available on the ledger.
func (*CertificationManager) NewCertificationRequest ¶
func (c *CertificationManager) NewCertificationRequest(ids []*token2.ID) ([]byte, error)
NewCertificationRequest creates a new certification request, in a serialized form, for the passed token ids.
func (*CertificationManager) VerifyCertifications ¶
func (c *CertificationManager) VerifyCertifications(ids []*token2.ID, certifications [][]byte) ([][]byte, error)
VerifyCertifications verifies the validity of the certifications of each token indexed by its token-id. The function returns the result of any processing of these certifications. In the simplest case, VerifyCertifications returns the certifications got in input
type CertificationStorage ¶ added in v0.4.0
type CertificationStorage struct {
// contains filtered or unexported fields
}
type CertifierWallet ¶
type CertifierWallet struct { *Wallet // contains filtered or unexported fields }
CertifierWallet models the wallet of a certifier
func (*CertifierWallet) GetCertifierIdentity ¶
func (a *CertifierWallet) GetCertifierIdentity() (Identity, error)
GetCertifierIdentity returns the certifier identity. This can be a long term identity or a pseudonym depending on the underlying token driver.
type Configuration ¶ added in v0.4.0
type Configuration struct {
// contains filtered or unexported fields
}
Configuration manages the configuration of the token-sdk
func (*Configuration) IsSet ¶ added in v0.4.0
func (m *Configuration) IsSet(key string) bool
IsSet checks to see if the key has been set in any of the data locations
func (*Configuration) UnmarshalKey ¶ added in v0.4.0
func (m *Configuration) UnmarshalKey(key string, rawVal interface{}) error
UnmarshalKey takes a single key and unmarshals it into a Struct
type IdentityConfiguration ¶ added in v0.4.0
type IdentityConfiguration = driver.IdentityConfiguration
type Input ¶
type Input struct { ActionIndex int Id *token.ID Owner Identity OwnerAuditInfo []byte EnrollmentID string RevocationHandler string Type token.Type Quantity token.Quantity }
Input models an input of a token action
type InputStream ¶
type InputStream struct {
// contains filtered or unexported fields
}
InputStream models a stream over a set of inputs (Input).
func NewInputStream ¶
func NewInputStream(qs QueryService, inputs []*Input, precision uint64) *InputStream
NewInputStream creates a new InputStream for the passed inputs and query service.
func (*InputStream) At ¶
func (is *InputStream) At(i int) *Input
At returns the input at the given index.
func (*InputStream) ByEnrollmentID ¶
func (is *InputStream) ByEnrollmentID(id string) *InputStream
ByEnrollmentID filters by enrollment ID.
func (*InputStream) ByType ¶
func (is *InputStream) ByType(tokenType token.Type) *InputStream
ByType filters by token type.
func (*InputStream) Count ¶
func (is *InputStream) Count() int
Count returns the number of inputs in the stream
func (*InputStream) EnrollmentIDs ¶
func (is *InputStream) EnrollmentIDs() []string
EnrollmentIDs returns the enrollment IDs of the owners of the inputs. It might be empty, if not available.
func (*InputStream) Filter ¶
func (is *InputStream) Filter(f func(t *Input) bool) *InputStream
Filter returns a new InputStream with only the inputs that satisfy the predicate
func (*InputStream) IDs ¶
func (is *InputStream) IDs() []*token.ID
IDs returns the IDs of the inputs.
func (*InputStream) Inputs ¶ added in v0.4.0
func (is *InputStream) Inputs() []*Input
Inputs returns the inputs in this InputStream.
func (*InputStream) IsAnyMine ¶
func (is *InputStream) IsAnyMine() (bool, error)
IsAnyMine returns true if any of the inputs are mine
func (*InputStream) Owners ¶
func (is *InputStream) Owners() *OwnerStream
Owners returns a list of identities that own the tokens in the stream
func (*InputStream) RevocationHandles ¶ added in v0.3.0
func (is *InputStream) RevocationHandles() []string
RevocationHandles returns the Revocation Handles of the owners of the inputs. It might be empty, if not available.
func (*InputStream) String ¶
func (is *InputStream) String() string
String returns a string representation of the input stream
func (*InputStream) Sum ¶
func (is *InputStream) Sum() *big.Int
Sum returns the sum of the quantities of the inputs.
func (*InputStream) TokenTypes ¶
func (is *InputStream) TokenTypes() []token.Type
TokenTypes returns the token types of the inputs.
type Issue ¶
type Issue struct { // Issuer is the issuer of the tokens Issuer Identity // Receivers is the list of identities of the receivers Receivers []Identity // ExtraSigners is the list of extra identities that must sign the token request to make it valid. // This field is to be used by the token drivers to list any additional identities that must // sign the token request. ExtraSigners []Identity }
Issue contains information about an issue operation. In particular, it carries the identities of the issuer and the receivers
type IssueAction ¶
type IssueAction struct {
// contains filtered or unexported fields
}
IssueAction represents an action that issues tokens.
func (*IssueAction) GetIssuer ¶
func (i *IssueAction) GetIssuer() []byte
GetIssuer returns the issuer of the action.
func (*IssueAction) GetMetadata ¶
func (i *IssueAction) GetMetadata() map[string][]byte
GetMetadata returns the metadata of the action.
func (*IssueAction) GetSerializedOutputs ¶
func (i *IssueAction) GetSerializedOutputs() ([][]byte, error)
GetSerializedOutputs returns the serialized outputs of the action.
func (*IssueAction) IsAnonymous ¶
func (i *IssueAction) IsAnonymous() bool
IsAnonymous returns true if the action is an anonymous action.
func (*IssueAction) IsGraphHiding ¶ added in v0.4.0
func (i *IssueAction) IsGraphHiding() bool
IsGraphHiding returns true if the action supports graph hiding.
func (*IssueAction) NumOutputs ¶
func (i *IssueAction) NumOutputs() int
NumOutputs returns the number of outputs in the action.
func (*IssueAction) Serialize ¶
func (i *IssueAction) Serialize() ([]byte, error)
Serialize returns the byte representation of the action.
type IssueMetadata ¶
type IssueMetadata struct {
*driver.IssueMetadata
}
IssueMetadata contains the metadata of an issue action
func (*IssueMetadata) IsOutputAbsent ¶
func (m *IssueMetadata) IsOutputAbsent(j int) bool
IsOutputAbsent returns true if the given output's metadata is absent
func (*IssueMetadata) Match ¶
func (m *IssueMetadata) Match(action *IssueAction) error
Match returns true if the given action matches this metadata
type IssueOption ¶
type IssueOption func(*IssueOptions) error
IssueOption is a function that modify IssueOptions
func WithIssueAttribute ¶
func WithIssueAttribute(attr, value interface{}) IssueOption
WithIssueAttribute sets an attribute to be used to customize the issue command
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 IssuerWallet ¶
type IssuerWallet struct { *Wallet // contains filtered or unexported fields }
IssuerWallet models the wallet of an issuer
func (*IssuerWallet) GetIssuerIdentity ¶
func (i *IssuerWallet) GetIssuerIdentity(tokenType token.Type) (Identity, error)
GetIssuerIdentity returns the issuer identity. This can be a long term identity or a pseudonym depending on the underlying token driver.
func (*IssuerWallet) GetSigner ¶
func (i *IssuerWallet) GetSigner(identity Identity) (Signer, error)
GetSigner returns the signer bound to the passed issuer identity.
func (*IssuerWallet) ListIssuedTokens ¶
func (i *IssuerWallet) ListIssuedTokens(opts ...ListTokensOption) (*token.IssuedTokens, error)
ListIssuedTokens returns the list of tokens issued by identities in this wallet and filter by the passed options. Options: WithType
type ListTokensOption ¶
type ListTokensOption func(*ListTokensOptions) error
ListTokensOption is a function that configures a ListTokensOptions
func WithContext ¶ added in v0.4.0
func WithContext(ctx context.Context) ListTokensOption
WithContext return a list tokens option that contains the passed context
func WithType ¶
func WithType(tokenType token.Type) ListTokensOption
WithType returns a list token option that filter by the passed token type. If the passed token type is the empty string, all token types are selected.
type ListTokensOptions ¶
type ListTokensOptions = driver.ListTokensOptions
ListTokensOptions options for listing tokens
type ManagementService ¶
type ManagementService struct {
// contains filtered or unexported fields
}
ManagementService (TMS, for short) is the entry point for the Token API. A TMS is uniquely identified by a network, channel, namespace, and public parameters. The TMS gives access, among other things, to the wallet manager, the public parameters, the token selector, and so on.
func GetManagementService ¶
func GetManagementService(sp ServiceProvider, opts ...ServiceOption) *ManagementService
GetManagementService returns the management service for the passed options. If no options are passed, the default management service is returned. Options: WithNetwork, WithChannel, WithNamespace, WithPublicParameterFetcher, WithTMS, WithTMSID The function panics if an error occurs. Use GetManagementServiceProvider(sp).GetManagementService(opts...) to handle any error directly
func (*ManagementService) Authorization ¶ added in v0.4.0
func (t *ManagementService) Authorization() *Authorization
func (*ManagementService) CertificationClient ¶
func (t *ManagementService) CertificationClient() (*CertificationClient, error)
CertificationClient returns the certification client for this TMS
func (*ManagementService) CertificationManager ¶
func (t *ManagementService) CertificationManager() *CertificationManager
CertificationManager returns the certification manager for this TMS. It returns nil if certification is not supported.
func (*ManagementService) Channel ¶
func (t *ManagementService) Channel() string
Channel returns the channel identifier
func (*ManagementService) Configuration ¶ added in v0.4.0
func (t *ManagementService) Configuration() *Configuration
Configuration returns the configuration for this TMS
func (*ManagementService) ID ¶
func (t *ManagementService) ID() TMSID
ID returns the TMS identifier
func (*ManagementService) Namespace ¶
func (t *ManagementService) Namespace() string
Namespace returns the namespace identifier, empty if not defined
func (*ManagementService) Network ¶
func (t *ManagementService) Network() string
Network returns the network identifier
func (*ManagementService) NewFullRequestFromBytes ¶ added in v0.4.0
func (t *ManagementService) NewFullRequestFromBytes(tr []byte) (*Request, error)
NewFullRequestFromBytes returns a new Token Request for the serialized version
func (*ManagementService) NewMetadataFromBytes ¶
func (t *ManagementService) NewMetadataFromBytes(raw []byte) (*Metadata, error)
NewMetadataFromBytes unmarshals the passed bytes into a Metadata object
func (*ManagementService) NewRequest ¶
func (t *ManagementService) NewRequest(id string) (*Request, error)
NewRequest returns a new Token Request whose anchor is the passed id
func (*ManagementService) NewRequestFromBytes ¶
func (t *ManagementService) NewRequestFromBytes(anchor string, actions []byte, meta []byte) (*Request, error)
NewRequestFromBytes returns a new Token Request for the passed anchor, and whose actions and metadata are unmarshalled from the passed bytes
func (*ManagementService) PublicParametersManager ¶
func (t *ManagementService) PublicParametersManager() *PublicParametersManager
PublicParametersManager returns a manager that gives access to the public parameters governing this TMS.
func (*ManagementService) SelectorManager ¶
func (t *ManagementService) SelectorManager() (SelectorManager, error)
SelectorManager returns a manager that gives access to the token selectors
func (*ManagementService) SigService ¶
func (t *ManagementService) SigService() *SignatureService
SigService returns the signature service for this TMS
func (*ManagementService) String ¶
func (t *ManagementService) String() string
String returns a string representation of the TMS
func (*ManagementService) Validator ¶
func (t *ManagementService) Validator() (*Validator, error)
Validator returns a new token validator for this TMS
func (*ManagementService) Vault ¶
func (t *ManagementService) Vault() *Vault
Vault returns the Token Vault for this TMS
func (*ManagementService) WalletManager ¶
func (t *ManagementService) WalletManager() *WalletManager
WalletManager returns the wallet manager for this TMS
type ManagementServiceProvider ¶
type ManagementServiceProvider struct {
// contains filtered or unexported fields
}
ManagementServiceProvider provides instances of the management service
func GetManagementServiceProvider ¶
func GetManagementServiceProvider(sp ServiceProvider) *ManagementServiceProvider
GetManagementServiceProvider returns the management service provider from the passed service provider. The function panics if an error occurs. An alternative way is to use `s, err := sp.GetService(&ManagementServiceProvider{}) and catch the error manually.`
func NewManagementServiceProvider ¶
func NewManagementServiceProvider( logger logging.Logger, tmsProvider driver.TokenManagerServiceProvider, normalizer TMSNormalizer, vaultProvider VaultProvider, certificationClientProvider CertificationClientProvider, selectorManagerProvider SelectorManagerProvider, ) *ManagementServiceProvider
NewManagementServiceProvider returns a new instance of ManagementServiceProvider
func (*ManagementServiceProvider) GetManagementService ¶
func (p *ManagementServiceProvider) GetManagementService(opts ...ServiceOption) (*ManagementService, error)
GetManagementService returns an instance of the management service for the passed options. If the management service has not been created yet, it will be created.
func (*ManagementServiceProvider) NewManagementService ¶ added in v0.4.0
func (p *ManagementServiceProvider) NewManagementService(opts ...ServiceOption) (*ManagementService, error)
NewManagementService returns a new instance of the management service for the passed options.
type Metadata ¶
type Metadata struct { TokenService driver.TokensService WalletService driver.WalletService TokenRequestMetadata *driver.TokenRequestMetadata Logger logging.Logger }
Metadata contains the metadata of a Token Request
func (*Metadata) FilterBy ¶
FilterBy returns a new Metadata containing only the metadata that matches the given enrollment IDs. For Issue actions, for each issue: - The sender; - The returned metadata will contain only the outputs whose owner has the given enrollment IDs. For Transfer actions, for each action: - The list of token IDs will be empty; - The returned metadata will contain only the outputs whose owner has the given enrollment IDs; - The senders are included if and only if there is at least one output whose owner has the given enrollment IDs. Application metadata is always included
func (*Metadata) GetToken ¶
GetToken unmarshals the given bytes to extract the token and its issuer (if any).
func (*Metadata) Issue ¶
func (m *Metadata) Issue(i int) (*IssueMetadata, error)
Issue returns the i-th issue metadata, if present
func (*Metadata) SpentTokenID ¶
SpentTokenID returns the token IDs of the tokens that were spent by the Token Request this metadata is associated with.
type Normalizer ¶
type Normalizer interface { // Normalize normalizes the given ServiceOptions struct. Normalize(opt *ServiceOptions) (*ServiceOptions, error) }
Normalizer is used to set default values of ServiceOptions struct, if needed.
type Output ¶
type Output struct { // ActionIndex is the index of the action that created this output ActionIndex int // Index is the absolute position of this output in the token request Index uint64 // Owner is the identity of the owner of this output Owner Identity // OwnerAuditInfo contains the audit information of the output's owner OwnerAuditInfo []byte // EnrollmentID is the enrollment ID of the owner of this output EnrollmentID string // RevocationHandler is the revocation handler of the owner of this output RevocationHandler string // Type is the type of token Type token.Type // Quantity is the quantity of tokens Quantity token.Quantity // LedgerOutput contains the output as it appears on the ledger LedgerOutput []byte // LedgerOutputFormat is the output type LedgerOutputFormat token.Format }
Output models the output of a token action
type OutputStream ¶
type OutputStream struct { Precision uint64 // contains filtered or unexported fields }
OutputStream models a stream over a set of outputs (Output).
func NewOutputStream ¶
func NewOutputStream(outputs []*Output, precision uint64) *OutputStream
NewOutputStream creates a new OutputStream for the passed outputs and Precision.
func (*OutputStream) At ¶
func (o *OutputStream) At(i int) *Output
At returns the output at the passed index.
func (*OutputStream) ByEnrollmentID ¶
func (o *OutputStream) ByEnrollmentID(id string) *OutputStream
ByEnrollmentID filters to only include outputs that match the passed enrollment ID.
func (*OutputStream) ByRecipient ¶
func (o *OutputStream) ByRecipient(id Identity) *OutputStream
ByRecipient filters the OutputStream to only include outputs that match the passed recipient.
func (*OutputStream) ByType ¶
func (o *OutputStream) ByType(typ token.Type) *OutputStream
ByType filters the OutputStream to only include outputs that match the passed type.
func (*OutputStream) Count ¶
func (o *OutputStream) Count() int
Count returns the number of outputs in the OutputStream.
func (*OutputStream) EnrollmentIDs ¶
func (o *OutputStream) EnrollmentIDs() []string
EnrollmentIDs returns the enrollment IDs of the outputs in the OutputStream.
func (*OutputStream) Filter ¶
func (o *OutputStream) Filter(f func(t *Output) bool) *OutputStream
Filter filters the OutputStream to only include outputs that match the passed predicate.
func (*OutputStream) Outputs ¶
func (o *OutputStream) Outputs() []*Output
Outputs returns the outputs of the OutputStream.
func (*OutputStream) RevocationHandles ¶ added in v0.3.0
func (o *OutputStream) RevocationHandles() []string
RevocationHandles returns the Revocation Handles of the owners of the outputs. It might be empty, if not available.
func (*OutputStream) String ¶ added in v0.4.0
func (o *OutputStream) String() string
String returns a string representation of the input stream
func (*OutputStream) Sum ¶
func (o *OutputStream) Sum() *big.Int
Sum returns the sum of the quantity of all outputs in the OutputStream.
func (*OutputStream) TokenTypes ¶
func (o *OutputStream) TokenTypes() []token.Type
TokenTypes returns the token types of the outputs in the OutputStream.
type OwnerFilter ¶
type OwnerFilter interface { // ID is the wallet identifier of the owner ID() string }
OwnerFilter tells if a passed identity is recognized
type OwnerStream ¶
type OwnerStream struct {
// contains filtered or unexported fields
}
func NewOwnerStream ¶
func NewOwnerStream(owners []string) *OwnerStream
func (*OwnerStream) Count ¶
func (s *OwnerStream) Count() int
type OwnerWallet ¶
type OwnerWallet struct { *Wallet // contains filtered or unexported fields }
OwnerWallet models the wallet of an owner
func (*OwnerWallet) Balance ¶ added in v0.4.0
func (o *OwnerWallet) Balance(opts ...ListTokensOption) (uint64, error)
Balance returns the sun of the amounts, with 64 bits of precision, of the tokens with type and EID equal to those passed as arguments.
func (*OwnerWallet) EnrollmentID ¶
func (o *OwnerWallet) EnrollmentID() string
func (*OwnerWallet) GetAuditInfo ¶
func (o *OwnerWallet) GetAuditInfo(id Identity) ([]byte, error)
GetAuditInfo returns auditing information for the passed identity
func (*OwnerWallet) GetRecipientIdentity ¶
func (o *OwnerWallet) GetRecipientIdentity() (Identity, error)
GetRecipientIdentity returns the owner identity. This can be a long term identity or a pseudonym depending on the underlying token driver.
func (*OwnerWallet) GetSigner ¶
func (o *OwnerWallet) GetSigner(identity Identity) (driver.Signer, error)
GetSigner returns the signer bound to the passed owner identity.
func (*OwnerWallet) GetTokenMetadata ¶
func (o *OwnerWallet) GetTokenMetadata(token []byte) ([]byte, error)
GetTokenMetadata returns the public information related to the token to be assigned to passed recipient identity.
func (*OwnerWallet) GetTokenMetadataAuditInfo ¶ added in v0.4.0
func (o *OwnerWallet) GetTokenMetadataAuditInfo(token []byte) ([]byte, error)
GetTokenMetadataAuditInfo returns private information about the token metadata assigned to the passed recipient identity.
func (*OwnerWallet) ListUnspentTokens ¶
func (o *OwnerWallet) ListUnspentTokens(opts ...ListTokensOption) (*token.UnspentTokens, error)
ListUnspentTokens returns a list of unspent tokens owned by identities in this wallet and filtered by the passed options. Options: WithType
func (*OwnerWallet) ListUnspentTokensIterator ¶
func (o *OwnerWallet) ListUnspentTokensIterator(opts ...ListTokensOption) (*UnspentTokensIterator, error)
ListUnspentTokensIterator returns an iterator of unspent tokens owned by identities in this wallet and filtered by the passed options. Options: WithType
func (*OwnerWallet) RegisterRecipient ¶ added in v0.3.0
func (o *OwnerWallet) RegisterRecipient(data *RecipientData) error
RegisterRecipient register the passed recipient data. The data is passed as pointer to allow the underlying token driver to modify them if needed.
func (*OwnerWallet) Remote ¶ added in v0.4.0
func (o *OwnerWallet) Remote() bool
Remote returns true if this wallet is verify only, meaning that the corresponding secret key is external to this wallet
type PublicParameters ¶ added in v0.3.0
type PublicParameters struct { driver.PublicParameters // contains filtered or unexported fields }
func (*PublicParameters) Auditors ¶ added in v0.3.0
func (c *PublicParameters) Auditors() []Identity
Auditors returns the list of auditors' identities
func (*PublicParameters) CertificationDriver ¶ added in v0.3.0
func (c *PublicParameters) CertificationDriver() string
CertificationDriver return the certification driver used to certify that tokens exist
func (*PublicParameters) GraphHiding ¶ added in v0.3.0
func (c *PublicParameters) GraphHiding() bool
GraphHiding returns true if graph hiding is enabled
func (*PublicParameters) Identifier ¶ added in v0.3.0
func (c *PublicParameters) Identifier() string
Identifier returns the identifier of the public parameters
func (*PublicParameters) MaxTokenValue ¶ added in v0.3.0
func (c *PublicParameters) MaxTokenValue() uint64
MaxTokenValue returns the maximum value a token can contain
func (*PublicParameters) Precision ¶ added in v0.3.0
func (c *PublicParameters) Precision() uint64
Precision returns the precision used to represent the token quantity
func (*PublicParameters) Serialize ¶ added in v0.3.0
func (c *PublicParameters) Serialize() ([]byte, error)
Serialize returns the public parameters in their serialized form
func (*PublicParameters) TokenDataHiding ¶ added in v0.3.0
func (c *PublicParameters) TokenDataHiding() bool
TokenDataHiding returns true if data hiding is enabled
type PublicParametersManager ¶
type PublicParametersManager struct {
// contains filtered or unexported fields
}
PublicParametersManager exposes methods to manage the public parameters
func (*PublicParametersManager) PublicParameters ¶ added in v0.3.0
func (c *PublicParametersManager) PublicParameters() *PublicParameters
PublicParameters returns the public parameters, nil if not set yet.
func (*PublicParametersManager) PublicParamsHash ¶ added in v0.4.0
func (c *PublicParametersManager) PublicParamsHash() PPHash
type PublicParamsFetcher ¶
type PublicParamsFetcher interface { // Fetch fetches the public parameters from the backend Fetch() ([]byte, error) }
PublicParamsFetcher models the public parameters fetcher
type QueryEngine ¶
type QueryEngine struct { // Variables used to control retry condition NumRetries int RetryDelay time.Duration // contains filtered or unexported fields }
QueryEngine models a token query engine
func NewQueryEngine ¶ added in v0.3.0
func NewQueryEngine(logger logging.Logger, qe driver.QueryEngine, numRetries int, retryDelay time.Duration) *QueryEngine
func (*QueryEngine) GetStatus ¶ added in v0.4.0
func (q *QueryEngine) GetStatus(txID string) (TxStatus, string, error)
GetStatus returns the status of the passed transaction
func (*QueryEngine) GetTokens ¶
GetTokens returns the tokens stored in the vault matching the given ids
func (*QueryEngine) IsMine ¶
func (q *QueryEngine) IsMine(id *token.ID) (bool, error)
IsMine returns true is the given token is in this vault and therefore owned by this client
func (*QueryEngine) ListAuditTokens ¶
func (*QueryEngine) ListHistoryIssuedTokens ¶
func (q *QueryEngine) ListHistoryIssuedTokens() (*token.IssuedTokens, error)
func (*QueryEngine) ListUnspentTokens ¶
func (q *QueryEngine) ListUnspentTokens() (*token.UnspentTokens, error)
ListUnspentTokens returns a list of all unspent tokens stored in the vault
func (*QueryEngine) PublicParams ¶
func (q *QueryEngine) PublicParams() ([]byte, error)
PublicParams returns the public parameters stored in the vault
func (*QueryEngine) UnspentTokensIterator ¶
func (q *QueryEngine) UnspentTokensIterator() (*UnspentTokensIterator, error)
UnspentTokensIterator returns an iterator over all unspent tokens stored in the vault
func (*QueryEngine) UnspentTokensIteratorBy ¶
func (q *QueryEngine) UnspentTokensIteratorBy(ctx context.Context, id string, tokenType token.Type) (driver.UnspentTokensIterator, error)
UnspentTokensIteratorBy is an iterator over all unspent tokens in this vault owned by passed wallet id and whose token type matches the passed token type
type RecipientData ¶ added in v0.3.0
type RecipientData = driver.RecipientData
RecipientData contains information about the identity of a token owner
type Request ¶
type Request struct { // Anchor is used to bind the Actions to a given Transaction Anchor string // Actions contains the token operations. Actions *driver.TokenRequest // Metadata contains the actions' metadata used to unscramble the content of the actions, if the // underlying token driver requires that Metadata *driver.TokenRequestMetadata // TokenService this request refers to TokenService *ManagementService `json:"-"` }
Request aggregates token operations that must be performed atomically. Operations are represented in a backend agnostic way but driver specific.
func NewFullRequestFromBytes ¶ added in v0.4.0
func NewFullRequestFromBytes(tokenService *ManagementService, tr []byte) (*Request, error)
NewFullRequestFromBytes creates a new request from the given byte representation
func NewRequest ¶
func NewRequest(tokenService *ManagementService, anchor string) *Request
NewRequest creates a new empty request for the given token service and anchor
func NewRequestFromBytes ¶
func NewRequestFromBytes(tokenService *ManagementService, anchor string, actions []byte, trmRaw []byte) (*Request, error)
NewRequestFromBytes creates a new request from the given anchor, and whose actions and metadata are unmarshalled from the given bytes
func (*Request) AddAuditorSignature ¶
AddAuditorSignature adds an auditor signature to the request.
func (*Request) ApplicationMetadata ¶
ApplicationMetadata returns the application metadata corresponding to the given key
func (*Request) AuditCheck ¶
AuditCheck performs the audit check of the request in addition to the checks of the token request itself via IsValid.
func (*Request) AuditRecord ¶
func (r *Request) AuditRecord() (*AuditRecord, error)
AuditRecord return the audit record of the request. The audit record contains: The anchor, the audit inputs and outputs
func (*Request) BindTo ¶
BindTo binds transfers' senders and receivers, that are senders, that are not me to the passed identity
func (*Request) Bytes ¶
Bytes marshals the request to bytes. It includes: Anchor (or ID), actions, and metadata.
func (*Request) FilterMetadataBy ¶
FilterMetadataBy returns a new Request with the metadata filtered by the given enrollment IDs.
func (*Request) FromBytes ¶
FromBytes unmarshalls the request from bytes overriding the content of the current request.
func (*Request) GetMetadata ¶
GetMetadata returns the metadata of the request.
func (*Request) Inputs ¶
func (r *Request) Inputs() (*InputStream, error)
Inputs returns the sequence of inputs of the request supporting sequential and parallel aggregate operations. Notice that the inputs do not carry Type and Quantity because this information might be available to all parties. If you are an auditor, you can use the AuditInputs method to get everything.
func (*Request) InputsAndOutputs ¶ added in v0.3.0
func (r *Request) InputsAndOutputs() (*InputStream, *OutputStream, error)
func (*Request) Issue ¶
func (r *Request) Issue(ctx context.Context, wallet *IssuerWallet, receiver Identity, typ token.Type, q uint64, opts ...IssueOption) (*IssueAction, error)
Issue appends an issue action to the request. The action will be prepared using the provided issuer wallet. The action issues to the receiver a token of the passed type and quantity. Additional options can be passed to customize the action.
func (*Request) IssueSigners ¶ added in v0.3.0
func (*Request) MarshalToAudit ¶
MarshalToAudit marshals the request to a message suitable for audit signature. In particular, metadata is not included.
func (*Request) MarshalToSign ¶
MarshalToSign marshals the request to a message suitable for signing.
func (*Request) MetadataToBytes ¶
MetadataToBytes marshals the request's metadata to bytes.
func (*Request) Outputs ¶
func (r *Request) Outputs() (*OutputStream, error)
Outputs returns the sequence of outputs of the request supporting sequential and parallel aggregate operations.
func (*Request) Redeem ¶
func (r *Request) Redeem(ctx context.Context, wallet *OwnerWallet, typ token.Type, value uint64, opts ...TransferOption) error
Redeem appends a redeem action to the request. The action will be prepared using the provided owner wallet. The action redeems tokens of the passed type for a total amount matching the passed value. Additional options can be passed to customize the action.
func (*Request) RequestToBytes ¶
RequestToBytes marshals the request's actions to bytes.
func (*Request) SetApplicationMetadata ¶
SetApplicationMetadata sets application metadata in terms of key-value pairs. The Token-SDK does not control the format of the metadata.
func (*Request) SetSignatures ¶ added in v0.4.0
func (*Request) SetTokenService ¶
func (r *Request) SetTokenService(service *ManagementService)
SetTokenService sets the token service.
func (*Request) Transfer ¶
func (r *Request) Transfer(ctx context.Context, wallet *OwnerWallet, typ token.Type, values []uint64, owners []Identity, opts ...TransferOption) (*TransferAction, error)
Transfer appends a transfer action to the request. The action will be prepared using the provided owner wallet. The action transfers tokens of the passed types to the receivers for the passed quantities. In other words, owners[0] will receives values[0], and so on. Additional options can be passed to customize the action.
func (*Request) TransferSigners ¶ added in v0.3.0
type Selector ¶
type Selector interface { // Select returns the list of token identifiers where // 1. The owner match the passed owner filter. // 2. The type is equal to the passed token type. // 3. The sum of amount in each token is at least the passed quantity. // Quantity is a string in decimal format // Notice that, the quantity selected might exceed the quantity requested due to the amounts // stored in each token. Select(ownerFilter OwnerFilter, q string, tokenType token2.Type) ([]*token2.ID, token2.Quantity, error) // Close closes the selector and releases its memory/cpu resources Close() error }
Selector is the interface of token selectors
type SelectorManager ¶
type SelectorManager interface { // NewSelector returns a new Selector instance bound the passed id. NewSelector(id string) (Selector, error) // Unlock unlocks the tokens bound to the passed id, if any Unlock(id string) error // Close closes the selector and releases its memory/cpu resources Close(id string) error }
SelectorManager handles token selection operations
type SelectorManagerProvider ¶
type SelectorManagerProvider interface { // SelectorManager returns a SelectorManager instance for the passed inputs. SelectorManager(tms *ManagementService) (SelectorManager, error) }
SelectorManagerProvider provides instances of SelectorManager
type ServiceOption ¶
type ServiceOption func(*ServiceOptions) error
ServiceOption is a function that configures a ServiceOptions
func WithNamespace ¶
func WithNamespace(namespace string) ServiceOption
WithNamespace sets the namespace for the service
func WithNetwork ¶
func WithNetwork(network string) ServiceOption
WithNetwork sets the network name
func WithPublicParameter ¶ added in v0.4.0
func WithPublicParameter(publicParams []byte) ServiceOption
WithPublicParameter sets the public parameters
func WithPublicParameterFetcher ¶
func WithPublicParameterFetcher(ppFetcher PublicParamsFetcher) ServiceOption
WithPublicParameterFetcher sets the public parameters fetcher
func WithTMS ¶
func WithTMS(network, channel, namespace string) ServiceOption
WithTMS filters by network, channel and namespace. Each of them can be empty
type ServiceOptions ¶
type ServiceOptions struct { // Network is the name of the network Network string // Channel is the name of the channel, if meaningful for the underlying backend Channel string // Namespace is the namespace of the token Namespace string // PublicParamsFetcher is used to fetch the public parameters PublicParamsFetcher PublicParamsFetcher // PublicParams contains the public params to use to instantiate the driver PublicParams []byte // Params is used to store any application specific parameter Params map[string]interface{} }
ServiceOptions is used to configure the service
func CompileServiceOptions ¶
func CompileServiceOptions(opts ...ServiceOption) (*ServiceOptions, error)
CompileServiceOptions compiles the given list of ServiceOption
func (ServiceOptions) ParamAsString ¶
func (o ServiceOptions) ParamAsString(key string) (string, error)
ParamAsString returns the value bound to the passed key. If the key is not found, it returns the empty string. if the value bound to the passed key is not a string, it returns an error.
func (ServiceOptions) TMSID ¶
func (o ServiceOptions) TMSID() TMSID
TMSID returns the TMSID for the given ServiceOptions
type ServiceProvider ¶
type ServiceProvider interface { // GetService returns an instance of the given type GetService(v interface{}) (interface{}, error) }
ServiceProvider is used to return instances of a given type
type SignatureService ¶
type SignatureService struct {
// contains filtered or unexported fields
}
SignatureService gives access to signature verifiers and signers bound to identities known by this service
func (*SignatureService) AuditorVerifier ¶
func (s *SignatureService) AuditorVerifier(id Identity) (Verifier, error)
AuditorVerifier returns a signature verifier for the given auditor identity
func (*SignatureService) GetSigner ¶
func (s *SignatureService) GetSigner(id Identity) (Signer, error)
GetSigner returns a signer bound to the given identity
func (*SignatureService) IsMe ¶
func (s *SignatureService) IsMe(party Identity) bool
IsMe returns true if for the given identity there is a signer registered
func (*SignatureService) IssuerVerifier ¶
func (s *SignatureService) IssuerVerifier(id Identity) (Verifier, error)
IssuerVerifier returns a signature verifier for the given issuer identity
func (*SignatureService) OwnerVerifier ¶
func (s *SignatureService) OwnerVerifier(id Identity) (Verifier, error)
OwnerVerifier returns a signature verifier for the given owner identity
func (*SignatureService) RegisterSigner ¶
func (s *SignatureService) RegisterSigner(identity Identity, signer Signer, verifier Verifier) error
RegisterSigner registers the pair (signer, verifier) bound to the given identity
type TMSNormalizer ¶ added in v0.4.0
type TMSNormalizer Normalizer
type Transfer ¶
type Transfer struct { // Senders is the list of identities of the senders Senders []Identity // Receivers is the list of identities of the receivers Receivers []Identity // ExtraSigners is the list of extra identities that must sign the token request to make it valid. // This field is to be used by the token drivers to list any additional identities that must // sign the token request. ExtraSigners []Identity }
Transfer contains information about a transfer operation. In particular, it carries the identities of the senders and the receivers
type TransferAction ¶
type TransferAction struct {
// contains filtered or unexported fields
}
TransferAction represents an action that transfers tokens.
func (*TransferAction) GetInputs ¶
func (t *TransferAction) GetInputs() []*token.ID
GetInputs returns the input ids used in the action.
func (*TransferAction) GetSerialNumbers ¶ added in v0.4.0
func (t *TransferAction) GetSerialNumbers() []string
func (*TransferAction) GetSerializedOutputs ¶
func (t *TransferAction) GetSerializedOutputs() ([][]byte, error)
GetSerializedOutputs returns the serialized outputs of the action.
func (*TransferAction) IsGraphHiding ¶
func (t *TransferAction) IsGraphHiding() bool
IsGraphHiding returns true if the action supports graph hiding.
func (*TransferAction) IsRedeemAt ¶
func (t *TransferAction) IsRedeemAt(i int) bool
IsRedeemAt returns true if the i-th output redeems.
func (*TransferAction) NumOutputs ¶
func (t *TransferAction) NumOutputs() int
NumOutputs returns the number of outputs in the action.
func (*TransferAction) Serialize ¶
func (t *TransferAction) Serialize() ([]byte, error)
Serialize returns the byte representation of the action.
func (*TransferAction) SerializeOutputAt ¶
func (t *TransferAction) SerializeOutputAt(i int) ([]byte, error)
SerializeOutputAt returns the serialized output at the i-th position.
type TransferMetadata ¶
type TransferMetadata struct {
*driver.TransferMetadata
}
TransferMetadata contains the metadata of a transfer action
func (*TransferMetadata) IsInputAbsent ¶
func (m *TransferMetadata) IsInputAbsent(j int) bool
IsInputAbsent returns true if the given input's metadata is absent
func (*TransferMetadata) IsOutputAbsent ¶
func (m *TransferMetadata) IsOutputAbsent(j int) bool
IsOutputAbsent returns true if the given output's metadata is absent
func (*TransferMetadata) Match ¶
func (m *TransferMetadata) Match(action *TransferAction) error
Match returns true if the given action matches this metadata
type TransferOption ¶
type TransferOption func(*TransferOptions) error
TransferOption is a function that modify TransferOptions
func WithRestRecipientIdentity ¶ added in v0.3.0
func WithRestRecipientIdentity(recipientData *RecipientData) TransferOption
WithRestRecipientIdentity sets the recipient data to be used to assign any rest left during a transfer operation
func WithTokenIDs ¶
func WithTokenIDs(ids ...*token.ID) TransferOption
WithTokenIDs sets the tokens ids to transfer
func WithTokenSelector ¶
func WithTokenSelector(selector Selector) TransferOption
WithTokenSelector sets the passed token selector
func WithTransferAttribute ¶
func WithTransferAttribute(attr, value interface{}) TransferOption
WithTransferAttribute sets an attribute to be used to customize the transfer command
func WithTransferMetadata ¶
func WithTransferMetadata(key string, value []byte) TransferOption
WithTransferMetadata sets transfer action metadata
type TransferOptions ¶
type TransferOptions struct { // Attributes is a container of generic options that might be driver specific Attributes map[interface{}]interface{} // Selector is the custom token selector to use. If nil, the default will be used. Selector Selector // TokenIDs to transfer. If empty, the tokens will be selected. TokenIDs []*token.ID // RestRecipientIdentity TODO: RestRecipientIdentity *RecipientData }
TransferOptions models the options that can be passed to the transfer command
type UnspentTokensIterator ¶
type UnspentTokensIterator struct {
driver.UnspentTokensIterator
}
UnspentTokensIterator models an iterator over all unspent tokens stored in the vault
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator validates a token request
func NewValidator ¶ added in v0.4.0
func (*Validator) UnmarshalActions ¶
UnmarshalActions returns the actions contained in the serialized token request
func (*Validator) UnmarshallAndVerify ¶
func (c *Validator) UnmarshallAndVerify(ctx context.Context, ledger Ledger, anchor string, raw []byte) ([]interface{}, error)
UnmarshallAndVerify unmarshalls the token request and verifies it against the passed ledger and anchor
func (*Validator) UnmarshallAndVerifyWithMetadata ¶ added in v0.3.0
func (c *Validator) UnmarshallAndVerifyWithMetadata(ctx context.Context, ledger Ledger, anchor string, raw []byte) ([]interface{}, map[string][]byte, error)
UnmarshallAndVerifyWithMetadata behaves as UnmarshallAndVerify. In addition, it returns the metadata extracts from the token request in the form of map.
type Vault ¶
type Vault struct {
// contains filtered or unexported fields
}
Vault models a token vault
func (*Vault) CertificationStorage ¶ added in v0.4.0
func (v *Vault) CertificationStorage() *CertificationStorage
func (*Vault) NewQueryEngine ¶
func (v *Vault) NewQueryEngine() *QueryEngine
NewQueryEngine returns a new query engine
type VaultProvider ¶
type VaultProvider interface { // Vault returns a token vault instance for the passed inputs Vault(network string, channel string, namespace string) (driver.Vault, error) }
VaultProvider provides token vault instances
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
Wallet models a generic wallet that has an identifier and contains one or mode identities. These identities own tokens.
func (*Wallet) ContainsToken ¶
func (w *Wallet) ContainsToken(token *token.UnspentToken) bool
ContainsToken returns true if the wallet contains an identity that owns the passed token.
func (*Wallet) TMS ¶
func (w *Wallet) TMS() *ManagementService
TMS returns the token management service.
type WalletLookupID ¶ added in v0.4.0
type WalletLookupID = driver.WalletLookupID
WalletLookupID defines the type of identifiers that can be used to retrieve a given wallet. It can be a string, as the name of the wallet, or an identity contained in that wallet. Ultimately, it is the token driver to decide which types are allowed.
type WalletManager ¶
type WalletManager struct {
// contains filtered or unexported fields
}
WalletManager defines the interface for managing wallets.
func NewWalletManager ¶ added in v0.3.0
func NewWalletManager(walletService driver.WalletService) *WalletManager
func (*WalletManager) AuditorWallet ¶
func (wm *WalletManager) AuditorWallet(id WalletLookupID) *AuditorWallet
AuditorWallet returns the auditor wallet bound to the passed identifier, if any is available. The identifier can be a label, as defined in the configuration file, an identity or a wallet ID. If no wallet is found, it returns nil.
func (*WalletManager) CertifierWallet ¶
func (wm *WalletManager) CertifierWallet(id WalletLookupID) *CertifierWallet
CertifierWallet returns the certifier wallet bound to the passed identifier, if any is available. The identifier can be a label, as defined in the configuration file, an identity or a wallet ID. If no wallet is found, it returns nil.
func (*WalletManager) GetEnrollmentID ¶
func (wm *WalletManager) GetEnrollmentID(identity Identity) (string, error)
GetEnrollmentID returns the enrollment ID of passed identity
func (*WalletManager) GetRevocationHandle ¶ added in v0.3.0
func (wm *WalletManager) GetRevocationHandle(identity Identity) (string, error)
GetRevocationHandle returns the revocation handle of the passed identity
func (*WalletManager) IssuerWallet ¶
func (wm *WalletManager) IssuerWallet(id WalletLookupID) *IssuerWallet
IssuerWallet returns the issuer wallet bound to the passed identifier, if any is available. The identifier can be a label, as defined in the configuration file, an identity or a wallet ID. If no wallet is found, it returns nil.
func (*WalletManager) OwnerWallet ¶
func (wm *WalletManager) OwnerWallet(id WalletLookupID) *OwnerWallet
OwnerWallet returns the owner wallet bound to the passed identifier, if any is available. The identifier can be a label, as defined in the configuration file, an identity or a wallet ID. If no wallet is found, it returns nil.
func (*WalletManager) OwnerWalletIDs ¶ added in v0.3.0
func (wm *WalletManager) OwnerWalletIDs() ([]string, error)
OwnerWalletIDs returns the list of owner wallet identifiers
func (*WalletManager) RegisterIssuerIdentity ¶ added in v0.4.0
func (wm *WalletManager) RegisterIssuerIdentity(id string, url string) error
RegisterIssuerIdentity registers an issuer long-term identity. The identity will be loaded from the passed url. Depending on the support, the url can be a path in the file system or something else.
func (*WalletManager) RegisterOwnerIdentity ¶ added in v0.4.0
func (wm *WalletManager) RegisterOwnerIdentity(id string, url string) error
RegisterOwnerIdentity registers an owner long-term identity. The identity will be loaded from the passed url. Depending on the support, the url can be a path in the file system or something else.
func (*WalletManager) RegisterOwnerIdentityConfiguration ¶ added in v0.4.0
func (wm *WalletManager) RegisterOwnerIdentityConfiguration(conf IdentityConfiguration) error
RegisterOwnerIdentityConfiguration registers an owner long-term identity via a identity configuration
func (*WalletManager) RegisterRecipientIdentity ¶
func (wm *WalletManager) RegisterRecipientIdentity(data *RecipientData) error
RegisterRecipientIdentity registers a new recipient identity
func (*WalletManager) SpentIDs ¶
func (wm *WalletManager) SpentIDs(ids []*token.ID) ([]string, error)
SpentIDs returns the spent keys corresponding to the passed token IDs
func (*WalletManager) Wallet ¶
func (wm *WalletManager) Wallet(identity Identity) *Wallet
Wallet returns the wallet bound to the passed identity, if any is available. If no wallet is found, it returns nil.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
zkatdlog/crypto/audit/mock
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
zkatdlog/crypto/transfer/mock
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
zkatdlog/crypto/validator/mock
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
mock
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
sdk
|
|
services
|
|
network/common/rws/translator/mock
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
network/fabric/tcc/mock
Code generated by counterfeiter.
|
Code generated by counterfeiter. |