common

package
v0.0.0-...-57ac6aa Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-2-Clause Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const EnvPrefix = "TALEK"

EnvPrefix defines the prefix for environment variables

View Source
const MsgMaxFragments = 128

MsgMaxFragments defines the maximum number of cells a message can span

Variables

This section is empty.

Functions

func RPCCall

func RPCCall(address string, methodName string, args interface{}, reply interface{}) error

RPCCall Makes a JSON RPC client.

func SilenceLoggers

func SilenceLoggers()

SilenceLoggers will disable all loggers created with this library

Types

type BatchReadReply

type BatchReadReply struct {
	Err     string
	Replies []ReadReply
}

BatchReadReply is a response to a BatchReadRequest.

type BatchReadRequest

type BatchReadRequest struct {
	Args       []EncodedReadArgs // Set of Read requests
	SeqNoRange Range
	ReplyChan  chan *BatchReadReply `json:"-"`
}

BatchReadRequest are a batch of requests sent to PIR servers from frontend.

type Config

type Config struct {
	// How many buckets are in the server?
	NumBuckets uint64
	// How many items are in a bucket?
	BucketDepth uint64
	// How many bytes are in an item?
	DataSize uint64 // Number of bytes
	// False positive rate of interest vectors
	BloomFalsePositive float64
	// Minimum period between writes
	WriteInterval time.Duration `json:",string"`
	// Minimum period between reads
	ReadInterval time.Duration `json:",string"`
	// On what multiple of write intervals will new interest vectors be computed
	InterestMultiple uint64
	// Base seed for hashing interest vectors
	InterestSeed int64
	// Max fraction of DB capacity that can store messages
	MaxLoadFactor float64

	/** @todo remove below **/
	// What fraction of items should be removed from the DB when items are removed?
	LoadFactorStep float64
}

Config is a shared configuration needed by both libtalek and server

func ConfigFromFile

func ConfigFromFile(file string) *Config

ConfigFromFile restores a JSON file. returns the config on success or nil if loading or parsing the file fails.

func (*Config) WindowSize

func (cc *Config) WindowSize() uint64

WindowSize is a computed property of Config for how many items are available at a time

type EncodedReadArgs

type EncodedReadArgs struct {
	ClientKey [32]byte
	Nonce     [24]byte
	PirArgs   [][]byte //An encrypted PirArgs for each trust domain
}

EncodedReadArgs are a trust-domain-encrypted form of ReadArgs

func (*EncodedReadArgs) Decode

func (r *EncodedReadArgs) Decode(id int, trustDomain *TrustDomainConfig) (out PirArgs, err error)

Decode decrypts a specific trust domain of encoded args to recover the pad and request vector.

type Error

type Error string

Error provides RPC errors as strings.

type FrontendInterface

type FrontendInterface interface {
	GetName(args *interface{}, reply *string) error
	GetConfig(args *interface{}, reply *Config) error
	Write(args *WriteArgs, reply *WriteReply) error
	Read(args *EncodedReadArgs, reply *ReadReply) error
	GetUpdates(args *GetUpdatesArgs, reply *GetUpdatesReply) error
}

FrontendInterface is the interface between libtalek and the frontend

type FrontendRPC

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

FrontendRPC is a stub for RPCs to the talek server.

func NewFrontendRPC

func NewFrontendRPC(name string, address string) *FrontendRPC

NewFrontendRPC instantiates a LeaderRPC stub

func (*FrontendRPC) GetConfig

func (f *FrontendRPC) GetConfig(_ *interface{}, reply *Config) error

GetConfig tells the client about current config.

func (*FrontendRPC) GetName

func (f *FrontendRPC) GetName(_ *interface{}, reply *string) error

GetName returns the name of the leader.

func (*FrontendRPC) GetUpdates

func (f *FrontendRPC) GetUpdates(args *GetUpdatesArgs, reply *GetUpdatesReply) error

GetUpdates provides the global interest vector.

func (*FrontendRPC) Read

func (f *FrontendRPC) Read(args *EncodedReadArgs, reply *ReadReply) error

func (*FrontendRPC) Write

func (f *FrontendRPC) Write(args *WriteArgs, reply *WriteReply) error

type GetUpdatesArgs

type GetUpdatesArgs struct {
}

GetUpdatesArgs is the empty pointer fullfilling the RPC calling convention.

type GetUpdatesReply

type GetUpdatesReply struct {
	Err            string
	InterestVector []byte
	Signature      [][32]byte
}

GetUpdatesReply has the interestvector response for a getupdates call

type Logger

type Logger struct {
	Trace *log.Logger
	Info  *log.Logger
	Warn  *log.Logger
	Error *log.Logger
	// contains filtered or unexported fields
}

Logger tracks status.

func NewLogger

func NewLogger(name string) *Logger

NewLogger makes a logger.

func (*Logger) Disable

func (l *Logger) Disable()

Disable will stop this logger from printing

func (*Logger) Enable

func (l *Logger) Enable()

Enable re-establishes the output for a logger

type PirArgs

type PirArgs struct {
	RequestVector []byte
	PadSeed       []byte
}

PirArgs have the actual PIR for shards to perform.

type PrivateTrustDomainConfig

type PrivateTrustDomainConfig struct {
	*TrustDomainConfig
	PrivateKey     [32]byte
	SignPrivateKey [64]byte
}

PrivateTrustDomainConfig allows export of the trust domain Private Key.

type Range

type Range struct {
	Start   uint64 //inclusive
	End     uint64 //exclusive
	Aborted []uint64
}

Range is a range of sequence numbers

func (*Range) Contains

func (r *Range) Contains(val uint64) bool

Contains checks subset inclusion of a range

func (*Range) Equals

func (r *Range) Equals(b Range) bool

Equals compares two ranges.

type ReadArgs

type ReadArgs struct {
	TD []PirArgs
}

ReadArgs have the ReadArgs for each trust domain in unencrypted form.

func (*ReadArgs) Bucket

func (r *ReadArgs) Bucket() int

Bucket returns the bucket index that a read requests, or -1 for invalid args.

func (*ReadArgs) Encode

func (r *ReadArgs) Encode(trustDomains []*TrustDomainConfig) (out EncodedReadArgs, err error)

Encode encrypts a read request for a given trust domain configuration.

type ReadReply

type ReadReply struct {
	Err            string
	Data           []byte
	GlobalSeqNo    Range
	LastInterestSN uint64
}

ReadReply contain the response to a read.

func (*ReadReply) Combine

func (r *ReadReply) Combine(other []byte) error

Combine xors two partial read replies together

type ReadRequest

type ReadRequest struct {
	Args      *EncodedReadArgs
	ReplyChan chan *ReadReply
}

ReadRequest is the actual request sent to the frontend from libtalek. response occurs on the provided replychan

func (*ReadRequest) Reply

func (r *ReadRequest) Reply(reply *ReadReply)

Reply returns the response to the client.

type ReplicaInterface

type ReplicaInterface interface {
	Write(args *ReplicaWriteArgs, reply *ReplicaWriteReply) error
	BatchRead(args *BatchReadRequest, reply *BatchReadReply) error
}

ReplicaInterface dictates the methods used for server-server communication in the Talek system

type ReplicaRPC

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

ReplicaRPC is a stub for the replica RPC interface

func NewReplicaRPC

func NewReplicaRPC(name string, config *TrustDomainConfig) *ReplicaRPC

NewReplicaRPC creates a new ReplicaRPC

func (*ReplicaRPC) BatchRead

func (r *ReplicaRPC) BatchRead(args *BatchReadRequest, reply *BatchReadReply) error

BatchRead performs a set of PIR reads.

func (*ReplicaRPC) Write

func (r *ReplicaRPC) Write(args *ReplicaWriteArgs, reply *ReplicaWriteReply) error

type ReplicaWriteArgs

type ReplicaWriteArgs struct {
	WriteArgs
	EpochFlag    bool
	InterestFlag bool
}

ReplicaWriteArgs forwards a client write from frontend to replicas.

type ReplicaWriteReply

type ReplicaWriteReply struct {
	Err         string
	GlobalSeqNo uint64
	InterestVec []byte
	Signature   []byte
}

ReplicaWriteReply contain return status of writes

type TrustDomainConfig

type TrustDomainConfig struct {
	Name          string
	Address       string
	IsValid       bool
	IsDistributed bool
	PublicKey     [32]byte // For PIR Encryption
	SignPublicKey [32]byte // For Signing Interest Vectors
	// contains filtered or unexported fields
}

TrustDomainConfig holds the keys for the different talek trust domains.

func NewTrustDomainConfig

func NewTrustDomainConfig(name string, address string, isValid bool,
	isDistributed bool) *TrustDomainConfig

NewTrustDomainConfig creates a TrustDomainConfig with a freshly generated keypair.

func (*TrustDomainConfig) GetAddress

func (td *TrustDomainConfig) GetAddress() (string, bool)

GetAddress returns the remote address of the TrustDomain

func (*TrustDomainConfig) GetName

func (td *TrustDomainConfig) GetName() (string, bool)

GetName provides the name of the trust domain.

func (*TrustDomainConfig) Private

Private exposes the Private key of a trust domain config for marshalling.

bytes, err := json.Marshal(trustdomainconfig.Private())

func (*TrustDomainConfig) UnmarshalJSON

func (td *TrustDomainConfig) UnmarshalJSON(marshaled []byte) error

UnmarshalJSON creates a TrustDomainConfig from a serialized form.

type WriteArgs

type WriteArgs struct {
	Bucket1        uint64
	Bucket2        uint64
	Data           []byte
	InterestVector []byte // sha256 hash - expect 32bytes
	//Internal
	GlobalSeqNo uint64
	ReplyChan   chan *WriteReply `json:"-"`
}

WriteArgs are passed in writes.

type WriteReply

type WriteReply struct {
	Err         string
	GlobalSeqNo uint64
}

WriteReply contain return status of writes

Jump to

Keyboard shortcuts

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