helium

package module
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

README

Helium

Helium is a secure multiparty computation (MPC) framework based on multiparty homomorphic encryption (MHE). The framework provides an interface for computing multiparty homorphic circuits and takes care of executing the necessary MHE protocols under the hood. It uses the Lattigo library for the M(HE) operations, and provides a built-in network transport layer based on gRPC. The framework currently supports the helper-assisted setting, where the parties in the MPC receive assistance from honest-but-curious server. The system and its operating principles are described in the paper: Helium: Scalable MPC among Lightweight Participants and under Churn.

Disclaimer: this is an highly experiental first release, aimed at providing a proof-of-concept. The code is expected to evolve without guaranteeing backward compatibility and it should not be used in a production setting.

Synopsis

Helium is a Go package that provides the types and methods to implement an end-to-end MHE application. Helium's two main types are:

  • The node.App type which lets the user define an application by specifying the circuits to be run.
  • The node.Node type which runs node.App applications by running the MHE setup phase and letting the user trigger circuit evaluations.

Here is an overview of an Helium application:

  // declares an helium application
  app = node.App{

    // describes the required MHE setup
    SetupDescription: &setup.Description{ Cpk: true, Rlk: true},
    
    // declares the application's circuits
    Circuits: map[circuits.Name]circuits.Circuit{
      "mul-2-dec": func(rt circuits.Runtime) error {
        in0, in1 := rt.Input("//p0/in"), rt.Input("//p1/in") // read the encrypted inputs from nodes p0 and p1

        // multiplies the inputs as a local operation
        opRes := rt.NewOperand("//eval/prod")
        if err := rt.EvalLocal(
          true, // circuit requires relin
          nil,  // circuit does not require any rotation
          func(eval he.Evaluator) error {
					  return eval.MulRelin(in0.Get().Ciphertext, in1.Get().Ciphertext,  opRes.Ciphertext)
				  }
        ); err != nil {
					return err
				}

        // decrypts the result with receiver "rec"
        return rt.DEC(opRes, "rec", map[string]string{
          "smudging": "40.0",
        })
      },
    },
  }

  inputProvider = func(ctx context.Context, cid session.CircuitID, ol circuits.OperandLabel, sess session.Session) (any, error) {
      // ... user-defined logic to provide input for a given circuit
  }

  ctx, config, nodelist := // ... (omitted config, usually loaded from files or command-line flags)

  var cdescs chan<- circuit.Descriptor
	var outs <-chan circuit.Output
	if nodeID == helperID {
    // the helper runs the server-side of helium
		cdescs, outs, err = centralized.RunHeliumServer(ctx, config, nodelist, app, inputProvider)
    
    // cdesc is a channel to send circuit evaluation request(s)
    cdescs <- circuits.Descriptor{
      Signature:   circuits.Signature{Name: circuits.Name("mul-4-dec")}, // evaluates circuit "mul-4-dec"
      CircuitID:   "mul-4-dec-0",                                        // as circuit  "mul-4-dec-0"
      // ... other runtime-specific info 
      }
	} else {
    // non-helper nodes run the client side
		outs, err = centralized.RunHeliumClient(ctx, config, nodelist, app, inputProvider)
	}
  // outs is a channel to recieve the evaluation(s) output(s)
  out <- outs 
  // ... 

A complete example application is available in the examples folder.

Features

The framework currently supports the following features:

  • N-out-of-N-threshold and T-out-of-N-threshold
  • Helper-assisted setting
  • Setup phase for any multiparty RLWE scheme suppported by Lattigo, compute phase for BGV.
  • Circuit evaluation with output to the input-parties (internal) and to the helper (external).

Current limitations:

  • This release does not fully implement the secure failure-handling mechanism of the Helium paper. The full implementation is currently being cleaned up and requires changes to the Lattigo library.
  • In the T-out-of-N setting, Helium assumes that the secret-key generation is already performed and that the user provides the generated secret-key. Implementing this phase in the framework is planned.
  • Altough supported by the MHE scheme, external computation-receiver other than the helper (ie., re-encryption under arbitrary public-keys) are not yet supported. Supporting this feature is expected soon as it is rather easy to implement.
  • The current version of Helium targets a proof of concept for lightweight MPC in the helper-assisted model. Altough most of the low-level code is already generic enough to support peer-to-peer applications, some more work on the high-level node implementation would be required to support fully it.

Roadmap: to come.

MHE-based MPC

Helium currently supports the MHE scheme and associated MPC protocol described in the paper "Multiparty Homomorphic Encryption from Ring-Learning-With-Errors" along with its extension to t-out-of-N-threshold encryption described in "An Efficient Threshold Access-Structure for RLWE-Based Multiparty Homomorphic Encryption". These schemes provide security against passive attackers that can corrupt up to t-1 of the input parties and can operate in various system models such as peer-to-peer, cloud-assisted or hybrid architecture.

The protocol consists in 2 main phases, the Setup phase and the Computation phase, as illustrated in the diagram below. The Setup phase is independent of the inputs and can be performed "offline". Its goal is to generate a collective public-key for which decryption requires collaboration among a parameterizable threshold number of parties. In the Computation phase, the parties provide their inputs encrypted under the generated collective key. Then, the circuit is homomorphically evaluated and the output is collaboratively re-encrypted to the receiver secret-key.

Issues & Contact

Please make use of Github's issue tracker for reporting bugs or ask questions. Feel free to contact me if you are interested in the project and would like to contribute. My contact email should be easy to find.

Citing Helium

@article{mouchet2024helium,
  title={Helium: Scalable MPC among Lightweight Participants and under Churn},
  author={Mouchet, Christian and Chatel, Sylvain and Pyrgelis, Apostolos and Troncoso, Carmela},
  journal={Cryptology ePrint Archive},
  year={2024}
}

Documentation

Overview

Package helium is the main entrypoint to the Helium library. It provides function to configure and run a Helium helper server and Helium clients.

Index

Constants

View Source
const (
	MaxMsgSize       = 1024 * 1024 * 32
	KeepaliveTime    = time.Second
	KeepaliveTimeout = time.Second
)
View Source
const (
	ClientConnectTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialer added in v0.2.0

type Dialer = func(c context.Context, addr string) (net.Conn, error)

Dialer is a function that returns a net.Conn to the provided address.

type HeliumClient added in v0.2.0

type HeliumClient struct {
	sessions.PublicKeyProvider

	*grpc.ClientConn
	pb.HeliumClient
	// contains filtered or unexported fields
}

HeliumClient is a client for the helium service. It is used by peer nodes to communicate with the helium server.

func NewHeliumClient added in v0.2.0

func NewHeliumClient(node *node.Node, helperID sessions.NodeID, helperAddress node.Address) *HeliumClient

NewHeliumClient creates a new helium client.

func RunHeliumClient added in v0.2.0

func RunHeliumClient(ctx context.Context, config node.Config, nl node.List, app node.App, ip compute.InputProvider) (hc *HeliumClient, outs <-chan circuits.Output, err error)

func (*HeliumClient) Connect added in v0.2.0

func (hc *HeliumClient) Connect() error

Connect establishes a connection to the helium server.

func (*HeliumClient) ConnectWithDialer added in v0.2.0

func (hc *HeliumClient) ConnectWithDialer(dialer Dialer) error

ConnectWithDialer establishes a connection to the helium server using the provided dialer.

func (*HeliumClient) Disconnect added in v0.2.0

func (hc *HeliumClient) Disconnect() error

func (*HeliumClient) GetAggregationOutput added in v0.2.0

func (hc *HeliumClient) GetAggregationOutput(ctx context.Context, pd protocols.Descriptor) (*protocols.AggregationOutput, error)

GetAggregationOutput queries and returns the aggregation output for a given protocol descriptor.

func (*HeliumClient) GetCiphertext added in v0.2.0

func (hc *HeliumClient) GetCiphertext(ctx context.Context, ctID sessions.CiphertextID) (*sessions.Ciphertext, error)

GetCiphertext queries and returns a ciphertext.

func (*HeliumClient) GetStats added in v0.2.0

func (s *HeliumClient) GetStats() NetStats

func (*HeliumClient) HandleConn added in v0.2.0

func (s *HeliumClient) HandleConn(_ context.Context, sta stats.ConnStats)

HandleConn processes the Conn stats.

func (*HeliumClient) HandleRPC added in v0.2.0

func (s *HeliumClient) HandleRPC(ctx context.Context, sta stats.RPCStats)

HandleRPC processes the RPC stats.

func (*HeliumClient) IncomingShares added in v0.2.0

func (hc *HeliumClient) IncomingShares() <-chan protocols.Share

func (*HeliumClient) NodeID added in v0.2.0

func (hc *HeliumClient) NodeID() sessions.NodeID

func (*HeliumClient) OutgoingShares added in v0.2.0

func (hc *HeliumClient) OutgoingShares() chan<- protocols.Share

func (*HeliumClient) PutCiphertext added in v0.2.0

func (hc *HeliumClient) PutCiphertext(ctx context.Context, ct sessions.Ciphertext) error

PutCiphertext sends a ciphertext to the helium server.

func (*HeliumClient) PutShare added in v0.2.0

func (hc *HeliumClient) PutShare(ctx context.Context, share protocols.Share) error

PutShare sends a share to the helium server.

func (*HeliumClient) Register added in v0.2.0

func (hc *HeliumClient) Register(ctx context.Context) (upstream *coordinator.Channel[node.Event], present int, err error)

Register registers the client with the helium server and returns a channel for receiving events. It returns the current sequence number for the event log as present. Reading present+1 events from the returned channel will not block for longer than network-introduced delays.

func (*HeliumClient) Run added in v0.2.0

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

func (*HeliumClient) TagConn added in v0.2.0

func (s *HeliumClient) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context

TagConn can attach some information to the given context. The returned context will be used for stats handling. For conn stats handling, the context used in HandleConn for this connection will be derived from the context returned. For RPC stats handling,

  • On server side, the context used in HandleRPC for all RPCs on this connection will be derived from the context returned.
  • On client side, the context is not derived from the context returned.

func (*HeliumClient) TagRPC added in v0.2.0

func (s *HeliumClient) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context

TagRPC can attach some information to the given context. The context used for the rest lifetime of the RPC will be derived from the returned context.

type HeliumServer added in v0.2.0

type HeliumServer struct {
	sessions.PublicKeyProvider

	// grpc API
	*grpc.Server
	*pb.UnimplementedHeliumServer
	// contains filtered or unexported fields
}

HeliumServer is the server-side of the helium transport. In the current implementation, the server is responsible for keeping the event log and a server cannot be restarted after it is closed. // TODO

func NewHeliumServer added in v0.2.0

func NewHeliumServer(helperNode *node.Node) *HeliumServer

NewHeliumServer creates a new helium server with the provided node information and handlers.

func RunHeliumServer added in v0.2.0

func RunHeliumServer(ctx context.Context, config node.Config, nl node.List, app node.App, ip compute.InputProvider) (hsv *HeliumServer, cdescs chan<- circuits.Descriptor, outs <-chan circuits.Output, err error)

func (*HeliumServer) AppendEventToLog added in v0.2.0

func (hsv *HeliumServer) AppendEventToLog(event node.Event)

AppendEventToLog is called by the server side to append a new event to the log and send it to all connected peers.

func (*HeliumServer) CloseEventLog added in v0.2.0

func (hsv *HeliumServer) CloseEventLog()

CloseEventLog is called by the server side to close the event log and stop sending events to connected peers.

func (*HeliumServer) GetAggregationOutput added in v0.2.0

func (hsv *HeliumServer) GetAggregationOutput(inctx context.Context, apipd *pb.ProtocolDescriptor) (*pb.AggregationOutput, error)

GetAggregationOutput is a gRPC handler for the GetAggregationOutput method of the Helium service.

func (*HeliumServer) GetCiphertext added in v0.2.0

func (hsv *HeliumServer) GetCiphertext(inctx context.Context, ctid *pb.CiphertextID) (*pb.Ciphertext, error)

GetCiphertext is a gRPC handler for the GetCiphertext method of the Helium service.

func (*HeliumServer) GetOperand added in v0.2.0

func (hsv *HeliumServer) GetOperand(opl circuits.OperandLabel) (*circuits.Operand, bool)

func (*HeliumServer) GetStats added in v0.2.0

func (s *HeliumServer) GetStats() NetStats

func (*HeliumServer) HandleConn added in v0.2.0

func (s *HeliumServer) HandleConn(_ context.Context, sta stats.ConnStats)

HandleConn processes the Conn stats.

func (*HeliumServer) HandleRPC added in v0.2.0

func (s *HeliumServer) HandleRPC(ctx context.Context, sta stats.RPCStats)

HandleRPC processes the RPC stats.

func (*HeliumServer) Logf added in v0.2.0

func (hsv *HeliumServer) Logf(msg string, v ...any)

func (*HeliumServer) PutCiphertext added in v0.2.0

func (hsv *HeliumServer) PutCiphertext(inctx context.Context, apict *pb.Ciphertext) (*pb.CiphertextID, error)

PutCiphertext is a gRPC handler for the PutCiphertext method of the Helium service.

func (*HeliumServer) PutOperand added in v0.2.0

func (hsv *HeliumServer) PutOperand(opl circuits.OperandLabel, op *circuits.Operand) error

func (*HeliumServer) PutShare added in v0.2.0

func (hsv *HeliumServer) PutShare(inctx context.Context, apiShare *pb.Share) (*pb.Void, error)

PutShare is a gRPC handler for the PutShare method of the Helium service.

func (*HeliumServer) Register added in v0.2.0

func (hsv *HeliumServer) Register(_ *pb.Void, stream pb.Helium_RegisterServer) error

Register is a gRPC handler for the Register method of the Helium service.

func (*HeliumServer) Run added in v0.2.0

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

func (*HeliumServer) TagConn added in v0.2.0

func (s *HeliumServer) TagConn(ctx context.Context, _ *stats.ConnTagInfo) context.Context

TagConn can attach some information to the given context. The returned context will be used for stats handling. For conn stats handling, the context used in HandleConn for this connection will be derived from the context returned. For RPC stats handling,

  • On server side, the context used in HandleRPC for all RPCs on this connection will be derived from the context returned.
  • On client side, the context is not derived from the context returned.

func (*HeliumServer) TagRPC added in v0.2.0

func (s *HeliumServer) TagRPC(ctx context.Context, _ *stats.RPCTagInfo) context.Context

TagRPC can attach some information to the given context. The context used for the rest lifetime of the RPC will be derived from the returned context.

type NetStats added in v0.2.0

type NetStats struct {
	Setup, Compute, Others ServiceStats
}

func (NetStats) String added in v0.2.0

func (ns NetStats) String() string

type ServiceStats added in v0.2.0

type ServiceStats struct {
	DataSent, DataRecv uint64
}

ServiceStats contains the network statistics of a connection.

func (ServiceStats) String added in v0.2.0

func (s ServiceStats) String() string

String returns a string representation of the network statistics.

Directories

Path Synopsis
api
Package api implements a translation layer between the protobuf and internal Helium types.
Package api implements a translation layer between the protobuf and internal Helium types.
pb
Package circuits provides the types and interfaces for defining, parsing and executing circuits.
Package circuits provides the types and interfaces for defining, parsing and executing circuits.
Package coordinator implements a generic coordinator functionality for helium nodes.
Package coordinator implements a generic coordinator functionality for helium nodes.
examples
Package node provides the main entry point for the Helium library.
Package node provides the main entry point for the Helium library.
Package objectstore defines an interface between the helium services and the session data.
Package objectstore defines an interface between the helium services and the session data.
Package protocols implements the MHE protocol execution.
Package protocols implements the MHE protocol execution.
Package services provides common utilities for services.
Package services provides common utilities for services.
compute
Package compute implements the MHE compute phase as a service.
Package compute implements the MHE compute phase as a service.
setup
Package setup implements the MHE setup phase as a service.
Package setup implements the MHE setup phase as a service.
Package sessions implements helium sessions.
Package sessions implements helium sessions.
Package utils defines a set of utility functions and types used across the helium project.
Package utils defines a set of utility functions and types used across the helium project.
certs
Package certs provides utility functions for managing certificates.
Package certs provides utility functions for managing certificates.

Jump to

Keyboard shortcuts

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