distdoc

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePayloadType

func ValidatePayloadType(payloadType string) bool

Types

type DAG

type DAG struct {
	// contains filtered or unexported fields
}

DAG is a directed acyclic graph consisting of nodes (documents) referring to preceding nodes.

func NewDAG

func NewDAG() *DAG

func (*DAG) Add

func (c *DAG) Add(documents ...Document) error

Add adds one or more documents to the DAG. If it can't be added an error is returned. Nil entries are ignored.

func (DAG) MissingDocuments

func (c DAG) MissingDocuments() []model.Hash

MissingDocuments returns the hashes of the documents we know we are missing and should still be resolved.

func (DAG) Walk

func (c DAG) Walk(visitor Visitor)

Walk visits every node of the DAG, starting at the root node and working down each level until every leaf is visited.

type Document

type Document interface {
	UnsignedDocument
	// SigningCertificate returns the certificate that was used for signing this document.
	SigningCertificate() *x509.Certificate
	// SigningTime returns the time that the document was signed.
	SigningTime() time.Time
	// Ref returns the reference to this document.
	Ref() model.Hash
	// Data returns the byte representation of this document which can be used for transport.
	Data() []byte
	// VerifySignature verifies that the signature are signing certificate are correct. If an error occurs or verification
	// fails an error is returned.
	VerifySignature(trustStore *x509.CertPool) error
}

Document defines a signed distributed document as described by RFC004 - Distributed Document Format.

func ParseDocument

func ParseDocument(input []byte) (Document, error)

type PayloadHash

type PayloadHash model.Hash

PayloadHash is a Hash of the payload of a Document

type UnsignedDocument

type UnsignedDocument interface {
	// PayloadType returns the MIME-formatted type of the payload. It must contain the context and specific type of the
	// payload, e.g. 'registry/endpoint'.
	PayloadType() string
	// Payload returns the hash of the payload of the document.
	Payload() PayloadHash
	// Previous returns the references of the previous documents this document points to.
	Previous() []model.Hash
	// Version returns the version number of the distributed document format.
	Version() Version
	// TimelineID returns the timeline ID of the document.
	TimelineID() model.Hash
	// TimelineVersion returns the timeline version of the document. If the returned version is < 1 the timeline version
	// is not set.
	TimelineVersion() int
	// Sign signs the document using the given key and certificate. The certificate must correspond with the given
	// signing key and must be meant (key usage) for signing. The moment parameter is included in the signature
	// as time of signing.
	Sign(key crypto.Signer, certificate *x509.Certificate, moment time.Time) (Document, error)
}

UnsignedDocument holds the base properties of a document which can be signed to create a Document.

func NewDocument

func NewDocument(payload PayloadHash, payloadType string, prevs []model.Hash) (UnsignedDocument, error)

NewDocument creates a new unsigned document. Parameters payload and payloadType can't be empty, but prevs is optional. Prevs must not contain empty or invalid hashes.

type Version

type Version int

Version defines a type for distributed document format version.

type Visitor

type Visitor func(document Document)

Visitor defines the contract for a function that visits the DAG.

Jump to

Keyboard shortcuts

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