encoders

package
v0.0.0-...-238a04e Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitVector

type BitVector struct {
	BitNumber uint64
	// contains filtered or unexported fields
}

BitVector - structure represents simple bit vector implementation

func CreateBitVectorFromDecimal

func CreateBitVectorFromDecimal(decimal uint64, numOfBits uint64) (result *BitVector)

CreateBitVectorFromDecimal - creates new bit vector and initializes it with given decimal value.

func CreateBitVectors

func CreateBitVectors(length uint64, initWithOne bool) (result *BitVector)

CreateBitVectors - creates bitvector with given length. Can be initialized with ones or zeroes

func (*BitVector) CopyTo

func (b *BitVector) CopyTo(from *BitVector)

CopyTo - copies values from one bit vector to another

func (*BitVector) CopyToRange

func (b *BitVector) CopyToRange(from *BitVector, numOfBits uint64)

CopyToRange - copies values from one bit vector to another but only given number of bits

func (*BitVector) GetBit

func (b *BitVector) GetBit(position uint64) (uint8, error)

GetBit - returns specific bit at given position

func (*BitVector) SetBit

func (b *BitVector) SetBit(position uint64, bit uint8) error

SetBit - sets a specific bit of a bit vector

func (*BitVector) ShiftToLeft

func (b *BitVector) ShiftToLeft(newBit uint8) error

ShiftToLeft - shiftInfVector(int *inf_vector, int newElem)

func (*BitVector) ShiftToRight

func (b *BitVector) ShiftToRight(newBit uint8) error

ShiftToRight siftuj(int *registar, int novaVrednost)

func (*BitVector) ToDecimal

func (b *BitVector) ToDecimal(numOfBits uint) uint64

ToDecimal - dummy

func (*BitVector) ToString

func (b *BitVector) ToString() string

ToString - prints the content of BitVector

type DesEncoder

type DesEncoder struct {
	EncoderImplementation
}

DesEncoder uses Des for encoding function

func (DesEncoder) EncodingFunction

func (d DesEncoder) EncodingFunction(key uint64, numOfBits uint64) uint64

EncodingFunction - implemented des for consensus algorithm

type Encoder

type Encoder interface {
	EncodingFunction(x uint64, numOfBits uint64) uint64
}

Encoder interface has EncodiningFunction that is used for consensus protocol. Various implementations can be created here: Grain, Des, TripleDes

func GetEncoder

func GetEncoder() Encoder

GetEncoder - function returns active encoder. Here, it should be changed for various implementations. Currently exists: GrainEncoder, DesEncoder,

TripleDesEncoder

type EncoderImplementation

type EncoderImplementation struct {
}

EncoderImplementation wrapper

type GrainEncoder

type GrainEncoder struct {
	EncoderImplementation
}

GrainEncoder encodingFunction

func (GrainEncoder) EncodingFunction

func (e GrainEncoder) EncodingFunction(key uint64, numOfBits uint64) uint64

EncodingFunction - final implementation of Grain used for consensus

type TripleDesEncoder

type TripleDesEncoder struct {
	EncoderImplementation
}

TripleDesEncoder uses TripleDes for encoding function

func (TripleDesEncoder) EncodingFunction

func (d TripleDesEncoder) EncodingFunction(key uint64, numOfBits uint64, isInit bool) uint64

EncodingFunction - tripleDes

Jump to

Keyboard shortcuts

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