node

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package node provides the main entry point for the Helium library. It defines the Node type, which implements the parties in the MHE-based MPC procotoles.

The current implementation specifically targets the helper-assisted setting, in which a single helper node coordinates the execution of the setup and compute phases, and serves as an aggregator and circuit evaluator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateConfig

func ValidateConfig(config Config, nl helium.NodesList) error

ValidateConfig checks that the configuration is valid.

Types

type App

type App struct {
	SetupDescription *setup.Description
	Circuits         map[circuits.Name]circuits.Circuit
}

App represents an Helium application. It specifes the setup phase and declares the circuits that can be executed by the nodes.

type Config

type Config struct {
	ID                helium.NodeID
	Address           helium.NodeAddress
	HelperID          helium.NodeID
	SessionParameters []session.Parameters
	SetupConfig       setup.ServiceConfig
	ComputeConfig     compute.ServiceConfig
	ObjectStoreConfig objectstore.Config
	TLSConfig         centralized.TLSConfig
}

Config is the configuration of a node. The struct is meant to be encoded and decoded to JSON with the standard library's encoding/json package.

In the current implementation, only a single session per node is supported.

func LoadConfigFromFile

func LoadConfigFromFile(filename string) (Config, error)

LoadConfigFromFile loads a node configuration from a JSON file.

type LocalTest

type LocalTest struct {
	Nodes      []*Node
	PeerNodes  []*Node
	HelperNode *Node
	Params     bgv.Parameters

	*session.TestSession
	HelperConfig    Config
	SessNodeConfigs []Config
	helium.NodesList
}

LocalTest represent a local test setting with several nodes and a single session with group secret key.

func NewLocalTest

func NewLocalTest(config LocalTestConfig) (test *LocalTest, err error)

NewLocalTest creates a new LocalTest from the configuration and returns it.

func (LocalTest) Close

func (lc LocalTest) Close() error

Close releases all the resources allocated by a localtest.

func (LocalTest) NodeIds

func (lc LocalTest) NodeIds() []helium.NodeID

NodeIds returns the node ideas of all nodes in the local test.

func (LocalTest) SessionNodes

func (lc LocalTest) SessionNodes() []*Node

SessionNodes returns the set of nodes in the local test that are part of the session.

func (LocalTest) SessionNodesIds

func (lc LocalTest) SessionNodesIds() []helium.NodeID

func (LocalTest) Start

func (lc LocalTest) Start()

Start creates some in-memory connections between the nodes and returns when all nodes are connected.

type LocalTestConfig

type LocalTestConfig struct {
	PeerNodes         int // Number of peer nodes in the session
	SessionParams     *session.Parameters
	InsecureChannels  bool                // use TLS for this test. TODO: fix TLS
	ObjectStoreConfig *objectstore.Config // nodes's object store configuration for this test
}

LocalTestConfig is a configuration structure for LocalTest types.

type Node

type Node struct {
	objectstore.ObjectStore
	// contains filtered or unexported fields
}

Node represents a Helium node. It is the main entry point for the Helium library. The node is responsible for managing the setup and compute services, and instantiates the transport layer.

Two types of nodes are supported in the current implementation:

  • the helper node coordinates the execution of the setup and compute phases, and serves a an aggregator and circuit evaluator. The helper node must have an address.
  • the peer nodes connect to the helper node and provide their protocol shares and encrypted inputs to the compuation. Peer nodes do not need to have an address.

func New

func New(config Config, nodeList helium.NodesList) (node *Node, err error)

New creates a new Helium node from the provided config and node list. The method returns an error if the config is invalid or if the node list is empty.

func RunNew

func RunNew(ctx context.Context, config Config, nodeList helium.NodesList, app App, ip compute.InputProvider) (node *Node, cdescs chan<- circuits.Descriptor, outs <-chan circuits.Output, err error)

RunNew creates a new Helium node from the provided config and node list, and runs the node with the provided app under the given context.

func (*Node) Close

func (node *Node) Close() error

Close releases all the resources allocated by the node. If the node is the helper node, it stops the server and waits for the peers to disconnect.

func (*Node) Connect

func (node *Node) Connect(ctx context.Context) error

Connect connects the node's transport layer to the network. If the node has an address, it starts a server at the address. If the node does not have an address, it connects to the helper node.

func (*Node) GetAggregationOutput

func (node *Node) GetAggregationOutput(ctx context.Context, pd protocols.Descriptor) (*protocols.AggregationOutput, error)

GetAggregationOutput returns the aggregation output for a given protocol descriptor. If this node is the helper node, the method retrieves the output from the services. If this node is a peer node, the method retrieves the output from the helper node.

func (*Node) GetCiphertext

func (node *Node) GetCiphertext(ctx context.Context, ctID helium.CiphertextID) (*helium.Ciphertext, error)

GetCiphertext returns a ciphertext from the compute service. If this node is the helper node, the method retrieves the ciphertext from the service. If this node is a peer node, the method retrieves the ciphertext from the helper node.

func (*Node) GetCollectivePublicKey

func (node *Node) GetCollectivePublicKey(ctx context.Context) (*rlwe.PublicKey, error)

GetCollectivePublicKey returns the collective public key.

func (*Node) GetDecryptor

func (node *Node) GetDecryptor(ctx context.Context) (*rlwe.Decryptor, error)

GetDecryptor returns a lattigo decryptor from the context's session. The decryptor is initialized with the node's secret key.

func (*Node) GetEncoder

func (node *Node) GetEncoder(ctx context.Context) (*bgv.Encoder, error)

GetEncoder returns a lattigo encoder from the context's session.

func (*Node) GetEncryptor

func (node *Node) GetEncryptor(ctx context.Context) (*rlwe.Encryptor, error)

GetEncryptor returns a lattigo encryptor from the context's session. The encryptor is initialized with the collective public key.

func (*Node) GetGaloisKey

func (node *Node) GetGaloisKey(ctx context.Context, galEl uint64) (*rlwe.GaloisKey, error)

GetGaloisKey returns the Galois keys for galois element galEl.

func (*Node) GetNetworkStats

func (node *Node) GetNetworkStats() centralized.NetStats

func (*Node) GetRelinearizationKey

func (node *Node) GetRelinearizationKey(ctx context.Context) (*rlwe.RelinearizationKey, error)

GetRelinearizationKey returns the relinearization key.

func (*Node) GetSessionFromContext

func (node *Node) GetSessionFromContext(ctx context.Context) (*session.Session, bool)

GetSessionFromContext returns the session by extracting the session id from the provided context.

func (*Node) GetSessionFromID

func (node *Node) GetSessionFromID(sessionID helium.SessionID) (*session.Session, bool)

GetSessionFromID returns the session with the given ID.

func (*Node) HasAddress

func (node *Node) HasAddress() bool

HasAddress returns true if the node has an address.

func (*Node) ID

func (node *Node) ID() helium.NodeID

ID returns the node's ID.

func (*Node) IsHelperNode

func (node *Node) IsHelperNode() bool

IsHelperNode returns true if the node is the helper node.

func (*Node) Logf

func (node *Node) Logf(msg string, v ...any)

Logf writes a log line with the provided message.

func (*Node) NodeList

func (node *Node) NodeList() helium.NodesList

NodeList returns the list of nodes known to the node.

func (*Node) PutCiphertext

func (node *Node) PutCiphertext(ctx context.Context, ct helium.Ciphertext) error

PutCiphertext registers a new ciphertext for the compute service. If this node is the helper node, the method registers the ciphertext with the service. If this node is a peer node, the method sends the ciphertext to the helper node.

func (*Node) PutShare

func (node *Node) PutShare(ctx context.Context, s protocols.Share) error

PutShare is called by the transport upon receiving a new share.

func (*Node) Register

func (node *Node) Register(peer helium.NodeID) error

Register is called by the transport upon connection of a new peer node.

func (*Node) Run

func (node *Node) Run(ctx context.Context, app App, ip compute.InputProvider) (cdescs chan<- circuits.Descriptor, outs <-chan circuits.Output, err error)

Run runs the node with the provided app under the given context. The method returns channels to send circuit descriptors and receive circuit outputs.

In the current implementation:

  • the method runs the setup and compute phases sequentially.
  • only the helper node can issue circuit descriptors.
  • loading and verification of the state from persistent storage is not implemented.

func (*Node) Unregister

func (node *Node) Unregister(peer helium.NodeID) error

Unregister is called by the transport upon disconnection of a peer node.

func (*Node) WaitForSetupDone

func (node *Node) WaitForSetupDone()

WaitForSetupDone blocks until the setup phase is done.

Jump to

Keyboard shortcuts

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