Documentation ¶
Index ¶
Constants ¶
const ( // MaxPayloadSize is the maximum allowed payload size for the Message type, in bytes MaxPayloadSize = swarm.ChunkSize - 3*swarm.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") )
var (
ErrNoHandler = errors.New("no handler found")
)
Functions ¶
func ParseRecipient ¶ added in v0.3.0
ParseRecipient extract ephemeral public key from the hexadecimal string to use with el-Gamal.
func Wrap ¶ added in v0.3.0
func Wrap(ctx context.Context, topic Topic, msg []byte, recipient *ecdsa.PublicKey, targets Targets) (swarm.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 Interface ¶
type Target ¶ added in v0.3.0
type Target []byte
Target is an alias for a partial address (overlay prefix) serving as potential destination
type Targets ¶ added in v0.3.0
type Targets []Target
Targets is an alias for a collection of targets
type Topic ¶ added in v0.3.0
type Topic [32]byte
Topic is the type that classifies messages, allows client applications to subscribe to
func NewTopic ¶ added in v0.3.0
NewTopic creates a new Topic from an input string by taking its hash
func Unwrap ¶ added in v0.3.0
func Unwrap(ctx context.Context, key *ecdsa.PrivateKey, chunk swarm.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