helium

package module
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: 7 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 
        opRes := rt.NewOperand("//eval/prod")
        opRes.Ciphertext, _ = rt.MulRelinNew(in0.Get().Ciphertext, in1.Get().Ciphertext)

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

  inputProvider = func(ctx context.Context, cid helium.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)

  n, cdescs, outputs, err := node.RunNew(ctx, config, nodelist, app, inputProvider) // create an helium node that runs the app
  if err != nil {
    log.Fatal(err)
  }

  // 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 
  }

  // outputs is a channel to recieve the evaluation(s) output(s)
  out <- outputs 
  // ... 

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 provides the main types and interfaces for the Helium framework.

Index

Constants

This section is empty.

Variables

View Source
var (
	// CtxSessionID is the context key for the session ID.
	// Helium contexts must always have a session id.
	CtxSessionID ctxKey = "session_id"
	// CtxCircuitID is the context key for the circuit ID.
	// The circuit ID is optional and is only present in the context
	// of a circuit execution.
	CtxCircuitID ctxKey = "circuit_id"
)

Functions

func ContextWithCircuitID

func ContextWithCircuitID(ctx context.Context, circID CircuitID) context.Context

ContextWithCircuitID returns a new context derived from ctx with the given session ID.

func NewBackgroundContext

func NewBackgroundContext(sessID SessionID, circID ...CircuitID) context.Context

NewBackgroundContext returns a new context derived from context.Background with the given session and circuit IDs.

func NewContext

func NewContext(ctx context.Context, sessID SessionID, circID ...CircuitID) context.Context

NewContext returns a new context derived from ctx with the given session and circuit IDs.

Types

type CachedKeyBackend

type CachedKeyBackend struct {
	sync.Mutex // TODO: could be more clever
	MemoryKeyStore
	PublicKeyProvider
}

CachedKeyBackend is a PublicKeyProvider queries a PublicKeyProvider for keys and caches them. The cached keys are cached indefinitely. This implementation is blocking if the underlying PublicKeyProvider is blocking. It returns an error if the underlying PublicKeyProvider returns an error. The implementation is safe for concurrent use.

func NewCachedPublicKeyBackend

func NewCachedPublicKeyBackend(kb PublicKeyProvider) (ckb *CachedKeyBackend)

NewCachedPublicKeyBackend creates a new CachedKeyBackend for the given PublicKeyProvider. The function panics if kb is nil.

func (*CachedKeyBackend) GetCollectivePublicKey

func (ckb *CachedKeyBackend) GetCollectivePublicKey(ctx context.Context) (*rlwe.PublicKey, error)

GetCollectivePublicKey returns the collective public key for the session in ctx. The method returns an error if the key is not in the store and the underlying PublicKeyProvider returns an error.

func (*CachedKeyBackend) GetGaloisKey

func (ckb *CachedKeyBackend) GetGaloisKey(ctx context.Context, galEl uint64) (*rlwe.GaloisKey, error)

GetGaloisKey returns the galois key for the session in ctx and the given Galois element. The method returns an error if the key is not in the store and the underlying PublicKeyProvider returns an error.

func (*CachedKeyBackend) GetRelinearizationKey

func (ckb *CachedKeyBackend) GetRelinearizationKey(ctx context.Context) (*rlwe.RelinearizationKey, error)

GetRelinearizationKey returns the relinearization key for the session in ctx. The method returns an error if the key is not in the store and the underlying PublicKeyProvider returns an error.

type Ciphertext

type Ciphertext struct {
	rlwe.Ciphertext
	CiphertextMetadata
}

Ciphertext is a type for ciphertext within the helium framework.

type CiphertextID

type CiphertextID string

type CiphertextMetadata

type CiphertextMetadata struct {
	ID   CiphertextID
	Type CiphertextType
}

CiphertextMetadata contains information on ciphertexts. In the current bgv-specific implementation, the type is not used.

type CiphertextType

type CiphertextType int

CiphertextType is an enumerated type for the types of ciphertexts.

const (
	// Unspecified is the default value for the type of a ciphertext.
	Unspecified CiphertextType = iota
	// BFV is the type of a ciphertext in the BFV scheme.
	BFV
	// BGV is the type of a ciphertext in the BGV scheme.
	BGV
	// CKKS is the type of a ciphertext in the CKKS scheme.
	CKKS
	// RGSW is the type of a ciphertext in the RGSW scheme.
	RGSW
)

func (CiphertextType) String

func (ctt CiphertextType) String() string

String returns a string representation of the ciphertext type.

type CircuitID

type CircuitID string

CircuitID is the unique identifier of a running circuit.

func CircuitIDFromContext

func CircuitIDFromContext(ctx context.Context) (CircuitID, bool)

CircuitIDFromContext returns the circuit ID from the context, if present.

type MemoryKeyStore

type MemoryKeyStore struct {
	*rlwe.PublicKey
	GaloisKeys map[uint64]*rlwe.GaloisKey
	*rlwe.RelinearizationKey
}

MemoryKeyStore is a simple in-memory implementation of PublicKeyProvider. This implementation is non-blocking and returns an error if the keys are not available.

func (*MemoryKeyStore) GetCollectivePublicKey

func (pkb *MemoryKeyStore) GetCollectivePublicKey(ctx context.Context) (cpk *rlwe.PublicKey, err error)

GetCollectivePublicKey returns the collective public key for the session in ctx. If the public key is not in the store, it returns an error.

func (*MemoryKeyStore) GetGaloisKey

func (pkb *MemoryKeyStore) GetGaloisKey(ctx context.Context, galEl uint64) (gk *rlwe.GaloisKey, err error)

GetGaloisKey returns the galois key for the session in ctx and the given Galois element. If the galois key is not in the store, it returns an error.

func (*MemoryKeyStore) GetRelinearizationKey

func (pkb *MemoryKeyStore) GetRelinearizationKey(ctx context.Context) (rlk *rlwe.RelinearizationKey, err error)

GetRelinearizationKey returns the relinearization key for the session in ctx. If the relinearization key is not in the store, it returns an error.

type NodeAddress

type NodeAddress string

NodeAddress is the network address of a node.

func (NodeAddress) String

func (na NodeAddress) String() string

String returns a string representation of the node address.

type NodeID

type NodeID string

NodeID is the unique identifier of a node.

type NodeInfo

type NodeInfo struct {
	NodeID
	NodeAddress
}

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

type NodesList

type NodesList []NodeInfo

NodesList 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 (NodesList) AddressOf

func (nl NodesList) AddressOf(id NodeID) NodeAddress

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 (NodesList) String

func (nl NodesList) String() string

String returns a string representation of the list of nodes.

type PublicKeyProvider

type PublicKeyProvider interface {
	// GetCollectivePublicKey returns the collective public key for the session in ctx.
	GetCollectivePublicKey(ctx context.Context) (*rlwe.PublicKey, error)
	// GetGaloisKey returns the galois key for the session in ctx and the given Galois element.
	GetGaloisKey(ctx context.Context, galEl uint64) (*rlwe.GaloisKey, error)
	// GetRelinearizationKey returns the relinearization key for the session in ctx.
	GetRelinearizationKey(ctx context.Context) (*rlwe.RelinearizationKey, error)
}

PublicKeyProvider is an interface for retrieving public keys. Implementations return the keys for the session provided in the context. It is not specified whether implementations should block or return an error if the keys are not available.

Notable implementations of this interface are setup.Service, and key stores like MemoryKeyStore and the CachedkeyStore.

type SessionID

type SessionID string

SessionID is the unique identifier of a session.

func SessionIDFromContext

func SessionIDFromContext(ctx context.Context) (SessionID, bool)

SessionIDFromContext returns the session ID from the context.

type TestKeyProvider

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

TestKeyProvider is an implementation of a PublicKeyProvider that generates the keys on the fly, and is used for testing purposes. The implementation is not safe for concurrent use.

func NewTestKeyBackend

func NewTestKeyBackend(params rlwe.Parameters, skIdeal *rlwe.SecretKey) *TestKeyProvider

NewTestKeyBackend creates a new TestKeyProvider for the given parameters and ideal secret key.

func (*TestKeyProvider) GetCollectivePublicKey

func (tkb *TestKeyProvider) GetCollectivePublicKey(ctx context.Context) (*rlwe.PublicKey, error)

GetCollectivePublicKey returns the collective public key for the session in ctx.

func (*TestKeyProvider) GetGaloisKey

func (tkb *TestKeyProvider) GetGaloisKey(ctx context.Context, galEl uint64) (*rlwe.GaloisKey, error)

GetGaloisKey returns the galois key for the session in ctx and the given Galois element.

func (*TestKeyProvider) GetRelinearizationKey

func (tkb *TestKeyProvider) GetRelinearizationKey(ctx context.Context) (*rlwe.RelinearizationKey, error)

GetRelinearizationKey returns the relinearization key for the session in ctx.

type URL

type URL url.URL

URL defines a URL format to serve as ciphertext identifier for the Helium framwork.

func ParseURL

func ParseURL(s string) (*URL, error)

ParseURL parses a string into a helium URL.

func (*URL) CiphertextBaseID

func (u *URL) CiphertextBaseID() CiphertextID

func (*URL) CiphertextID

func (u *URL) CiphertextID() CiphertextID

func (*URL) CircuitID

func (u *URL) CircuitID() string

CircuitID returns the circuit id part of the URL, if any. Returns the empty string if no circuit id is present.

func (*URL) NodeID

func (u *URL) NodeID() NodeID

NodeID returns the host part of the URL as a NodeID.

func (*URL) String

func (u *URL) String() string

String returns the string representation of the URL.

Directories

Path Synopsis
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 provides types and methods for the coordination of Helium nodes.
Package coordinator provides types and methods for the coordination of Helium nodes.
examples
vec-mul command
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.
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 session implements helium sessions.
Package session implements helium sessions.
transport
centralized
Package centralized defines a client-server-based transport for the helium services.
Package centralized defines a client-server-based transport for the helium services.
pb
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