Documentation
¶
Index ¶
- Constants
- func ToProtoIdentitySlice(identities []Identity) []*request.Identity
- func ToTokenID(id *request.TokenID) *token.ID
- type Action
- type ActionWithInputs
- type AuditInfoProvider
- type AuditableIdentity
- type AuditorService
- type AuditorSignature
- type AuditorWallet
- type Authorization
- type CertificationClient
- type CertificationService
- type CertificationStorage
- type CertifierWallet
- type Configuration
- type Deserializer
- type Driver
- type FullIdentity
- type GetStateFnc
- type Identity
- type IdentityConfiguration
- type IdentityProvider
- type IssueAction
- type IssueInputMetadata
- type IssueMetadata
- type IssueOptions
- type IssueOutputMetadata
- type IssueService
- type IssuerWallet
- type Ledger
- type LedgerTokensIterator
- type ListTokensOptions
- type Matcher
- type Output
- type OwnerWallet
- type PPHash
- type PPMFactory
- type PPReader
- type PublicParameters
- type PublicParamsFetcher
- type PublicParamsManager
- type QueryCallback2Func
- type QueryCallbackFunc
- type QueryEngine
- type RecipientData
- type ServiceOptions
- type ServiceProvider
- type SetupAction
- type SignatureProvider
- type Signer
- type SigningIdentity
- type SpendableTokensIterator
- type TMSID
- type TokenDriverName
- type TokenDriverVersion
- type TokenManagerService
- type TokenManagerServiceProvider
- type TokenOutput
- type TokenOutputMetadata
- type TokenRequest
- func (r *TokenRequest) Bytes() ([]byte, error)
- func (r *TokenRequest) FromBytes(raw []byte) error
- func (r *TokenRequest) FromProtos(tr *request.TokenRequest) error
- func (r *TokenRequest) MarshalToMessageToSign(anchor []byte) ([]byte, error)
- func (r *TokenRequest) ToProtos() (*request.TokenRequest, error)
- type TokenRequestAnchor
- type TokenRequestMetadata
- type TokenUpgradeRequest
- type TokensService
- type TokensUpgradeChallenge
- type TokensUpgradeProof
- type TokensUpgradeService
- type TokensUpgradeWitness
- type TransferAction
- type TransferInputMetadata
- type TransferMetadata
- func (t *TransferMetadata) FromProtos(transferMetadata *request.TransferMetadata) error
- func (t *TransferMetadata) Receivers() []Identity
- func (t *TransferMetadata) Senders() []Identity
- func (t *TransferMetadata) ToProtos() (*request.TransferMetadata, error)
- func (t *TransferMetadata) TokenIDAt(index int) *token.ID
- func (t *TransferMetadata) TokenIDs() []*token.ID
- type TransferOptions
- type TransferOutputMetadata
- type TransferService
- type TxStatus
- type UnspentTokensIterator
- type UnsupportedTokensIterator
- type ValidationAttributeID
- type ValidationAttributes
- type Validator
- type ValidatorLedger
- type Vault
- type Verifier
- type Wallet
- type WalletLookupID
- type WalletService
- type WalletServiceFactory
Constants ¶
const (
ProtocolV1 = 1
)
Variables ¶
This section is empty.
Functions ¶
func ToProtoIdentitySlice ¶ added in v0.5.0
ToProtoIdentitySlice converts []Identity to []*request.Identity
Types ¶
type ActionWithInputs ¶ added in v0.5.0
type ActionWithInputs interface { // NumInputs returns the number of inputs in the action NumInputs() int // GetInputs returns the identifiers of the inputs in the action. GetInputs() []*token.ID // GetSerializedInputs returns the serialized inputs of the action GetSerializedInputs() ([][]byte, error) // GetSerialNumbers returns the serial numbers of the inputs if this action supports graph hiding GetSerialNumbers() []string // IsGraphHiding returns true if the action is graph hiding IsGraphHiding() bool // GetMetadata returns the action's metadata GetMetadata() map[string][]byte // ExtraSigners returns the extra signers of the action ExtraSigners() []Identity }
ActionWithInputs models an action with inputs
type AuditInfoProvider ¶ added in v0.4.0
type AuditInfoProvider interface { // GetAuditInfo returns the audit information for the given identity, if available. GetAuditInfo(ctx context.Context, identity Identity) ([]byte, error) }
AuditInfoProvider models a provider of audit information
type AuditableIdentity ¶ added in v0.5.0
func (*AuditableIdentity) FromProtos ¶ added in v0.5.0
func (a *AuditableIdentity) FromProtos(auditableIdentity *request.AuditableIdentity) error
func (*AuditableIdentity) ToProtos ¶ added in v0.5.0
func (a *AuditableIdentity) ToProtos() (*request.AuditableIdentity, error)
type AuditorService ¶
type AuditorService interface { // AuditorCheck verifies the well-formedness of the passed request with the respect to the passed metadata and anchor AuditorCheck(ctx context.Context, request *TokenRequest, metadata *TokenRequestMetadata, anchor TokenRequestAnchor) error }
AuditorService models the auditor service
type AuditorSignature ¶ added in v0.5.0
func (*AuditorSignature) FromProtos ¶ added in v0.5.0
func (r *AuditorSignature) FromProtos(tr *request.AuditorSignature) error
func (*AuditorSignature) ToProtos ¶ added in v0.5.0
func (r *AuditorSignature) ToProtos() (*request.AuditorSignature, error)
type AuditorWallet ¶
type AuditorWallet interface { Wallet // GetAuditorIdentity returns an auditor identity. // Depending on the underlying wallet implementation, this can be a long-term or ephemeral identity. GetAuditorIdentity() (Identity, error) }
AuditorWallet models the wallet of an auditor
type Authorization ¶ added in v0.4.0
type Authorization interface { // IsMine returns true if the passed token is owned by an owner wallet. // It returns the ID of the owner wallet (walletID) and any additional owner identifier (additionalOwners), if supported. // It is possible that walletID is empty additionalOwners is not. // If walletID is not empty, this means that the corresponding wallet can spend the token directly. // If walletID is empty, then additionalOwners must cooperate in some way in order to spend the token. IsMine(ctx context.Context, tok *token.Token) (walletID string, additionalOwners []string, mine bool) // AmIAnAuditor return true if the passed TMS contains an auditor wallet for any of the auditor identities // defined in the public parameters of the passed TMS. AmIAnAuditor() bool // Issued returns true if the passed issuer issued the passed token Issued(ctx context.Context, issuer Identity, tok *token.Token) bool // OwnerType returns the type of owner (e.g. 'idemix' or 'htlc') and the identity bytes OwnerType(raw []byte) (string, []byte, error) }
Authorization defines method to check the relation between a token and wallets (owner, auditor, etc.)
type CertificationClient ¶
type CertificationClient interface { // IsCertified returns true if the passed token-id has been already certified IsCertified(ctx context.Context, id *token.ID) bool // RequestCertification requests the certifications of the passed tokens RequestCertification(ctx context.Context, ids ...*token.ID) error }
type CertificationService ¶
type CertificationService interface { // NewCertificationRequest creates a new certification request, in a serialized form, for the passed token ids. NewCertificationRequest(ids []*token.ID) ([]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. Certify(wallet CertifierWallet, ids []*token.ID, tokens [][]byte, request []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 VerifyCertifications(ids []*token.ID, certifications [][]byte) ([][]byte, error) }
type CertificationStorage ¶
type CertifierWallet ¶
type CertifierWallet interface { Wallet // GetCertifierIdentity returns a certifier identity. // Depending on the underlying wallet implementation, this can be a long-term or ephemeral identity. GetCertifierIdentity() (Identity, error) }
CertifierWallet models the wallet of a certifier
type Configuration ¶ added in v0.4.0
type Configuration interface { // ID identities the TMS this configuration refers to. ID() TMSID // IsSet checks to see if the key has been set in any of the data locations IsSet(key string) bool // UnmarshalKey takes a single key and unmarshals it into a struct. // The key must be relative to the TMS this configuration refers to. UnmarshalKey(key string, rawVal interface{}) error // GetString returns the value associated with the key as a string GetString(key string) string // GetBool returns the value associated with the key as a bool GetBool(key string) bool // TranslatePath translates the passed path relative to the config path TranslatePath(path string) string }
Configuration provides functions to access the configuration of a given TMS
type Deserializer ¶
type Deserializer interface { // GetOwnerVerifier returns the verifier associated to the passed owner identity GetOwnerVerifier(id Identity) (Verifier, error) // GetIssuerVerifier returns the verifier associated to the passed issuer identity GetIssuerVerifier(id Identity) (Verifier, error) // GetAuditorVerifier returns the verifier associated to the passed auditor identity GetAuditorVerifier(id Identity) (Verifier, error) // Recipients returns the recipient identities from the given serialized representation Recipients(raw Identity) ([]Identity, error) // GetAuditInfoMatcher returns an identity matcher for the passed identity and audit data GetAuditInfoMatcher(owner Identity, auditInfo []byte) (Matcher, error) // MatchIdentity returns nil if the given identity matches the given audit information. // An error otherwise. MatchIdentity(identity Identity, info []byte) error // GetAuditInfo returns the audit information for the passed identity GetAuditInfo(ctx context.Context, id Identity, p AuditInfoProvider) ([]byte, error) }
Deserializer models the deserializer of owner, issuer, and auditor identities to get signature verifiers
type Driver ¶
type Driver interface { PPReader // NewTokenService returns a new TokenManagerService instance. NewTokenService(tmsID TMSID, publicParams []byte) (TokenManagerService, error) // NewDefaultValidator returns a new Validator instance from the passed public parameters NewDefaultValidator(pp PublicParameters) (Validator, error) }
Driver is the interface that must be implemented by a token driver.
type FullIdentity ¶ added in v0.4.0
type FullIdentity interface { SigningIdentity Verifier }
type GetStateFnc ¶
GetStateFnc models a function that returns the value for the given key from the ledger
type Identity ¶ added in v0.4.0
Identity represents a generic identity
func FromProtoIdentitySlice ¶ added in v0.5.0
FromProtoIdentitySlice converts []*request.Identity to []Identity
func ToIdentity ¶ added in v0.5.0
ToIdentity converts *request.Identity to Identity
type IdentityConfiguration ¶ added in v0.4.0
type IdentityProvider ¶
type IdentityProvider interface { // RegisterRecipientData stores the passed recipient data RegisterRecipientData(ctx context.Context, data *RecipientData) error // GetAuditInfo returns the audit information associated to the passed identity, nil otherwise GetAuditInfo(ctx context.Context, identity Identity) ([]byte, error) // GetSigner returns a Signer for passed identity. GetSigner(ctx context.Context, identity Identity) (Signer, error) // RegisterVerifier registers a Verifier for passed identity. RegisterVerifier(ctx context.Context, identity Identity, v Verifier) error // RegisterSigner registers a Signer and a Verifier for passed identity. RegisterSigner(ctx context.Context, identity Identity, signer Signer, verifier Verifier, signerInfo []byte) error // AreMe returns the hashes of the passed identities that have a signer registered before AreMe(ctx context.Context, identities ...Identity) []string // IsMe returns true if a signer was ever registered for the passed identity IsMe(ctx context.Context, party Identity) bool // GetEnrollmentID extracts the enrollment ID from the passed audit info GetEnrollmentID(identity Identity, auditInfo []byte) (string, error) // GetRevocationHandler extracts the revocation handler from the passed audit info GetRevocationHandler(identity Identity, auditInfo []byte) (string, error) // GetEIDAndRH returns both enrollment ID and revocation handle GetEIDAndRH(identity Identity, auditInfo []byte) (string, string, error) // Bind binds longTerm to the passed ephemeral identity. The same signer, verifier, and audit of the long term // identity is associated to id, if copyAll is true. Bind(ctx context.Context, longTerm Identity, ephemeral Identity, copyAll bool) error // RegisterRecipientIdentity register the passed identity as a third-party recipient identity. RegisterRecipientIdentity(id Identity) error }
IdentityProvider manages identity-related concepts like signature signers, verifiers, audit information, and so on.
type IssueAction ¶
type IssueAction interface { Action ActionWithInputs // Serialize returns the serialized version of the action Serialize() ([]byte, error) // NumOutputs returns the number of outputs of the action NumOutputs() int // GetSerializedOutputs returns the serialized outputs of the action GetSerializedOutputs() ([][]byte, error) // GetOutputs returns the outputs of the action GetOutputs() []Output // IsAnonymous returns true if the issuer is anonymous IsAnonymous() bool // GetIssuer returns the issuer of the action GetIssuer() []byte // GetMetadata returns the metadata of the action GetMetadata() map[string][]byte // IsGraphHiding returns true if the action is graph hiding IsGraphHiding() bool // ExtraSigners returns the extra signers of the action ExtraSigners() []Identity }
IssueAction is the action used to issue tokens
type IssueInputMetadata ¶ added in v0.5.0
func (*IssueInputMetadata) FromProtos ¶ added in v0.5.0
func (i *IssueInputMetadata) FromProtos(issueInputMetadata *request.IssueInputMetadata) error
func (*IssueInputMetadata) ToProtos ¶ added in v0.5.0
func (i *IssueInputMetadata) ToProtos() (*request.IssueInputMetadata, error)
type IssueMetadata ¶
type IssueMetadata struct { // Issuer is the identity of the issuer Issuer AuditableIdentity Inputs []*IssueInputMetadata Outputs []*IssueOutputMetadata // ExtraSigners is the list of extra identities that are not part of the issue action per se // but needs to sign the request ExtraSigners []Identity }
IssueMetadata contains the metadata of an issue action. In more details, there is an issuer and a list of outputs. For each output, there is a token info and a list of receivers with their audit info to recover their enrollment ID.
func (*IssueMetadata) FromProtos ¶ added in v0.5.0
func (i *IssueMetadata) FromProtos(issueMetadata *request.IssueMetadata) error
func (*IssueMetadata) Receivers ¶
func (i *IssueMetadata) Receivers() []Identity
func (*IssueMetadata) ToProtos ¶ added in v0.5.0
func (i *IssueMetadata) ToProtos() (*request.IssueMetadata, error)
type IssueOptions ¶
type IssueOptions struct { // Attributes is a container of generic options that might be driver specific Attributes map[interface{}]interface{} // TokensUpgradeRequest is a request to upgrade tokens TokensUpgradeRequest *TokenUpgradeRequest // Wallet is the wallet that should be used to issue the tokens. Wallet IssuerWallet }
IssueOptions models the options that can be passed to the issue command
type IssueOutputMetadata ¶ added in v0.5.0
type IssueOutputMetadata struct { OutputMetadata []byte // Receivers, for each output we have a receiver Receivers []*AuditableIdentity }
IssueOutputMetadata is the metadata of an output in an issue action
func (*IssueOutputMetadata) FromProtos ¶ added in v0.5.0
func (i *IssueOutputMetadata) FromProtos(outputsMetadata *request.OutputMetadata) error
func (*IssueOutputMetadata) RecipientAt ¶ added in v0.5.0
func (i *IssueOutputMetadata) RecipientAt(index int) *AuditableIdentity
func (*IssueOutputMetadata) ToProtos ¶ added in v0.5.0
func (i *IssueOutputMetadata) ToProtos() (*request.OutputMetadata, error)
type IssueService ¶
type IssueService interface { // Issue generates an IssuerAction whose tokens are issued by the passed identity. // The tokens to be issued are passed as pairs (value, owner). // In addition, a set of options can be specified to further customize the issue command. // The function returns an IssuerAction, the associated metadata, and the identity of the issuer (depending on the implementation, it can be different from // the one passed in input). // The metadata is an array with an entry for each output created by the action. Issue(ctx context.Context, issuerIdentity Identity, tokenType token.Type, values []uint64, owners [][]byte, opts *IssueOptions) (IssueAction, *IssueMetadata, error) // VerifyIssue checks the well-formedness of the passed IssuerAction with the respect to the passed metadata VerifyIssue(ia IssueAction, metadata []*IssueOutputMetadata) error // DeserializeIssueAction deserializes the passed bytes into an IssuerAction DeserializeIssueAction(raw []byte) (IssueAction, error) }
IssueService models the token issue service
type IssuerWallet ¶
type IssuerWallet interface { Wallet // GetIssuerIdentity returns an issuer identity for the passed token type. // Depending on the underlying wallet implementation, this can be a long-term or ephemeral identity. GetIssuerIdentity(tokenType token.Type) (Identity, error) // HistoryTokens returns the list of tokens issued by this wallet filtered using the passed options. HistoryTokens(ctx context.Context, opts *ListTokensOptions) (*token.IssuedTokens, error) }
IssuerWallet models the wallet of an issuer
type Ledger ¶
type Ledger interface { // GetState returns the value for the given key GetState(id token.ID) ([]byte, error) }
Ledger models a read-only ledger
type LedgerTokensIterator ¶ added in v0.5.0
type LedgerTokensIterator = iterators.Iterator[*token.LedgerToken]
type ListTokensOptions ¶
type ListTokensOptions struct { // TokenType is the type of token to list TokenType token.Type // Context is used to track the operation Context context.Context }
ListTokensOptions contains options that can be used to list tokens from a wallet
type Matcher ¶
type Matcher interface { // Match returns true if the passed identity matches this matcher Match(identity []byte) error }
Matcher models a matcher that can be used to match identities
type Output ¶
type Output interface { // Serialize returns the serialized version of the output Serialize() ([]byte, error) // IsRedeem returns true if the output is a redeem output IsRedeem() bool // GetOwner returns the owner of this token GetOwner() []byte }
Output models an output of an action
type OwnerWallet ¶
type OwnerWallet interface { Wallet // GetRecipientIdentity returns a recipient identity. // Depending on the underlying wallet implementation, this can be a long-term or ephemeral identity. // Using the returned identity as an index, one can retrieve the following information: // - Identity audit info via GetAuditInfo; // - TokenMetadata via GetTokenMetadata; // - TokenIdentityMetadata via GetTokenMetadataAuditInfo. GetRecipientIdentity(ctx context.Context) (Identity, error) // GetRecipientData returns a recipient data struct, it does not include the token metadata audit info GetRecipientData(ctx context.Context) (*RecipientData, error) // GetAuditInfo returns auditing information for the passed identity GetAuditInfo(ctx context.Context, id Identity) ([]byte, error) // GetTokenMetadata returns the public information related to the token to be assigned to passed recipient identity. GetTokenMetadata(id Identity) ([]byte, error) // GetTokenMetadataAuditInfo returns private information about the token metadata assigned to the passed recipient identity. GetTokenMetadataAuditInfo(id Identity) ([]byte, error) // ListTokens returns the list of unspent tokens owned by this wallet filtered using the passed options. ListTokens(opts *ListTokensOptions) (*token.UnspentTokens, error) // ListTokensIterator returns an iterator of unspent tokens owned by this wallet filtered using the passed options. ListTokensIterator(opts *ListTokensOptions) (UnspentTokensIterator, error) // 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. Balance(ctx context.Context, opts *ListTokensOptions) (uint64, error) // EnrollmentID returns the enrollment ID of the owner wallet EnrollmentID() string // RegisterRecipient register the given recipient data RegisterRecipient(ctx context.Context, data *RecipientData) error // Remote returns true if this wallet is verify only, meaning that the corresponding secret key is external to this wallet Remote() bool }
OwnerWallet models the wallet of a token recipient.
type PPHash ¶ added in v0.4.0
type PPHash []byte
PPHash is used to model the hash of the raw public parameters. This should avoid confusion between the bytes of the public params themselves and its hash.
type PPMFactory ¶ added in v0.4.0
type PPMFactory interface { PPReader // NewPublicParametersManager returns a new PublicParametersManager instance from the passed public parameters NewPublicParametersManager(pp PublicParameters) (PublicParamsManager, error) // DefaultValidator returns a new Validator instance from the passed public parameters DefaultValidator(pp PublicParameters) (Validator, error) }
PPMFactory contains the static logic of the driver
type PPReader ¶ added in v0.4.0
type PPReader interface { // PublicParametersFromBytes unmarshals the bytes to a PublicParameters instance. PublicParametersFromBytes(params []byte) (PublicParameters, error) }
type PublicParameters ¶
type PublicParameters interface { // TokenDriverName returns the name of the token driver TokenDriverName() TokenDriverName // TokenDriverVersion return the version of the token driver TokenDriverVersion() TokenDriverVersion // TokenDataHiding returns true if the token data is hidden TokenDataHiding() bool // GraphHiding returns true if the token graph is hidden GraphHiding() bool // MaxTokenValue returns the maximum token value MaxTokenValue() uint64 // CertificationDriver returns the certification driver identifier CertificationDriver() string // Auditors returns the list of auditors. Auditors() []Identity // Issuers returns the list of issuers. Issuers() []Identity // Precision returns the precision used to represent the token value. Precision() uint64 // String returns a readable version of the public parameters String() string // Serialize returns the serialized version of this public parameters Serialize() ([]byte, error) // Validate returns true if the public parameters are well-formed Validate() error }
PublicParameters is the interface that must be implemented by the driver public parameters.
type PublicParamsFetcher ¶
type PublicParamsFetcher interface { // Fetch fetches the public parameters from a repository. Fetch() ([]byte, error) }
PublicParamsFetcher models a public parameters fetcher.
type PublicParamsManager ¶
type PublicParamsManager interface { // PublicParameters returns the public parameters. PublicParameters() PublicParameters // NewCertifierKeyPair generates a new key pair for the certifier, if supported NewCertifierKeyPair() ([]byte, []byte, error) // PublicParamsHash returns the hash of the raw public parameters PublicParamsHash() PPHash }
PublicParamsManager is the interface that must be implemented by the driver public parameters manager.
type QueryEngine ¶
type QueryEngine interface { // IsPending returns true if the transaction the passed id refers to is still pending, false otherwise IsPending(ctx context.Context, id *token.ID) (bool, error) // GetStatus returns the status of the passed transaction GetStatus(ctx context.Context, txID string) (TxStatus, string, error) // IsMine returns true if the passed id is owned by any known wallet IsMine(ctx context.Context, id *token.ID) (bool, error) // UnspentTokensIterator returns an iterator over all unspent tokens UnspentTokensIterator(ctx context.Context) (UnspentTokensIterator, error) // UnspentLedgerTokensIteratorBy returns an iterator over all unspent ledger tokens UnspentLedgerTokensIteratorBy(ctx context.Context) (LedgerTokensIterator, error) // UnspentTokensIteratorBy returns an iterator of unspent tokens owned by the passed id and whose type is the passed on. // The token type can be empty. In that case, tokens of any type are returned. UnspentTokensIteratorBy(ctx context.Context, walletID string, tokenType token.Type) (UnspentTokensIterator, error) // ListUnspentTokens returns the list of unspent tokens ListUnspentTokens(ctx context.Context) (*token.UnspentTokens, error) // ListAuditTokens returns the audited tokens associated to the passed ids ListAuditTokens(ctx context.Context, ids ...*token.ID) ([]*token.Token, error) // ListHistoryIssuedTokens returns the list of issues tokens ListHistoryIssuedTokens(ctx context.Context) (*token.IssuedTokens, error) // PublicParams returns the public parameters PublicParams(ctx context.Context) ([]byte, error) // GetTokenMetadata retrieves the token information for the passed ids. // For each id, the callback is invoked to unmarshal the token information GetTokenMetadata(ctx context.Context, ids []*token.ID) ([][]byte, error) // GetTokenOutputs retrieves the token output as stored on the ledger for the passed ids. // For each id, the callback is invoked to unmarshal the output GetTokenOutputs(ctx context.Context, ids []*token.ID, callback QueryCallbackFunc) error // GetTokenOutputsAndMeta retrieves both the token output and information for the passed ids. GetTokenOutputsAndMeta(ctx context.Context, ids []*token.ID) ([][]byte, [][]byte, []token.Format, error) // GetTokens returns the list of tokens with their respective vault keys GetTokens(ctx context.Context, inputs ...*token.ID) ([]*token.Token, error) // WhoDeletedTokens returns info about who deleted the passed tokens. // The bool array is an indicator used to tell if the token at a given position has been deleted or not WhoDeletedTokens(ctx context.Context, inputs ...*token.ID) ([]string, []bool, 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. Balance(ctx context.Context, id string, tokenType token.Type) (uint64, error) }
type RecipientData ¶ added in v0.4.0
type RecipientData struct { // Identity is the identity of the token owner Identity Identity // AuditInfo contains private information Identity AuditInfo []byte // TokenMetadata contains public information related to the token to be assigned to this Recipient. TokenMetadata []byte // TokenMetadataAuditInfo contains private information TokenMetadata TokenMetadataAuditInfo []byte }
RecipientData contains information about the identity of a token owner
type ServiceOptions ¶ added in v0.4.0
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 (ServiceOptions) ParamAsString ¶ added in v0.4.0
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) String ¶ added in v0.4.0
func (o ServiceOptions) String() string
type ServiceProvider ¶ added in v0.4.0
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 SetupAction ¶
SetupAction is the action used to update the public parameters
type SignatureProvider ¶
type SignatureProvider interface { // HasBeenSignedBy returns true and the verified signature if the provider contains a valid signature for the passed identity and verifier HasBeenSignedBy(id Identity, verifier Verifier) ([]byte, error) // Signatures returns the signatures inside this provider Signatures() [][]byte }
type Signer ¶
type Signer interface { // Sign signs message bytes and returns the signature or an error on failure. Sign(message []byte) ([]byte, error) }
Signer is an interface which wraps the Sign method.
type SigningIdentity ¶
type SigningIdentity interface { // Sign signs message bytes and returns the signature or an error on failure. Sign(raw []byte) ([]byte, error) // Serialize serializes the signing identity Serialize() ([]byte, error) }
SigningIdentity models a signing identity
type SpendableTokensIterator ¶ added in v0.4.0
type SpendableTokensIterator = iterators.Iterator[*token.UnspentTokenInWallet]
type TokenDriverName ¶ added in v0.4.0
type TokenDriverName string
TokenDriverName is the name of a token driver
type TokenDriverVersion ¶ added in v0.5.0
type TokenDriverVersion uint64
TokenDriverVersion is the version of a token driver
type TokenManagerService ¶
type TokenManagerService interface { IssueService() IssueService TransferService() TransferService TokensService() TokensService // TokensUpgradeService return an instance of the TokensUpgradeService interface TokensUpgradeService() TokensUpgradeService AuditorService() AuditorService CertificationService() CertificationService Deserializer() Deserializer IdentityProvider() IdentityProvider Validator() (Validator, error) PublicParamsManager() PublicParamsManager Configuration() Configuration WalletService() WalletService Authorization() Authorization // Done releases all the resources allocated by this service Done() error }
TokenManagerService is the entry point of the Driver API and gives access to the rest of the API
type TokenManagerServiceProvider ¶
type TokenManagerServiceProvider interface { // GetTokenManagerService returns a TokenManagerService instance for the passed parameters // If a TokenManagerService is not available, it creates one. GetTokenManagerService(opts ServiceOptions) (TokenManagerService, error) // NewTokenManagerService returns a new TokenManagerService instance for the passed parameters NewTokenManagerService(opts ServiceOptions) (TokenManagerService, error) Update(options ServiceOptions) error Configurations() ([]Configuration, error) }
type TokenOutput ¶ added in v0.5.0
type TokenOutput []byte
TokenOutput models an output on the edger
type TokenOutputMetadata ¶ added in v0.5.0
type TokenOutputMetadata []byte
TokenOutputMetadata models the metadata of an output on the ledger
type TokenRequest ¶
type TokenRequest struct { Issues [][]byte Transfers [][]byte Signatures [][]byte AuditorSignatures []*AuditorSignature }
TokenRequest is a collection of Token Action: Issues, to create new Tokens; Transfers, to manipulate Tokens (e.g., transfer ownership or redeem) The actions in the collection are independent. An action cannot spend tokens created by another action in the same Token Request. In addition, actions comes with a set of Witnesses to verify the right to spend or the right to issue a given token
func (*TokenRequest) Bytes ¶
func (r *TokenRequest) Bytes() ([]byte, error)
func (*TokenRequest) FromBytes ¶
func (r *TokenRequest) FromBytes(raw []byte) error
func (*TokenRequest) FromProtos ¶ added in v0.5.0
func (r *TokenRequest) FromProtos(tr *request.TokenRequest) error
func (*TokenRequest) MarshalToMessageToSign ¶ added in v0.5.0
func (r *TokenRequest) MarshalToMessageToSign(anchor []byte) ([]byte, error)
func (*TokenRequest) ToProtos ¶ added in v0.5.0
func (r *TokenRequest) ToProtos() (*request.TokenRequest, error)
type TokenRequestAnchor ¶ added in v0.5.0
type TokenRequestAnchor string
TokenRequestAnchor models the anchor of a token request
type TokenRequestMetadata ¶
type TokenRequestMetadata struct { // Issues is the list of issue actions metadata Issues []*IssueMetadata // Transfers is the list of transfer actions metadata Transfers []*TransferMetadata // Application enables attaching more info to the TokenRequestMetadata Application map[string][]byte }
TokenRequestMetadata is a collection of actions metadata
func (*TokenRequestMetadata) Bytes ¶
func (m *TokenRequestMetadata) Bytes() ([]byte, error)
func (*TokenRequestMetadata) FromBytes ¶
func (m *TokenRequestMetadata) FromBytes(raw []byte) error
func (*TokenRequestMetadata) FromProtos ¶ added in v0.5.0
func (m *TokenRequestMetadata) FromProtos(trm *request.TokenRequestMetadata) error
func (*TokenRequestMetadata) ToProtos ¶ added in v0.5.0
func (m *TokenRequestMetadata) ToProtos() (*request.TokenRequestMetadata, error)
type TokenUpgradeRequest ¶ added in v0.5.0
type TokenUpgradeRequest struct { // Challenge is a challenge to be solved by the prover Challenge TokensUpgradeChallenge // Tokens is a list of tokens to be converted Tokens []token.LedgerToken // Proof is a proof that the prover has solved the challenge Proof TokensUpgradeProof }
TokenUpgradeRequest is a request to convert tokens
type TokensService ¶ added in v0.4.0
type TokensService interface { // SupportedTokenFormats returns the supported token formats SupportedTokenFormats() []token.Format // Deobfuscate processes the passed output and metadata to derive the following: // - a token.Token, // - its issuer (if any), // - the recipients defined by Token.Owner, // = and the output format Deobfuscate(output TokenOutput, outputMetadata TokenOutputMetadata) (*token.Token, Identity, []Identity, token.Format, error) // Recipients returns the recipients of the passed output Recipients(output TokenOutput) ([]Identity, error) }
TokensService models the token service
type TokensUpgradeChallenge ¶ added in v0.5.0
type TokensUpgradeChallenge = []byte
TokensUpgradeChallenge is the challenge the issuer generates to make sure the client is not cheating
type TokensUpgradeProof ¶ added in v0.5.0
type TokensUpgradeProof = []byte
TokensUpgradeProof is the proof generated with the respect to a given challenge to prove the validity of the tokens to be upgrade
type TokensUpgradeService ¶ added in v0.5.0
type TokensUpgradeService interface { // NewUpgradeChallenge generates a new upgrade challenge NewUpgradeChallenge() (TokensUpgradeChallenge, error) // GenUpgradeProof generates an upgrade proof for the given challenge and tokens GenUpgradeProof(ch TokensUpgradeChallenge, tokens []token.LedgerToken, witness TokensUpgradeWitness) (TokensUpgradeProof, error) // CheckUpgradeProof checks the upgrade proof for the given challenge and tokens CheckUpgradeProof(ch TokensUpgradeChallenge, proof TokensUpgradeProof, tokens []token.LedgerToken) (bool, error) }
TokensUpgradeService models the token update service
type TokensUpgradeWitness ¶ added in v0.5.0
type TokensUpgradeWitness = []byte
TokensUpgradeWitness contains any other additional information needed to generate a TokensUpgradeProof
type TransferAction ¶
type TransferAction interface { Action ActionWithInputs // Serialize returns the serialized version of the action Serialize() ([]byte, error) // NumOutputs returns the number of outputs of the action NumOutputs() int // GetSerializedOutputs returns the serialized outputs of the action GetSerializedOutputs() ([][]byte, error) // GetOutputs returns the outputs of the action GetOutputs() []Output // IsRedeemAt returns true if the output is a redeem output at the passed index IsRedeemAt(index int) bool // SerializeOutputAt returns the serialized output at the passed index SerializeOutputAt(index int) ([]byte, error) // IsGraphHiding returns true if the action is graph hiding IsGraphHiding() bool // GetMetadata returns the action's metadata GetMetadata() map[string][]byte // GetIssuer returns a non-empty identity of the issuer in case the transfer contains redeeming outputs GetIssuer() Identity }
TransferAction is the action used to transfer tokens
type TransferInputMetadata ¶ added in v0.5.0
type TransferInputMetadata struct { TokenID *token.ID Senders []*AuditableIdentity }
func (*TransferInputMetadata) FromProtos ¶ added in v0.5.0
func (t *TransferInputMetadata) FromProtos(transferInputMetadata *request.TransferInputMetadata) error
func (*TransferInputMetadata) ToProtos ¶ added in v0.5.0
func (t *TransferInputMetadata) ToProtos() (*request.TransferInputMetadata, error)
type TransferMetadata ¶
type TransferMetadata struct { Inputs []*TransferInputMetadata Outputs []*TransferOutputMetadata // ExtraSigners is the list of extra identities that are not part of the transfer action per se // but needs to sign the request ExtraSigners []Identity // Issuer contains the identity of the issuer to sign the transfer action Issuer Identity }
TransferMetadata contains the metadata of a transfer action For each TokenID there is a sender with its audit info to recover its enrollment ID, For each Output there is: - A OutputMetadata entry to de-obfuscate the output; - A Receiver identity; - A ReceiverAuditInfo entry to recover the enrollment ID of the receiver - A Flag to indicate if the receiver is a sender in this very same action
func (*TransferMetadata) FromProtos ¶ added in v0.5.0
func (t *TransferMetadata) FromProtos(transferMetadata *request.TransferMetadata) error
func (*TransferMetadata) Receivers ¶
func (t *TransferMetadata) Receivers() []Identity
func (*TransferMetadata) Senders ¶
func (t *TransferMetadata) Senders() []Identity
func (*TransferMetadata) ToProtos ¶ added in v0.5.0
func (t *TransferMetadata) ToProtos() (*request.TransferMetadata, error)
func (*TransferMetadata) TokenIDAt ¶
func (t *TransferMetadata) TokenIDAt(index int) *token.ID
TokenIDAt returns the TokenID at the given index. It returns nil if the index is out of bounds.
func (*TransferMetadata) TokenIDs ¶
func (t *TransferMetadata) TokenIDs() []*token.ID
type TransferOptions ¶
type TransferOptions struct {
// Attributes is a container of generic options that might be driver specific
Attributes map[interface{}]interface{}
}
TransferOptions models the options that can be passed to the transfer command
type TransferOutputMetadata ¶ added in v0.5.0
type TransferOutputMetadata struct { OutputMetadata []byte // OutputAuditInfo, for each output owner we have audit info OutputAuditInfo []byte // Receivers is the list of receivers Receivers []*AuditableIdentity }
TransferOutputMetadata is the metadata of an output in a transfer action
func (*TransferOutputMetadata) FromProtos ¶ added in v0.5.0
func (t *TransferOutputMetadata) FromProtos(transferOutputMetadata *request.OutputMetadata) error
func (*TransferOutputMetadata) RecipientAt ¶ added in v0.5.0
func (t *TransferOutputMetadata) RecipientAt(index int) *AuditableIdentity
func (*TransferOutputMetadata) ToProtos ¶ added in v0.5.0
func (t *TransferOutputMetadata) ToProtos() (*request.OutputMetadata, error)
type TransferService ¶
type TransferService interface { // Transfer generates a TransferAction that spend the passed token ids and created the passed outputs. // In addition, a set of options can be specified to further customize the transfer command. // The function returns an TransferAction and the associated metadata. Transfer(ctx context.Context, anchor TokenRequestAnchor, wallet OwnerWallet, ids []*token2.ID, outputs []*token2.Token, opts *TransferOptions) (TransferAction, *TransferMetadata, error) // VerifyTransfer checks the well-formedness of the passed TransferAction with the respect to the passed output metadata VerifyTransfer(ctx context.Context, tr TransferAction, outputMetadata []*TransferOutputMetadata) error // DeserializeTransferAction deserializes the passed bytes into an TransferAction DeserializeTransferAction(raw []byte) (TransferAction, error) }
TransferService models the token transfer service
type TxStatus ¶ added in v0.4.0
type TxStatus = int
TxStatus is the status of a transaction
const ( // Unknown is the status of a transaction that is unknown Unknown TxStatus = iota // Pending is the status of a transaction that has been submitted to the ledger Pending // Confirmed is the status of a transaction that has been confirmed by the ledger Confirmed // Deleted is the status of a transaction that has been deleted due to a failure to commit Deleted )
type UnspentTokensIterator ¶
type UnspentTokensIterator = iterators.Iterator[*token.UnspentToken]
type UnsupportedTokensIterator ¶ added in v0.5.0
type UnsupportedTokensIterator = iterators.Iterator[*token.LedgerToken]
type ValidationAttributeID ¶ added in v0.4.0
type ValidationAttributeID = string
ValidationAttributeID is the type of validation attribute identifier
type ValidationAttributes ¶ added in v0.4.0
type ValidationAttributes = map[ValidationAttributeID][]byte
ValidationAttributes is a map containing attributes generated during validation
type Validator ¶
type Validator interface { // UnmarshalActions returns the actions contained in the serialized token request UnmarshalActions(raw []byte) ([]interface{}, error) // VerifyTokenRequestFromRaw verifies the passed marshalled token request against the passed ledger and anchor. // The function returns additionally a map that contains information about the token request. The content of this map // is driver-dependant VerifyTokenRequestFromRaw(ctx context.Context, getState GetStateFnc, anchor TokenRequestAnchor, raw []byte) ([]interface{}, ValidationAttributes, error) }
Validator models a token request validator
type ValidatorLedger ¶ added in v0.4.0
type Vault ¶
type Vault interface { QueryEngine() QueryEngine CertificationStorage() CertificationStorage }
type Verifier ¶
type Verifier interface { // Verify verifies the signature over the message bytes and returns nil if the signature is valid and an error otherwise. Verify(message, sigma []byte) error }
Verifier is an interface which wraps the Verify method.
type Wallet ¶
type Wallet interface { // ID returns the ID of this wallet ID() string // Contains returns true if the passed identity belongs to this wallet Contains(identity Identity) bool // ContainsToken returns true if the passed token is owned by this wallet ContainsToken(token *token.UnspentToken) bool // GetSigner returns the Signer bound to the passed identity GetSigner(ctx context.Context, identity Identity) (Signer, error) }
Wallet models a generic wallet
type WalletLookupID ¶ added in v0.4.0
type WalletLookupID = any
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 WalletService ¶
type WalletService interface { // RegisterRecipientIdentity registers the passed recipient identity together with the associated audit information RegisterRecipientIdentity(ctx context.Context, data *RecipientData) error // GetAuditInfo retrieves the audit information for the passed identity GetAuditInfo(ctx context.Context, id Identity) ([]byte, error) // GetEnrollmentID extracts the enrollment id from the passed audit information GetEnrollmentID(identity Identity, auditInfo []byte) (string, error) // GetRevocationHandle extracts the revocation handler from the passed audit information GetRevocationHandle(identity Identity, auditInfo []byte) (string, error) // GetEIDAndRH returns both enrollment ID and revocation handle GetEIDAndRH(identity Identity, auditInfo []byte) (string, string, error) // Wallet returns the wallet bound to the passed identity, if any is available Wallet(ctx context.Context, identity Identity) Wallet // RegisterOwnerIdentity registers an owner long-term identity RegisterOwnerIdentity(ctx context.Context, config IdentityConfiguration) error // RegisterIssuerIdentity registers an issuer long-term wallet RegisterIssuerIdentity(ctx context.Context, config IdentityConfiguration) error // OwnerWalletIDs returns the list of owner wallet identifiers OwnerWalletIDs(ctx context.Context) ([]string, error) // OwnerWallet returns an instance of the OwnerWallet interface bound to the passed id. // The id can be: the wallet identifier or a unique id of a view identity belonging to the wallet. OwnerWallet(ctx context.Context, id WalletLookupID) (OwnerWallet, error) // IssuerWallet returns an instance of the IssuerWallet interface bound to the passed id. // The id can be: the wallet identifier or a unique id of a view identity belonging to the wallet. IssuerWallet(ctx context.Context, id WalletLookupID) (IssuerWallet, error) // AuditorWallet returns an instance of the AuditorWallet interface bound to the passed id. // The id can be: the wallet identifier or a unique id of a view identity belonging to the wallet. AuditorWallet(ctx context.Context, id WalletLookupID) (AuditorWallet, error) // CertifierWallet returns an instance of the CertifierWallet interface bound to the passed id. // The id can be: the wallet identifier or a unique id of a view identity belonging to the wallet. CertifierWallet(ctx context.Context, id WalletLookupID) (CertifierWallet, error) // SpendIDs returns the spend ids for the passed token ids SpendIDs(ids ...*token.ID) ([]string, error) }
WalletService models the wallet service that handles issuer, owner, auditor, and certifier wallets
type WalletServiceFactory ¶ added in v0.4.0
type WalletServiceFactory interface { PPReader // NewWalletService returns an instance of the WalletService interface for the passed arguments NewWalletService(tmsConfig Configuration, params PublicParameters) (WalletService, error) }