s11n

package
v0.0.0-...-9e52cca Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: GPL-3.0, Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package s11n implements serialization routines for the various PKI data structures.

Index

Constants

View Source
const (
	// DocumentVersion is the string identifying the format of the Document
	DocumentVersion = "document-v0"
)

Variables

View Source
var (
	// CertificateExpiration is the time a descriptor certificate will be valid for.
	CertificateExpiration = (epochtime.Period * 3) + (time.Minute * 10)
)
View Source
var (
	// ErrInvalidEpoch is the error to return when the document epoch is
	// invalid.
	ErrInvalidEpoch = errors.New("invalid document epoch")
)

Functions

func GetVerifierFromDescriptor

func GetVerifierFromDescriptor(rawDesc []byte) (cert.Verifier, error)

GetVerifierFromDescriptor returns a verifier for the given mix descriptor certificate.

func IsDescriptorWellFormed

func IsDescriptorWellFormed(d *pki.MixDescriptor, epoch uint64) error

IsDescriptorWellFormed validates the descriptor and returns a descriptive error iff there are any problems that would make it unusable as part of a PKI Document.

func IsDocumentWellFormed

func IsDocumentWellFormed(d *pki.Document) error

IsDocumentWellFormed validates the document and returns a descriptive error iff there are any problems that invalidates the document.

func ParseDescriptorWithoutVerify

func ParseDescriptorWithoutVerify(b []byte) (*pki.MixDescriptor, error)

func SerializeDocument

func SerializeDocument(d *Document) ([]byte, error)

func SignDescriptor

func SignDescriptor(signer cert.Signer, base *pki.MixDescriptor) ([]byte, error)

SignDescriptor signs and serializes the descriptor with the provided signing key.

func VerifyAndParseDescriptor

func VerifyAndParseDescriptor(verifier cert.Verifier, b []byte, epoch uint64) (*pki.MixDescriptor, error)

VerifyAndParseDescriptor verifies the signature and deserializes the descriptor. MixDescriptors returned from this routine are guaranteed to have been correctly self signed by the IdentityKey listed in the MixDescriptor.

func VerifyAndParseDocument

func VerifyAndParseDocument(payload []byte) (*pki.Document, error)

Types

type Document

type Document struct {
	// Version uniquely identifies the document format as being for the
	// specified version so that it can be rejected if the format changes.
	Version           string
	Epoch             uint64
	GenesisEpoch      uint64
	SendRatePerMinute uint64

	Mu              float64
	MuMaxDelay      uint64
	LambdaP         float64
	LambdaPMaxDelay uint64
	LambdaL         float64
	LambdaLMaxDelay uint64
	LambdaD         float64
	LambdaDMaxDelay uint64
	LambdaM         float64
	LambdaMMaxDelay uint64

	Topology  [][][]byte
	Providers [][]byte
}

Document is the on-the-wire representation of a PKI Document.

Jump to

Keyboard shortcuts

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