protocol

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 3 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Current returns latest version of protocol.
	Current() (Version, error)

	// Get returns the version at the given transaction time.
	Get(transactionTime uint64) (Version, error)
}

Client defines interface for accessing protocol version/information.

type ClientProvider

type ClientProvider interface {
	ForNamespace(namespace string) (Client, error)
}

ClientProvider returns a protocol client for the given namespace.

type DocumentComposer

type DocumentComposer interface {
	ApplyPatches(doc document.Document, patches []patch.Patch) (document.Document, error)
}

DocumentComposer applies patches to the given document.

type DocumentTransformer

type DocumentTransformer interface {
	TransformDocument(rm *ResolutionModel, info TransformationInfo) (*document.ResolutionResult, error)
}

DocumentTransformer transforms internal resolution model into external document(resolution result).

type DocumentValidator

type DocumentValidator interface {
	IsValidOriginalDocument(payload []byte) error
	IsValidPayload(payload []byte) error
}

DocumentValidator is an interface for validating document operations.

type OperationApplier

type OperationApplier interface {
	Apply(op *operation.AnchoredOperation, rm *ResolutionModel) (*ResolutionModel, error)
}

OperationApplier applies the given operation to the document.

type OperationParser

type OperationParser interface {
	Parse(namespace string, operation []byte) (*operation.Operation, error)
	ParseDID(namespace, shortOrLongFormDID string) (string, []byte, error)
	GetRevealValue(operation []byte) (string, error)
	GetCommitment(operation []byte) (string, error)
}

OperationParser defines the functions for parsing operations.

type Protocol

type Protocol struct {
	// GenesisTime is inclusive starting logical anchoring time that this protocol applies to.
	// (e.g. block number in a blockchain)
	GenesisTime uint64 `json:"genesisTime"`

	// MultihashAlgorithms are supported multihash algorithm codes
	MultihashAlgorithms []uint `json:"multihashAlgorithms"`

	// MaxOperationCount defines maximum number of operations per batch.
	MaxOperationCount uint `json:"maxOperationCount"`

	// MaxOperationSize is maximum operation size in bytes (used to reject operations before parsing them)
	// It has to be greater than max delta size (big) + max proof size (medium) + other small values (operation type, suffix-data)
	MaxOperationSize uint `json:"maxOperationSize"`

	// MaxOperationHashLength is maximum operation hash length
	MaxOperationHashLength uint `json:"maxOperationHashLength"`

	// MaxDeltaSize is maximum size of operation's delta property.
	MaxDeltaSize uint `json:"maxDeltaSize"`

	// MaxCasUriLength is maximum length of CAS URI in batch files.
	MaxCasURILength uint `json:"maxCasUriLength"`

	// CompressionAlgorithm is file compression algorithm.
	CompressionAlgorithm string `json:"compressionAlgorithm"`

	// MaxCoreIndexFileSize is maximum allowed size (in bytes) of core index file stored in CAS.
	MaxCoreIndexFileSize uint `json:"maxCoreIndexFileSize"`

	// MaxProofFileSize is maximum allowed size (in bytes) of proof files stored in CAS.
	MaxProofFileSize uint `json:"maxProofFileSize"`

	// MaxProvisionalIndexFileSize is maximum allowed size (in bytes) of provisional index file stored in CAS.
	MaxProvisionalIndexFileSize uint `json:"maxProvisionalIndexFileSize"`

	// MaxChunkFileSize is maximum allowed size (in bytes) of chunk file stored in CAS.
	MaxChunkFileSize uint `json:"maxChunkFileSize"`

	// Patches contains the list of allowed patches.
	Patches []string `json:"patches"`

	// SignatureAlgorithms contain supported signature algorithms for signed operations (e.g. EdDSA, ES256, ES384, ES512, ES256K).
	SignatureAlgorithms []string `json:"signatureAlgorithms"`

	// KeyAlgorithms contain supported key algorithms for signed operations (e.g. secp256k1, P-256, P-384, P-512, Ed25519).
	KeyAlgorithms []string `json:"keyAlgorithms"`

	// MaxOperationTimeDelta is maximum time that operation should be valid before it expires; used with anchor from time
	MaxOperationTimeDelta uint64 `json:"maxOperationTimeDelta"`

	// NonceSize is the number of bytes in nonce values
	NonceSize uint64 `json:"nonceSize"`

	// MaxMemoryDecompressionFactor is maximum file size after decompression (e.g. 3 times maximum file size)
	MaxMemoryDecompressionFactor uint `json:"maxMemoryDecompressionFactor"`
}

Protocol defines protocol parameters.

type ResolutionModel

type ResolutionModel struct {
	Doc                            document.Document
	CreatedTime                    uint64
	UpdatedTime                    uint64
	LastOperationTransactionTime   uint64
	LastOperationTransactionNumber uint64
	LastOperationProtocolVersion   uint64
	UpdateCommitment               string
	RecoveryCommitment             string
	Deactivated                    bool
	AnchorOrigin                   interface{}
	EquivalentReferences           []string
	CanonicalReference             string
	VersionID                      string
	PublishedOperations            []*operation.AnchoredOperation
	UnpublishedOperations          []*operation.AnchoredOperation
}

ResolutionModel contains temporary data during document resolution.

type TransformationInfo

type TransformationInfo map[string]interface{}

TransformationInfo contains document transformation info.

type Version

type Version interface {
	Version() string
	Protocol() Protocol
	OperationParser() OperationParser
	OperationApplier() OperationApplier
	DocumentTransformer() DocumentTransformer
	DocumentValidator() DocumentValidator
}

Version contains the protocol and corresponding implementations that are compatible with the protocol version.

Jump to

Keyboard shortcuts

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