Documentation
¶
Index ¶
- Constants
- func ThinClientErrorToString(errorCode uint8) string
- type ChannelMap
- type CloseChannel
- type Config
- type ConnectionStatusEvent
- type CreateReadChannel
- type CreateReadChannelReply
- type CreateWriteChannel
- type CreateWriteChannelReply
- type Event
- type MessageIDGarbageCollected
- type MessageReplyEvent
- type MessageSentEvent
- type NewDocumentEvent
- type NewPKIDocumentEvent
- type ReadChannel
- type ReadChannelReply
- type Request
- type Response
- type SendARQMessage
- type SendDropDecoy
- type SendLoopDecoy
- type SendMessage
- type ShutdownEvent
- type ThinClient
- func (t *ThinClient) BlockingSendMessage(ctx context.Context, payload []byte, destNode *[32]byte, destQueue []byte) ([]byte, error)
- func (t *ThinClient) BlockingSendReliableMessage(ctx context.Context, messageID *[MessageIDLength]byte, payload []byte, ...) (reply []byte, err error)
- func (t *ThinClient) Close() error
- func (t *ThinClient) CloseChannel(ctx context.Context, channelID uint16) error
- func (t *ThinClient) CreateReadChannel(ctx context.Context, readCap *bacap.ReadCap, ...) (uint16, *bacap.MessageBoxIndex, error)
- func (t *ThinClient) CreateWriteChannel(ctx context.Context, WriteCap *bacap.WriteCap, ...) (uint16, *bacap.ReadCap, *bacap.WriteCap, *bacap.MessageBoxIndex, error)
- func (t *ThinClient) Dial() error
- func (t *ThinClient) EventSink() chan Event
- func (t *ThinClient) GetConfig() *Config
- func (t *ThinClient) GetLogger(prefix string) *logging.Logger
- func (t *ThinClient) GetService(serviceName string) (*common.ServiceDescriptor, error)
- func (t *ThinClient) GetServices(capability string) ([]*common.ServiceDescriptor, error)
- func (t *ThinClient) IsConnected() bool
- func (t *ThinClient) NewMessageID() *[MessageIDLength]byte
- func (t *ThinClient) NewQueryID() *[QueryIDLength]byte
- func (t *ThinClient) NewSURBID() *[sConstants.SURBIDLength]byte
- func (t *ThinClient) PKIDocument() *cpki.Document
- func (t *ThinClient) PKIDocumentForEpoch(epoch uint64) (*cpki.Document, error)
- func (t *ThinClient) ReadChannel(ctx context.Context, channelID uint16, replyIndex *uint8) ([]byte, *bacap.MessageBoxIndex, *uint8, error)
- func (t *ThinClient) ReadChannelWithReply(ctx context.Context, channelID uint16, replyIndex uint8) ([]byte, error)
- func (t *ThinClient) ReadChannelWithRetry(ctx context.Context, channelID uint16) ([]byte, error)
- func (t *ThinClient) SendChannelQuery(ctx context.Context, channelID uint16, payload []byte, destNode *[32]byte, ...) error
- func (t *ThinClient) SendMessage(surbID *[sConstants.SURBIDLength]byte, payload []byte, destNode *[32]byte, ...) error
- func (t *ThinClient) SendMessageWithoutReply(payload []byte, destNode *[32]byte, destQueue []byte) error
- func (t *ThinClient) SendReliableMessage(messageID *[MessageIDLength]byte, payload []byte, destNode *[32]byte, ...) error
- func (t *ThinClient) Shutdown()
- func (t *ThinClient) StopEventSink(ch chan Event)
- func (t *ThinClient) WriteChannel(ctx context.Context, channelID uint16, payload []byte) ([]byte, *bacap.MessageBoxIndex, error)
- func (t *ThinClient) WriteChannelWithRetry(ctx context.Context, channelID uint16, payload []byte) error
- type ThinClose
- type ThinResponse
- type WriteChannel
- type WriteChannelReply
Constants ¶
const ( MessageIDLength = 16 QueryIDLength = 16 )
const ( // ThinClientSuccess indicates that the operation completed successfully // with no errors. This is the default success state. ThinClientSuccess uint8 = 0 // ThinClientErrorConnectionLost indicates that the connection to the daemon // was lost during the operation. The client should attempt to reconnect. ThinClientErrorConnectionLost uint8 = 1 // ThinClientErrorTimeout indicates that the operation timed out before // completion. This may occur during network operations or when waiting // for responses from the mixnet. ThinClientErrorTimeout uint8 = 2 // ThinClientErrorInvalidRequest indicates that the request format was // invalid or contained malformed data that could not be processed. ThinClientErrorInvalidRequest uint8 = 3 // ThinClientErrorInternalError indicates an internal error occurred within // the client daemon or thin client that prevented operation completion. ThinClientErrorInternalError uint8 = 4 // ThinClientErrorMaxRetries indicates that the maximum number of retry // attempts was exceeded for a reliable operation (such as ARQ). ThinClientErrorMaxRetries uint8 = 5 // ThinClientErrorInvalidChannel indicates that the specified channel ID // is invalid or malformed. ThinClientErrorInvalidChannel uint8 = 6 // ThinClientErrorChannelNotFound indicates that the specified channel // does not exist or has been garbage collected. ThinClientErrorChannelNotFound uint8 = 7 // ThinClientErrorPermissionDenied indicates that the operation was denied // due to insufficient permissions or capability restrictions. ThinClientErrorPermissionDenied uint8 = 8 // ThinClientErrorInvalidPayload indicates that the message payload was // invalid, too large, or otherwise could not be processed. ThinClientErrorInvalidPayload uint8 = 9 // or functionality is currently unavailable. ThinClientErrorServiceUnavailable uint8 = 10 // ThinClientErrorDuplicateCapability indicates that the provided capability // (read or write cap) has already been used and is considered a duplicate. ThinClientErrorDuplicateCapability uint8 = 11 // ThinClientErrorCourierCacheCorruption indicates that the courier's cache // has detected corruption. ThinClientErrorCourierCacheCorruption uint8 = 12 // ThinClientPropagationError indicates that the request could not be // propagated to replicas. ThinClientPropagationError uint8 = 13 )
Thin client error codes provide standardized error reporting across the protocol. These codes are used in response messages to indicate the success or failure of operations, allowing applications to handle errors consistently.
const ChannelIDLength = 32
Variables ¶
This section is empty.
Functions ¶
func ThinClientErrorToString ¶ added in v0.0.50
ThinClientErrorToString converts a thin client error code to a human-readable string. This function provides consistent error message formatting across the thin client protocol and is used for logging and error reporting.
Parameters:
- errorCode: The error code to convert
Returns:
- string: A human-readable description of the error
Types ¶
type ChannelMap ¶ added in v0.0.50
type ChannelMap struct {
ReadChannels map[[ChannelIDLength]byte]*bacap.StatefulReader `cbor:"read_channels"`
WriteChannels map[[ChannelIDLength]byte]*bacap.StatefulWriter `cbor:"write_channels"`
}
type CloseChannel ¶ added in v0.0.52
type CloseChannel struct {
ChannelID uint16 `cbor:"channel_id"`
}
CloseChannel requests closing a pigeonhole channel.
func (*CloseChannel) String ¶ added in v0.0.52
func (c *CloseChannel) String() string
type Config ¶ added in v0.0.49
type Config struct {
// SphinxGeometry is the Sphinx geometry used by the client daemon that this thin client will connect to.
SphinxGeometry *geo.Geometry
// PigeonholeGeometry is the pigeonhole geometry used for payload size validation.
PigeonholeGeometry *pigeonholeGeo.Geometry
// Network is the client daemon's listening network.
Network string
// Address is the client daemon's listening address.
Address string
}
Config is the thin client config.
func FromConfig ¶ added in v0.0.49
type ConnectionStatusEvent ¶
type ConnectionStatusEvent struct {
// IsConnected is true iff the client is connected to the entry node.
IsConnected bool `cbor:"is_connected"`
// Err is the error encountered when connecting or by the connection if any.
Err error `cbor:"err"`
}
ConnectionStatusEvent is the event sent when an account's connection status changes.
func (*ConnectionStatusEvent) String ¶
func (e *ConnectionStatusEvent) String() string
String returns a string representation of the ConnectionStatusEvent.
type CreateReadChannel ¶ added in v0.0.50
type CreateReadChannel struct {
// QueryID is used for correlating this thin client request with the
// thin client reponse, the CreateWriteChannelReply.
QueryID *[QueryIDLength]byte `cbor:"query_id"`
// ReadCap is the read capability that grants access to the channel.
// This capability is typically shared by the channel creator and allows
// reading messages from the specified channel.
ReadCap *bacap.ReadCap `cbor:"read_cap"`
// MessageBoxIndex specifies the starting read position for the channel.
// If nil, reading will start from the beginning of the channel.
MessageBoxIndex *bacap.MessageBoxIndex `cbor:"message_box_index,omitempty"`
}
CreateReadChannel requests the creation of a new pigeonhole read channel from an existing read capability. Read channels allow receiving messages from a communication channel created by the holder of the write capability.
type CreateReadChannelReply ¶ added in v0.0.50
type CreateReadChannelReply struct {
// QueryID is used for correlating this reply with the CreateReadChannel request
// that created it.
QueryID *[QueryIDLength]byte `cbor:"query_id"`
// ChannelID is the unique identifier for the created read channel, used in
// subsequent ReadChannel operations.
ChannelID uint16 `cbor:"channel_id"`
// NextMessageIndex indicates the current read position in the channel,
// showing where the next read operation will start from.
NextMessageIndex *bacap.MessageBoxIndex `cbor:"next_message_index"`
// ErrorCode indicates the success or failure of the channel creation.
// A value of ThinClientErrorSuccess indicates successful creation.
ErrorCode uint8 `cbor:"error_code"`
}
CreateReadChannelReply is sent in response to a CreateReadChannel request. It provides the channel ID and current read position for the newly created pigeonhole read channel.
func (*CreateReadChannelReply) String ¶ added in v0.0.50
func (e *CreateReadChannelReply) String() string
String returns a string representation of the CreateReadChannelReply.
type CreateWriteChannel ¶ added in v0.0.50
type CreateWriteChannel struct {
// QueryID is used for correlating this thin client request with the
// thin client reponse, the CreateWriteChannelReply.
QueryID *[QueryIDLength]byte `cbor:"query_id"`
// WriteCap is the write capability for resuming an existing channel.
// If nil, a new channel will be created. If provided, the channel will
// be resumed from the specified MessageBoxIndex position.
WriteCap *bacap.WriteCap `cbor:"write_cap,omitempty"`
// MessageBoxIndex specifies the starting or resume point for the channel.
// This field is required when resuming an existing channel (WriteCap != nil)
// and optional when creating a new channel (defaults to a random starting point).
MessageBoxIndex *bacap.MessageBoxIndex `cbor:"message_box_index,omitempty"`
}
CreateWriteChannel requests the creation of a new pigeonhole write channel or the resumption of an existing one. Write channels allow sending messages to a persistent communication channel that can be read by holders of the corresponding read capability.
type CreateWriteChannelReply ¶ added in v0.0.50
type CreateWriteChannelReply struct {
// QueryID is used for correlating this reply with the CreateWriteChannel request
// that created it.
QueryID *[QueryIDLength]byte `cbor:"query_id"`
// ChannelID is the unique identifier for the created channel, used in
// subsequent WriteChannel operations.
ChannelID uint16 `cbor:"channel_id"`
// ReadCap is the read capability that can be shared with others to allow
// them to read messages from this channel.
ReadCap *bacap.ReadCap `cbor:"read_cap"`
// WriteCap is the write capability that should be stored for channel
// persistence and resumption across client restarts.
WriteCap *bacap.WriteCap `cbor:"write_cap"`
// NextMessageIndex indicates the current write position in the channel,
// used for tracking message ordering and resumption.
NextMessageIndex *bacap.MessageBoxIndex `cbor:"next_message_index"`
// ErrorCode indicates the success or failure of the channel creation.
// A value of ThinClientErrorSuccess indicates successful creation.
ErrorCode uint8 `cbor:"error_code"`
}
CreateWriteChannelReply is sent in response to a CreateWriteChannel request. It provides the channel ID and capabilities needed to use the newly created or resumed pigeonhole write channel.
func (*CreateWriteChannelReply) String ¶ added in v0.0.50
func (e *CreateWriteChannelReply) String() string
String returns a string representation of the CreateWriteChannelReply.
type Event ¶
type Event interface {
// String returns a string representation of the Event.
String() string
}
Event is the generic event sent over the event listener channel.
type MessageIDGarbageCollected ¶
type MessageIDGarbageCollected struct {
// MessageID is the local unique identifier for the message.
MessageID *[MessageIDLength]byte `cbor:"message_id"`
}
MessageIDGarbageCollected is the event used to signal when a given message ID has been garbage collected.
func (*MessageIDGarbageCollected) String ¶
func (e *MessageIDGarbageCollected) String() string
String returns a string representation of a MessageIDGarbageCollected.
type MessageReplyEvent ¶
type MessageReplyEvent struct {
// MessageID is the unique identifier for the request associated with the
// reply.
MessageID *[MessageIDLength]byte `cbor:"message_id"`
// SURBID must be a unique identity for each request.
// This field should be nil if WithSURB is false.
SURBID *[sConstants.SURBIDLength]byte `cbor:"surbid"`
// Payload is the reply payload if any.
Payload []byte `cbor:"payload"`
// ReplyIndex is the index of the reply that was actually used when processing
// this message. This is particularly relevant for pigeonhole channel reads.
ReplyIndex *uint8 `cbor:"reply_index,omitempty"`
// ErrorCode indicates the success or failure of the message operation.
// A value of ThinClientSuccess (0) indicates no error occurred.
// Non-zero values indicate specific error conditions.
ErrorCode uint8 `cbor:"error_code"`
}
MessageReplyEvent is the event sent when a new message is received.
func (*MessageReplyEvent) String ¶
func (e *MessageReplyEvent) String() string
String returns a string representation of the MessageReplyEvent.
type MessageSentEvent ¶
type MessageSentEvent struct {
// MessageID is the local unique identifier for the message, generated
// when the message was enqueued.
MessageID *[MessageIDLength]byte `cbor:"message_id"`
// SURBID must be a unique identity for each request.
// This field should be nil if WithSURB is false.
SURBID *[sConstants.SURBIDLength]byte `cbor:"surbid"`
// SentAt contains the time the message was sent.
SentAt time.Time `cbor:"sent_at"`
// ReplyETA is the expected round trip time to receive a response.
ReplyETA time.Duration `cbor:"reply_eta"`
// Err is the error message if any error was encountered when sending the message.
// Empty string indicates no error occurred.
Err string `cbor:"err,omitempty"`
}
MessageSentEvent is the event sent when a message has been fully transmitted.
func (*MessageSentEvent) String ¶
func (e *MessageSentEvent) String() string
String returns a string representation of a MessageSentEvent.
type NewDocumentEvent ¶
NewDocumentEvent is the new document event, signaling that we have received a new document from the PKI.
func (*NewDocumentEvent) String ¶
func (e *NewDocumentEvent) String() string
String returns a string representation of a NewDocumentEvent.
type NewPKIDocumentEvent ¶
type NewPKIDocumentEvent struct {
Payload []byte `cbor:"payload"`
}
NewPKIDocumentEvent is the unix domain socket protocol message used by the daemon to tell the thin client about new PKI document events. The payload field contains a CBOR encoded PKI document, stripped of signatures.
func (*NewPKIDocumentEvent) String ¶
func (e *NewPKIDocumentEvent) String() string
String returns a string representation of a NewDocumentEvent.
type ReadChannel ¶ added in v0.0.50
type ReadChannel struct {
// ChannelID identifies the source channel for the read operation.
// This ID was returned when the channel was created.
ChannelID uint16 `cbor:"channel_id"`
// QueryID is used for correlating this thin client request with the
// thin client reponse, the ReadChannelReply.
QueryID *[QueryIDLength]byte `cbor:"query_id"`
// ReplyIndex is the index of the reply to return. It is optional and
// a default of zero will be used if not specified.
ReplyIndex *uint8 `cbor:"reply_index"`
}
ReadChannel requests reading the next message from a pigeonhole channel. The daemon will prepare a query for the next available message and return the serialized payload that should be sent via SendChannelQuery.
func (*ReadChannel) String ¶ added in v0.0.50
func (r *ReadChannel) String() string
String returns a string representation of the ReadChannel request.
type ReadChannelReply ¶ added in v0.0.50
type ReadChannelReply struct {
// QueryID is used for correlating this reply with the ReadChannel request
// that created it.
QueryID *[QueryIDLength]byte `cbor:"query_id"`
// ChannelID identifies the channel this reply corresponds to.
ChannelID uint16 `cbor:"channel_id"`
// SendMessagePayload contains the prepared query that should be sent via
// SendChannelQuery to retrieve the next message from the channel.
SendMessagePayload []byte `cbor:"send_message_payload"`
// NextMessageIndex indicates the message index to use after successfully
// reading the current message.
NextMessageIndex *bacap.MessageBoxIndex `cbor:"next_message_index"`
// ReplyIndex is the index of the reply that was used when creating this ReadChannelReply.
// This corresponds to the ReplyIndex parameter from the ReadChannel request.
ReplyIndex *uint8 `cbor:"reply_index"`
// ErrorCode indicates the success or failure of preparing the read operation.
// A value of ThinClientErrorSuccess indicates the query is ready to send.
ErrorCode uint8 `cbor:"error_code"`
}
ReadChannelReply is sent in response to a ReadChannel request. It provides the prepared query payload that should be sent through the mixnet to retrieve the next message from the channel.
func (*ReadChannelReply) String ¶ added in v0.0.50
func (e *ReadChannelReply) String() string
String returns a string representation of the ReadChannelReply.
type Request ¶
type Request struct {
// CreateWriteChannel is used to create a new Pigeonhole write channel.
CreateWriteChannel *CreateWriteChannel `cbor:"create_write_channel"`
// CreateReadChannel is used to create a new Pigeonhole read channel.
CreateReadChannel *CreateReadChannel `cbor:"create_read_channel"`
// WriteChannel is used to write to a Pigeonhole channel.
WriteChannel *WriteChannel `cbor:"write_channel"`
// ReadChannel is used to read from a Pigeonhole channel.
ReadChannel *ReadChannel `cbor:"read_channel"`
// CloseChannel is used to close a Pigeonhole channel.
CloseChannel *CloseChannel `cbor:"close_channel"`
// SendMessage is used to send a message through the mix network.
SendMessage *SendMessage `cbor:"send_message"`
// SendARQMessage is used to send a message through the mix network
// using the naive ARQ error correction scheme.
SendARQMessage *SendARQMessage `cbor:"send_arq_message"`
// SendLoopDecoy is used to send a loop decoy message.
SendLoopDecoy *SendLoopDecoy `cbor:"send_loop_decoy"`
// SendDropDecoy is used to send a drop decoy message.
SendDropDecoy *SendDropDecoy `cbor:"send_drop_decoy"`
// ThinClose is used to indicate that the thin client is disconnecting
// from the daemon.
ThinClose *ThinClose `cbor:"thin_close"`
}
type Response ¶
type Response struct {
ShutdownEvent *ShutdownEvent `cbor:"shudown_event"`
ConnectionStatusEvent *ConnectionStatusEvent `cbor:"connection_status_event"`
NewPKIDocumentEvent *NewPKIDocumentEvent `cbor:"new_pki_document_event"`
MessageSentEvent *MessageSentEvent `cbor:"message_sent_event"`
MessageReplyEvent *MessageReplyEvent `cbor:"message_reply_event"`
MessageIDGarbageCollected *MessageIDGarbageCollected `cbor:"message_id_garbage_collected"`
CreateWriteChannelReply *CreateWriteChannelReply `cbor:"create_write_channel_reply"`
CreateReadChannelReply *CreateReadChannelReply `cbor:"create_read_channel_reply"`
WriteChannelReply *WriteChannelReply `cbor:"write_channel_reply"`
ReadChannelReply *ReadChannelReply `cbor:"read_channel_reply"`
}
type SendARQMessage ¶ added in v0.0.50
type SendARQMessage struct {
// ID is the unique identifier with respect to the Payload.
// This is only used by the ARQ.
ID *[MessageIDLength]byte `cbor:"id"`
// WithSURB indicates if the message should be sent with a SURB
// in the Sphinx payload.
WithSURB bool `cbor:"with_surb"`
// SURBID must be a unique identity for each request.
// This field should be nil if WithSURB is false.
SURBID *[sConstants.SURBIDLength]byte `cbor:"surbid"`
// DestinationIdHash is 32 byte hash of the destination Provider's
// identity public key.
DestinationIdHash *[hash.HashSize]byte `cbor:"destination_id_hash"`
// RecipientQueueID is the queue identity which will receive the message.
RecipientQueueID []byte `cbor:"recipient_queue_id"`
// Payload is the actual Sphinx packet.
Payload []byte `cbor:"payload"`
}
type SendDropDecoy ¶ added in v0.0.50
type SendDropDecoy struct {
}
type SendLoopDecoy ¶ added in v0.0.50
type SendLoopDecoy struct {
}
type SendMessage ¶ added in v0.0.50
type SendMessage struct {
// ID is the unique identifier with respect to the Payload.
// This is only used by the ARQ.
ID *[MessageIDLength]byte `cbor:"id"`
// WithSURB indicates if the message should be sent with a SURB
// in the Sphinx payload.
WithSURB bool `cbor:"with_surb"`
// ChannelID is optional and only used for sending channel messages.
// For non-channel messages, this field should be nil.
ChannelID *uint16 `cbor:"channel_id,omitempty"`
// SURBID must be a unique identity for each request.
// This field should be nil if WithSURB is false.
SURBID *[sConstants.SURBIDLength]byte `cbor:"surbid"`
// DestinationIdHash is 32 byte hash of the destination Provider's
// identity public key.
DestinationIdHash *[hash.HashSize]byte `cbor:"destination_id_hash"`
// RecipientQueueID is the queue identity which will receive the message.
RecipientQueueID []byte `cbor:"recipient_queue_id"`
// Payload is the actual Sphinx packet.
Payload []byte `cbor:"payload"`
}
type ShutdownEvent ¶
type ShutdownEvent struct{}
func (*ShutdownEvent) String ¶
func (e *ShutdownEvent) String() string
type ThinClient ¶
ThinClient is the client that handles communication between the mixnet application and the client daemon. It does not do any encryption or decryption or checking of cryptographic signatures; those responsibilities are left to the client daemon process.
func NewThinClient ¶
func NewThinClient(cfg *Config, logging *config.Logging) *ThinClient
NewThinClient creates a new thing client.
func (*ThinClient) BlockingSendMessage ¶
func (t *ThinClient) BlockingSendMessage(ctx context.Context, payload []byte, destNode *[32]byte, destQueue []byte) ([]byte, error)
BlockingSendMessage blocks until a reply is received and returns it or an error. This method requires mixnet connectivity.
func (*ThinClient) BlockingSendReliableMessage ¶
func (t *ThinClient) BlockingSendReliableMessage(ctx context.Context, messageID *[MessageIDLength]byte, payload []byte, destNode *[32]byte, destQueue []byte) (reply []byte, err error)
BlockingSendReliableMessage blocks until the message is reliably sent and the ARQ reply is received. This method requires mixnet connectivity.
func (*ThinClient) Close ¶
func (t *ThinClient) Close() error
Close halts the thin client worker thread and closes the socket connection with the client daemon.
func (*ThinClient) CloseChannel ¶ added in v0.0.52
func (t *ThinClient) CloseChannel(ctx context.Context, channelID uint16) error
CloseChannel closes a pigeonhole channel.
func (*ThinClient) CreateReadChannel ¶ added in v0.0.50
func (t *ThinClient) CreateReadChannel(ctx context.Context, readCap *bacap.ReadCap, messageBoxIndex *bacap.MessageBoxIndex) (uint16, *bacap.MessageBoxIndex, error)
CreateReadChannel creates a read channel from a read capability.
func (*ThinClient) CreateWriteChannel ¶ added in v0.0.50
func (t *ThinClient) CreateWriteChannel(ctx context.Context, WriteCap *bacap.WriteCap, messageBoxIndex *bacap.MessageBoxIndex) (uint16, *bacap.ReadCap, *bacap.WriteCap, *bacap.MessageBoxIndex, error)
CreateWriteChannel creates a new pigeonhole write channel and returns the channel ID, read capability, and write capability.
func (*ThinClient) EventSink ¶
func (t *ThinClient) EventSink() chan Event
EventSink returns a channel that receives all Events. The channel should be closed when done.
func (*ThinClient) GetConfig ¶
func (t *ThinClient) GetConfig() *Config
GetConfig returns the config
func (*ThinClient) GetLogger ¶
func (t *ThinClient) GetLogger(prefix string) *logging.Logger
GetLogger(prefix) returns a logger with prefix
func (*ThinClient) GetService ¶
func (t *ThinClient) GetService(serviceName string) (*common.ServiceDescriptor, error)
GetService returns a randomly selected service matching the specified service name
func (*ThinClient) GetServices ¶
func (t *ThinClient) GetServices(capability string) ([]*common.ServiceDescriptor, error)
GetServices returns the services matching the specified service name
func (*ThinClient) IsConnected ¶ added in v0.0.53
func (t *ThinClient) IsConnected() bool
IsConnected returns true if the daemon is connected to the mixnet
func (*ThinClient) NewMessageID ¶
func (t *ThinClient) NewMessageID() *[MessageIDLength]byte
NewMessageID returns a new message id.
func (*ThinClient) NewQueryID ¶ added in v0.0.54
func (t *ThinClient) NewQueryID() *[QueryIDLength]byte
NewQueryID returns a new query id.
func (*ThinClient) NewSURBID ¶
func (t *ThinClient) NewSURBID() *[sConstants.SURBIDLength]byte
NewSURBID returns a new surb id.
func (*ThinClient) PKIDocument ¶
func (t *ThinClient) PKIDocument() *cpki.Document
PKIDocument returns the thin client's current reference to the PKI doc
func (*ThinClient) PKIDocumentForEpoch ¶ added in v0.0.50
func (t *ThinClient) PKIDocumentForEpoch(epoch uint64) (*cpki.Document, error)
PKIDocumentForEpoch returns the PKI document for a specific epoch from cache. If the document for the requested epoch is not cached, returns the current document. This ensures consistency during epoch transitions where Alice and Bob might use different PKI documents, leading to different envelope hashes.
func (*ThinClient) ReadChannel ¶ added in v0.0.50
func (t *ThinClient) ReadChannel(ctx context.Context, channelID uint16, replyIndex *uint8) ([]byte, *bacap.MessageBoxIndex, *uint8, error)
ReadChannel prepares a read query for a pigeonhole channel and returns the payload, next MessageBoxIndex, and used ReplyIndex. The thin client must then call SendChannelQuery with the returned payload to actually send the query.
func (*ThinClient) ReadChannelWithReply ¶ added in v0.0.54
func (t *ThinClient) ReadChannelWithReply(ctx context.Context, channelID uint16, replyIndex uint8) ([]byte, error)
ReadChannelWithReply sends a read query for a pigeonhole channel with a specific reply index. This method requires mixnet connectivity and will fail in offline mode.
func (*ThinClient) ReadChannelWithRetry ¶ added in v0.0.54
ReadChannelWithRetry sends a read query for a pigeonhole channel with automatic reply index retry. It first tries reply index 0 up to 3 times, and if that fails, it tries reply index 1 up to 3 times. This method handles the common case where the courier has cached replies at different indices and accounts for timing issues where messages may not have propagated yet. This method requires mixnet connectivity and will fail in offline mode.
func (*ThinClient) SendChannelQuery ¶ added in v0.0.50
func (t *ThinClient) SendChannelQuery( ctx context.Context, channelID uint16, payload []byte, destNode *[32]byte, destQueue []byte, messageID *[MessageIDLength]byte, ) error
SendChannelQuery sends a channel query (prepared by WriteChannel or ReadChannel) to the mixnet. This method requires mixnet connectivity and will fail in offline mode.
func (*ThinClient) SendMessage ¶
func (t *ThinClient) SendMessage(surbID *[sConstants.SURBIDLength]byte, payload []byte, destNode *[32]byte, destQueue []byte) error
SendMessage takes a message payload, a destination node, destination queue ID and a SURB ID and sends a message along with a SURB so that you can later receive the reply along with the SURBID you choose. This method of sending messages should be considered to be asynchronous because it does NOT actually wait until the client daemon sends the message. Nor does it wait for a reply. The only blocking aspect to it's behavior is merely blocking until the client daemon receives our request to send a message. This method requires mixnet connectivity.
func (*ThinClient) SendMessageWithoutReply ¶
func (t *ThinClient) SendMessageWithoutReply(payload []byte, destNode *[32]byte, destQueue []byte) error
SendMessageWithoutReply sends a message encapsulated in a Sphinx packet, without any SURB. No reply will be possible. This method requires mixnet connectivity.
func (*ThinClient) SendReliableMessage ¶
func (t *ThinClient) SendReliableMessage(messageID *[MessageIDLength]byte, payload []byte, destNode *[32]byte, destQueue []byte) error
func (*ThinClient) Shutdown ¶
func (t *ThinClient) Shutdown()
func (*ThinClient) StopEventSink ¶ added in v0.0.43
func (t *ThinClient) StopEventSink(ch chan Event)
StopEventSink tells eventSinkWorker to stop sending events to ch
func (*ThinClient) WriteChannel ¶ added in v0.0.50
func (t *ThinClient) WriteChannel(ctx context.Context, channelID uint16, payload []byte) ([]byte, *bacap.MessageBoxIndex, error)
WriteChannel prepares a write message for a pigeonhole channel and returns the prepared payload and next MessageBoxIndex. The thin client must then call SendChannelQuery with the returned payload to actually send the message.
func (*ThinClient) WriteChannelWithRetry ¶ added in v0.0.54
func (t *ThinClient) WriteChannelWithRetry(ctx context.Context, channelID uint16, payload []byte) error
WriteChannelWithReply writes a message to a pigeonhole channel and waits for the write confirmation. This method handles the complete write flow: preparing the write payload, sending it to the courier, and waiting for the write completion confirmation. This method requires mixnet connectivity and will fail in offline mode.
type ThinResponse ¶
type ThinResponse struct {
// SURBID, a unique indentifier for this response,
// which should precisely match the application's chosen
// SURBID of the sent message.
SURBID *[sConstants.SURBIDLength]byte
// ID is the unique ID for the corresponding sent message.
ID *[MessageIDLength]byte
// Payload is the decrypted payload plaintext.
Payload []byte
}
ThinResponse is used to encapsulate a message response that are passed to the client application.
type WriteChannel ¶ added in v0.0.50
type WriteChannel struct {
// ChannelID identifies the target channel for the write operation.
// This ID was returned when the channel was created.
ChannelID uint16 `cbor:"channel_id"`
// QueryID is used for correlating the write request with its response.
// This allows the client to match responses to specific write operations.
// This field is required.
QueryID *[QueryIDLength]byte `cbor:"query_id"`
// Payload contains the message data to write to the channel.
// The payload size must not exceed the channel's configured limits.
Payload []byte `cbor:"payload"`
}
WriteChannel requests writing a message to an existing pigeonhole channel. The daemon will prepare the message for transmission and return the serialized payload that should be sent via SendChannelQuery.
func (*WriteChannel) String ¶ added in v0.0.50
func (w *WriteChannel) String() string
String returns a string representation of the WriteChannel request.
type WriteChannelReply ¶ added in v0.0.50
type WriteChannelReply struct {
// ChannelID identifies the channel this reply corresponds to.
ChannelID uint16 `cbor:"channel_id"`
// SendMessagePayload contains the prepared Sphinx packet that should be
// sent via SendChannelQuery to complete the write operation.
SendMessagePayload []byte `cbor:"send_message_payload"`
// NextMessageIndex indicates the message index to use after the courier
// acknowledges successful delivery of this message.
NextMessageIndex *bacap.MessageBoxIndex `cbor:"next_message_index"`
// QueryID is used for correlating this reply with the WriteChannel request
// that created it.
QueryID *[QueryIDLength]byte `cbor:"query_id"`
// EnvelopeHash is the hash of the CourierEnvelope that was sent to the
EnvelopeHash [32]byte `cbor:"envelope_hash"`
// EnvelopeDescriptor contains the serialized EnvelopeDescriptor that
// contains the private key material needed to decrypt the envelope reply.
EnvelopeDescriptor []byte `cbor:"envelope_descriptor"`
// ErrorCode indicates the success or failure of preparing the write operation.
// A value of ThinClientErrorSuccess indicates the payload is ready to send.
ErrorCode uint8 `cbor:"error_code"`
}
WriteChannelReply is sent in response to a WriteChannel request. It provides the prepared message payload that should be sent through the mixnet to complete the channel write operation.
func (*WriteChannelReply) String ¶ added in v0.0.50
func (e *WriteChannelReply) String() string
String returns a string representation of the WriteChannelReply.