Documentation
¶
Index ¶
- Constants
- func IssueValidate(ctx *Context) error
- func TransferBalanceValidate(ctx *Context) error
- func TransferHTLCValidate(ctx *Context) error
- func TransferSignatureValidate(ctx *Context) error
- type ActionDeserializer
- type AuditorService
- type Context
- type IssueAction
- func (i *IssueAction) Deserialize(raw []byte) error
- func (i *IssueAction) GetIssuer() []byte
- func (i *IssueAction) GetMetadata() map[string][]byte
- func (i *IssueAction) GetOutputs() []driver.Output
- func (i *IssueAction) GetSerializedOutputs() ([][]byte, error)
- func (i *IssueAction) IsAnonymous() bool
- func (i *IssueAction) IsGraphHiding() bool
- func (i *IssueAction) NumOutputs() int
- func (i *IssueAction) Serialize() ([]byte, error)
- type IssueService
- func (s *IssueService) DeserializeIssueAction(raw []byte) (driver.IssueAction, error)
- func (s *IssueService) Issue(ctx context.Context, issuerIdentity driver.Identity, tokenType token2.Type, ...) (driver.IssueAction, *driver.IssueMetadata, error)
- func (s *IssueService) VerifyIssue(tr driver.IssueAction, tokenInfos [][]byte) error
- type Output
- type OutputMetadata
- type PublicParams
- func (pp *PublicParams) AddAuditor(auditor driver.Identity)
- func (pp *PublicParams) AddIssuer(issuer driver.Identity)
- func (pp *PublicParams) AuditorIdentity() driver.Identity
- func (pp *PublicParams) Auditors() []driver.Identity
- func (pp *PublicParams) Bytes() ([]byte, error)
- func (pp *PublicParams) CertificationDriver() string
- func (pp *PublicParams) ComputeMaxTokenValue() uint64
- func (pp *PublicParams) Deserialize(raw []byte) error
- func (pp *PublicParams) GraphHiding() bool
- func (pp *PublicParams) Identifier() string
- func (pp *PublicParams) MaxTokenValue() uint64
- func (pp *PublicParams) Precision() uint64
- func (pp *PublicParams) Serialize() ([]byte, error)
- func (pp *PublicParams) String() string
- func (pp *PublicParams) TokenDataHiding() bool
- func (pp *PublicParams) Validate() error
- type Service
- type TokenLoader
- type TokenVault
- type TokensService
- type TransferAction
- func (t *TransferAction) Deserialize(raw []byte) error
- func (t *TransferAction) GetInputs() []*token.ID
- func (t *TransferAction) GetMetadata() map[string][]byte
- func (t *TransferAction) GetOutputs() []driver.Output
- func (t *TransferAction) GetSerialNumbers() []string
- func (t *TransferAction) GetSerializedInputs() ([][]byte, error)
- func (t *TransferAction) GetSerializedOutputs() ([][]byte, error)
- func (t *TransferAction) IsGraphHiding() bool
- func (t *TransferAction) IsRedeemAt(index int) bool
- func (t *TransferAction) NumOutputs() int
- func (t *TransferAction) Serialize() ([]byte, error)
- func (t *TransferAction) SerializeOutputAt(index int) ([]byte, error)
- type TransferService
- func (s *TransferService) DeserializeTransferAction(raw []byte) (driver.TransferAction, error)
- func (s *TransferService) Transfer(ctx context.Context, _ string, _ driver.OwnerWallet, tokenIDs []*token.ID, ...) (driver.TransferAction, *driver.TransferMetadata, error)
- func (s *TransferService) VerifyTransfer(tr driver.TransferAction, outputsMetadata [][]byte) error
- type ValidateIssueFunc
- type ValidateTransferFunc
- type Validator
- type WalletFactory
Constants ¶
const ( // PublicParameters is the key to be used to look up fabtoken parameters PublicParameters = "fabtoken" DefaultPrecision = uint64(64) )
Variables ¶
This section is empty.
Functions ¶
func IssueValidate ¶ added in v0.4.0
func TransferBalanceValidate ¶
TransferBalanceValidate checks that the sum of the inputs is equal to the sum of the outputs
func TransferHTLCValidate ¶
TransferHTLCValidate checks the validity of the HTLC scripts, if any
func TransferSignatureValidate ¶
TransferSignatureValidate validates the signatures for the inputs spent by an action
Types ¶
type ActionDeserializer ¶ added in v0.4.0
type ActionDeserializer struct{}
func (*ActionDeserializer) DeserializeActions ¶ added in v0.4.0
func (a *ActionDeserializer) DeserializeActions(tr *driver.TokenRequest) ([]*IssueAction, []*TransferAction, error)
type AuditorService ¶ added in v0.4.0
type AuditorService struct{}
func NewAuditorService ¶ added in v0.4.0
func NewAuditorService() *AuditorService
func (*AuditorService) AuditorCheck ¶ added in v0.4.0
func (s *AuditorService) AuditorCheck(ctx context.Context, request *driver.TokenRequest, metadata *driver.TokenRequestMetadata, anchor string) error
AuditorCheck verifies if the passed tokenRequest matches the tokenRequestMetadata fabtoken does not make use of AuditorCheck as the token request contains token information in the clear
type Context ¶
type Context = common.Context[*PublicParams, *Output, *TransferAction, *IssueAction, driver.Deserializer]
type IssueAction ¶
type IssueAction struct { // issuer's public key Issuer driver.Identity // new tokens to be issued Outputs []*Output // metadata of the issue action Metadata map[string][]byte }
IssueAction encodes a fabtoken Issue
func (*IssueAction) Deserialize ¶
func (i *IssueAction) Deserialize(raw []byte) error
Deserialize un-marshals IssueAction
func (*IssueAction) GetIssuer ¶
func (i *IssueAction) GetIssuer() []byte
GetIssuer returns the issuer encoded in IssueAction
func (*IssueAction) GetMetadata ¶
func (i *IssueAction) GetMetadata() map[string][]byte
GetMetadata returns the IssueAction metadata
func (*IssueAction) GetOutputs ¶
func (i *IssueAction) GetOutputs() []driver.Output
GetOutputs returns the outputs in an IssueAction
func (*IssueAction) GetSerializedOutputs ¶
func (i *IssueAction) GetSerializedOutputs() ([][]byte, error)
GetSerializedOutputs returns the serialization of the outputs in an IssueAction
func (*IssueAction) IsAnonymous ¶
func (i *IssueAction) IsAnonymous() bool
IsAnonymous returns false, indicating that the identity of issuers in fabtoken is revealed during issue
func (*IssueAction) IsGraphHiding ¶ added in v0.4.0
func (i *IssueAction) IsGraphHiding() bool
IsGraphHiding returns false, indicating that fabtoken does not hide the transaction graph
func (*IssueAction) NumOutputs ¶
func (i *IssueAction) NumOutputs() int
NumOutputs returns the number of outputs in an IssueAction
func (*IssueAction) Serialize ¶
func (i *IssueAction) Serialize() ([]byte, error)
Serialize marshals IssueAction
type IssueService ¶ added in v0.4.0
type IssueService struct { PublicParamsManager driver.PublicParamsManager WalletService driver.WalletService Deserializer driver.Deserializer }
func NewIssueService ¶ added in v0.4.0
func NewIssueService(publicParamsManager driver.PublicParamsManager, walletService driver.WalletService, deserializer driver.Deserializer) *IssueService
func (*IssueService) DeserializeIssueAction ¶ added in v0.4.0
func (s *IssueService) DeserializeIssueAction(raw []byte) (driver.IssueAction, error)
DeserializeIssueAction un-marshals the passed bytes into an IssueAction If unmarshalling fails, then DeserializeIssueAction returns an error
func (*IssueService) Issue ¶ added in v0.4.0
func (s *IssueService) Issue(ctx context.Context, issuerIdentity driver.Identity, tokenType token2.Type, values []uint64, owners [][]byte, opts *driver.IssueOptions) (driver.IssueAction, *driver.IssueMetadata, error)
Issue returns an IssueAction as a function of the passed arguments Issue also returns a serialization OutputMetadata associated with issued tokens and the identity of the issuer
func (*IssueService) VerifyIssue ¶ added in v0.4.0
func (s *IssueService) VerifyIssue(tr driver.IssueAction, tokenInfos [][]byte) error
VerifyIssue checks if the outputs of an IssueAction match the passed tokenInfos
type Output ¶
Output carries the output of an action
func (*Output) Deserialize ¶ added in v0.4.0
Deserialize unmarshals Token
type OutputMetadata ¶
OutputMetadata contains a serialization of the issuer of the token. type, value and owner of token can be derived from the token itself.
func (*OutputMetadata) Deserialize ¶
func (m *OutputMetadata) Deserialize(b []byte) error
Deserialize un-marshals Metadata
func (*OutputMetadata) Serialize ¶
func (m *OutputMetadata) Serialize() ([]byte, error)
Serialize un-marshals Metadata
type PublicParams ¶
type PublicParams struct { // Label is the label associated with the PublicParams. // It can be used by the driver for versioning purpose. Label string // The precision of token quantities QuantityPrecision uint64 // This is set when audit is enabled Auditor []byte // This encodes the list of authorized issuers Issuers [][]byte // MaxToken is the maximum quantity a token can hold MaxToken uint64 }
PublicParams is the public parameters for fabtoken
func NewPublicParamsFromBytes ¶
func NewPublicParamsFromBytes(raw []byte, label string) (*PublicParams, error)
NewPublicParamsFromBytes deserializes the raw bytes into public parameters The resulting public parameters are labeled with the passed label
func (*PublicParams) AddAuditor ¶
func (pp *PublicParams) AddAuditor(auditor driver.Identity)
AddAuditor sets the Auditor field in PublicParams to the passed identity
func (*PublicParams) AddIssuer ¶
func (pp *PublicParams) AddIssuer(issuer driver.Identity)
AddIssuer adds the passed issuer to the array of Issuers in PublicParams
func (*PublicParams) AuditorIdentity ¶
func (pp *PublicParams) AuditorIdentity() driver.Identity
AuditorIdentity returns the auditor identity encoded in PublicParams
func (*PublicParams) Auditors ¶
func (pp *PublicParams) Auditors() []driver.Identity
Auditors returns the list of authorized auditors fabtoken only supports a single auditor
func (*PublicParams) Bytes ¶
func (pp *PublicParams) Bytes() ([]byte, error)
Bytes marshals PublicParams
func (*PublicParams) CertificationDriver ¶
func (pp *PublicParams) CertificationDriver() string
CertificationDriver returns the label of the PublicParams From the label, one can deduce what certification process will be used if any.
func (*PublicParams) ComputeMaxTokenValue ¶
func (pp *PublicParams) ComputeMaxTokenValue() uint64
func (*PublicParams) Deserialize ¶
func (pp *PublicParams) Deserialize(raw []byte) error
Deserialize un-marshals the passed bytes into PublicParams
func (*PublicParams) GraphHiding ¶
func (pp *PublicParams) GraphHiding() bool
GraphHiding indicates if the PublicParams corresponds to a driver that hides the transaction graph fabtoken does not hide the graph, hence, GraphHiding returns false
func (*PublicParams) Identifier ¶
func (pp *PublicParams) Identifier() string
Identifier returns the label associated with the PublicParams todo shall we used Identifier instead of Label?
func (*PublicParams) MaxTokenValue ¶
func (pp *PublicParams) MaxTokenValue() uint64
MaxTokenValue returns the maximum value that a token can hold according to PublicParams
func (*PublicParams) Precision ¶
func (pp *PublicParams) Precision() uint64
Precision returns the quantity precision encoded in PublicParams
func (*PublicParams) Serialize ¶
func (pp *PublicParams) Serialize() ([]byte, error)
Serialize marshals a wrapper around PublicParams (SerializedPublicParams)
func (*PublicParams) String ¶ added in v0.3.0
func (pp *PublicParams) String() string
func (*PublicParams) TokenDataHiding ¶
func (pp *PublicParams) TokenDataHiding() bool
TokenDataHiding indicates if the PublicParams corresponds to a driver that hides token data fabtoken does not hide token data, hence, TokenDataHiding returns false
func (*PublicParams) Validate ¶
func (pp *PublicParams) Validate() error
Validate validates the public parameters
type Service ¶
type Service struct { *common.Service[*PublicParams] }
func NewService ¶
func NewService( logger logging.Logger, ws *common.WalletService, ppm common.PublicParametersManager[*PublicParams], identityProvider driver.IdentityProvider, serializer driver.Serializer, deserializer driver.Deserializer, configuration driver.Configuration, issueService driver.IssueService, transferService driver.TransferService, auditorService driver.AuditorService, tokensService driver.TokensService, authorization driver.Authorization, ) (*Service, error)
type TokenLoader ¶
type TokenVault ¶
type TokensService ¶ added in v0.4.0
type TokensService struct { *common.TokensService OutputTokenFormat token2.Format }
func NewTokensService ¶ added in v0.4.0
func NewTokensService(pp *PublicParams) (*TokensService, error)
func (*TokensService) Deobfuscate ¶ added in v0.4.0
func (s *TokensService) Deobfuscate(output []byte, outputMetadata []byte) (*token2.Token, driver.Identity, token2.Format, error)
Deobfuscate returns a deserialized token and the identity of its issuer
func (*TokensService) SupportedTokenFormats ¶ added in v0.4.0
func (s *TokensService) SupportedTokenFormats() []token2.Format
type TransferAction ¶
type TransferAction struct { // identifier of token to be transferred Inputs []*token.ID // InputTokens are the inputs transferred by this action InputTokens []*Output // outputs to be created as a result of the transfer Outputs []*Output // Metadata contains the transfer action's metadata Metadata map[string][]byte }
TransferAction encodes a fabtoken transfer
func (*TransferAction) Deserialize ¶
func (t *TransferAction) Deserialize(raw []byte) error
Deserialize un-marshals TransferAction
func (*TransferAction) GetInputs ¶
func (t *TransferAction) GetInputs() []*token.ID
GetInputs returns inputs of the TransferAction
func (*TransferAction) GetMetadata ¶
func (t *TransferAction) GetMetadata() map[string][]byte
GetMetadata returns the transfer action's metadata
func (*TransferAction) GetOutputs ¶
func (t *TransferAction) GetOutputs() []driver.Output
GetOutputs returns the outputs in a TransferAction
func (*TransferAction) GetSerialNumbers ¶ added in v0.4.0
func (t *TransferAction) GetSerialNumbers() []string
func (*TransferAction) GetSerializedInputs ¶ added in v0.4.0
func (t *TransferAction) GetSerializedInputs() ([][]byte, error)
func (*TransferAction) GetSerializedOutputs ¶
func (t *TransferAction) GetSerializedOutputs() ([][]byte, error)
GetSerializedOutputs returns the serialization of the outputs in a TransferAction
func (*TransferAction) IsGraphHiding ¶
func (t *TransferAction) IsGraphHiding() bool
IsGraphHiding returns false, indicating that fabtoken does not hide the transaction graph
func (*TransferAction) IsRedeemAt ¶
func (t *TransferAction) IsRedeemAt(index int) bool
IsRedeemAt returns true if the output at the specified index is a redeemed output todo update interface to account for nil t.outputs[index]
func (*TransferAction) NumOutputs ¶
func (t *TransferAction) NumOutputs() int
NumOutputs returns the number of outputs in an TransferAction
func (*TransferAction) Serialize ¶
func (t *TransferAction) Serialize() ([]byte, error)
Serialize marshals TransferAction
func (*TransferAction) SerializeOutputAt ¶
func (t *TransferAction) SerializeOutputAt(index int) ([]byte, error)
SerializeOutputAt marshals the output at the specified index in TransferAction
type TransferService ¶ added in v0.4.0
type TransferService struct { Logger logging.Logger PublicParametersManager common.PublicParametersManager[*PublicParams] WalletService driver.WalletService TokenLoader TokenLoader Deserializer driver.Deserializer }
func NewTransferService ¶ added in v0.4.0
func NewTransferService( logger logging.Logger, publicParametersManager common.PublicParametersManager[*PublicParams], walletService driver.WalletService, tokenLoader TokenLoader, deserializer driver.Deserializer, ) *TransferService
func (*TransferService) DeserializeTransferAction ¶ added in v0.4.0
func (s *TransferService) DeserializeTransferAction(raw []byte) (driver.TransferAction, error)
DeserializeTransferAction un-marshals a TransferAction from the passed array of bytes. DeserializeTransferAction returns an error, if the un-marshalling fails.
func (*TransferService) Transfer ¶ added in v0.4.0
func (s *TransferService) Transfer(ctx context.Context, _ string, _ driver.OwnerWallet, tokenIDs []*token.ID, Outputs []*token.Token, opts *driver.TransferOptions) (driver.TransferAction, *driver.TransferMetadata, error)
Transfer returns a TransferAction as a function of the passed arguments It also returns the corresponding TransferMetadata
func (*TransferService) VerifyTransfer ¶ added in v0.4.0
func (s *TransferService) VerifyTransfer(tr driver.TransferAction, outputsMetadata [][]byte) error
VerifyTransfer checks the outputs in the TransferAction against the passed tokenInfos
type ValidateIssueFunc ¶ added in v0.4.0
type ValidateIssueFunc = common.ValidateIssueFunc[*PublicParams, *Output, *TransferAction, *IssueAction, driver.Deserializer]
type ValidateTransferFunc ¶
type ValidateTransferFunc = common.ValidateTransferFunc[*PublicParams, *Output, *TransferAction, *IssueAction, driver.Deserializer]
type Validator ¶
type Validator = common.Validator[*PublicParams, *Output, *TransferAction, *IssueAction, driver.Deserializer]
func NewValidator ¶
func NewValidator(logger logging.Logger, pp *PublicParams, deserializer driver.Deserializer, extraValidators ...ValidateTransferFunc) *Validator
type WalletFactory ¶ added in v0.4.0
type WalletFactory struct {
// contains filtered or unexported fields
}
func NewWalletFactory ¶ added in v0.4.0
func NewWalletFactory(logger logging.Logger, identityProvider driver.IdentityProvider, tokenVault TokenVault) *WalletFactory
func (*WalletFactory) NewWallet ¶ added in v0.4.0
func (w *WalletFactory) NewWallet(role driver.IdentityRole, walletRegistry common.WalletRegistry, info driver.IdentityInfo, id string) (driver.Wallet, error)