message

package
v1.6.8 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 9 Imported by: 4

Documentation

Overview

Package message is used to create network messages for the purpose of confirming integrity and proof of work.

The main purpose of the message is the possibility of retransmission with verification by the network key and hide the structure of the true message.

NETWORK MESSAGE FORMAT

Sc || Sa || E( KDF(K,Sc), P(HLMV) || HLMV || LM || M || V )
where
	HLMV = H( KDF(K,Sa), LM || M || V )
	LM   = L(M)
	Sc   = G(N)
	Sa   = G(N)
	where
		KDF - key derivation function
		H   - hmac
		K   - network key
		Sa  - auth salt
		M   - message bytes
		L   - length
		G   - prng
		Sc  - cipher salt
		P   - proof of work
		E   - encrypt
		V   - void bytes
		N   - num random bytes

Scheme: https://github.com/number571/go-peer/blob/master/images/go-peer_layer1_net_message.jpg

Index

Constants

View Source
const (
	CMessageHeadSize = 2*cSaltSize +
		symmetric.CAESBlockSize +
		hashing.CSHA256Size +
		3*encoding.CSizeUint64
)

Variables

View Source
var (
	ErrUnknownType        = &SMessageError{"unknown type"}
	ErrInvalidHeaderSize  = &SMessageError{"length of message bytes < size of header"}
	ErrInvalidProofOfWork = &SMessageError{"got invalid proof of work"}
	ErrInvalidPayloadSize = &SMessageError{"got invalid payload size"}
	ErrInvalidAuthHash    = &SMessageError{"got invalid auth hash"}
	ErrDecodePayload      = &SMessageError{"decode payload"}
)

Functions

This section is empty.

Types

type IMessage

type IMessage interface {
	types.IConverter

	GetHash() []byte
	GetVoid() []byte
	GetSalt() [2][]byte
	GetProof() uint64
	GetPayload() payload.IPayload
}

func LoadMessage

func LoadMessage(pSett ISettings, pData interface{}) (IMessage, error)

func NewMessage

func NewMessage(pSett ISettings, pPld payload.IPayload, pParallel, pLimitVoidSize uint64) IMessage

type ISettings added in v1.5.21

type ISettings interface {
	GetWorkSizeBits() uint64
	GetNetworkKey() string
}

func NewSettings added in v1.5.21

func NewSettings(pSett *SSettings) ISettings

type SMessageError added in v1.6.8

type SMessageError struct {
	// contains filtered or unexported fields
}

func (*SMessageError) Error added in v1.6.8

func (err *SMessageError) Error() string

type SSettings added in v1.5.21

type SSettings sSettings

Jump to

Keyboard shortcuts

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