s11n

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 12 Imported by: 0

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"
	// SharedRandomLength is the length in bytes of a SharedRandomCommit.
	SharedRandomLength = 40
	// SharedRandomValueLength is the length in bytes of a SharedRandomValue.
	SharedRandomValueLength = 32
)

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 MultiSignDocument

func MultiSignDocument(signer cert.Signer, peerSignatures []*cert.Signature, verifiers map[string]cert.Verifier, d *Document) ([]byte, error)

MultiSignDocument signs and serializes the document with the provided signing key, adding the signature to the existing signatures.

func SignDescriptor

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

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

func SignDocument

func SignDocument(signer cert.Signer, d *Document) ([]byte, error)

SignDocument signs and serializes the document 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(b []byte, verifier cert.Verifier) (*pki.Document, error)

VerifyAndParseDocument verifies the signature and deserializes the document.

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

	SharedRandomCommit []byte
	SharedRandomValue  []byte
	PriorSharedRandom  [][]byte
}

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

func FromPayload

func FromPayload(verifier cert.Verifier, payload []byte) (*Document, error)

FromPayload deserializes, then verifies a Document, and returns the Document or error.

Jump to

Keyboard shortcuts

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