Documentation ¶
Index ¶
- func GetRequestContentsSize(payloadSize int) int
- func GetRequestPartContentsSize(externalPayloadSize int) int
- func GetRequestPayloadSize(externalPayloadSize, pubKeySize int) int
- type Collator
- type Part
- type Request
- func (m Request) GetPayload() []byte
- func (m Request) GetPayloadSize() int
- func (m Request) GetPubKey(grp *cyclic.Group) *cyclic.Int
- func (m Request) GetPubKeySize() int
- func (m Request) Marshal() []byte
- func (m Request) SetPayload(payload []byte)
- func (m Request) SetPubKey(pubKey *cyclic.Int)
- func (m Request) Version() uint8
- type RequestPart
- func (m RequestPart) GetContents() []byte
- func (m RequestPart) GetContentsSize() int
- func (m RequestPart) GetMaxContentsSize() int
- func (m RequestPart) GetNumParts() uint8
- func (m RequestPart) GetPartNum() uint8
- func (m RequestPart) Marshal() []byte
- func (m RequestPart) SetContents(contents []byte)
- func (m RequestPart) SetPartNum(num uint8)
- type RequestPayload
- func (mp RequestPayload) GetContents() []byte
- func (mp RequestPayload) GetContentsSize() int
- func (mp RequestPayload) GetMaxContentsSize() int
- func (mp RequestPayload) GetMaxResponseParts() uint8
- func (mp RequestPayload) GetNonce() uint64
- func (mp RequestPayload) GetNumParts() uint8
- func (mp RequestPayload) GetNumRequestParts() uint8
- func (mp RequestPayload) GetPartNum() uint8
- func (mp RequestPayload) GetRecipientID(pubKey *cyclic.Int) *id.ID
- func (mp RequestPayload) Marshal() []byte
- func (mp RequestPayload) SetContents(contents []byte)
- func (mp RequestPayload) SetMaxResponseParts(num uint8)
- func (mp RequestPayload) SetNonce(rng io.Reader) error
- func (mp RequestPayload) SetNumRequestParts(num uint8)
- func (mp RequestPayload) String() string
- type ResponsePart
- func (m ResponsePart) GetContents() []byte
- func (m ResponsePart) GetContentsSize() int
- func (m ResponsePart) GetMaxContentsSize() int
- func (m ResponsePart) GetNumParts() uint8
- func (m ResponsePart) GetPartNum() uint8
- func (m ResponsePart) Marshal() []byte
- func (m ResponsePart) SetContents(contents []byte)
- func (m ResponsePart) SetNumParts(max uint8)
- func (m ResponsePart) SetPartNum(num uint8)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRequestContentsSize ¶
GetRequestContentsSize returns the size of the contents of a RequestPayload given the payload size.
func GetRequestPartContentsSize ¶
GetRequestPartContentsSize returns the size of the contents for the given external payload size.
func GetRequestPayloadSize ¶
GetRequestPayloadSize returns the size of the payload for the given external payload size and public key size.
Types ¶
type Collator ¶
Collator stores the list of payloads in the correct order.
func NewCollator ¶
NewCollator generates an empty list of payloads to fit the max number of possible messages. maxNum is set to indicate that it is not yet set.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
NewRequest generates a new empty message for a request that is the size of the specified external payload.
func UnmarshalRequest ¶
UnmarshalRequest unmarshalls a byte slice into a Request. An error is returned if the slice is not large enough for the public key size.
func (Request) GetPayload ¶
GetPayload returns the encrypted payload of the message.
func (Request) GetPayloadSize ¶
GetPayloadSize returns the length of the encrypted payload.
func (Request) GetPubKeySize ¶
GetPubKeySize returns the length of the public key.
func (Request) SetPayload ¶
SetPayload saves the supplied bytes as the payload of the message, if the size is correct.
type RequestPart ¶
type RequestPart struct {
// contains filtered or unexported fields
}
func NewRequestPart ¶
func NewRequestPart(externalPayloadSize int) RequestPart
NewRequestPart generates a new request message part of the specified size.
func UnmarshalRequestPart ¶
func UnmarshalRequestPart(b []byte) (RequestPart, error)
UnmarshalRequestPart converts a byte buffer into a request message part.
func (RequestPart) GetContents ¶
func (m RequestPart) GetContents() []byte
GetContents returns the contents of the message part.
func (RequestPart) GetContentsSize ¶
func (m RequestPart) GetContentsSize() int
GetContentsSize returns the length of the contents.
func (RequestPart) GetMaxContentsSize ¶
func (m RequestPart) GetMaxContentsSize() int
GetMaxContentsSize returns the max capacity of the contents.
func (RequestPart) GetNumParts ¶
func (m RequestPart) GetNumParts() uint8
GetNumParts always returns 0. It is here so that RequestPart adheres to th Part interface.
func (RequestPart) GetPartNum ¶
func (m RequestPart) GetPartNum() uint8
GetPartNum returns the index of this part in the message.
func (RequestPart) Marshal ¶
func (m RequestPart) Marshal() []byte
Marshal returns the bytes of the message part.
func (RequestPart) SetContents ¶
func (m RequestPart) SetContents(contents []byte)
SetContents sets the contents of the message part. Does not zero out previous contents.
func (RequestPart) SetPartNum ¶
func (m RequestPart) SetPartNum(num uint8)
SetPartNum sets the part number of the message.
type RequestPayload ¶
type RequestPayload struct {
// contains filtered or unexported fields
}
RequestPayload is the structure of Request's payload.
func NewRequestPayload ¶
func NewRequestPayload(payloadSize int, payload []byte, maxMsgs uint8) RequestPayload
NewRequestPayload generates a new empty message for request that is the size of the specified payload, which should match the size of the payload in the corresponding Request.
func UnmarshalRequestPayload ¶
func UnmarshalRequestPayload(b []byte) (RequestPayload, error)
UnmarshalRequestPayload unmarshalls a byte slice into a RequestPayload. An error is returned if the slice is not large enough for the reception ID and message count.
func (RequestPayload) GetContents ¶
func (mp RequestPayload) GetContents() []byte
GetContents returns the payload's contents.
func (RequestPayload) GetContentsSize ¶
func (mp RequestPayload) GetContentsSize() int
GetContentsSize returns the length of payload's contents.
func (RequestPayload) GetMaxContentsSize ¶
func (mp RequestPayload) GetMaxContentsSize() int
GetMaxContentsSize returns the max capacity of the contents.
func (RequestPayload) GetMaxResponseParts ¶
func (mp RequestPayload) GetMaxResponseParts() uint8
GetMaxResponseParts returns the maximum number of response messages allowed.
func (RequestPayload) GetNonce ¶
func (mp RequestPayload) GetNonce() uint64
GetNonce returns the nonce as an uint64.
func (RequestPayload) GetNumParts ¶
func (mp RequestPayload) GetNumParts() uint8
GetNumParts returns the number of messages in the request. This function wraps GetMaxRequestParts so that RequestPayload adheres to the Part interface.
func (RequestPayload) GetNumRequestParts ¶
func (mp RequestPayload) GetNumRequestParts() uint8
GetNumRequestParts returns the number of messages in the request.
func (RequestPayload) GetPartNum ¶
func (mp RequestPayload) GetPartNum() uint8
GetPartNum always returns 0 since it is the first message.
func (RequestPayload) GetRecipientID ¶
func (mp RequestPayload) GetRecipientID(pubKey *cyclic.Int) *id.ID
GetRecipientID generates the recipient ID from the bytes of the payload.
func (RequestPayload) Marshal ¶
func (mp RequestPayload) Marshal() []byte
Marshal returns the serialised data of a RequestPayload.
func (RequestPayload) SetContents ¶
func (mp RequestPayload) SetContents(contents []byte)
SetContents saves the contents to the payload, if the size is correct. Does not zero out previous content.
func (RequestPayload) SetMaxResponseParts ¶
func (mp RequestPayload) SetMaxResponseParts(num uint8)
SetMaxResponseParts sets the maximum number of response messages allowed.
func (RequestPayload) SetNonce ¶
func (mp RequestPayload) SetNonce(rng io.Reader) error
SetNonce generates a random nonce from the RNG. An error is returned if the reader fails.
func (RequestPayload) SetNumRequestParts ¶
func (mp RequestPayload) SetNumRequestParts(num uint8)
SetNumRequestParts sets the number of messages in the request.
func (RequestPayload) String ¶
func (mp RequestPayload) String() string
String returns the contents of a RequestPayload as a human-readable string. This function adheres to the fmt.Stringer interface.
type ResponsePart ¶
type ResponsePart struct {
// contains filtered or unexported fields
}
func NewResponsePart ¶
func NewResponsePart(externalPayloadSize int) ResponsePart
NewResponsePart generates a new response message part of the specified size.
func UnmarshalResponsePart ¶
func UnmarshalResponsePart(data []byte) (ResponsePart, error)
UnmarshalResponsePart converts a byte buffer into a response message part.
func (ResponsePart) GetContents ¶
func (m ResponsePart) GetContents() []byte
GetContents returns the contents of the message part.
func (ResponsePart) GetContentsSize ¶
func (m ResponsePart) GetContentsSize() int
GetContentsSize returns the length of the contents.
func (ResponsePart) GetMaxContentsSize ¶
func (m ResponsePart) GetMaxContentsSize() int
GetMaxContentsSize returns the max capacity of the contents.
func (ResponsePart) GetNumParts ¶
func (m ResponsePart) GetNumParts() uint8
GetNumParts returns the number of parts in the message.
func (ResponsePart) GetPartNum ¶
func (m ResponsePart) GetPartNum() uint8
GetPartNum returns the index of this part in the message.
func (ResponsePart) Marshal ¶
func (m ResponsePart) Marshal() []byte
Marshal returns the bytes of the message part.
func (ResponsePart) SetContents ¶
func (m ResponsePart) SetContents(contents []byte)
SetContents sets the contents of the message part. Does not zero out previous contents.
func (ResponsePart) SetNumParts ¶
func (m ResponsePart) SetNumParts(max uint8)
SetNumParts sets the number of parts in the message.
func (ResponsePart) SetPartNum ¶
func (m ResponsePart) SetPartNum(num uint8)
SetPartNum sets the part number of the message.