Documentation
¶
Index ¶
- Constants
- Variables
- func IsDescriptorWellFormed(d *MixDescriptor, epoch uint64) error
- func IsDocumentWellFormed(d *Document, verifiers []sign.PublicKey) error
- func IsReplicaDescriptorWellFormed(d *ReplicaDescriptor, epoch uint64) error
- func MultiSignDocument(signer sign.PrivateKey, verifier sign.PublicKey, ...) ([]byte, error)
- func SignDocument(signer sign.PrivateKey, verifier sign.PublicKey, d *Document) ([]byte, error)
- type Client
- type Document
- func (d *Document) AddSignature(verifier sign.PublicKey, signature cert.Signature) error
- func (d *Document) GetGateway(name string) (*MixDescriptor, error)
- func (d *Document) GetGatewayByKeyHash(keyhash *[32]byte) (*MixDescriptor, error)
- func (d *Document) GetMix(name string) (*MixDescriptor, error)
- func (d *Document) GetMixByKeyHash(keyhash *[32]byte) (*MixDescriptor, error)
- func (d *Document) GetMixLayer(keyhash *[32]byte) (uint8, error)
- func (d *Document) GetMixesInLayer(layer uint8) ([]*MixDescriptor, error)
- func (d *Document) GetNode(name string) (*MixDescriptor, error)
- func (d *Document) GetNodeByKeyHash(keyhash *[32]byte) (*MixDescriptor, error)
- func (d *Document) GetReplicaNodeByKeyHash(keyhash *[32]byte) (*ReplicaDescriptor, error)
- func (d *Document) GetServiceNode(name string) (*MixDescriptor, error)
- func (d *Document) GetServiceNodeByKeyHash(keyhash *[32]byte) (*MixDescriptor, error)
- func (d *Document) MarshalCertificate() ([]byte, error)
- func (d *Document) String() string
- func (d *Document) Sum256() [32]byte
- func (d *Document) UnmarshalCertificate(data []byte) error
- type MixDescriptor
- func (d *MixDescriptor) MarshalBinary() ([]byte, error)
- func (d *MixDescriptor) String() string
- func (d *MixDescriptor) UnmarshalBinary(data []byte) error
- func (d *MixDescriptor) UnmarshalMixKeyAsKEM(epoch uint64, g *geo.Geometry) (kem.PublicKey, error)
- func (d *MixDescriptor) UnmarshalMixKeyAsNike(epoch uint64, g *geo.Geometry) (nike.PublicKey, error)
- type ReplicaDescriptor
- type SharedRandom
- type SignedReplicaUpload
- type SignedUpload
Constants ¶
const ( // LayerGateway is the Layer that gateways list in their MixDescriptors. LayerGateway = 255 // LayerService is the Layer that service nodes list in their MixDescriptors. LayerService = 254 PublicKeyHashSize = 32 // DocumentVersion identifies the document format version DocumentVersion = "v0" )
const (
DescriptorVersion = "v0"
)
Variables ¶
var ( ErrNoSignature = errors.New("MixDescriptor has no signature") ErrInvalidSignature = errors.New("MixDescriptor has an invalid signature") ErrTooManySignatures = errors.New("MixDescriptor has more than one signature") )
var ( // ErrDocumentGone is the error returned when there never will be a document // for a given epoch. ErrDocumentGone = errors.New("pki: requested epoch will never get a document") // ErrNoDocument is the error returned when there was no consensus found ErrNoDocument = errors.New("pki: requested epoch has no document") // ErrInvalidPostEpoch is the error returned when the server rejects a // descriptor upload for a given epoch due to time reasons. ErrInvalidPostEpoch = errors.New("pki: post for epoch will never succeeed") // ErrInvalidEpoch is the error to return when the document epoch is invalid. ErrInvalidEpoch = errors.New("invalid document epoch") // ErrDocumentNotSigned is the error returned when deserializing an unsigned // document ErrDocumentNotSigned = errors.New("document not signed") // TrustOnFirstUseAuth is a MixDescriptor.AuthenticationType TrustOnFirstUseAuth = "tofu" // OutOfBandAuth is a MixDescriptor.AuthenticationType OutOfBandAuth = "oob" )
var ( // TransportInvalid is the invalid transport. TransportInvalid string // TransportTCP is TCP, with the IP version determined by the results of // a name server lookup. TransportTCP string = "tcp" // TransportWS is Websocket TransportWS string = "ws" // TransportTCPv4 is TCP over IPv4. TransportTCPv4 string = "tcp4" // TransportTCPv6 is TCP over IPv6. TransportTCPv6 string = "tcp6" // TransportQUIC is QUIC, with the IP version determined by the results // of a name server lookup TransportQUIC string = "quic" // TransportOnion is a tor hidden service, to be announced in PKI TransportOnion string = "onion" // InternalTransports is the list of transports used for non-client related // communications. InternalTransports = []string{TransportTCPv4, TransportTCPv6, TransportQUIC} // ClientTransports is the list of transports used by default for client // to provider communication. ClientTransports = []string{TransportTCP, TransportTCPv4, TransportTCPv6, TransportQUIC, TransportWS, TransportOnion} )
Functions ¶
func IsDescriptorWellFormed ¶
func IsDescriptorWellFormed(d *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 ¶
IsDocumentWellFormed validates the document and returns a descriptive error iff there are any problems that invalidates the document.
func IsReplicaDescriptorWellFormed ¶ added in v0.0.44
func IsReplicaDescriptorWellFormed(d *ReplicaDescriptor, epoch uint64) error
IsReplicaDescriptorWellFormed 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 MultiSignDocument ¶
func MultiSignDocument(signer sign.PrivateKey, verifier sign.PublicKey, peerSignatures []*cert.Signature, verifiers map[[32]byte]sign.PublicKey, d *Document) ([]byte, error)
MultiSignDocument signs and serializes the document with the provided signing key, adding the signature to the existing signatures.
func SignDocument ¶
SignDocument signs and serializes the document with the provided signing key.
Types ¶
type Client ¶
type Client interface { // Get returns the PKI document along with the raw serialized form for the provided epoch. Get(ctx context.Context, epoch uint64) (*Document, []byte, error) // Post posts the node's descriptor to the PKI for the provided epoch. Post(ctx context.Context, epoch uint64, signingPrivateKey sign.PrivateKey, signingPublicKey sign.PublicKey, d *MixDescriptor, loopstats *loops.LoopStats) error // PostReplica posts the pigeonhole storage replica node's descriptor to the PKI for the provided epoch. PostReplica(ctx context.Context, epoch uint64, signingPrivateKey sign.PrivateKey, signingPublicKey sign.PublicKey, d *ReplicaDescriptor) error // Deserialize returns PKI document given the raw bytes. Deserialize(raw []byte) (*Document, error) }
Client is the abstract interface used for PKI interaction.
type Document ¶
type Document struct { // Epoch is the epoch for which this Document instance is valid for. Epoch uint64 // GenesisEpoch is the epoch on which authorities started consensus GenesisEpoch uint64 // SendRatePerMinute is the number of packets per minute a client can send. SendRatePerMinute uint64 // Mu is the inverse of the mean of the exponential distribution // that the Sphinx packet per-hop mixing delay will be sampled from. Mu float64 // MuMaxDelay is the maximum Sphinx packet per-hop mixing delay in // milliseconds. MuMaxDelay uint64 // LambdaP is the inverse of the mean of the exponential distribution // that clients will sample to determine the time interval between sending // messages from it's FIFO egress queue or drop decoy messages if the queue // is empty. LambdaP float64 // LambdaPMaxDelay is the maximum time interval in milliseconds. LambdaPMaxDelay uint64 // LambdaL is the inverse of the mean of the exponential distribution // that clients will sample to determine the time interval between sending // decoy loop messages. LambdaL float64 // LambdaLMaxDelay is the maximum time interval in milliseconds. LambdaLMaxDelay uint64 // LambdaD is the inverse of the mean of the exponential distribution // that clients will sample to determine the time interval between sending // decoy drop messages. LambdaD float64 // LambdaDMaxDelay is the maximum time interval in milliseconds. LambdaDMaxDelay uint64 // LambdaM is the inverse of the mean of the exponential distribution // that mixes will sample to determine send timing of mix loop decoy traffic. LambdaM float64 // LambdaMMaxDelay is the maximum send interval in milliseconds. LambdaMMaxDelay uint64 // LambdaG is the inverse of the mean of the exponential distribution // that mixes will sample to determine send timing of gateway node loop decoy traffic. LambdaG float64 // LambdaMMaxDelay is the maximum send interval in milliseconds. LambdaGMaxDelay uint64 // Topology is the mix network topology, excluding providers. Topology [][]*MixDescriptor // GatewayNodes is the list of nodes that can allow clients to interact // with the mix network. GatewayNodes []*MixDescriptor // ServiceNodes is the list of nodes that can allow services to interact // with tehe mix network. ServiceNodes []*MixDescriptor // StorageReplicas is the list of Storage Replica nodes that do not talk over the mixnet // but are expected to handle connections from the Service Nodes and the other replicas. StorageReplicas []*ReplicaDescriptor // Signatures holds detached Signatures from deserializing a signed Document Signatures map[[PublicKeyHashSize]byte]cert.Signature `cbor:"-"` SharedRandomCommit map[[PublicKeyHashSize]byte][]byte SharedRandomReveal map[[PublicKeyHashSize]byte][]byte SharedRandomValue []byte PriorSharedRandom [][]byte // SphinxGeometryHash is used to ensure all mixnet actors have the same // Sphinx Geometry. SphinxGeometryHash []byte // Version uniquely identifies the document format as being for the // specified version so that it can be rejected if the format changes. Version string // PKISignatureScheme specifies the cryptographic signature scheme PKISignatureScheme string }
Document is a PKI document.
func FromPayload ¶
FromPayload deserializes, then verifies a Document, and returns the Document or error.
func ParseDocument ¶
ParseDocument deserializes the document.
func (*Document) AddSignature ¶
AddSignature will add a Signature over this Document if it is signed by verifier.
func (*Document) GetGateway ¶ added in v0.0.33
func (d *Document) GetGateway(name string) (*MixDescriptor, error)
GetGateway returns the MixDescriptor for the given gateway Name.
func (*Document) GetGatewayByKeyHash ¶ added in v0.0.33
func (d *Document) GetGatewayByKeyHash(keyhash *[32]byte) (*MixDescriptor, error)
GetGatewayByKeyHash returns the specific gateway descriptor corresponding to the specified IdentityKey hash.
func (*Document) GetMix ¶
func (d *Document) GetMix(name string) (*MixDescriptor, error)
GetMix returns the MixDescriptor for the given mix Name.
func (*Document) GetMixByKeyHash ¶
func (d *Document) GetMixByKeyHash(keyhash *[32]byte) (*MixDescriptor, error)
GetMixByKey returns the specific mix descriptor corresponding to the specified IdentityKey hash.
func (*Document) GetMixLayer ¶
GetMixLayer returns the assigned layer for the given mix from Topology
func (*Document) GetMixesInLayer ¶
func (d *Document) GetMixesInLayer(layer uint8) ([]*MixDescriptor, error)
GetMixesInLayer returns all the mix descriptors for a given layer.
func (*Document) GetNode ¶
func (d *Document) GetNode(name string) (*MixDescriptor, error)
GetNode returns the specific descriptor corresponding to the specified node Name.
func (*Document) GetNodeByKeyHash ¶
func (d *Document) GetNodeByKeyHash(keyhash *[32]byte) (*MixDescriptor, error)
GetNodeByKeyHash returns the specific descriptor corresponding to the specified IdentityKey hash.
func (*Document) GetReplicaNodeByKeyHash ¶ added in v0.0.44
func (d *Document) GetReplicaNodeByKeyHash(keyhash *[32]byte) (*ReplicaDescriptor, error)
func (*Document) GetServiceNode ¶ added in v0.0.33
func (d *Document) GetServiceNode(name string) (*MixDescriptor, error)
GetService returns the MixDescriptor for the given service Name.
func (*Document) GetServiceNodeByKeyHash ¶ added in v0.0.33
func (d *Document) GetServiceNodeByKeyHash(keyhash *[32]byte) (*MixDescriptor, error)
GetServiceByKeyHash returns the specific service descriptor corresponding to the specified IdentityKey hash.
func (*Document) MarshalCertificate ¶ added in v0.0.41
MarshalBinary implements encoding.BinaryMarshaler interface and wraps a Document with a cert.Certificate
func (*Document) UnmarshalCertificate ¶ added in v0.0.41
UnmarshalBinary implements encoding.BinaryUnmarshaler interface and populates Document with detached Signatures
type MixDescriptor ¶
type MixDescriptor struct { // Name is the human readable (descriptive) node identifier. Name string // Epoch is the Epoch in which this descriptor was created Epoch uint64 // IdentityKey is the node's identity (signing) key. IdentityKey []byte // LinkKey is the node's wire protocol public key. LinkKey []byte // MixKeys is a map of epochs to Sphinx keys. MixKeys map[uint64][]byte // Addresses is the map of transport to address combinations that can // be used to reach the node. Addresses map[string][]string // Kaetzchen is the map of provider autoresponder agents by capability // to parameters. Kaetzchen map[string]map[string]interface{} `cbor:"omitempty"` // IsGatewayNode indicates that this Mix is a gateway node. // Essentially a gateway allows clients to interact with the mixnet. // This option being set to true is mutually exclusive with // `IsServiceNode` being set to true. IsGatewayNode bool // IsServiceNode indicates that this Mix is a service node. // Service nodes run services which the mixnet interacts with. IsServiceNode bool // LoadWeight is the node's load balancing weight (unused). LoadWeight uint8 // AuthenticationType is the authentication mechanism required AuthenticationType string // Version uniquely identifies the descriptor format as being for the // specified version so that it can be rejected if the format changes. Version string }
MixDescriptor is a description of a given Mix or Provider (node).
func (*MixDescriptor) MarshalBinary ¶
func (d *MixDescriptor) MarshalBinary() ([]byte, error)
MarshalBinary implmements encoding.BinaryMarshaler
func (*MixDescriptor) String ¶
func (d *MixDescriptor) String() string
String returns a human readable MixDescriptor suitable for terse logging.
func (*MixDescriptor) UnmarshalBinary ¶
func (d *MixDescriptor) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler interface
func (*MixDescriptor) UnmarshalMixKeyAsKEM ¶
func (*MixDescriptor) UnmarshalMixKeyAsNike ¶
type ReplicaDescriptor ¶ added in v0.0.44
type ReplicaDescriptor struct { // Name is the unique name of the pigeonhole storage replica. Name string // Epoch is the Epoch in which this descriptor was created Epoch uint64 // IdentityKey is the node's identity (signing) key. IdentityKey []byte // LinkKey is our PQ Noise Public Key. LinkKey []byte // EnvelopeKeys is mapping from Replica Epoch ID to Public NIKE Key used with our MKEM scheme. EnvelopeKeys map[uint64][]byte // Addresses is the map of transport to address combinations that can // be used to reach the node. Addresses map[string][]string }
ReplicaDescriptor describe pigeonhole storage replica nodes.
func (*ReplicaDescriptor) Marshal ¶ added in v0.0.44
func (d *ReplicaDescriptor) Marshal() ([]byte, error)
MarshalBinary implmements encoding.BinaryMarshaler
func (*ReplicaDescriptor) Unmarshal ¶ added in v0.0.44
func (d *ReplicaDescriptor) Unmarshal(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler interface
type SharedRandom ¶
type SharedRandom struct {
// contains filtered or unexported fields
}
SharedRandom is a container for commit-and-reveal protocol messages
func (*SharedRandom) Commit ¶
func (s *SharedRandom) Commit(epoch uint64) ([]byte, error)
Commit produces a SharedRandom commit value for the given epoch
func (*SharedRandom) GetCommit ¶
func (s *SharedRandom) GetCommit() []byte
GetCommit returns the commit value
func (*SharedRandom) GetEpoch ¶
func (s *SharedRandom) GetEpoch() uint64
GetEpoch returns the epoch value
func (*SharedRandom) Reveal ¶
func (s *SharedRandom) Reveal() []byte
Reveal returns the reveal value
func (*SharedRandom) SetCommit ¶
func (s *SharedRandom) SetCommit(rawCommit []byte)
SetCommit sets the commit value
func (*SharedRandom) Verify ¶
func (s *SharedRandom) Verify(reveal []byte) bool
Verify checks that the reveal value verifies the commit value
type SignedReplicaUpload ¶ added in v0.0.44
type SignedReplicaUpload struct { // Signature is the signature over the serialized SignedReplicaUpload. Signature *cert.Signature // ReplicaDescriptor is the replica descriptor. ReplicaDescriptor *ReplicaDescriptor }
func (*SignedReplicaUpload) Marshal ¶ added in v0.0.44
func (s *SignedReplicaUpload) Marshal() ([]byte, error)
func (*SignedReplicaUpload) Sign ¶ added in v0.0.44
func (s *SignedReplicaUpload) Sign(privKey sign.PrivateKey, pubKey sign.PublicKey) error
func (*SignedReplicaUpload) Unmarshal ¶ added in v0.0.44
func (s *SignedReplicaUpload) Unmarshal(data []byte) error
type SignedUpload ¶ added in v0.0.32
type SignedUpload struct { // Signature is the signature over the serialized SignedUpload. Signature *cert.Signature // MixDescriptor is the mix descriptor. MixDescriptor *MixDescriptor // LoopStats is the mix loop statistics. LoopStats *loops.LoopStats }
func (*SignedUpload) Marshal ¶ added in v0.0.32
func (s *SignedUpload) Marshal() ([]byte, error)
func (*SignedUpload) Sign ¶ added in v0.0.32
func (s *SignedUpload) Sign(privKey sign.PrivateKey, pubKey sign.PublicKey) error
func (*SignedUpload) Unmarshal ¶ added in v0.0.32
func (s *SignedUpload) Unmarshal(data []byte) error