Documentation
¶
Overview ¶
Package compute implements the MHE compute phase as a service. This service is responsible for evaluating circuits and running associated the protocols. It stats a protocol.Executor and acts as a coordinator for it.
Index ¶
- Constants
- type CircuitRuntime
- type FHEProvider
- type InputProvider
- type KeyOperationRunner
- type OutputReceiver
- type PublicKeyProvider
- type Service
- func (s *Service) AggregationOutputHandler(ctx context.Context, aggOut protocols.AggregationOutput) error
- func (s *Service) GetCiphertext(ctx context.Context, ctID helium.CiphertextID) (*helium.Ciphertext, error)
- func (s *Service) GetDecryptor(ctx context.Context) (*rlwe.Decryptor, error)
- func (s *Service) GetEncoder(ctx context.Context) (*bgv.Encoder, error)
- func (s *Service) GetEncryptor(ctx context.Context) (*rlwe.Encryptor, error)
- func (s *Service) GetEvaluator(ctx context.Context, relin bool, galEls []uint64) (*fheEvaluator, error)
- func (s *Service) GetProtocolInput(ctx context.Context, pd protocols.Descriptor) (in protocols.Input, err error)
- func (s *Service) Incoming() <-chan protocols.Event
- func (s *Service) Init(ctx context.Context, complCd, runCd []circuits.Descriptor, ...) error
- func (s *Service) Logf(msg string, v ...any)
- func (s *Service) Outgoing() chan<- protocols.Event
- func (s *Service) PutCiphertext(ctx context.Context, ct helium.Ciphertext) error
- func (s *Service) RegisterCircuit(name circuits.Name, circ circuits.Circuit) error
- func (s *Service) RegisterCircuits(cs map[circuits.Name]circuits.Circuit) error
- func (s *Service) Run(ctx context.Context, ip InputProvider, or OutputReceiver, ...) error
- func (s *Service) RunKeyOperation(ctx context.Context, sig protocols.Signature) (err error)
- type ServiceConfig
- type Transport
Constants ¶
const ( // DefaultCircQueueSize is the default size of the circuit execution queue. DefaultCircQueueSize = 512 // DefaultMaxCircuitEvaluation is the default maximum number of circuits that can be evaluated concurrently. DefaultMaxCircuitEvaluation = 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitRuntime ¶
type CircuitRuntime interface {
// Init provides the circuit runtime with the circuit's metadata.
Init(ctx context.Context, md circuits.Metadata) (err error)
// Eval runs the circuit evaluation, given the circuit.
Eval(ctx context.Context, c circuits.Circuit) (err error)
// IncomingOperand provides the circuit runtime with an incoming operand.
IncomingOperand(circuits.Operand) error
// CompletedProtocol informs the circuit runtime that a protocol has been completed.
CompletedProtocol(protocols.Descriptor) error
// GetOperand returns the operand with the given label, if it exists.
GetOperand(context.Context, circuits.OperandLabel) (*circuits.Operand, bool)
// GetFutureOperand returns the future operand with the given label, if it exists.
GetFutureOperand(context.Context, circuits.OperandLabel) (*circuits.FutureOperand, bool)
// Wait blocks until the circuit executing in this runtime (including its related protocols) completes.
Wait() error
}
CircuitRuntime is the interface of a circuit's execution environment. There are two notable instantiation of this interface:
- evaluator: the node that evaluates the circuit
- participant: the node that provides input to the circuit, participates in the protocols and recieve outputs.
type FHEProvider ¶
type FHEProvider interface {
GetEncoder(ctx context.Context) (*bgv.Encoder, error)
GetEncryptor(ctx context.Context) (*rlwe.Encryptor, error)
GetEvaluator(ctx context.Context, rlk bool, galEls []uint64) (*fheEvaluator, error)
GetDecryptor(ctx context.Context) (*rlwe.Decryptor, error)
}
FHEProvider is an interface for requesting FHE-related objects as implemented in the Lattigo library.
type InputProvider ¶
type InputProvider func(context.Context, helium.CircuitID, circuits.OperandLabel, session.Session) (any, error)
InputProvider is a type for providing input to a circuit. It is generally provided by the user, and lets the framework query for inputs to the circuit by their label. See circuits.OperandLabel for more information on operand labels. Input providers are expected to return one of the following types: - *rlwe.Ciphertext: an encrypted input - *rlwe.Plaintext: a Lattigo plaintext input, which will be encrypted by the framework - []uint64: a Go plaintext input, which will be encoded and encrypted by the framework
type KeyOperationRunner ¶
type KeyOperationRunner interface {
RunKeyOperation(ctx context.Context, sig protocols.Signature) error
}
KeyOperationRunner is an interface for running key operations. It is used by the evaluatorRuntime to run key operations as they are requested by the circuit.
type OutputReceiver ¶
OutputReceiver is a type for receiving outputs from a circuit.
var NoOutput OutputReceiver = make(OutputReceiver)
NoOutput is an output receiver that do not send any input
type PublicKeyProvider ¶
type PublicKeyProvider interface {
GetCollectivePublicKey(context.Context) (*rlwe.PublicKey, error)
GetGaloisKey(ctx context.Context, galEl uint64) (*rlwe.GaloisKey, error)
GetRelinearizationKey(context.Context) (*rlwe.RelinearizationKey, error)
}
PublicKeyProvider is an interface for querying public encryption- and evaluation-keys. The setup service is a notable implementation of this interface.
type Service ¶
Service represents a compute service instance.
func NewComputeService ¶
func NewComputeService(ownID helium.NodeID, sessions session.SessionProvider, conf ServiceConfig, pkbk PublicKeyProvider, trans Transport) (s *Service, err error)
NewComputeService creates a new compute service instance.
func (*Service) AggregationOutputHandler ¶
func (s *Service) AggregationOutputHandler(ctx context.Context, aggOut protocols.AggregationOutput) error
AggregationOutputHandler recieves the completed protocol aggregations from the executor.
func (*Service) GetCiphertext ¶
func (s *Service) GetCiphertext(ctx context.Context, ctID helium.CiphertextID) (*helium.Ciphertext, error)
GetCiphertext retreives a ciphertext from the corresponding circuit runtime. The runtime is identified by the circuit ID part of the ciphertext ids.
func (*Service) GetDecryptor ¶
GetDecryptor returns a new decryptor from the context's session. The decryptor is inialized with a secret key of 0.
func (*Service) GetEncoder ¶
GetEncoder returns a new encoder from the context's session.
func (*Service) GetEncryptor ¶
GetEncryptor returns a new encryptor from the context's session and the collective public key.
func (*Service) GetEvaluator ¶
func (s *Service) GetEvaluator(ctx context.Context, relin bool, galEls []uint64) (*fheEvaluator, error)
GetEvaluator returns a new evaluator from the context's session and relevant evaluation keys.
func (*Service) GetProtocolInput ¶
func (s *Service) GetProtocolInput(ctx context.Context, pd protocols.Descriptor) (in protocols.Input, err error)
GetProtocolInput returns the input for a protocol from the corresponding circuit runtime. The input is the ciphertext identified by the "op" protocol argument. The runtime is identified by the circuit ID part of the operand label.
func (*Service) Init ¶
func (s *Service) Init(ctx context.Context, complCd, runCd []circuits.Descriptor, complPd, runPd []protocols.Descriptor) error
Init initializes the compute service with the currently completed and running circuits and protocols. It queues running circuits and protocols for execution.
func (*Service) PutCiphertext ¶
PutCiphertext provides the ciphertext to the corresponding circuit runtime. The runtime is identified by the circuit ID part of the ciphertext ids.
func (*Service) RegisterCircuit ¶
RegisterCircuit registers a circuit to the service's library. It returns an error if the circuit is already registered.
func (*Service) RegisterCircuits ¶
RegisterCircuits registers a set of circuits to the service's library. It returns an error if any of the circuits is already registered.
func (*Service) Run ¶
func (s *Service) Run(ctx context.Context, ip InputProvider, or OutputReceiver, coord coordinator.Coordinator) error
Run runs the compute service. The service processes incoming events from the upstream coordinator and acts as a coordinator for the protocol executor. It also processes the circuit execution queue and fetches the output for completed circuits. The method returns when the upstream coordinator is done and all circuits are completed.
type ServiceConfig ¶
type ServiceConfig struct {
// CircQueueSize is the size of the circuit execution queue.
// Passed this size, attempting to queue circuit for execution will block.
CircQueueSize int
// MaxCircuitEvaluation is the maximum number of circuits that can be evaluated concurrently.
MaxCircuitEvaluation int
// Protocols is the configuration of the protocol executor.
Protocols protocols.ExecutorConfig
}
ServiceConfig is the configuration of a compute service.
type Transport ¶
type Transport interface {
protocols.Transport
// PutCiphertext registers a ciphertext within the transport
PutCiphertext(ctx context.Context, ct helium.Ciphertext) error
// GetCiphertext requests a ciphertext from the transport.
GetCiphertext(ctx context.Context, ctID helium.CiphertextID) (*helium.Ciphertext, error)
}
Transport defines the transport interface necessary for the compute service. In the current implementation (helper-assisted setting), this corresponds to the helper interface.