Documentation
¶
Overview ¶
Wire protocol commands.
Wire protocol commands.
Index ¶
- Constants
- func DescriptorErrorToString(code uint8) string
- func HybridKeySize(scheme nike.Scheme) int
- type Cert
- type CertStatus
- type Command
- type Commands
- type Consensus
- type Consensus2
- type Disconnect
- type GetConsensus
- type GetConsensus2
- type GetVote
- type Message
- type MessageACK
- type MessageEmpty
- type NoOp
- type PostDescriptor
- type PostDescriptorStatus
- type PostReplicaDescriptor
- type PostReplicaDescriptorStatus
- type ReplicaDecoy
- type ReplicaMessage
- type ReplicaMessageReply
- type ReplicaWrite
- type ReplicaWriteReply
- type RetrieveMessage
- type Reveal
- type RevealStatus
- type SendPacket
- type SendRetrievePacket
- type SendRetrievePacketReply
- type Sig
- type SigStatus
- type Vote
- type VoteStatus
Constants ¶
const ( // CmdOverhead is the wire protocol overhead for commands (command ID + reserved byte + 4-byte length field). CmdOverhead = 1 + 1 + 4 // ConsensusOk signifies that the GetConsensus request has completed // successfully. ConsensusOk = 0 // ConsensusNotFound signifies that the document document corresponding // to the epoch in the GetConsensus was not found, but retrying later // may be successful. ConsensusNotFound = 1 // ConsensusGone signifies that the document corresponding to the epoch // in the GetConsensus was not found, and that retrying later will // not be successful. ConsensusGone = 2 // DescriptorOk signifies that the PostDescriptor request has completed // succcessfully. DescriptorOk = 0 // DescriptorInvalid signifies that the PostDescriptor request has failed // due to an unspecified error. DescriptorInvalid = 1 // DescriptorConflict signifies that the PostDescriptor request has // failed due to the uploaded descriptor conflicting with a previously // uploaded descriptor. DescriptorConflict = 2 // DescriptorForbidden signifies that the PostDescriptor request has // failed due to an authentication error. DescriptorForbidden = 3 // VoteOk signifies that the vote was accepted by the peer. VoteOk = 0 // VoteTooLate signifies that the vote was too late. VoteTooLate = 1 // VoteTooEarly signifies that the vote was too late. VoteTooEarly = 2 // VoteNotAuthorized signifies that the voting entity's key is not authorized. VoteNotAuthorized = 3 // VoteNotSigned signifies that the vote payload failed signature verification. VoteNotSigned = 4 // VoteMalformed signifies that the vote payload was invalid. VoteMalformed = 5 // VoteAlreadyReceived signifies that the vote from that peer was already received. VoteAlreadyReceived = 6 // VoteNotFound signifies that the vote was not found. VoteNotFound = 7 // RevealOk signifies that the reveal was accepted by the peer. RevealOk = 8 // RevealTooEarly signifies that the peer is breaking protocol. RevealTooEarly = 9 // RevealNotAuthorized signifies that the revealing entity's key is not authorized. RevealNotAuthorized = 10 // RevealNotSigned signifies that the reveal payload failed signature verification. RevealNotSigned = 11 // RevealAlreadyReceived signifies that the reveal from that peer was already received. RevealAlreadyReceived = 12 // RevealTooLate signifies that the reveal from that peer arrived too late. RevealTooLate = 13 // CertOk signifies that the certificate was accepted by the peer. CertOk = 14 // CertTooEarly signifies that the peer is breaking protocol. CertTooEarly = 15 // CertNotAuthorized signifies that the certifying entity's key is not CertNotAuthorized = 16 // CertNotSigned signifies that the certficiate payload failed signature verification. CertNotSigned = 17 // CertAlreadyReceived signifies that the certificate from that peer was already received. CertAlreadyReceived = 18 // CertTooLate signifies that the certificate from that peer arrived too late. CertTooLate = 19 // SigOK signifies that the signature was accepted by the peer. SigOk = 20 // SigNotAuthorized signifies that the entity's key is not authorized. SigNotAuthorized = 21 // SigNotSigned signifies that the signature command failed signature verification. SigNotSigned = 22 // SigTooEarly signifies that the peer is breaking protocol. SigTooEarly = 23 // SigTooLate signifies that the signature from that peer arrived too late. SigTooLate = 24 // SigAlreadyReceived signifies that the signature from that peer was already received. SigAlreadyReceived = 25 // SigInvalid signifies that the signature failed to deserialiez. SigInvalid = 26 )
Variables ¶
This section is empty.
Functions ¶
func DescriptorErrorToString ¶ added in v0.0.67
DescriptorErrorToString returns a human-readable string for descriptor error codes.
func HybridKeySize ¶ added in v0.0.44
HybridKeySize is a helper function which is used in our geometry calculations below.
Types ¶
type CertStatus ¶
type CertStatus struct {
ErrorCode uint8
}
CertStatus is a resonse status for a Cert command.
func (*CertStatus) Length ¶ added in v0.0.44
func (c *CertStatus) Length() int
func (*CertStatus) String ¶ added in v0.0.71
func (c *CertStatus) String() string
func (*CertStatus) ToBytes ¶
func (c *CertStatus) ToBytes() []byte
ToBytes serializes the CertStatus and returns the resulting slice.
type Command ¶
type Command interface {
// ToBytes serializes the command and returns the resulting slice.
ToBytes() []byte
// Length returns the length in bytes of the given command.
Length() int
}
Command is the common interface exposed by all message command structures.
type Commands ¶
type Commands struct {
MaxMessageLenServerToClient int
MaxMessageLenClientToServer int
// contains filtered or unexported fields
}
Commands encapsulates all of the wire protocol commands so that it can pass around a sphinx geometry where needed.
func NewMixnetCommands ¶ added in v0.0.44
NewMixnetCommands creates a Commands instance suitale to be used by mixnet nodes.
func NewPKICommands ¶
NewPKICommands creates a Commands instance suitale to be used by PKI nodes.
func NewStorageReplicaCommands ¶ added in v0.0.44
NewStorageReplicaCommands creates a Commands instance suitale to be used by storage replica nodes and couriers. This ensures all messages are padded to the same size.
func (*Commands) FromBytes ¶
FromBytes de-serializes the command in the buffer b, returning a Command or an error.
func (*Commands) MaxCommandSize ¶ added in v0.0.44
type Consensus2 ¶ added in v0.0.46
type Consensus2 struct {
Cmds *Commands
ErrorCode uint8
ChunkNum uint32
ChunkTotal uint32
Payload []byte
}
Consensus2 is used to send a PKI document in compressed binary chunks.
func (*Consensus2) Length ¶ added in v0.0.46
func (c *Consensus2) Length() int
func (*Consensus2) String ¶ added in v0.0.71
func (c *Consensus2) String() string
func (*Consensus2) ToBytes ¶ added in v0.0.46
func (c *Consensus2) ToBytes() []byte
ToBytes serializes the Consensus and returns the resulting byte slice.
type Disconnect ¶
type Disconnect struct {
Cmds *Commands
}
Disconnect is a de-serialized disconnect command.
func (*Disconnect) Length ¶ added in v0.0.44
func (c *Disconnect) Length() int
func (*Disconnect) String ¶ added in v0.0.71
func (c *Disconnect) String() string
func (*Disconnect) ToBytes ¶
func (c *Disconnect) ToBytes() []byte
ToBytes serializes the Disconnect and returns the resulting slice.
type GetConsensus ¶
type GetConsensus struct {
Epoch uint64
Cmds *Commands
MixnetTransmission bool // if GetConsensus is sent over the mixnet, if true we need to pad the message
}
GetConsensus is a de-serialized get_consensus command.
func (*GetConsensus) Length ¶ added in v0.0.44
func (c *GetConsensus) Length() int
func (*GetConsensus) String ¶ added in v0.0.71
func (c *GetConsensus) String() string
func (*GetConsensus) ToBytes ¶
func (c *GetConsensus) ToBytes() []byte
ToBytes serializes the GetConsensus and returns the resulting byte slice.
type GetConsensus2 ¶ added in v0.0.46
func (*GetConsensus2) Length ¶ added in v0.0.46
func (c *GetConsensus2) Length() int
func (*GetConsensus2) String ¶ added in v0.0.71
func (c *GetConsensus2) String() string
func (*GetConsensus2) ToBytes ¶ added in v0.0.46
func (c *GetConsensus2) ToBytes() []byte
ToBytes serializes the GetConsensus and returns the resulting byte slice.
type Message ¶
type Message struct {
Geo *geo.Geometry
Cmds *Commands
QueueSizeHint uint8
Sequence uint32
Payload []byte
}
Message is a de-serialized message command containing a message.
type MessageACK ¶
type MessageACK struct {
Geo *geo.Geometry
Cmds *Commands
QueueSizeHint uint8
Sequence uint32
ID [constants.SURBIDLength]byte
Payload []byte
}
MessageACK is a de-serialized message command containing an ACK.
func (*MessageACK) Length ¶ added in v0.0.44
func (c *MessageACK) Length() int
func (*MessageACK) String ¶ added in v0.0.71
func (c *MessageACK) String() string
func (*MessageACK) ToBytes ¶
func (c *MessageACK) ToBytes() []byte
ToBytes serializes the MessageACK and returns the resulting slice.
type MessageEmpty ¶
MessageEmpty is a de-serialized message command signifying a empty queue.
func (*MessageEmpty) Length ¶ added in v0.0.44
func (c *MessageEmpty) Length() int
func (*MessageEmpty) String ¶ added in v0.0.71
func (c *MessageEmpty) String() string
func (*MessageEmpty) ToBytes ¶
func (c *MessageEmpty) ToBytes() []byte
ToBytes serializes the MessageEmpty and returns the resulting slice.
type PostDescriptor ¶
PostDescriptor is a de-serialized post_descriptor command.
func (*PostDescriptor) Length ¶ added in v0.0.44
func (c *PostDescriptor) Length() int
func (*PostDescriptor) String ¶ added in v0.0.71
func (c *PostDescriptor) String() string
func (*PostDescriptor) ToBytes ¶
func (c *PostDescriptor) ToBytes() []byte
ToBytes serializes the PostDescriptor and returns the resulting byte slice.
type PostDescriptorStatus ¶
type PostDescriptorStatus struct {
ErrorCode uint8
}
PostDescriptorStatus is a de-serialized post_descriptor_status command.
func (*PostDescriptorStatus) Length ¶ added in v0.0.44
func (c *PostDescriptorStatus) Length() int
func (*PostDescriptorStatus) String ¶ added in v0.0.71
func (c *PostDescriptorStatus) String() string
func (*PostDescriptorStatus) ToBytes ¶
func (c *PostDescriptorStatus) ToBytes() []byte
ToBytes serializes the PostDescriptorStatus and returns the resulting byte slice.
type PostReplicaDescriptor ¶ added in v0.0.44
PostReplicaDescriptor is a de-serialized post_descriptor command.
func (*PostReplicaDescriptor) Length ¶ added in v0.0.44
func (c *PostReplicaDescriptor) Length() int
func (*PostReplicaDescriptor) String ¶ added in v0.0.71
func (c *PostReplicaDescriptor) String() string
func (*PostReplicaDescriptor) ToBytes ¶ added in v0.0.44
func (c *PostReplicaDescriptor) ToBytes() []byte
ToBytes serializes the PostReplicaDescriptor and returns the resulting byte slice.
type PostReplicaDescriptorStatus ¶ added in v0.0.44
type PostReplicaDescriptorStatus struct {
ErrorCode uint8
}
PostReplicaDescriptorStatus is a de-serialized post_replica_descriptor_status command.
func (*PostReplicaDescriptorStatus) Length ¶ added in v0.0.44
func (c *PostReplicaDescriptorStatus) Length() int
func (*PostReplicaDescriptorStatus) String ¶ added in v0.0.71
func (c *PostReplicaDescriptorStatus) String() string
func (*PostReplicaDescriptorStatus) ToBytes ¶ added in v0.0.44
func (c *PostReplicaDescriptorStatus) ToBytes() []byte
ToBytes serializes the PostReplicaDescriptorStatus and returns the resulting byte slice.
type ReplicaDecoy ¶ added in v0.0.54
type ReplicaDecoy struct {
Cmds *Commands
}
ReplicaDecoy is a decoy message type used by replicas and couriers.
func (*ReplicaDecoy) Length ¶ added in v0.0.54
func (c *ReplicaDecoy) Length() int
func (*ReplicaDecoy) String ¶ added in v0.0.71
func (c *ReplicaDecoy) String() string
func (*ReplicaDecoy) ToBytes ¶ added in v0.0.54
func (c *ReplicaDecoy) ToBytes() []byte
type ReplicaMessage ¶ added in v0.0.44
type ReplicaMessage struct {
Cmds *Commands
PigeonholeGeometry *pgeo.Geometry
Scheme nike.Scheme
SenderEPubKey []byte
DEK *[mkem.DEKSize]byte
Ciphertext []byte
}
ReplicaMessage used over wire protocol from couriers to replicas, one replica at a time.
func (*ReplicaMessage) EnvelopeHash ¶ added in v0.0.50
func (c *ReplicaMessage) EnvelopeHash() *[hash.HashSize]byte
func (*ReplicaMessage) Length ¶ added in v0.0.44
func (c *ReplicaMessage) Length() int
Length is the largest possible length of a ReplicaMessage.
func (*ReplicaMessage) String ¶ added in v0.0.71
func (c *ReplicaMessage) String() string
func (*ReplicaMessage) ToBytes ¶ added in v0.0.44
func (c *ReplicaMessage) ToBytes() []byte
type ReplicaMessageReply ¶ added in v0.0.44
type ReplicaMessageReply struct {
Cmds *Commands
PigeonholeGeometry *pgeo.Geometry
// ErrorCode indicates failure on non-zero.
ErrorCode uint8
// EnvelopeHash identifies which query the request is replying to.
EnvelopeHash *[32]byte
// ReplicaID identifies the replica replying.
ReplicaID uint8
// IsRead indicates whether the request was a read operation.
IsRead bool
// EnvelopeReply contains the mkem ciphertext reply.
EnvelopeReply []byte
}
ReplicaMessageReply is sent by replicas to couriers as a reply to the ReplicaMessage command.
func (*ReplicaMessageReply) Length ¶ added in v0.0.44
func (c *ReplicaMessageReply) Length() int
Length calculates the largest possible length of a ReplicaMessageReply.
func (*ReplicaMessageReply) String ¶ added in v0.0.71
func (c *ReplicaMessageReply) String() string
func (*ReplicaMessageReply) ToBytes ¶ added in v0.0.44
func (c *ReplicaMessageReply) ToBytes() []byte
type ReplicaWrite ¶ added in v0.0.44
type ReplicaWrite struct {
// Cmds is set to nil if you want to serialize this type
// without padding.
Cmds *Commands
// PigeonholeGeometry is used to calculate the precise payload size
// for padding. Set to nil if you don't want padding.
PigeonholeGeometry *pgeo.Geometry
BoxID *[bacap.BoxIDSize]byte
Signature *[bacap.SignatureSize]byte
Payload []byte
}
ReplicaWrite has two distinct uses. Firstly, it is to be used directly on the wire for replication between replicas. Secondly, it can be embedded inside a ReplicaMessage which of course are sent from couriers to replicas.
func (*ReplicaWrite) Length ¶ added in v0.0.44
func (c *ReplicaWrite) Length() int
func (*ReplicaWrite) String ¶ added in v0.0.71
func (c *ReplicaWrite) String() string
func (*ReplicaWrite) ToBytes ¶ added in v0.0.44
func (c *ReplicaWrite) ToBytes() []byte
type ReplicaWriteReply ¶ added in v0.0.44
ReplicaWriteReply can facilitate replication between replicas as the reply to the ReplicaWrite command. Otherwise it is embedded in a ReplicaMessageReply and sent from replicas to couriers.
func (*ReplicaWriteReply) Length ¶ added in v0.0.44
func (c *ReplicaWriteReply) Length() int
func (*ReplicaWriteReply) String ¶ added in v0.0.71
func (c *ReplicaWriteReply) String() string
func (*ReplicaWriteReply) ToBytes ¶ added in v0.0.44
func (c *ReplicaWriteReply) ToBytes() []byte
type RetrieveMessage ¶
RetrieveMessage is a de-serialized retrieve_message command.
func (*RetrieveMessage) Length ¶ added in v0.0.44
func (c *RetrieveMessage) Length() int
func (*RetrieveMessage) String ¶ added in v0.0.71
func (c *RetrieveMessage) String() string
func (*RetrieveMessage) ToBytes ¶
func (c *RetrieveMessage) ToBytes() []byte
ToBytes serializes the RetrieveMessage and returns the resulting slice.
type RevealStatus ¶
type RevealStatus struct {
ErrorCode uint8
}
RevealStatus is a de-serialized revealStatus command.
func (*RevealStatus) Length ¶ added in v0.0.44
func (c *RevealStatus) Length() int
func (*RevealStatus) String ¶ added in v0.0.71
func (c *RevealStatus) String() string
func (*RevealStatus) ToBytes ¶
func (r *RevealStatus) ToBytes() []byte
ToBytes serializes the RevealStatus and returns the resulting byte slice.
type SendPacket ¶
SendPacket is a de-serialized send_packet command.
func (*SendPacket) Length ¶ added in v0.0.44
func (c *SendPacket) Length() int
func (*SendPacket) String ¶ added in v0.0.71
func (c *SendPacket) String() string
func (*SendPacket) ToBytes ¶
func (c *SendPacket) ToBytes() []byte
ToBytes serializes the SendPacket and returns the resulting slice.
type SendRetrievePacket ¶ added in v0.0.36
SendRetrievePacket is a command that sends a message or decoy and also retrieves a new message or decoy.
func (*SendRetrievePacket) Length ¶ added in v0.0.44
func (c *SendRetrievePacket) Length() int
func (*SendRetrievePacket) String ¶ added in v0.0.71
func (c *SendRetrievePacket) String() string
func (*SendRetrievePacket) ToBytes ¶ added in v0.0.36
func (c *SendRetrievePacket) ToBytes() []byte
type SendRetrievePacketReply ¶ added in v0.0.36
type SendRetrievePacketReply struct {
Cmds *Commands
Geo *geo.Geometry
SURBID [constants.SURBIDLength]byte
Payload []byte
}
SendRetrievePacketReply is the reply command for a previously sent `SendRetrievePacket`
func (*SendRetrievePacketReply) Length ¶ added in v0.0.44
func (c *SendRetrievePacketReply) Length() int
func (*SendRetrievePacketReply) String ¶ added in v0.0.71
func (c *SendRetrievePacketReply) String() string
func (*SendRetrievePacketReply) ToBytes ¶ added in v0.0.36
func (c *SendRetrievePacketReply) ToBytes() []byte
type SigStatus ¶
type SigStatus struct {
ErrorCode uint8
}
SigStatus is a resonse status for a Sig command.
type VoteStatus ¶
type VoteStatus struct {
ErrorCode uint8
}
VoteStatus is a resonse status for a Vote command.
func (*VoteStatus) Length ¶ added in v0.0.44
func (c *VoteStatus) Length() int
func (*VoteStatus) String ¶ added in v0.0.71
func (c *VoteStatus) String() string
func (*VoteStatus) ToBytes ¶
func (c *VoteStatus) ToBytes() []byte
ToBytes serializes the VoteStatus and returns the resulting slice.