coder

package
v0.0.0-...-70c1fab Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMatrixDimensionMismatch           = errors.New("can't perform matrix multiplication")
	ErrAllUsefulPiecesReceived           = errors.New("no more pieces required for decoding")
	ErrMoreUsefulPiecesRequired          = errors.New("not enough pieces received yet to decode")
	ErrCopyFailedDuringPieceConstruction = errors.New("failed to copy whole data before splitting into pieces")
	ErrPieceCountMoreThanTotalBytes      = errors.New("requested piece count > total bytes of original data")
	ErrZeroPieceSize                     = errors.New("pieces can't be sized as zero byte")
	ErrBadPieceCount                     = errors.New("minimum 2 pieces required for RLNC")
	ErrCodedDataLengthMismatch           = errors.New("coded data length != coded piece count x coded piece length")
	ErrCodingVectorLengthMismatch        = errors.New("coding vector length > coded piece length ( in total )")
	ErrPieceNotDecodedYet                = errors.New("piece not decoded yet, more pieces required")
	ErrPieceOutOfBound                   = errors.New("requested piece index >= pieceCount ( pieces coded together )")
)

Functions

This section is empty.

Types

type CodedPiece

type CodedPiece struct {
	Vector CodingVector
	Piece  Piece
}

Coded piece along with randomly generated coding vector to be used by recoder/ decoder

func CodedPiecesForRecoding

func CodedPiecesForRecoding(data []byte, pieceCount uint, piecesCodedTogether uint) ([]*CodedPiece, error)

Before recoding can be performed, coded pieces byte array i.e. []<< coding vector ++ coded piece >> where each coded piece is << coding vector ++ coded piece >> ( flattened ) is splitted into structured data i.e. into components {coding vector, coded piece}, where how many coded pieces are present in byte array ( read `data` ) & how many pieces are coded together ( read coding vector length ) are provided

func (*CodedPiece) Flatten

func (c *CodedPiece) Flatten() []byte

Flattens coded piece into single byte slice ( vector ++ piece ), so that decoding steps can be performed -- rref on received data matrix

func (*CodedPiece) IsSystematic

func (c *CodedPiece) IsSystematic() bool

Returns true if finds this piece is coded systematically i.e. piece is actually uncoded, just being augmented that it's coded which is why coding vector has only one non-zero element ( 1 )

func (*CodedPiece) Len

func (c *CodedPiece) Len() uint

Total length of coded piece --- len(coding_vector) + len(piece)

type CodingVector

type CodingVector []byte

One component of coded piece; holding information regarding how original pieces are combined together

func GenerateCodingVector

func GenerateCodingVector(n uint) CodingVector

Generates random coding vector of specified length

No specific randomization choice is made, default available source is used

type Piece

type Piece []byte

A piece of data is nothing but a byte array

func OriginalPiecesFromDataAndPieceCount

func OriginalPiecesFromDataAndPieceCount(data []byte, pieceCount uint) ([]Piece, uint, error)

When you want to split whole data chunk into N-many original pieces, this function will do it, while appending extra zero bytes ( read padding bytes ) at end of last piece if exact division is not feasible

func OriginalPiecesFromDataAndPieceSize

func OriginalPiecesFromDataAndPieceSize(data []byte, pieceSize uint) ([]Piece, uint, error)

Given whole chunk of data & desired size of each pieces ( in terms of bytes ), it'll split chunk into pieces, which are to be used by encoder for performing RLNC

In case whole data chunk can't be properly divided into pieces of requested size, extra zero bytes may be appended at end, considered as padding bytes --- given that each piece must be of same size

func (*Piece) Multiply

func (p *Piece) Multiply(piece Piece, by byte, field *galoisfield.GF)

Multiple pieces are coded together by performing symbol by symbol finite field arithmetic, where a single byte is a symbol

`by` is coding coefficient

Directories

Path Synopsis
galoisfield

Jump to

Keyboard shortcuts

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