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 ¶
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 ¶
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 ¶
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 Panurus the option to attach public data to the token transaction.
func RetrieveAuditTokens ¶
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 ¶
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 ¶
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 Panurus the option to attach public data to the token transaction.
func ValidateIssueActionTokenTypes ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
type AuthorizationMultiplexer struct {
// contains filtered or unexported fields
}
AuthorizationMultiplexer iterates over multiple authorization checker
func NewAuthorizationMultiplexer ¶
func NewAuthorizationMultiplexer(ownerships ...Authorization) *AuthorizationMultiplexer
NewAuthorizationMultiplexer returns a new AuthorizationMultiplexer for the passed ownership checkers
func (*AuthorizationMultiplexer) AmIAnAuditor ¶
func (o *AuthorizationMultiplexer) AmIAnAuditor() bool
AmIAnAuditor returns true it there exists an authorization checker that returns true
func (*AuthorizationMultiplexer) IsMine ¶
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 ¶
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 ¶
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 ¶
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 ¶
CountMetadataKey increments the counter for the passed metadata key.
type Deserializer ¶
type Deserializer struct {
// contains filtered or unexported fields
}
Deserializer deserializes verifiers associated with issuers, owners, and auditors
func NewDeserializer ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
MatchIdentity returns nil if the given identity matches the given audit information.
func (*Deserializer) Recipients ¶
Recipients returns the recipient identities extracted from the passed identity.
type IdentityTokenAndMetadataDeserializer ¶
type IdentityTokenAndMetadataDeserializer struct{}
IdentityTokenAndMetadataDeserializer is a deserializer that returns the input bytes as is.
func (IdentityTokenAndMetadataDeserializer) DeserializeMetadata ¶
func (i IdentityTokenAndMetadataDeserializer) DeserializeMetadata(bytes []byte) ([]byte, error)
DeserializeMetadata returns the input bytes as is.
func (IdentityTokenAndMetadataDeserializer) DeserializeToken ¶
func (i IdentityTokenAndMetadataDeserializer) DeserializeToken(bytes []byte) ([]byte, error)
DeserializeToken returns the input bytes as is.
type LoadedToken ¶
LoadedToken represents a token and its metadata loaded from the vault.
type MetadataCounterID ¶
type MetadataCounterID = string
MetadataCounterID defines the type for metadata counter identifiers.
type PublicParametersManager ¶
type PublicParametersManager[T driver.PublicParameters] interface { driver.PublicParamsManager PublicParams() T }
PublicParametersManager defines an interface for managing public parameters.
type PublicParamsDeserializer ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (v *PublicParamsManager[T]) NewCertifierKeyPair() ([]byte, []byte, error)
NewCertifierKeyPair returns a new certifier key pair.
func (*PublicParamsManager[T]) PublicParameters ¶
func (v *PublicParamsManager[T]) PublicParameters() driver.PublicParameters
PublicParameters returns the public parameters managed by this manager.
func (*PublicParamsManager[T]) PublicParams ¶
func (v *PublicParamsManager[T]) PublicParams() T
PublicParams returns the public parameters managed by this manager.
func (*PublicParamsManager[T]) PublicParamsHash ¶
func (v *PublicParamsManager[T]) PublicParamsHash() driver.PPHash
PublicParamsHash returns the hash of the public parameters.
type Service ¶
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 ¶
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 ¶
func (s *Service[T]) AuditorService() driver.AuditorService
AuditorService returns the auditor service associated with the service.
func (*Service[T]) Authorization ¶
func (s *Service[T]) Authorization() driver.Authorization
Authorization returns the authorization service associated with the service.
func (*Service[T]) CertificationService ¶
func (s *Service[T]) CertificationService() driver.CertificationService
CertificationService returns the certification service associated with the service.
func (*Service[T]) Configuration ¶
func (s *Service[T]) Configuration() driver.Configuration
Configuration returns the configuration manager associated with the service.
func (*Service[T]) Deserializer ¶
func (s *Service[T]) Deserializer() driver.Deserializer
Deserializer returns the deserializer associated with the service.
func (*Service[T]) IdentityProvider ¶
func (s *Service[T]) IdentityProvider() driver.IdentityProvider
IdentityProvider returns the identity provider associated with the service.
func (*Service[T]) IssueService ¶
func (s *Service[T]) IssueService() driver.IssueService
IssueService returns the issue service associated with the service.
func (*Service[T]) PublicParamsManager ¶
func (s *Service[T]) PublicParamsManager() driver.PublicParamsManager
PublicParamsManager returns the manager of the public parameters associated with the service.
func (*Service[T]) TokensService ¶
func (s *Service[T]) TokensService() driver.TokensService
TokensService returns the tokens service associated with the service.
func (*Service[T]) TokensUpgradeService ¶
func (s *Service[T]) TokensUpgradeService() driver.TokensUpgradeService
TokensUpgradeService returns the tokens upgrade service associated with the service.
func (*Service[T]) TransferService ¶
func (s *Service[T]) TransferService() driver.TransferService
TransferService returns the transfer service associated with the service.
func (*Service[T]) WalletService ¶
func (s *Service[T]) WalletService() driver.WalletService
WalletService returns the wallet service associated with the service.
type ValidateAuditingFunc ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
UnmarshalActions unmarshals the actions from the passed raw representation of a token request.
func (*Validator[P, T, TA, IA, DS]) VerifyAuditing ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
ValidatorFactory is a function that returns a driver.Validator instance.
type VaultLedgerTokenAndMetadataLoader ¶
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 ¶
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 ¶
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 ¶
type VaultTokenCertificationLoader struct {
TokenCertificationStorage driver.TokenCertificationStorage
}
VaultTokenCertificationLoader loads token certifications.
func (*VaultTokenCertificationLoader) GetCertifications ¶
func (s *VaultTokenCertificationLoader) GetCertifications(ctx context.Context, ids []*token.ID) ([][]byte, error)
GetCertifications returns certifications for the passed token IDs.
type VaultTokenInfoLoader ¶
type VaultTokenInfoLoader[M any] struct { TokenVault driver.QueryEngine Deserializer driver.MetadataDeserializer[M] }
VaultTokenInfoLoader loads token metadata from the vault.
func NewVaultTokenInfoLoader ¶
func NewVaultTokenInfoLoader[M any](tokenVault driver.QueryEngine, deserializer driver.MetadataDeserializer[M]) *VaultTokenInfoLoader[M]
NewVaultTokenInfoLoader returns a new VaultTokenInfoLoader instance.
func (*VaultTokenInfoLoader[M]) GetTokenInfos ¶
GetTokenInfos takes an array of token identifiers (txID, index) and returns the corresponding token metadata.
type VaultTokenLoader ¶
type VaultTokenLoader struct {
TokenVault driver.QueryEngine
}
VaultTokenLoader loads tokens from the vault.
func NewVaultTokenLoader ¶
func NewVaultTokenLoader(tokenVault driver.QueryEngine) *VaultTokenLoader
NewVaultTokenLoader returns a new VaultTokenLoader instance.
type WalletBasedAuthorization ¶
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 ¶
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 ¶
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.