trojan

package
v0.9.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2023 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPayloadSize is the maximum allowed payload size for the Message type, in bytes
	MaxPayloadSize = cluster.ChunkSize - 3*cluster.HashSize
)

Variables

View Source
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

func ParseRecipient(recipientHexString string) (*ecdsa.PublicKey, error)

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 Targets

type Targets []Target

Targets is an alias for a collection of targets

type Topic

type Topic [32]byte

Topic is the type that classifies messages, allows client applications to subscribe to

func NewTopic

func NewTopic(text string) Topic

NewTopic creates a new Topic from an input string by taking its hash

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL