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 CircuitNotRunningError
- type CircuitRuntime
- type Coordinator
- type Encoder
- type Event
- type FHEProvider
- type InputProvider
- type KeyOperationRunner
- type OperandProvider
- type OutputReceiver
- type Service
- func (s *Service) AggregationOutputHandler(ctx context.Context, aggOut protocols.AggregationOutput) error
- func (s *Service) EvalCircuit(ctx context.Context, cd circuits.Descriptor) error
- func (s *Service) GetCiphertext(ctx context.Context, ctID sessions.CiphertextID) (*sessions.Ciphertext, error)
- func (s *Service) GetDecryptor(ctx context.Context) (*rlwe.Decryptor, error)
- func (s *Service) GetEncoder(ctx context.Context) (enc Encoder, err error)
- func (s *Service) GetEncryptor(ctx context.Context) (*rlwe.Encryptor, error)
- func (s *Service) GetOperand(opl circuits.OperandLabel) (*circuits.Operand, bool)
- func (s *Service) GetParameters(ctx context.Context) (sessions.FHEParameters, 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) Logf(msg string, v ...any)
- func (s *Service) Outgoing() chan<- protocols.Event
- func (s *Service) PutCiphertext(ctx context.Context, ct sessions.Ciphertext) error
- func (s *Service) PutOperand(opl circuits.OperandLabel, op *circuits.Operand) 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, upstream Coordinator, ...) error
- func (s *Service) RunKeyOperation(ctx context.Context, sig protocols.Signature) (err error)
- type ServiceConfig
- type Transport
- type URL
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 CircuitNotRunningError ¶ added in v0.2.0
func (CircuitNotRunningError) Error ¶ added in v0.2.0
func (e CircuitNotRunningError) Error() string
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 Coordinator ¶ added in v0.2.0
type Coordinator coordinator.Coordinator[Event]
type FHEProvider ¶
type FHEProvider interface { GetParameters(ctx context.Context) (sessions.FHEParameters, error) GetEncoder(ctx context.Context) (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, sessions.CircuitID, circuits.OperandLabel, sessions.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 OperandProvider ¶ added in v0.2.0
type OperandProvider interface { GetOperand(circuits.OperandLabel) (*circuits.Operand, bool) PutOperand(circuits.OperandLabel, *circuits.Operand) error }
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 Service ¶
Service represents a compute service instance.
func NewComputeService ¶
func NewComputeService(ownID sessions.NodeID, sessProv sessions.Provider, conf ServiceConfig, pkbk circuits.PublicKeyProvider) (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) EvalCircuit ¶ added in v0.2.0
func (*Service) GetCiphertext ¶
func (s *Service) GetCiphertext(ctx context.Context, ctID sessions.CiphertextID) (*sessions.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) GetOperand ¶ added in v0.2.0
func (*Service) GetParameters ¶ added in v0.2.0
GetParameters returns the parameters of the context's session.
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) 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) PutOperand ¶ added in v0.2.0
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, upstream Coordinator, trans Transport) 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 sessions.Ciphertext) error // GetCiphertext requests a ciphertext from the transport. GetCiphertext(ctx context.Context, ctID sessions.CiphertextID) (*sessions.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.
type URL ¶ added in v0.2.0
URL defines a URL format to serve as ciphertext identifier for the Helium framwork.
func (*URL) CiphertextBaseID ¶ added in v0.2.0
func (u *URL) CiphertextBaseID() sessions.CiphertextID
func (*URL) CiphertextID ¶ added in v0.2.0
func (u *URL) CiphertextID() sessions.CiphertextID
func (*URL) CircuitID ¶ added in v0.2.0
CircuitID returns the circuit id part of the URL, if any. Returns the empty string if no circuit id is present.