token

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: Apache-2.0 Imports: 21 Imported by: 8

Documentation ¶

Overview ¶

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index ¶

Constants ¶

View Source
const (
	TransferMetadataPrefix = meta.TransferMetadataPrefix
	IssueMetadataPrefix    = meta.IssueMetadataPrefix
)
View Source
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
)

Variables ¶

View Source
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 is used to bind the Actions to a given Transaction
	Anchor RequestAnchor
	// Inputs represent the input tokens of the transaction
	Inputs *InputStream
	// Outputs represent the output tokens of the transaction
	Outputs *OutputStream
	// Attributes are metadata which are stored on the public ledger as part of the transaction Actions.
	Attributes map[string][]byte
}

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.

func (*AuditorWallet) GetSigner ¶

func (a *AuditorWallet) GetSigner(ctx context.Context, identity driver.Identity) (driver.Signer, error)

GetSigner returns the signer bound to the passed auditor identity.

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 Binder ¶ added in v0.4.0

type Binder interface {
	Bind(ctx context.Context, longTerm Identity, ephemeral Identity) error
}

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(ctx context.Context, 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(ctx context.Context, 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
}

func (*CertificationStorage) Exists ¶ added in v0.4.0

func (c *CertificationStorage) Exists(ctx context.Context, id *token.ID) bool

func (*CertificationStorage) Store ¶ added in v0.4.0

func (c *CertificationStorage) Store(ctx context.Context, certifications map[*token.ID][]byte) error

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.

func (*CertifierWallet) GetSigner ¶

func (a *CertifierWallet) GetSigner(ctx context.Context, identity driver.Identity) (driver.Signer, error)

GetSigner returns the signer bound to the passed certifier identity.

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 Hashable ¶ added in v0.4.0

type Hashable []byte

func (Hashable) Raw ¶ added in v0.4.0

func (id Hashable) Raw() []byte

func (Hashable) RawString ¶ added in v0.4.0

func (id Hashable) RawString() string

func (Hashable) String ¶ added in v0.4.0

func (id Hashable) String() string

type Identity ¶ added in v0.4.0

type Identity = driver.Identity

Identity represents a generic identity

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(ctx context.Context) (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) NumInputs ¶ added in v0.5.0

func (i *IssueAction) NumInputs() int

NumInputs returns the number of inputs in the action

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.

func (*IssueAction) Validate ¶ added in v0.5.0

func (i *IssueAction) Validate() error

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

func WithIssueMetadata ¶ added in v0.5.0

func WithIssueMetadata(key string, value []byte) IssueOption

WithIssueMetadata sets issue action metadata

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(ctx context.Context, identity driver.Identity) (driver.Signer, error)

GetSigner returns the signer bound to the passed issuer identity.

func (*IssuerWallet) ListIssuedTokens ¶

func (i *IssuerWallet) ListIssuedTokens(ctx context.Context, 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 Ledger ¶

type Ledger = driver.ValidatorLedger

Ledger models a read-only ledger

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 RequestAnchor) (*Request, error)

NewRequest returns a new Token Request whose anchor is the passed id

func (*ManagementService) NewRequestFromBytes ¶

func (t *ManagementService) NewRequestFromBytes(anchor RequestAnchor, 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) TokensService ¶ added in v0.5.0

func (t *ManagementService) TokensService() *TokensService

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.

func (*ManagementServiceProvider) Update ¶ added in v0.4.0

func (p *ManagementServiceProvider) Update(tmsID TMSID, val []byte) error

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 ¶

func (m *Metadata) FilterBy(eIDs ...string) (*Metadata, error)

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) Issue ¶

func (m *Metadata) Issue(i int) (*IssueMetadata, error)

Issue returns the i-th issue metadata, if present

func (*Metadata) SpentTokenID ¶

func (m *Metadata) SpentTokenID() []*token.ID

SpentTokenID returns the token IDs of the tokens that were spent by the Token Request this metadata is associated with.

func (*Metadata) Transfer ¶

func (m *Metadata) Transfer(i int) (*TransferMetadata, error)

Transfer returns the i-th transfer metadata, if present

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 {
	token.Token
	// 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
	// LedgerOutputMetadata is the metadata of the output
	LedgerOutputMetadata []byte
	// Issuer is the identity of the issuer of this output, if any
	Issuer driver.Identity
}

Output models the output of a token action

func (Output) ID ¶

func (o Output) ID(anchor RequestAnchor) *token.ID

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(ctx context.Context, 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(ctx context.Context, id Identity) ([]byte, error)

GetAuditInfo returns auditing information for the passed identity

func (*OwnerWallet) GetRecipientData ¶ added in v0.5.0

func (o *OwnerWallet) GetRecipientData(ctx context.Context) (*RecipientData, error)

GetRecipientData return the owner recipient identity, it does not include token metadata audit info

func (*OwnerWallet) GetRecipientIdentity ¶

func (o *OwnerWallet) GetRecipientIdentity(ctx context.Context) (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(ctx context.Context, identity driver.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(ctx context.Context, 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 PPHash ¶ added in v0.4.0

type PPHash = driver.PPHash

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

func (*PublicParameters) TokenDriverName ¶ added in v0.5.0

func (c *PublicParameters) TokenDriverName() driver.TokenDriverName

Identifier returns the identifier of the public parameters

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(ctx context.Context, txID string) (TxStatus, string, error)

GetStatus returns the status of the passed transaction

func (*QueryEngine) GetTokenOutputs ¶ added in v0.5.0

func (q *QueryEngine) GetTokenOutputs(ctx context.Context, ds []*token.ID, f func(id *token.ID, tokenRaw []byte) error) 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

func (*QueryEngine) GetTokens ¶

func (q *QueryEngine) GetTokens(ctx context.Context, inputs ...*token.ID) ([]*token.Token, error)

GetTokens returns the tokens stored in the vault matching the given ids

func (*QueryEngine) IsMine ¶

func (q *QueryEngine) IsMine(ctx context.Context, 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 (q *QueryEngine) ListAuditTokens(ctx context.Context, ids ...*token.ID) ([]*token.Token, error)

func (*QueryEngine) ListHistoryIssuedTokens ¶

func (q *QueryEngine) ListHistoryIssuedTokens(ctx context.Context) (*token.IssuedTokens, error)

func (*QueryEngine) ListUnspentTokens ¶

func (q *QueryEngine) ListUnspentTokens(ctx context.Context) (*token.UnspentTokens, error)

ListUnspentTokens returns a list of all unspent tokens stored in the vault

func (*QueryEngine) PublicParams ¶

func (q *QueryEngine) PublicParams(ctx context.Context) ([]byte, error)

PublicParams returns the public parameters stored in the vault

func (*QueryEngine) UnspentLedgerTokensIteratorBy ¶ added in v0.5.0

func (q *QueryEngine) UnspentLedgerTokensIteratorBy(ctx context.Context) (driver.LedgerTokensIterator, error)

func (*QueryEngine) UnspentTokensIterator ¶

func (q *QueryEngine) UnspentTokensIterator(ctx context.Context) (*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

func (*QueryEngine) WhoDeletedTokens ¶ added in v0.5.0

func (q *QueryEngine) WhoDeletedTokens(ctx context.Context, iDs ...*token.ID) ([]string, []bool, 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

type QueryService ¶

type QueryService interface {
	IsMine(ctx context.Context, id *token.ID) (bool, error)
}

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 driver.TokenRequestAnchor
	// 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 RequestAnchor) *Request

NewRequest creates a new empty request for the given token service and anchor

func NewRequestFromBytes ¶

func NewRequestFromBytes(tokenService *ManagementService, anchor RequestAnchor, 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 ¶

func (r *Request) AddAuditorSignature(identity Identity, sigma []byte)

AddAuditorSignature adds an auditor signature to the request.

func (*Request) AllApplicationMetadata ¶ added in v0.5.0

func (r *Request) AllApplicationMetadata() map[string][]byte

func (*Request) ApplicationMetadata ¶

func (r *Request) ApplicationMetadata(k string) []byte

ApplicationMetadata returns the application metadata corresponding to the given key

func (*Request) AuditCheck ¶

func (r *Request) AuditCheck(ctx context.Context) error

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(ctx context.Context) (*AuditRecord, error)

AuditRecord return the audit record of the request. The audit record contains: The anchor, the audit inputs and outputs

func (*Request) BindTo ¶

func (r *Request) BindTo(ctx context.Context, binder Binder, identity Identity) error

BindTo binds transfers' senders and receivers, that are senders, that are not me to the passed identity

func (*Request) Bytes ¶

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

Bytes marshals the request to bytes. It includes: Anchor (or ID), actions, and metadata.

func (*Request) FilterMetadataBy ¶

func (r *Request) FilterMetadataBy(eIDs ...string) (*Request, error)

FilterMetadataBy returns a new Request with the metadata filtered by the given enrollment IDs.

func (*Request) FromBytes ¶

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

FromBytes unmarshalls the request from bytes overriding the content of the current request.

func (*Request) GetMetadata ¶

func (r *Request) GetMetadata() (*Metadata, error)

GetMetadata returns the metadata of the request.

func (*Request) ID ¶

func (r *Request) ID() RequestAnchor

ID returns the anchor 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(ctx context.Context) (*InputStream, *OutputStream, map[string][]byte, error)

func (*Request) InputsAndOutputsNoRecipients ¶ added in v0.5.0

func (r *Request) InputsAndOutputsNoRecipients(ctx context.Context) (*InputStream, *OutputStream, error)

func (*Request) IsValid ¶

func (r *Request) IsValid(ctx context.Context) error

IsValid checks that the request is valid.

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 (r *Request) IssueSigners() []Identity

func (*Request) Issues ¶

func (r *Request) Issues() []*Issue

Issues returns the list of issued tokens.

func (*Request) MarshalToAudit ¶

func (r *Request) MarshalToAudit() ([]byte, error)

MarshalToAudit marshals the request to a message suitable for audit signature. In particular, metadata is not included.

func (*Request) MarshalToSign ¶

func (r *Request) MarshalToSign() ([]byte, error)

MarshalToSign marshals the request to a message suitable for signing.

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) PublicParamsHash ¶ added in v0.5.0

func (r *Request) PublicParamsHash() PPHash

func (*Request) Redeem ¶

func (r *Request) Redeem(ctx context.Context, wallet *OwnerWallet, typ token.Type, value uint64, opts ...TransferOption) (*TransferAction, 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 ¶

func (r *Request) RequestToBytes() ([]byte, error)

RequestToBytes marshals the request's actions to bytes.

func (*Request) SetApplicationMetadata ¶

func (r *Request) SetApplicationMetadata(k string, v []byte)

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 (r *Request) SetSignatures(sigmas map[string][]byte) bool

func (*Request) SetTokenService ¶

func (r *Request) SetTokenService(service *ManagementService)

SetTokenService sets the token service.

func (*Request) String ¶ added in v0.5.0

func (r *Request) String() string

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

func (r *Request) TransferSigners() []Identity

func (*Request) Transfers ¶

func (r *Request) Transfers() []*Transfer

Transfers returns the list of transfers.

func (*Request) Upgrade ¶ added in v0.5.0

func (r *Request) Upgrade(
	ctx context.Context,
	wallet *IssuerWallet,
	receiver Identity,
	challenge TokensUpgradeChallenge,
	tokens []token.LedgerToken,
	proof TokensUpgradeProof,
	opts ...IssueOption,
) (*IssueAction, error)

Upgrade performs an upgrade operation of the passed ledger tokens. A proof and its challenge will be used to verify that the request of upgrade is legit. If the proof verifies then the passed wallet will be used to issue a new amount of tokens matching those whose upgrade has been requested.

type RequestAnchor ¶ added in v0.5.0

type RequestAnchor = driver.TokenRequestAnchor

RequestAnchor models the anchor of a token request

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(ctx context.Context, ownerFilter OwnerFilter, q string, tokenType token.Type) ([]*token.ID, token.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(ctx context.Context, 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 WithChannel ¶

func WithChannel(channel string) ServiceOption

WithChannel sets the channel

func WithDuration ¶ added in v0.5.0

func WithDuration(duration time.Duration) ServiceOption

WithDuration sets the duration a given operation should take

func WithInitiator ¶ added in v0.5.0

func WithInitiator(initiator view.View) ServiceOption

WithInitiator sets the view initiating the service

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

func WithTMSID ¶

func WithTMSID(id TMSID) ServiceOption

WithTMSID filters by TMS identifier

func WithTMSIDPointer ¶ added in v0.5.0

func WithTMSIDPointer(id *TMSID) ServiceOption

WithTMSIDPointer filters by TMS identifier, if provided

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{}
	// Initiator is the view initiating the service
	Initiator view.View
	// Duration is the duration a given operation should take
	Duration time.Duration
}

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) AreMe ¶ added in v0.5.0

func (s *SignatureService) AreMe(ctx context.Context, identities ...Identity) []string

AreMe returns the hashes of the passed identities that have a signer registered before

func (*SignatureService) AuditorVerifier ¶

func (s *SignatureService) AuditorVerifier(id Identity) (Verifier, error)

AuditorVerifier returns a signature verifier for the given auditor identity

func (*SignatureService) GetAuditInfo ¶ added in v0.5.0

func (s *SignatureService) GetAuditInfo(ctx context.Context, ids ...Identity) ([][]byte, error)

GetAuditInfo returns the audit infor

func (*SignatureService) GetSigner ¶

func (s *SignatureService) GetSigner(ctx context.Context, id Identity) (Signer, error)

GetSigner returns a signer bound to the given identity

func (*SignatureService) IsMe ¶

func (s *SignatureService) IsMe(ctx context.Context, 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(ctx context.Context, identity Identity, signer Signer, verifier Verifier) error

RegisterSigner registers the pair (signer, verifier) bound to the given identity

type Signer ¶

type Signer = driver.Signer

Signer models a signature signer

type TMSID ¶

type TMSID = driver.TMSID

TMSID models a TMS identifier

type TMSNormalizer ¶ added in v0.4.0

type TMSNormalizer Normalizer

type TokensService ¶ added in v0.5.0

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

TokensService models the token service

func (*TokensService) Deobfuscate ¶ added in v0.5.0

func (t *TokensService) Deobfuscate(output []byte, outputMetadata []byte) (*token.Token, Identity, []Identity, token.Format, error)

Deobfuscate processes the passed output and metadata to derive a token.Token, its issuer (if any), and its token format

func (*TokensService) GenUpgradeProof ¶ added in v0.5.0

func (t *TokensService) GenUpgradeProof(id []byte, tokens []token.LedgerToken) ([]byte, error)

GenUpgradeProof generates an upgrade proof for the given challenge and tokens

func (*TokensService) NewUpgradeChallenge ¶ added in v0.5.0

func (t *TokensService) NewUpgradeChallenge() ([]byte, error)

NewUpgradeChallenge generates a new upgrade challenge

func (*TokensService) SupportedTokenFormats ¶ added in v0.5.0

func (t *TokensService) SupportedTokenFormats() []token.Format

SupportedTokenFormats returns the supported token formats

type TokensUpgradeChallenge ¶ added in v0.5.0

type TokensUpgradeChallenge = driver.TokensUpgradeChallenge

TokensUpgradeChallenge is the challenge the issuer generates to make sure the client is not cheating

type TokensUpgradeProof ¶ added in v0.5.0

type TokensUpgradeProof = driver.TokensUpgradeProof

TokensUpgradeProof is the proof generated with the respect to a given challenge to prove the validity of the tokens to be upgrade

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
	// Issuer
	Issuer 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 {
	driver.TransferAction
}

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) GetIssuer ¶ added in v0.5.0

func (t *TransferAction) GetIssuer() Identity

GetIssuer returns a non-empty identity of the issuer in case the transfer contains redeeming outputs

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.

func (*TransferAction) Validate ¶ added in v0.5.0

func (t *TransferAction) Validate() error

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

func CompileTransferOptions ¶ added in v0.5.0

func CompileTransferOptions(opts ...TransferOption) (*TransferOptions, error)

type TxStatus ¶ added in v0.4.0

type TxStatus = driver.TxStatus

TxStatus is the status of a transaction

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 NewValidator(backend driver.Validator) *Validator

func (*Validator) UnmarshalActions ¶

func (c *Validator) UnmarshalActions(raw []byte) ([]interface{}, error)

UnmarshalActions returns the actions contained in the serialized token request

func (*Validator) UnmarshallAndVerify ¶

func (c *Validator) UnmarshallAndVerify(ctx context.Context, ledger Ledger, anchor RequestAnchor, 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 RequestAnchor, 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 Verifier ¶

type Verifier = driver.Verifier

Verifier models a signature verifier

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) Contains ¶

func (w *Wallet) Contains(identity Identity) bool

Contains returns true if the wallet contains the passed identity.

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) ID ¶

func (w *Wallet) ID() string

ID returns the wallet identifier.

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(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, identity Identity) (string, error)

GetEnrollmentID returns the enrollment ID of passed identity

func (*WalletManager) GetRevocationHandle ¶ added in v0.3.0

func (wm *WalletManager) GetRevocationHandle(ctx context.Context, identity Identity) (string, error)

GetRevocationHandle returns the revocation handle of the passed identity

func (*WalletManager) IssuerWallet ¶

func (wm *WalletManager) IssuerWallet(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context) ([]string, error)

OwnerWalletIDs returns the list of owner wallet identifiers

func (*WalletManager) RegisterIssuerIdentity ¶ added in v0.4.0

func (wm *WalletManager) RegisterIssuerIdentity(ctx context.Context, 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(ctx context.Context, 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(ctx context.Context, conf IdentityConfiguration) error

RegisterOwnerIdentityConfiguration registers an owner long-term identity via a identity configuration

func (*WalletManager) RegisterRecipientIdentity ¶

func (wm *WalletManager) RegisterRecipientIdentity(ctx context.Context, 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(ctx context.Context, identity Identity) *Wallet

Wallet returns the wallet bound to the passed identity, if any is available. If no wallet is found, it returns nil.

Directories ¶

Path Synopsis
zkatdlog/nogh/v1/audit/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
zkatdlog/nogh/v1/crypto/upgrade/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
zkatdlog/nogh/v1/transfer/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
zkatdlog/nogh/v1/validator/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
mock
Code generated by counterfeiter.
Code generated by counterfeiter.
sdk
db
dig
tms
services
db
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.
ttx

Jump to

Keyboard shortcuts

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