Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidatePayloadType ¶
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 (*DAG) Add ¶
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 ¶
MissingDocuments returns the hashes of the documents we know we are missing and should still be resolved.
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 ¶
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.