payload

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeWakuMessage

func DecodeWakuMessage(message *pb.WakuMessage, keyInfo *KeyInfo) error

func EncodeWakuMessage

func EncodeWakuMessage(message *pb.WakuMessage, keyInfo *KeyInfo) error

Types

type DecodedPayload

type DecodedPayload struct {
	Data      []byte           // Decoded message payload
	Padding   []byte           // Used to align data size, since data size alone might reveal important metainformation.
	PubKey    *ecdsa.PublicKey // The public key that signed the payload
	Signature []byte
}

DecodedPayload contains the data of the received message after decrypting it

func DecodePayload

func DecodePayload(message *pb.WakuMessage, keyInfo *KeyInfo) (*DecodedPayload, error)

DecodePayload decodes a WakuMessage depending on the version parameter. 0 for raw unencrypted data, and 1 for using WakuV1 decoding

type KeyInfo

type KeyInfo struct {
	Kind    KeyKind           // Indicates the type of encryption to use
	SymKey  []byte            // If the encryption is Symmetric, a Symmetric key must be specified
	PubKey  ecdsa.PublicKey   // If the encryption is Asymmetric, the public key of the message receptor must be specified
	PrivKey *ecdsa.PrivateKey // Set a privkey if the message requires a signature
}

type KeyKind

type KeyKind string

KeyKind indicates the type of encryption to apply

const (
	Symmetric  KeyKind = "Symmetric"
	Asymmetric KeyKind = "Asymmetric"
	None       KeyKind = "None"
)

type Payload

type Payload struct {
	Data    []byte   // Raw message payload
	Padding []byte   // Used to align data size, since data size alone might reveal important metainformation.
	Key     *KeyInfo // Contains the type of encryption to apply and the private key to use for signing the message
}

Payload contains the data of the message to encode

func (Payload) Encode

func (payload Payload) Encode(version uint32) ([]byte, error)

Encode encodes a payload depending on the version parameter. 0 for raw unencrypted data, and 1 for using WakuV1 encoding.

Jump to

Keyboard shortcuts

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