util

package
v0.0.0-...-87ea4a5 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Network = "tcp4" // Type of network, choices are in net.DialTCP

	PortsPerCarrier = 3 // Used by the config generator to know how many ports to reserve for each carrier

	//LogTimeFormat = zerolog.TimeFormatUnixMs
	LogTimeFormat = time.RFC3339
)

Variables

This section is empty.

Functions

func Build

func Build(Vb []byte, tsxSize int) [][]byte

func DecodeStringToBdn

func DecodeStringToBdn(sk, pk string) (kyber.Scalar, kyber.Point, error)

func DecodeStringToBdnPK

func DecodeStringToBdnPK(pk string) (kyber.Point, error)

func DecodeStringToBdnSK

func DecodeStringToBdnSK(sk string) (kyber.Scalar, error)

func DialTCP

func DialTCP(raddr *net.TCPAddr) (*net.TCPConn, error)

DialTCP Simple wrapper around net.DialTCP

func EncodeBdnToString

func EncodeBdnToString(sk kyber.Scalar, pk kyber.Point) (string, string, error)

func EncodeBdnToStringPk

func EncodeBdnToStringPk(pk kyber.Point) (string, error)

func EncodeBdnToStringSk

func EncodeBdnToStringSk(sk kyber.Scalar) (string, error)

func Frame

func Frame(buf []byte) []byte

func ListenTCP

func ListenTCP(laddr *net.TCPAddr) (*net.TCPListener, error)

ListenTCP Simple wrawpper around net.ListenTCP

func MarshalUInt32

func MarshalUInt32(n uint32) []byte

MarshalUInt32 returns a byte array of length 8 in little-endian encoding

func MarshalUInt64

func MarshalUInt64(n uint64) []byte

MarshalUInt64 returns a byte array of length 8 in little-endian encoding

func ResolveTCPAddr

func ResolveTCPAddr(address string) (*net.TCPAddr, error)

ResolveTCPAddr Simple wrapper around net.ResolveTCPAddr

func UnmarshalUInt32

func UnmarshalUInt32(buf []byte) uint32

func UnmarshalUInt64

func UnmarshalUInt64(buf []byte) uint64

func WriteKeypairFile

func WriteKeypairFile(f string, kp *KeyPairString) error

Types

type Addresses

type Addresses struct {
	Client   string `json:"client"`
	Carrier  string `json:"carrier"`
	Front    string `json:"front"`
	Decision string `json:"decision"`
}

type Config

type Config struct {
	ID         string        `json:"id"`
	Addresses  Addresses     `json:"addresses"`
	Keys       KeyPairString `json:"keys"`
	Neighbours []Neighbour   `json:"neighbours"`
	Settings   Settings      `json:"settings"`
}

func LoadConfig

func LoadConfig(file string) (*Config, error)

type KeyPair

type KeyPair struct {
	Name string
	Sk   kyber.Scalar
	Pk   kyber.Point
}

func NewKeyPair

func NewKeyPair(sk kyber.Scalar, pk kyber.Point) *KeyPair

func (*KeyPair) Convert

func (kp *KeyPair) Convert() (*KeyPairString, error)

type KeyPairString

type KeyPairString struct {
	Sk string `json:"sk"`
	Pk string `json:"pk"`
}

func GenerateRandomKeypair

func GenerateRandomKeypair() (*KeyPairString, error)

func ReadKeypairFile

func ReadKeypairFile(f string) (*KeyPairString, error)

func (*KeyPairString) Convert

func (kpstr *KeyPairString) Convert() (*KeyPair, error)

type Neighbour

type Neighbour struct {
	ID      string `json:"id"`
	Address string `json:"address"`
	PK      string `json:"pk"`
}

type Params

type Params struct {
	Hosts    []string `json:"hosts"`
	Fronts   []string `json:"fronts"`
	Settings Settings `json:"settings"`
}

func LoadParams

func LoadParams(file string) (*Params, error)

type Settings

type Settings struct {
	TsxSize int `json:"tsx-size"`
	Rate    int `json:"rate"`
	Nodes   int `json:"nodes"`

	DecisionPort int `json:"decision-port"`
	ClientPort   int `json:"client-port"`
	CarrierPort  int `json:"carrier-port"`

	InitThreshold int    `json:"init-threshold"`
	ForwardMode   int    `json:"forward-mode"`
	LogLevel      string `json:"log-level"`

	CarrierConnRetryDelay int `json:"carrier-conn-retry-delay"`
	CarrierConnMaxRetry   int `json:"carrier-conn-max-retry"`
	NodeConnRetryDelay    int `json:"node-conn-retry-delay"`
	NodeConnMaxRetry      int `json:"node-conn-max-retry"`

	LocalBasePort  int `json:"local-base-port"`
	LocalFrontPort int `json:"local-front-port"`
}

func NewSettings

func NewSettings() Settings

type Signature

type Signature struct {
	S        string `json:"s"`
	SenderID string `json:"sender-id"`
}

Jump to

Keyboard shortcuts

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