node

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 28 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 NewTestTransport added in v0.2.0

func NewTestTransport(hid sessions.NodeID, helperSetupSrv *setup.Service, helperCompSrv *compute.Service) *testTransport

func ValidateConfig

func ValidateConfig(config Config, nl List) error

ValidateConfig checks that the configuration is valid.

Types

type Address added in v0.2.0

type Address string

Address is the network address of a node.

func (Address) String added in v0.2.0

func (na Address) String() string

String returns a string representation of the node address.

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                sessions.NodeID
	Address           Address
	HelperID          sessions.NodeID
	SessionParameters []sessions.Parameters
	SetupConfig       setup.ServiceConfig
	ComputeConfig     compute.ServiceConfig
	ObjectStoreConfig objectstore.Config
	TLSConfig         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 Coordinator added in v0.2.0

type Coordinator coordinator.Coordinator[Event]

type Event added in v0.2.0

type Event struct {
	SetupEvent   *setup.Event
	ComputeEvent *compute.Event
}

func (Event) IsCompute added in v0.2.0

func (ev Event) IsCompute() bool

func (Event) IsSetup added in v0.2.0

func (ev Event) IsSetup() bool

func (Event) String added in v0.2.0

func (ev Event) String() string

type Info added in v0.2.0

type Info struct {
	sessions.NodeID
	Address
}

Info contains the unique identifier and the network address of a node.

type List added in v0.2.0

type List []Info

List is a list of known nodes in the network. It must contains all nodes for a given application, including the current node. It does not need to contain an address for all nodes, except for the helper node.

func (List) AddressOf added in v0.2.0

func (nl List) AddressOf(id sessions.NodeID) Address

AddressOf returns the network address of the node with the given ID. Returns an empty string if the node is not found in the list.

func (List) String added in v0.2.0

func (nl List) String() string

String returns a string representation of the list of nodes.

type LocalTest

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

	*sessions.TestSession
	HelperConfig    Config
	SessNodeConfigs []Config
	List
	// contains filtered or unexported fields
}

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() []sessions.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() []sessions.NodeID

type LocalTestConfig

type LocalTestConfig struct {
	PeerNodes         int // Number of peer nodes in the session
	SessionParams     *sessions.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 List) (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 (*Node) Address added in v0.2.0

func (node *Node) Address() Address

Address returns the node's address.

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 sessions.CiphertextID) (*sessions.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) 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) GetOperand added in v0.2.0

func (node *Node) GetOperand(opl circuits.OperandLabel) (*circuits.Operand, bool)

func (*Node) GetParameters added in v0.2.0

func (node *Node) GetParameters(ctx context.Context) (sessions.FHEParameters, error)

GetParameters returns the parameters from the context's session.

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) (*sessions.Session, bool)

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

func (*Node) GetSessionFromID

func (node *Node) GetSessionFromID(sessionID sessions.ID) (*sessions.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() sessions.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() List

NodeList returns the list of nodes known to the node.

func (*Node) PutCiphertext

func (node *Node) PutCiphertext(ctx context.Context, ct sessions.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) PutOperand added in v0.2.0

func (node *Node) PutOperand(opl circuits.OperandLabel, op *circuits.Operand) error

func (*Node) Register

func (node *Node) Register(peer sessions.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, upstream Coordinator, trans Transport) (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 sessions.NodeID) error

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

func (*Node) WaitForSetupDone

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

WaitForSetupDone blocks until the setup phase is done.

type ServicesCoordinator added in v0.2.0

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

type TLSConfig added in v0.2.0

type TLSConfig struct {
	InsecureChannels bool                       // if set, disables TLS authentication
	FromDirectory    string                     // path to a directory containing the TLS material as files
	PeerPKs          map[sessions.NodeID]string // Mapping of <node, pubKey> where pubKey is PEM encoded
	PeerCerts        map[sessions.NodeID]string // Mapping of <node, certifcate> where pubKey is PEM encoded ASN.1 DER string
	CACert           string                     // Root CA certificate as a PEM encoded ASN.1 DER string
	OwnCert          string                     // Own certificate as a PEM encoded ASN.1 DER string
	OwnPk            string                     // Own public key as a PEM encoded string
	OwnSk            string                     // Own secret key as a PEM encoded string
}

TLSConfig is a struct for specifying TLS-related configuration. TLS is not supported yet.

type Transport added in v0.2.0

type Transport interface {
	setup.Transport
	compute.Transport
}

Jump to

Keyboard shortcuts

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