Documentation
¶
Index ¶
- Constants
- Variables
- func AuditingSignaturesValidate[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, ...](c context.Context, ctx *Context[P, T, TA, IA, DS]) error
- func ExtractTokenIDsAndCheckDuplicates(metadata *driver.TokenRequestMetadata, anchor driver.TokenRequestAnchor) ([]*token.ID, error)
- func IsAnyNil[T any](args ...*T) bool
- func IssueApplicationDataValidate[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, ...](c context.Context, ctx *Context[P, T, TA, IA, DS]) error
- func RetrieveAuditTokens(ctx context.Context, logger logging.Logger, queryEngine driver.QueryEngine, ...) (map[string]*token.Token, error)
- func SelectIssuerForRedeem(issuers []driver.Identity, opts *driver.TransferOptions) (driver.Identity, error)
- func TransferApplicationDataValidate[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, ...](c context.Context, ctx *Context[P, T, TA, IA, DS]) error
- func ValidateIssueActionTokenTypes(metadata *driver.IssueMetadata, auditTokens map[string]*token.Token) error
- func ValidateStructure(tokenRequest *driver.TokenRequest, ...) error
- func ValidateTransferActionTokenTypes(metadata *driver.TransferMetadata, auditTokens map[string]*token.Token, ...) error
- type AuditContext
- type Auditor
- func (a *Auditor[P, IA, TA, DS]) Check(ctx context.Context, tokenRequest *driver.TokenRequest, ...) error
- func (a *Auditor[P, IA, TA, DS]) CheckIssue(ctx context.Context, anchor driver.TokenRequestAnchor, ...) error
- func (a *Auditor[P, IA, TA, DS]) CheckTransfer(ctx context.Context, anchor driver.TokenRequestAnchor, ...) error
- type Authorization
- type AuthorizationMultiplexer
- func (o *AuthorizationMultiplexer) AmIAnAuditor() bool
- func (o *AuthorizationMultiplexer) IsMine(ctx context.Context, tok *token2.Token) (string, []string, bool)
- func (o *AuthorizationMultiplexer) Issued(ctx context.Context, issuer token.Identity, tok *token2.Token) bool
- func (o *AuthorizationMultiplexer) OwnerType(raw []byte) (driver.IdentityType, []byte, error)
- type Backend
- type Context
- type Deserializer
- func (d *Deserializer) GetAuditInfo(ctx context.Context, id driver.Identity, p driver.AuditInfoProvider) ([]byte, error)
- func (d *Deserializer) GetAuditInfoMatcher(ctx context.Context, owner driver.Identity, auditInfo []byte) (driver.Matcher, error)
- func (d *Deserializer) GetAuditorVerifier(ctx context.Context, id driver.Identity) (driver.Verifier, error)
- func (d *Deserializer) GetIssuerVerifier(ctx context.Context, id driver.Identity) (driver.Verifier, error)
- func (d *Deserializer) GetOwnerVerifier(ctx context.Context, id driver.Identity) (driver.Verifier, error)
- func (d *Deserializer) MatchIdentity(ctx context.Context, id driver.Identity, ai []byte) error
- func (d *Deserializer) Recipients(id driver.Identity) ([]driver.Identity, error)
- type IdentityTokenAndMetadataDeserializer
- type LoadedToken
- type MetadataCounterID
- type PublicParametersManager
- type PublicParamsDeserializer
- type PublicParamsManager
- type Service
- func (s *Service[T]) AuditorService() driver.AuditorService
- func (s *Service[T]) Authorization() driver.Authorization
- func (s *Service[T]) CertificationService() driver.CertificationService
- func (s *Service[T]) Configuration() driver.Configuration
- func (s *Service[T]) Deserializer() driver.Deserializer
- func (s *Service[T]) Done() error
- func (s *Service[T]) IdentityProvider() driver.IdentityProvider
- func (s *Service[T]) IssueService() driver.IssueService
- func (s *Service[T]) PublicParamsManager() driver.PublicParamsManager
- func (s *Service[T]) TokensService() driver.TokensService
- func (s *Service[T]) TokensUpgradeService() driver.TokensUpgradeService
- func (s *Service[T]) TransferService() driver.TransferService
- func (s *Service[T]) Validator() (driver.Validator, error)
- func (s *Service[T]) WalletService() driver.WalletService
- type ValidateAuditingFunc
- type ValidateIssueAuditFunc
- type ValidateIssueFunc
- type ValidateTransferAuditFunc
- type ValidateTransferFunc
- type Validator
- func (v *Validator[P, T, TA, IA, DS]) SetMinProtocolVersion(version uint32)
- func (v *Validator[P, T, TA, IA, DS]) UnmarshalActions(raw []byte) ([]any, error)
- func (v *Validator[P, T, TA, IA, DS]) VerifyAuditing(ctx context.Context, anchor driver.TokenRequestAnchor, ...) error
- func (v *Validator[P, T, TA, IA, DS]) VerifyIssue(ctx context.Context, anchor driver.TokenRequestAnchor, ...) error
- func (v *Validator[P, T, TA, IA, DS]) VerifyTokenRequest(ctx context.Context, ledger driver.Ledger, ...) ([]any, driver.ValidationAttributes, error)
- func (v *Validator[P, T, TA, IA, DS]) VerifyTokenRequestFromRaw(ctx context.Context, getState driver.GetStateFnc, ...) ([]any, driver.ValidationAttributes, error)
- func (v *Validator[P, T, TA, IA, DS]) VerifyTransfer(ctx context.Context, anchor driver.TokenRequestAnchor, ...) error
- type ValidatorFactory
- type VaultLedgerTokenAndMetadataLoader
- type VaultTokenCertificationLoader
- type VaultTokenInfoLoader
- type VaultTokenLoader
- type WalletBasedAuthorization
Constants ¶
const ( // TokenRequestToSign is the attribute ID for the token request to sign. TokenRequestToSign driver.ValidationAttributeID = "trs" // TokenRequestSignatures is the attribute ID for the token request signatures. TokenRequestSignatures driver.ValidationAttributeID = "sigs" )
Variables ¶
var ( ErrAuditorSignaturesMissing = errors.New("auditor signatures missing") ErrAuditorSignaturesPresent = errors.New("auditor signatures present") )
Functions ¶
func AuditingSignaturesValidate ¶ added in v0.5.0
func AuditingSignaturesValidate[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer](c context.Context, ctx *Context[P, T, TA, IA, DS]) error
AuditingSignaturesValidate validates the auditor signatures in the token request.
Auditor Signature Model:
The current implementation follows a 1-of-N auditor signature policy:
- If auditors are configured in the public parameters, at least one valid auditor signature must be present in the token request.
- Multiple auditor public keys may be configured (e.g., during key rotation).
- The validator verifies that each provided auditor signature corresponds to a configured auditor and that the signature is valid.
- The validator does NOT enforce N-of-N semantics.
- The validator does NOT enforce per-entity auditor checks.
- All configured auditor public keys are treated as belonging to a single logical auditor entity.
This behavior matches the semantics implemented by current token drivers.
func ExtractTokenIDsAndCheckDuplicates ¶ added in v0.13.0
func ExtractTokenIDsAndCheckDuplicates( metadata *driver.TokenRequestMetadata, anchor driver.TokenRequestAnchor, ) ([]*token.ID, error)
ExtractTokenIDsAndCheckDuplicates extracts all token IDs from both transfer and issue actions in the metadata and checks for duplicates. Returns the list of unique token IDs or an error if duplicates are found.
This function is used by auditors to ensure that no token is spent multiple times within a single transaction.
func IssueApplicationDataValidate ¶ added in v0.7.0
func IssueApplicationDataValidate[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer](c context.Context, ctx *Context[P, T, TA, IA, DS]) error
IssueApplicationDataValidate accepts any metadata in the "pub" namespace. This gives the user of the Token SDK the option to attach public data to the token transaction.
func RetrieveAuditTokens ¶ added in v0.13.0
func RetrieveAuditTokens( ctx context.Context, logger logging.Logger, queryEngine driver.QueryEngine, tokenIDs []*token.ID, anchor driver.TokenRequestAnchor, ) (map[string]*token.Token, error)
RetrieveAuditTokens retrieves audit tokens from the query engine for the given token IDs and builds a map for efficient lookup. Returns the token map or an error if retrieval fails.
The returned map uses token ID pointers as keys, allowing callers to efficiently look up tokens by their ID during validation.
IMPORTANT: This function always returns a non-nil map (possibly empty) to ensure validation logic can distinguish between "no tokens requested" and "tokens not found".
func SelectIssuerForRedeem ¶ added in v0.5.0
func SelectIssuerForRedeem(issuers []driver.Identity, opts *driver.TransferOptions) (driver.Identity, error)
SelectIssuerForRedeem returns the issuer's public key to use for a redeem. If opts specify an FSC issuer identity, then we expect to find in the opts also the public key to add in the transfer action. Otherwise, the first public key in the public params is used.
func TransferApplicationDataValidate ¶ added in v0.7.0
func TransferApplicationDataValidate[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer](c context.Context, ctx *Context[P, T, TA, IA, DS]) error
TransferApplicationDataValidate accepts any metadata in the "pub" namespace. This gives the user of the Token SDK the option to attach public data to the token transaction.
func ValidateIssueActionTokenTypes ¶ added in v0.13.0
func ValidateIssueActionTokenTypes( metadata *driver.IssueMetadata, auditTokens map[string]*token.Token, ) error
ValidateIssueActionTokenTypes ensures all inputs and outputs in an issue action have the same token type. It also validates that input tokens exist in the auditTokens map.
For issue actions with inputs (token upgrades/conversions), this validates that: - All input tokens exist in the audit token map - All inputs have the same token type - All outputs have the same token type as the inputs
This ensures token type consistency within an issue action.
func ValidateStructure ¶ added in v0.13.0
func ValidateStructure( tokenRequest *driver.TokenRequest, tokenRequestMetadata *driver.TokenRequestMetadata, txID driver.TokenRequestAnchor, ) error
ValidateStructure ensures complete structural correspondence between TokenRequest and TokenRequestMetadata. It validates that: - Action counts match between request and metadata - Each action has corresponding metadata with correct type - ActionIDs are sequential and match their position - Action types align with metadata types (no mixed metadata)
This validation ensures that the request and metadata are structurally consistent before performing deeper semantic validation.
func ValidateTransferActionTokenTypes ¶ added in v0.13.0
func ValidateTransferActionTokenTypes( metadata *driver.TransferMetadata, auditTokens map[string]*token.Token, validateValueSum bool, precision uint64, ) error
ValidateTransferActionTokenTypes ensures all inputs and outputs in a transfer action have the same token type. It also validates that input tokens exist in the auditTokens map.
When validateValueSum is true (for privacy-preserving tokens like zkatdlog), this also validates that the sum of input values equals the sum of output values using the provided precision.
For transfer actions, this validates that: - auditTokens map is non-empty (required for validation) - All input tokens exist in the audit token map - All inputs have the same token type - All outputs have the same token type as the inputs - (Optional) Sum of input values equals sum of output values
This ensures token type consistency and value conservation within a transfer action.
Types ¶
type AuditContext ¶ added in v0.13.0
type AuditContext[P driver.PublicParameters, IA driver.IssueAction, TA driver.TransferAction, DS driver.Deserializer] struct { Logger logging.Logger Tracer trace.Tracer PP P Anchor driver.TokenRequestAnchor TokenRequest *driver.TokenRequest TokenRequestMetadata *driver.TokenRequestMetadata Deserializer DS AuditTokens map[string]*token.Token IssueAction IA TransferAction TA ActionIndex int // Index of the current action being validated }
AuditContext contains the context for token request auditing.
type Auditor ¶ added in v0.13.0
type Auditor[P driver.PublicParameters, IA driver.IssueAction, TA driver.TransferAction, DS driver.Deserializer] struct { Logger logging.Logger Tracer trace.Tracer PublicParams P Deserializer DS ActionDeserializer driver.ActionDeserializer[TA, IA] IssueValidators []ValidateIssueAuditFunc[P, IA, TA, DS] TransferValidators []ValidateTransferAuditFunc[P, IA, TA, DS] }
Auditor validates token requests against their metadata.
func NewAuditor ¶ added in v0.13.0
func NewAuditor[P driver.PublicParameters, IA driver.IssueAction, TA driver.TransferAction, DS driver.Deserializer]( logger logging.Logger, tracer trace.Tracer, publicParams P, deserializer DS, actionDeserializer driver.ActionDeserializer[TA, IA], issueValidators []ValidateIssueAuditFunc[P, IA, TA, DS], transferValidators []ValidateTransferAuditFunc[P, IA, TA, DS], ) *Auditor[P, IA, TA, DS]
NewAuditor returns a new Auditor instance for the passed arguments.
func (*Auditor[P, IA, TA, DS]) Check ¶ added in v0.13.0
func (a *Auditor[P, IA, TA, DS]) Check( ctx context.Context, tokenRequest *driver.TokenRequest, tokenRequestMetadata *driver.TokenRequestMetadata, txID driver.TokenRequestAnchor, auditTokens map[string]*token.Token, ) error
Check validates TokenRequest against TokenRequestMetadata. It ensures complete 1:1 correspondence between actions and metadata, then validates each action.
func (*Auditor[P, IA, TA, DS]) CheckIssue ¶ added in v0.13.0
func (a *Auditor[P, IA, TA, DS]) CheckIssue( ctx context.Context, anchor driver.TokenRequestAnchor, tokenRequest *driver.TokenRequest, tokenRequestMetadata *driver.TokenRequestMetadata, action IA, auditTokens map[string]*token.Token, actionIndex int, ) error
CheckIssue validates an issue action.
func (*Auditor[P, IA, TA, DS]) CheckTransfer ¶ added in v0.13.0
func (a *Auditor[P, IA, TA, DS]) CheckTransfer( ctx context.Context, anchor driver.TokenRequestAnchor, tokenRequest *driver.TokenRequest, tokenRequestMetadata *driver.TokenRequestMetadata, action TA, auditTokens map[string]*token.Token, actionIndex int, ) error
CheckTransfer validates a transfer action.
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 and any additional owner identifier, if supported.
// It is possible that the wallet ID is empty and the additional owner identifier list is not.
IsMine(ctx context.Context, tok *token2.Token) (string, []string, 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 token.Identity, tok *token2.Token) bool
}
Authorization defines an interface for checking the ownership, issuance, and auditor status of tokens.
type AuthorizationMultiplexer ¶ added in v0.4.0
type AuthorizationMultiplexer struct {
// contains filtered or unexported fields
}
AuthorizationMultiplexer iterates over multiple authorization checker
func NewAuthorizationMultiplexer ¶ added in v0.4.0
func NewAuthorizationMultiplexer(ownerships ...Authorization) *AuthorizationMultiplexer
NewAuthorizationMultiplexer returns a new AuthorizationMultiplexer for the passed ownership checkers
func (*AuthorizationMultiplexer) AmIAnAuditor ¶ added in v0.4.0
func (o *AuthorizationMultiplexer) AmIAnAuditor() bool
AmIAnAuditor returns true it there exists an authorization checker that returns true
func (*AuthorizationMultiplexer) IsMine ¶ added in v0.4.0
func (o *AuthorizationMultiplexer) IsMine(ctx context.Context, tok *token2.Token) (string, []string, bool)
IsMine returns true it there exists an authorization checker that returns true
func (*AuthorizationMultiplexer) Issued ¶ added in v0.4.0
func (o *AuthorizationMultiplexer) Issued(ctx context.Context, issuer token.Identity, tok *token2.Token) bool
Issued returns true it there exists an authorization checker that returns true
func (*AuthorizationMultiplexer) OwnerType ¶ added in v0.4.0
func (o *AuthorizationMultiplexer) OwnerType(raw []byte) (driver.IdentityType, []byte, error)
OwnerType returns the type of owner (e.g. 'idemix' or 'htlc') and the identity bytes.
type Backend ¶
type Backend struct {
Logger logging.Logger
// Ledger to access the ledger state
Ledger driver.GetStateFnc
// Message to be signed or verified
Message []byte
// Cursor is used to iterate over the signatures
Cursor int
// Sigs contains signatures on Message
Sigs [][]byte
}
Backend represents a backend for token operations, providing access to the ledger and transaction signatures.
func NewBackend ¶
func NewBackend(logger logging.Logger, ledger driver.GetStateFnc, message []byte, sigs [][]byte) *Backend
NewBackend returns a new Backend instance with the provided logger, ledger, message, and signatures.
func (*Backend) GetState ¶
GetState returns the state associated with the provided token ID from the ledger.
func (*Backend) HasBeenSignedBy ¶
func (b *Backend) HasBeenSignedBy(ctx context.Context, id driver.Identity, verifier driver.Verifier) ([]byte, error)
HasBeenSignedBy checks if a given Message has been signed by the signing identity matching the passed verifier. It returns the signature and any error encountered during verification.
func (*Backend) Signatures ¶
Signatures returns the signatures associated with the backend.
type Context ¶ added in v0.4.0
type Context[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer] struct { Logger logging.Logger PP P Anchor driver.TokenRequestAnchor TokenRequest *driver.TokenRequest Deserializer DS SignatureProvider driver.SignatureProvider Signatures [][]byte InputTokens []T TransferAction TA IssueAction IA Ledger driver.Ledger MetadataCounter map[MetadataCounterID]int Attributes driver.ValidationAttributes }
Context contains the context for token request validation.
func (*Context[P, T, TA, IA, DS]) CountMetadataKey ¶ added in v0.4.0
CountMetadataKey increments the counter for the passed metadata key.
type Deserializer ¶ added in v0.4.0
type Deserializer struct {
// contains filtered or unexported fields
}
Deserializer deserializes verifiers associated with issuers, owners, and auditors
func NewDeserializer ¶ added in v0.4.0
func NewDeserializer( auditorDeserializer driver.VerifierDeserializer, ownerDeserializer driver.VerifierDeserializer, issuerDeserializer driver.VerifierDeserializer, auditMatcherProvider driver.AuditMatcherProvider, recipientExtractor driver.RecipientExtractor, ) *Deserializer
NewDeserializer returns a new Deserializer for the passed arguments.
func (*Deserializer) GetAuditInfo ¶ added in v0.5.0
func (d *Deserializer) GetAuditInfo(ctx context.Context, id driver.Identity, p driver.AuditInfoProvider) ([]byte, error)
GetAuditInfo returns the audit information for the passed identity, if available.
func (*Deserializer) GetAuditInfoMatcher ¶ added in v0.5.0
func (d *Deserializer) GetAuditInfoMatcher(ctx context.Context, owner driver.Identity, auditInfo []byte) (driver.Matcher, error)
GetAuditInfoMatcher returns an identity matcher for the passed identity and audit info.
func (*Deserializer) GetAuditorVerifier ¶ added in v0.4.0
func (d *Deserializer) GetAuditorVerifier(ctx context.Context, id driver.Identity) (driver.Verifier, error)
GetAuditorVerifier returns the verifier associated to the passed auditor identity.
func (*Deserializer) GetIssuerVerifier ¶ added in v0.4.0
func (d *Deserializer) GetIssuerVerifier(ctx context.Context, id driver.Identity) (driver.Verifier, error)
GetIssuerVerifier returns the verifier associated to the passed issuer identity.
func (*Deserializer) GetOwnerVerifier ¶ added in v0.4.0
func (d *Deserializer) GetOwnerVerifier(ctx context.Context, id driver.Identity) (driver.Verifier, error)
GetOwnerVerifier returns the verifier associated to the passed owner identity.
func (*Deserializer) MatchIdentity ¶ added in v0.5.0
MatchIdentity returns nil if the given identity matches the given audit information.
func (*Deserializer) Recipients ¶ added in v0.4.0
Recipients returns the recipient identities extracted from the passed identity.
type IdentityTokenAndMetadataDeserializer ¶ added in v0.4.0
type IdentityTokenAndMetadataDeserializer struct{}
IdentityTokenAndMetadataDeserializer is a deserializer that returns the input bytes as is.
func (IdentityTokenAndMetadataDeserializer) DeserializeMetadata ¶ added in v0.4.0
func (i IdentityTokenAndMetadataDeserializer) DeserializeMetadata(bytes []byte) ([]byte, error)
DeserializeMetadata returns the input bytes as is.
func (IdentityTokenAndMetadataDeserializer) DeserializeToken ¶ added in v0.4.0
func (i IdentityTokenAndMetadataDeserializer) DeserializeToken(bytes []byte) ([]byte, error)
DeserializeToken returns the input bytes as is.
type LoadedToken ¶ added in v0.4.0
LoadedToken represents a token and its metadata loaded from the vault.
type MetadataCounterID ¶ added in v0.4.0
type MetadataCounterID = string
MetadataCounterID defines the type for metadata counter identifiers.
type PublicParametersManager ¶ added in v0.4.0
type PublicParametersManager[T driver.PublicParameters] interface { driver.PublicParamsManager PublicParams() T }
PublicParametersManager defines an interface for managing public parameters.
type PublicParamsDeserializer ¶ added in v0.4.0
type PublicParamsDeserializer[T driver.PublicParameters] interface { DeserializePublicParams(raw []byte, name driver.TokenDriverName, version driver.TokenDriverVersion) (T, error) }
PublicParamsDeserializer deserializes public parameters from their raw representation.
type PublicParamsManager ¶ added in v0.4.0
type PublicParamsManager[T driver.PublicParameters] struct { // label of the public params DriverName driver.TokenDriverName DriverVersion driver.TokenDriverVersion // contains filtered or unexported fields }
PublicParamsManager manages public parameters.
func NewPublicParamsManager ¶ added in v0.4.0
func NewPublicParamsManager[T driver.PublicParameters]( PublicParamsDeserializer PublicParamsDeserializer[T], driverName driver.TokenDriverName, driverVersion driver.TokenDriverVersion, ppRaw []byte, ) (*PublicParamsManager[T], error)
NewPublicParamsManager returns a new PublicParamsManager instance for the passed arguments.
func NewPublicParamsManagerFromParams ¶ added in v0.4.0
func NewPublicParamsManagerFromParams[T driver.PublicParameters](pp T) (*PublicParamsManager[T], error)
NewPublicParamsManagerFromParams returns a new PublicParamsManager instance for the passed public parameters.
func (*PublicParamsManager[T]) NewCertifierKeyPair ¶ added in v0.4.0
func (v *PublicParamsManager[T]) NewCertifierKeyPair() ([]byte, []byte, error)
NewCertifierKeyPair returns a new certifier key pair.
func (*PublicParamsManager[T]) PublicParameters ¶ added in v0.4.0
func (v *PublicParamsManager[T]) PublicParameters() driver.PublicParameters
PublicParameters returns the public parameters managed by this manager.
func (*PublicParamsManager[T]) PublicParams ¶ added in v0.4.0
func (v *PublicParamsManager[T]) PublicParams() T
PublicParams returns the public parameters managed by this manager.
func (*PublicParamsManager[T]) PublicParamsHash ¶ added in v0.4.0
func (v *PublicParamsManager[T]) PublicParamsHash() driver.PPHash
PublicParamsHash returns the hash of the public parameters.
type Service ¶ added in v0.4.0
type Service[T driver.PublicParameters] struct { Logger logging.Logger PublicParametersManager PublicParametersManager[T] // contains filtered or unexported fields }
Service is a generic implementation of a token service.
func NewTokenService ¶ added in v0.4.0
func NewTokenService[T driver.PublicParameters]( logger logging.Logger, ws driver.WalletService, publicParametersManager PublicParametersManager[T], identityProvider driver.IdentityProvider, deserializer driver.Deserializer, configManager driver.Configuration, certificationService driver.CertificationService, issueService driver.IssueService, transferService driver.TransferService, auditorService driver.AuditorService, tokensService driver.TokensService, tokensUpgradeService driver.TokensUpgradeService, authorization driver.Authorization, validator driver.Validator, ) (*Service[T], error)
NewTokenService returns a new token service instance for the passed arguments.
func (*Service[T]) AuditorService ¶ added in v0.4.0
func (s *Service[T]) AuditorService() driver.AuditorService
AuditorService returns the auditor service associated with the service.
func (*Service[T]) Authorization ¶ added in v0.4.0
func (s *Service[T]) Authorization() driver.Authorization
Authorization returns the authorization service associated with the service.
func (*Service[T]) CertificationService ¶ added in v0.4.0
func (s *Service[T]) CertificationService() driver.CertificationService
CertificationService returns the certification service associated with the service.
func (*Service[T]) Configuration ¶ added in v0.4.0
func (s *Service[T]) Configuration() driver.Configuration
Configuration returns the configuration manager associated with the service.
func (*Service[T]) Deserializer ¶ added in v0.4.0
func (s *Service[T]) Deserializer() driver.Deserializer
Deserializer returns the deserializer associated with the service.
func (*Service[T]) Done ¶ added in v0.4.0
Done releases all the resources allocated by this service.
func (*Service[T]) IdentityProvider ¶ added in v0.4.0
func (s *Service[T]) IdentityProvider() driver.IdentityProvider
IdentityProvider returns the identity provider associated with the service.
func (*Service[T]) IssueService ¶ added in v0.4.0
func (s *Service[T]) IssueService() driver.IssueService
IssueService returns the issue service associated with the service.
func (*Service[T]) PublicParamsManager ¶ added in v0.4.0
func (s *Service[T]) PublicParamsManager() driver.PublicParamsManager
PublicParamsManager returns the manager of the public parameters associated with the service.
func (*Service[T]) TokensService ¶ added in v0.4.0
func (s *Service[T]) TokensService() driver.TokensService
TokensService returns the tokens service associated with the service.
func (*Service[T]) TokensUpgradeService ¶ added in v0.5.0
func (s *Service[T]) TokensUpgradeService() driver.TokensUpgradeService
TokensUpgradeService returns the tokens upgrade service associated with the service.
func (*Service[T]) TransferService ¶ added in v0.4.0
func (s *Service[T]) TransferService() driver.TransferService
TransferService returns the transfer service associated with the service.
func (*Service[T]) Validator ¶ added in v0.7.0
Validator returns the validator associated with the service.
func (*Service[T]) WalletService ¶ added in v0.4.0
func (s *Service[T]) WalletService() driver.WalletService
WalletService returns the wallet service associated with the service.
type ValidateAuditingFunc ¶ added in v0.5.0
type ValidateAuditingFunc[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer] func(c context.Context, ctx *Context[P, T, TA, IA, DS]) error
ValidateAuditingFunc is a function type for validating auditing information.
type ValidateIssueAuditFunc ¶ added in v0.13.0
type ValidateIssueAuditFunc[P driver.PublicParameters, IA driver.IssueAction, TA driver.TransferAction, DS driver.Deserializer] func(c context.Context, ctx *AuditContext[P, IA, TA, DS]) error
ValidateIssueAuditFunc is a function type for validating issue actions during audit.
type ValidateIssueFunc ¶ added in v0.4.0
type ValidateIssueFunc[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer] func(c context.Context, ctx *Context[P, T, TA, IA, DS]) error
ValidateIssueFunc is a function type for validating issue actions.
type ValidateTransferAuditFunc ¶ added in v0.13.0
type ValidateTransferAuditFunc[P driver.PublicParameters, IA driver.IssueAction, TA driver.TransferAction, DS driver.Deserializer] func(c context.Context, ctx *AuditContext[P, IA, TA, DS]) error
ValidateTransferAuditFunc is a function type for validating transfer actions during audit.
type ValidateTransferFunc ¶ added in v0.4.0
type ValidateTransferFunc[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer] func(c context.Context, ctx *Context[P, T, TA, IA, DS]) error
ValidateTransferFunc is a function type for validating transfer actions.
type Validator ¶ added in v0.4.0
type Validator[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer] struct { Logger logging.Logger PublicParams P Deserializer DS ActionDeserializer driver.ActionDeserializer[TA, IA] AuditingValidators []ValidateAuditingFunc[P, T, TA, IA, DS] TransferValidators []ValidateTransferFunc[P, T, TA, IA, DS] IssueValidators []ValidateIssueFunc[P, T, TA, IA, DS] // MinProtocolVersion specifies the minimum protocol version required for token requests. // If set to 0, no minimum version is enforced (accepts all versions). // If set to a specific version (e.g., driver.ProtocolV1), only requests with that version // or higher will be accepted, rejecting older protocol versions. MinProtocolVersion uint32 }
Validator validates token requests.
func NewValidator ¶ added in v0.4.0
func NewValidator[P driver.PublicParameters, T driver.Input, TA driver.TransferAction, IA driver.IssueAction, DS driver.Deserializer]( Logger logging.Logger, publicParams P, deserializer DS, actionDeserializer driver.ActionDeserializer[TA, IA], transferValidators []ValidateTransferFunc[P, T, TA, IA, DS], issueValidators []ValidateIssueFunc[P, T, TA, IA, DS], auditingValidators []ValidateAuditingFunc[P, T, TA, IA, DS], ) *Validator[P, T, TA, IA, DS]
NewValidator returns a new Validator instance for the passed arguments.
func (*Validator[P, T, TA, IA, DS]) SetMinProtocolVersion ¶ added in v0.10.1
SetMinProtocolVersion configures the minimum protocol version that this validator will accept. Token requests with a protocol version below this minimum will be rejected during validation. Setting this to 0 (default) accepts all protocol versions.
func (*Validator[P, T, TA, IA, DS]) UnmarshalActions ¶ added in v0.4.0
UnmarshalActions unmarshals the actions from the passed raw representation of a token request.
func (*Validator[P, T, TA, IA, DS]) VerifyAuditing ¶ added in v0.5.0
func (v *Validator[P, T, TA, IA, DS]) VerifyAuditing( ctx context.Context, anchor driver.TokenRequestAnchor, tokenRequest *driver.TokenRequest, ledger driver.Ledger, signatureProvider driver.SignatureProvider, attributes driver.ValidationAttributes, ) error
VerifyAuditing verifies the auditing information in a token request.
func (*Validator[P, T, TA, IA, DS]) VerifyIssue ¶ added in v0.5.0
func (v *Validator[P, T, TA, IA, DS]) VerifyIssue( ctx context.Context, anchor driver.TokenRequestAnchor, tokenRequest *driver.TokenRequest, action IA, ledger driver.Ledger, signatureProvider driver.SignatureProvider, attributes driver.ValidationAttributes, ) error
VerifyIssue verifies an issue action.
func (*Validator[P, T, TA, IA, DS]) VerifyTokenRequest ¶ added in v0.4.0
func (v *Validator[P, T, TA, IA, DS]) VerifyTokenRequest( ctx context.Context, ledger driver.Ledger, signatureProvider driver.SignatureProvider, anchor driver.TokenRequestAnchor, tr *driver.TokenRequest, attributes driver.ValidationAttributes, ) ([]any, driver.ValidationAttributes, error)
VerifyTokenRequest verifies a token request.
func (*Validator[P, T, TA, IA, DS]) VerifyTokenRequestFromRaw ¶ added in v0.4.0
func (v *Validator[P, T, TA, IA, DS]) VerifyTokenRequestFromRaw(ctx context.Context, getState driver.GetStateFnc, anchor driver.TokenRequestAnchor, raw []byte) ([]any, driver.ValidationAttributes, error)
VerifyTokenRequestFromRaw verifies a token request from its raw representation.
func (*Validator[P, T, TA, IA, DS]) VerifyTransfer ¶ added in v0.5.0
func (v *Validator[P, T, TA, IA, DS]) VerifyTransfer( ctx context.Context, anchor driver.TokenRequestAnchor, tokenRequest *driver.TokenRequest, action TA, ledger driver.Ledger, signatureProvider driver.SignatureProvider, attributes driver.ValidationAttributes, ) error
VerifyTransfer verifies a transfer action.
type ValidatorFactory ¶ added in v0.7.0
ValidatorFactory is a function that returns a driver.Validator instance.
type VaultLedgerTokenAndMetadataLoader ¶ added in v0.4.0
type VaultLedgerTokenAndMetadataLoader[T any, M any] struct { TokenVault driver.TokenVault Deserializer driver.TokenAndMetadataDeserializer[T, M] }
VaultLedgerTokenAndMetadataLoader loads tokens and their metadata from the vault ledger.
func NewVaultLedgerTokenAndMetadataLoader ¶ added in v0.4.0
func NewVaultLedgerTokenAndMetadataLoader[T any, M any](tokenVault driver.TokenVault, deserializer driver.TokenAndMetadataDeserializer[T, M]) *VaultLedgerTokenAndMetadataLoader[T, M]
NewVaultLedgerTokenAndMetadataLoader returns a new VaultLedgerTokenAndMetadataLoader instance.
func (*VaultLedgerTokenAndMetadataLoader[T, M]) LoadTokens ¶ added in v0.4.0
func (s *VaultLedgerTokenAndMetadataLoader[T, M]) LoadTokens(ctx context.Context, ids []*token.ID) ([]LoadedToken[T, M], error)
LoadTokens takes an array of token identifiers (txID, index) and returns the keys in the vault matching the token identifiers, the corresponding zkatdlog tokens, the information of the tokens in clear text and the identities of their owners.
type VaultTokenCertificationLoader ¶ added in v0.4.0
type VaultTokenCertificationLoader struct {
TokenCertificationStorage driver.TokenCertificationStorage
}
VaultTokenCertificationLoader loads token certifications.
func (*VaultTokenCertificationLoader) GetCertifications ¶ added in v0.4.0
func (s *VaultTokenCertificationLoader) GetCertifications(ctx context.Context, ids []*token.ID) ([][]byte, error)
GetCertifications returns certifications for the passed token IDs.
type VaultTokenInfoLoader ¶ added in v0.4.0
type VaultTokenInfoLoader[M any] struct { TokenVault driver.QueryEngine Deserializer driver.MetadataDeserializer[M] }
VaultTokenInfoLoader loads token metadata from the vault.
func NewVaultTokenInfoLoader ¶ added in v0.4.0
func NewVaultTokenInfoLoader[M any](tokenVault driver.QueryEngine, deserializer driver.MetadataDeserializer[M]) *VaultTokenInfoLoader[M]
NewVaultTokenInfoLoader returns a new VaultTokenInfoLoader instance.
func (*VaultTokenInfoLoader[M]) GetTokenInfos ¶ added in v0.4.0
GetTokenInfos takes an array of token identifiers (txID, index) and returns the corresponding token metadata.
type VaultTokenLoader ¶ added in v0.4.0
type VaultTokenLoader struct {
TokenVault driver.QueryEngine
}
VaultTokenLoader loads tokens from the vault.
func NewVaultTokenLoader ¶ added in v0.4.0
func NewVaultTokenLoader(tokenVault driver.QueryEngine) *VaultTokenLoader
NewVaultTokenLoader returns a new VaultTokenLoader instance.
type WalletBasedAuthorization ¶ added in v0.4.0
type WalletBasedAuthorization struct {
Logger logging.Logger
PublicParameters driver.PublicParameters
WalletService driver.WalletService
// contains filtered or unexported fields
}
WalletBasedAuthorization is a wallet-based authorization implementation
func NewTMSAuthorization ¶ added in v0.4.0
func NewTMSAuthorization(logger logging.Logger, publicParameters driver.PublicParameters, walletService driver.WalletService) *WalletBasedAuthorization
NewTMSAuthorization returns a new WalletBasedAuthorization for the passed public parameters and wallet service.
func (*WalletBasedAuthorization) AmIAnAuditor ¶ added in v0.4.0
func (w *WalletBasedAuthorization) AmIAnAuditor() 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.
func (*WalletBasedAuthorization) IsMine ¶ added in v0.4.0
func (w *WalletBasedAuthorization) IsMine(ctx context.Context, tok *token2.Token) (string, []string, bool)
IsMine returns true if the passed token is owned by an owner wallet. It returns the ID of the owner wallet and no additional owner identifiers.