s11n

package
v0.0.0-...-c15aa5a Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: GPL-3.0, Apache-2.0 Imports: 9 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.
	// 600 epoch by default
	CertificateExpiration uint64 = 600
)
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 ParseDescriptor

func ParseDescriptor(b []byte, epochNow uint64) (*pki.MixDescriptor, error)

func SerializeDocument

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

func SignDescriptor

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

SignDescriptor signs and serializes the descriptor with the provided signing key. TODO: figure out a way to calculate epoch without initialize a http client then we can remove expiration from function

func VerifyAndParseDescriptor

func VerifyAndParseDescriptor(verifier cert.Verifier, b []byte, epoch uint64, epochNow 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, epochNow uint64) (*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