Documentation ¶
Index ¶
Constants ¶
const ( // MaxPayloadSize is the maximum allowed payload size for the Message type, in bytes MaxPayloadSize = cluster.ChunkSize - 3*cluster.HashSize )
Variables ¶
var ( // ErrPayloadTooBig is returned when a given payload for a Message type is longer than the maximum amount allowed ErrPayloadTooBig = fmt.Errorf("message payload size cannot be greater than %d bytes", MaxPayloadSize) // ErrEmptyTargets is returned when the given target list for a trojan chunk is empty ErrEmptyTargets = errors.New("target list cannot be empty") // ErrVarLenTargets is returned when the given target list for a trojan chunk has addresses of different lengths ErrVarLenTargets = errors.New("target list cannot have targets of different length") )
Functions ¶
func ParseRecipient ¶
ParseRecipient extract ephemeral public key from the hexadecimal string to use with el-Gamal.
func Wrap ¶
func Wrap(ctx context.Context, topic Topic, msg []byte, recipient *ecdsa.PublicKey, targets Targets) (cluster.Chunk, error)
Wrap creates a new serialised message with the given topic, payload and recipient public key used for encryption - span as topic hint (H(key|topic)[0:8]) to match topic chunk payload: - nonce is chosen so that the chunk address will have one of the targets as its prefix and thus will be forwarded to the neighbourhood of the recipient overlay address the target is derived from trojan payload: - ephemeral public key for el-Gamal encryption ciphertext - plaintext: - plaintext length encoding - integrity protection message:
Types ¶
type Target ¶
type Target []byte
Target is an alias for a partial address (overlay prefix) serving as potential destination
type Topic ¶
type Topic [32]byte
Topic is the type that classifies messages, allows client applications to subscribe to
func Unwrap ¶
func Unwrap(ctx context.Context, key *ecdsa.PrivateKey, chunk cluster.Chunk, topics []Topic) (topic Topic, msg []byte, err error)
Unwrap takes a chunk, a topic and a private key, and tries to decrypt the payload using the private key, the prepended ephemeral public key for el-Gamal using the topic as salt