Documentation ¶
Overview ¶
Package packet provides a standard message binary serialised data format and message segmentation scheme which includes address.Sender cloaked public key and address.Receiver private keys for generating a shared cipher and applying to messages/message segments.
Index ¶
Constants ¶
const ErrDupe = "found duplicate packet, no redundancy, decoding failed"
const ErrEmptyBytes = "cannot encode empty bytes"
const ErrLostNoRedundant = "no redundancy with %d lost of %d"
const ErrMismatch = "found disagreement about common data in segment %d of %d" +
" in field %s value: got %v expected %v"
const ErrNotEnough = "too many lost to recover in section %d, have %d, need " +
"%d minimum"
const Overhead = 4 + nonce.IVLen + pub.KeyLen
Overhead is the base overhead on a packet, use GetOverhead to add any extra as found in a Packet.
Variables ¶
This section is empty.
Functions ¶
func Encode ¶
Encode creates a Packet, encrypts the payload using the given private from key and the public to key, serializes the form, signs the bytes and appends the signature to the end.
func GetKeys ¶
GetKeys returns the To field of the message in order, checks the packet checksum and recovers the public key.
After this, if the matching private key to the cloaked address returned is found, it is combined with the public key to generate the cipher and the entire packet should then be decrypted, and the Decode function will then decode a OnionSkin.
Types ¶
type EP ¶
type EP struct { To *pub.Key From *prv.Key Parity int Seq int Length int Deadline time.Time Data []byte }
EP defines the parameters for creating a (split) packet given a set of keys, cipher, and data. To, From, Blk and Data are required, Parity is optional, set it to define a level of Reed Solomon redundancy on the split packets. Seen should be populated to send a signal to the other side of keys that have been seen at time of constructing this packet that can now be discarded as they will not be used to generate a cipher again.
This library is for creating segmented, FEC redundancy protected network packets, and the To sender key should be the publicly advertised public key of a relay.
Deadline is a special field that gives a timeout period after which an incomplete message can be considered expired and flushed from the cache. It is 32 bits in size as precision to the second is sufficient, and low latency messages will potentially beat the deadline at one second.
func (EP) GetOverhead ¶
GetOverhead returns the amount of the message that will not be part of the payload.
type Packet ¶
type Packet struct { // Seq specifies the segment number of the message, 4 bytes long. Seq uint16 // Length is the number of segments in the batch Length uint32 // Parity is the ratio of redundancy. In each 256 segment Parity byte // Deadline is a time after which the message should be received and // dispatched. Deadline time.Time // Data is the message. Data []byte }
Packet is the standard format for an encrypted, possibly segmented message container with parameters for Reed Solomon Forward Error Correction.
func Decode ¶
Decode a packet and return the Packet with encrypted payload and signer's public key. This assumes GetKeys succeeded and the matching private key was found.
func (*Packet) GetOverhead ¶
GetOverhead returns the packet frame overhead given the settings found in the packet.
type Packets ¶
type Packets []*Packet
Packets is a slice of pointers to packets.