relay

package
v0.0.0-...-465a192 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateHmac256

func ValidateHmac256(message, inputHmac []byte, clientID int) bool

ValidateHmac256 returns true iff the recomputed HMAC is equal to the given one

Types

type BlamingData

type BlamingData struct {
	RoundID            int32
	BitPos             int
	ClientID           int
	ClientBitRevealed  int
	TrusteeID          int
	TrusteeBitRevealed int
}

BlamingData is a struct used in the blame phase of the disruption protection. [round#, bitPos, clientID, bitRevealed, trusteeID, bitRevealed]

type BufferableRoundManager

type BufferableRoundManager struct {
	sync.Mutex

	//stop/resume functions when we have too much/little ciphers
	DoSendStopResumeMessages bool
	LowBound                 int //restart sending at lowerbound
	HighBound                int //stop sending at higherbound
	// contains filtered or unexported fields
}

Stores ciphers for different rounds. Manages the transition between rounds, the rate limiting of trustees

func NewBufferableRoundManager

func NewBufferableRoundManager(nClients, nTrustees, maxNumberOfConcurrentRounds int) *BufferableRoundManager

NewBufferableRoundManager creates a Round Manager that handles the buffering of cipher, the rounds and their transitions, and the rate-limiting

func (*BufferableRoundManager) AddClientCipher

func (b *BufferableRoundManager) AddClientCipher(roundID int32, clientID int, data []byte) error

AddClientCipher adds a client cipher for a given round

func (*BufferableRoundManager) AddRateLimiter

func (b *BufferableRoundManager) AddRateLimiter(lowBound, highBound int, stopFunction, resumeFunction func(int)) error

*

  • Adds a component to the BufferManager, that reacts to the # of buffered cipher (per trustees), and call stopFn()
  • and resumeFn() when the bounds are reached

func (*BufferableRoundManager) AddTrusteeCipher

func (b *BufferableRoundManager) AddTrusteeCipher(roundID int32, trusteeID int, data []byte) error

AddTrusteeCipher adds a trustee cipher for a given round

func (*BufferableRoundManager) CloseRound

func (b *BufferableRoundManager) CloseRound() error

CloseRound finalizes this round, returning all ciphers stored, then increasing the round number. Should only be called when HasAllCiphersForCurrentRound() == true

func (*BufferableRoundManager) CollectRoundData

func (b *BufferableRoundManager) CollectRoundData() ([][]byte, [][]byte, error)

CloseRound finalizes this round, returning all ciphers stored, then increasing the round number. Should only be called when HasAllCiphersForCurrentRound() == true

func (*BufferableRoundManager) CurrentRound

func (b *BufferableRoundManager) CurrentRound() int32

CurrentRound returns the current round, ie the smallest open round, or returns (false, -1) if no rounds are open

func (*BufferableRoundManager) Dump

func (b *BufferableRoundManager) Dump()

Dump prints the contents of this BufferableRoundManager

func (*BufferableRoundManager) ForceCloseRound

func (b *BufferableRoundManager) ForceCloseRound() error

CloseRound finalizes this round, returning all ciphers stored, then increasing the round number. Should only be called when HasAllCiphersForCurrentRound() == true

func (*BufferableRoundManager) GetDataAlreadySent

func (b *BufferableRoundManager) GetDataAlreadySent(roundID int32) *net.REL_CLI_DOWNSTREAM_DATA

GetDataAlreadySent gets the "DataAlreadySent" field for the given round

func (*BufferableRoundManager) HasAllCiphersForCurrentRound

func (b *BufferableRoundManager) HasAllCiphersForCurrentRound() bool

HasAllCiphersForCurrentRound returns true iff we received exactly one cipher for every client and trustee for this round

func (*BufferableRoundManager) IsNextDownstreamRoundForOpenClosedRequest

func (b *BufferableRoundManager) IsNextDownstreamRoundForOpenClosedRequest(nClients int) bool

IsNextDownstreamRoundForOpenClosedRequest return true if the next downstream round should have flagOpenCloseScheduleRequest == true

func (*BufferableRoundManager) IsRoundOpenend

func (b *BufferableRoundManager) IsRoundOpenend(roundID int32) bool

IsRoundOpenend checks if we are in the given round (ie, used to check if we are stuck)

func (*BufferableRoundManager) MemoryUsage

func (b *BufferableRoundManager) MemoryUsage()

Dumps precise statistics about the memory used by this datastructure

func (*BufferableRoundManager) MissingCiphersForCurrentRound

func (b *BufferableRoundManager) MissingCiphersForCurrentRound() ([]int, []int)

MissingCiphersForCurrentRound returns a pair of (clientIDs, trusteesIDs) where those entities did not send a cipher for this round

func (*BufferableRoundManager) NextDownstreamRoundForOpenClosedRequest

func (b *BufferableRoundManager) NextDownstreamRoundForOpenClosedRequest() int32

NextDownstreamRoundForOpenClosedRequest return the next downstream round should have flagOpenCloseScheduleRequest == true

func (*BufferableRoundManager) NextRoundToOpen

func (b *BufferableRoundManager) NextRoundToOpen() int32

NextRoundToOpen returns the next round to open as RoundID. If none are open, uses the "lastRoundClosed"+1.

func (*BufferableRoundManager) NumberOfBufferedCiphers

func (b *BufferableRoundManager) NumberOfBufferedCiphers(trusteeID int) int

NumberOfBufferedCiphers returns the number of buffered ciphers for this trustee.

func (*BufferableRoundManager) OpenNextRound

func (b *BufferableRoundManager) OpenNextRound() int32

Open next round, fetch the buffered ciphers, reset the ACK map

func (*BufferableRoundManager) SetDataAlreadySent

func (b *BufferableRoundManager) SetDataAlreadySent(roundID int32, data *net.REL_CLI_DOWNSTREAM_DATA)

SetDataAlreadySent sets the "DataAlreadySent" field for the given round

func (*BufferableRoundManager) SetStoredRoundSchedule

func (b *BufferableRoundManager) SetStoredRoundSchedule(s map[int]bool)

SetStoredRoundSchedule stores the schedule, and resets the nextOwner to be 0

func (*BufferableRoundManager) TimeSpentInRound

func (b *BufferableRoundManager) TimeSpentInRound(roundID int32) time.Duration

return the time delta since the creation of the DCNetRound struct

func (*BufferableRoundManager) UpdateAndGetNextOwnerID

func (b *BufferableRoundManager) UpdateAndGetNextOwnerID() int

UpdateAndGetNextOwnerID returns the next slot owner.

type NodeRepresentation

type NodeRepresentation struct {
	ID                 int
	Connected          bool
	PublicKey          kyber.Point
	EphemeralPublicKey kyber.Point
}

NodeRepresentation regroups the information about one client or trustee.

type PriFiLibRelayInstance

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

PriFiLibInstance contains the mutable state of a PriFi entity.

func NewRelay

func NewRelay(dataOutputEnabled bool, dataForClients chan []byte, dataFromDCNet chan []byte, experimentResultChan chan interface{}, timeoutHandler func([]int, []int), msgSender *net.MessageSenderWrapper) *PriFiLibRelayInstance

NewPriFiRelay creates a new PriFi relay entity state. Note: the returned state is not sufficient for the PrFi protocol to start; this entity will expect a ALL_ALL_PARAMETERS message as first received message to complete it's state.

func (*PriFiLibRelayInstance) BroadcastParameters

func (p *PriFiLibRelayInstance) BroadcastParameters() error

ConnectToTrustees connects to the trustees and initializes them with default parameters.

func (*PriFiLibRelayInstance) ReceivedMessage

func (p *PriFiLibRelayInstance) ReceivedMessage(msg interface{}) error

ReceivedMessage must be called when a PriFi host receives a message. It takes care to call the correct message handler function.

func (*PriFiLibRelayInstance) Received_ALL_ALL_PARAMETERS

func (p *PriFiLibRelayInstance) Received_ALL_ALL_PARAMETERS(msg net.ALL_ALL_PARAMETERS) error

Received_ALL_REL_PARAMETERS handles ALL_REL_PARAMETERS. It initializes the relay with the parameters contained in the message.

func (*PriFiLibRelayInstance) Received_ALL_ALL_SHUTDOWN

func (p *PriFiLibRelayInstance) Received_ALL_ALL_SHUTDOWN(msg net.ALL_ALL_SHUTDOWN) error

Received_ALL_REL_SHUTDOWN handles ALL_REL_SHUTDOWN messages. When we receive this message, we should warn other protocol participants and clean resources.

func (*PriFiLibRelayInstance) Received_CLI_REL_DISRUPTION_BLAME

func (p *PriFiLibRelayInstance) Received_CLI_REL_DISRUPTION_BLAME(msg net.CLI_REL_DISRUPTION_BLAME) error

Received_CLI_REL_BLAME

func (*PriFiLibRelayInstance) Received_CLI_REL_DISRUPTION_REVEAL

func (p *PriFiLibRelayInstance) Received_CLI_REL_DISRUPTION_REVEAL(msg net.CLI_REL_DISRUPTION_REVEAL) error

* Received_CLI_REL_DISRUPTION_REVEAL handles CLI_REL_DISRUPTION_REVEAL messages * First, saves the bits reveal by the client. * It checks that the bits received by the client matches with the ones of the disruptive round. * For this it XORs the bits revealed together and compares it to the bit in the disruptive position. * If there is a mismatch, the client is the disruptor. * Else checks if all the reveals are received to move to next blame phase.

func (*PriFiLibRelayInstance) Received_CLI_REL_OPENCLOSED_DATA

func (p *PriFiLibRelayInstance) Received_CLI_REL_OPENCLOSED_DATA(msg net.CLI_REL_OPENCLOSED_DATA) error

Received_CLI_REL_OPENCLOSED_DATA handles the reception of the OpenClosed map, which details which pseudonymous clients want to transmit in a given round

func (*PriFiLibRelayInstance) Received_CLI_REL_SHARED_SECRET

func (p *PriFiLibRelayInstance) Received_CLI_REL_SHARED_SECRET(msg net.CLI_REL_SHARED_SECRET) error

Received_CLI_REL_SHARED_SECRET handles CLI_REL_SECRET messages Check the NIZK, if correct regenerate the cipher up to the disrupted round and check if this client is the disruptor

func (*PriFiLibRelayInstance) Received_CLI_REL_TELL_PK_AND_EPH_PK

func (p *PriFiLibRelayInstance) Received_CLI_REL_TELL_PK_AND_EPH_PK(msg net.CLI_REL_TELL_PK_AND_EPH_PK) error

Received_CLI_REL_TELL_PK_AND_EPH_PK handles CLI_REL_TELL_PK_AND_EPH_PK messages. Those are sent by the client to tell their identity. We do nothing until we have collected one per client; then, we pack them in one message and send them to the first trustee for it to Neff-Shuffle them.

func (*PriFiLibRelayInstance) Received_CLI_REL_UPSTREAM_DATA

func (p *PriFiLibRelayInstance) Received_CLI_REL_UPSTREAM_DATA(msg net.CLI_REL_UPSTREAM_DATA) error

Received_CLI_REL_UPSTREAM_DATA handles CLI_REL_UPSTREAM_DATA messages and is part of PriFi's main loop. This is what happens in one round, for the relay. We receive some upstream data. If we have collected data from all entities for this round, we can call DecodeCell() and get the output. If we get data for another round (in the future) we should buffer it. If we finished a round (we had collected all data, and called DecodeCell()), we need to finish the round by sending some data down. Either we send something from the SOCKS/VPN buffer, or we answer the latency-test message if we received any, or we send 1 bit.

func (*PriFiLibRelayInstance) Received_TRU_REL_DC_CIPHER

func (p *PriFiLibRelayInstance) Received_TRU_REL_DC_CIPHER(msg net.TRU_REL_DC_CIPHER) error

Received_TRU_REL_DC_CIPHER handles TRU_REL_DC_CIPHER messages. Those contain a DC-net cipher from a Trustee. If it's for this round, we call decode on it, and remember we received it. If for a future round we need to Buffer it.

func (*PriFiLibRelayInstance) Received_TRU_REL_DISRUPTION_REVEAL

func (p *PriFiLibRelayInstance) Received_TRU_REL_DISRUPTION_REVEAL(msg net.TRU_REL_DISRUPTION_REVEAL) error

* Received_TRU_REL_DISRUPTION_REVEAL handles TRU_REL_DISRUPTION_REVEAL messages * First, saves the bits reveal by the trustee. * It checks that the bits received by the trustee matches with the ones of the disruptive round. * For this it XORs the bits revealed together and compares it to the bit in the disruptive position. * If there is a mismatch, the trustee is the disruptor. * Else checks if all the reveals are received to move to next blame phase.

func (*PriFiLibRelayInstance) Received_TRU_REL_SHARED_SECRETS

func (p *PriFiLibRelayInstance) Received_TRU_REL_SHARED_SECRETS(msg net.TRU_REL_SHARED_SECRET) error

Received_TRU_REL_SHARED_SECRETS handles TRU_REL_SECRET messages Check the NIZK, if correct regenerate the cipher up to the disrupted round and check if this trustee is the disruptor

func (*PriFiLibRelayInstance) Received_TRU_REL_SHUFFLE_SIG

func (p *PriFiLibRelayInstance) Received_TRU_REL_SHUFFLE_SIG(msg net.TRU_REL_SHUFFLE_SIG) error

Received_TRU_REL_SHUFFLE_SIG handles TRU_REL_SHUFFLE_SIG messages. Those contain the signature from the NeffShuffleS-transcript from one trustee. We do nothing until we have all signatures; when we do, we pack those in one message with the result of the Neff-Shuffle and send them to the clients. When this is done, we are finally ready to communicate. We wait for the client's messages.

func (*PriFiLibRelayInstance) Received_TRU_REL_TELL_NEW_BASE_AND_EPH_PKS

func (p *PriFiLibRelayInstance) Received_TRU_REL_TELL_NEW_BASE_AND_EPH_PKS(msg net.TRU_REL_TELL_NEW_BASE_AND_EPH_PKS) error

Received_TRU_REL_TELL_NEW_BASE_AND_EPH_PKS handles TRU_REL_TELL_NEW_BASE_AND_EPH_PKS messages. Those are sent by the trustees once they finished a Neff-Shuffle. In that case, we forward the result to the next trustee. We do nothing until the last trustee sends us this message. When this happens, we pack a transcript, and broadcast it to all the trustees who will sign it.

func (*PriFiLibRelayInstance) Received_TRU_REL_TELL_PK

func (p *PriFiLibRelayInstance) Received_TRU_REL_TELL_PK(msg net.TRU_REL_TELL_PK) error

Received_TRU_REL_TELL_PK handles TRU_REL_TELL_PK messages. Those are sent by the trustees message when we connect them. We do nothing, until we have received one per trustee; Then, we pack them in one message, and broadcast it to the clients.

type RelayState

type RelayState struct {
	DCNet *dcnet.DCNetEntity

	DataForClients            chan []byte // VPN / SOCKS should put data there !
	HashOfLastUpstreamMessage [32]byte
	PriorityDataForClients    chan []byte
	DataFromDCNet             chan []byte // VPN / SOCKS should read data from there !
	DataOutputEnabled         bool        // If FALSE, nothing will be written to DataFromDCNet
	DownstreamCellSize        int
	MessageHistory            kyber.XOF
	Name                      string

	PublicKey            kyber.Point
	ExperimentRoundLimit int

	PayloadSize        int
	UseDummyDataDown   bool
	UseOpenClosedSlots bool
	UseUDP             bool

	WindowSize              int
	ExperimentResultChannel chan interface{}
	ExperimentResultData    []string

	DisruptionProtectionEnabled            bool
	OpenClosedSlotsMinDelayBetweenRequests int
	OpenClosedSlotsRequestsRoundID         map[int32]bool // contains roundID -> true if that round should be a OC slot request

	MaxNumberOfConsecutiveFailedRounds int // Kill the protocol if that many rounds fail consecutively
	ProcessingLoopSleepTime            int
	RoundTimeOut                       int //The timeout before retransmission (UDP) and/or considering the round failed
	TrusteeCacheLowBound               int // Number of ciphertexts buffered by trustees. When <= TRUSTEE_CACHE_LOWBOUND, resume sending
	TrusteeCacheHighBound              int // Number of ciphertexts buffered by trustees. When >= TRUSTEE_CACHE_HIGHBOUND, stop sending
	EquivocationProtectionEnabled      bool

	//disruption protection
	LastMessageOfClients       map[int32][]byte
	BEchoFlags                 map[int32]byte
	CiphertextsHistoryTrustees map[int32]map[int32][]byte
	CiphertextsHistoryClients  map[int32]map[int32][]byte
	DisruptionReveal           bool

	EphemeralPublicKeys []kyber.Point

	//disruption testing
	ForceDisruptionSinceRound3 bool

	//Used for verifiable DC-net, part of the dcnet.old/owned.go
	VerifiableDCNetKeys [][]byte
	// contains filtered or unexported fields
}

RelayState contains the mutable state of the relay.

Jump to

Keyboard shortcuts

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