Documentation ¶
Overview ¶
Package protocols implements the MHE protocol execution. It uses Lattigo as the underlying MHE library.
Index ¶
- func AllocateOutput(sig Signature, params rlwe.Parameters) interface{}
- func GetParticipants(sig Signature, onlineNodes utils.Set[sessions.NodeID], threshold int) ([]sessions.NodeID, error)
- func GetProtocolPrivateRandomness(pd Descriptor, sess *sessions.Session) blake2b.XOF
- func GetProtocolPublicRandomness(pd Descriptor, sess *sessions.Session) blake2b.XOF
- type AggregationOutput
- type AggregationOutputReceiver
- type CKGProtocol
- func (ckg *CKGProtocol) AggregatedShares(dst Share, ss ...Share) error
- func (ckg *CKGProtocol) AllocateShare() Share
- func (ckg *CKGProtocol) Finalize(crp Input, aggShare Share, rec interface{}) error
- func (ckg *CKGProtocol) GenShare(sk *rlwe.SecretKey, crp Input, share Share) error
- func (ckg *CKGProtocol) ReadCRP(crs drlwe.CRS) (CRP, error)
- type CKSProtocol
- func (cks *CKSProtocol) AggregatedShares(dst Share, ss ...Share) error
- func (cks *CKSProtocol) AllocateShare() Share
- func (cks *CKSProtocol) Finalize(in Input, aggShare Share, rec interface{}) error
- func (cks *CKSProtocol) GenShare(sk *rlwe.SecretKey, in Input, share Share) error
- func (cks *CKSProtocol) ReadCRP(crs drlwe.CRS) (CRP, error)
- type CRP
- type CompleteMap
- type Descriptor
- type Event
- type EventType
- type Executor
- func (s *Executor) GetOutput(ctx context.Context, aggOut AggregationOutput, rec interface{}) error
- func (s *Executor) Logf(msg string, v ...any)
- func (s *Executor) NodeID() sessions.NodeID
- func (s *Executor) Register(peer sessions.NodeID) error
- func (s *Executor) Run(ctx context.Context, trans Transport) error
- func (s *Executor) RunDescriptorAsAggregator(ctx context.Context, pd Descriptor) (aggOut *AggregationOutput, err error)
- func (s *Executor) RunSignature(ctx context.Context, sig Signature, aggOutRec AggregationOutputReceiver) (err error)
- func (s *Executor) Unregister(peer sessions.NodeID) error
- type ExecutorConfig
- type ID
- type Input
- type InputProvider
- type KeySwitchInput
- type LattigoShare
- type Output
- type PCKSProtocol
- func (cks *PCKSProtocol) AggregatedShares(dst Share, ss ...Share) error
- func (cks *PCKSProtocol) AllocateShare() Share
- func (cks *PCKSProtocol) Finalize(in Input, aggShare Share, rec interface{}) error
- func (cks *PCKSProtocol) GenShare(sk *rlwe.SecretKey, in Input, share Share) error
- func (cks *PCKSProtocol) ReadCRP(crs drlwe.CRS) (CRP, error)
- type Protocol
- func (p *Protocol) Aggregate(ctx context.Context, incoming <-chan Share) <-chan AggregationOutput
- func (p *Protocol) AllocateShare() Share
- func (p *Protocol) Descriptor() Descriptor
- func (p *Protocol) GenShare(sk *rlwe.SecretKey, in Input, shareOut *Share) error
- func (p *Protocol) HID() string
- func (p *Protocol) HasRole() bool
- func (p *Protocol) HasShareFrom(nid sessions.NodeID) bool
- func (p *Protocol) ID() ID
- func (p *Protocol) IsAggregator() bool
- func (p *Protocol) IsParticipant() bool
- func (p *Protocol) Logf(msg string, v ...any)
- func (p *Protocol) Output(in Input, agg AggregationOutput, out interface{}) error
- func (p *Protocol) ReadCRP() (CRP, error)
- type RKGProtocol
- func (rkg *RKGProtocol) AggregatedShares(dst Share, ss ...Share) error
- func (rkg *RKGProtocol) AllocateShare() (share Share)
- func (rkg *RKGProtocol) Finalize(round1 Input, aggShares Share, rec interface{}) error
- func (rkg *RKGProtocol) GenShare(sk *rlwe.SecretKey, input Input, share Share) error
- func (rkg *RKGProtocol) ReadCRP(crs drlwe.CRS) (CRP, error)
- type RTGProtocol
- func (rtg *RTGProtocol) AggregatedShares(dst Share, ss ...Share) error
- func (rtg *RTGProtocol) AllocateShare() Share
- func (rtg *RTGProtocol) Finalize(crp Input, aggShare Share, rec interface{}) error
- func (rtg *RTGProtocol) GenShare(sk *rlwe.SecretKey, crp Input, share Share) error
- func (rtg *RTGProtocol) ReadCRP(crs drlwe.CRS) (CRP, error)
- type ReceiverKey
- type SKGProtocol
- type Share
- type ShareMetadata
- type Signature
- type TestTransport
- type Transport
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllocateOutput ¶
func AllocateOutput(sig Signature, params rlwe.Parameters) interface{}
AllocateOutput returns a newly allocated output for the protocol signature.
func GetParticipants ¶
func GetParticipants(sig Signature, onlineNodes utils.Set[sessions.NodeID], threshold int) ([]sessions.NodeID, error)
GetParticipants returns a set of protocol participants, given the online nodes and the threshold. This function handle the case of the DEC protocol, where the target must be considered a participant. It returns an error if there are not enough online nodes.
func GetProtocolPrivateRandomness ¶
func GetProtocolPrivateRandomness(pd Descriptor, sess *sessions.Session) blake2b.XOF
GetProtocolPrivateRandomness intitializes a keyed PRF from the session's private seed and the protocol's information. This function ensures that the PRF is unique for each protocol execution.
func GetProtocolPublicRandomness ¶
func GetProtocolPublicRandomness(pd Descriptor, sess *sessions.Session) blake2b.XOF
GetProtocolPublicRandomness intitializes a keyed PRF from the session's public seed and the protocol's information. This function ensures that the PRF is unique for each protocol execution.
Types ¶
type AggregationOutput ¶
type AggregationOutput struct { Descriptor Descriptor Error error }
AggregationOutput is a type for the output of a protocol's aggregation step. In addition to the protocol's descriptor, it contains either the aggregated share or an error if the aggregation has failed.
type AggregationOutputReceiver ¶
type AggregationOutputReceiver func(context.Context, AggregationOutput) error
AggregationOutputReceiver is the interface for receiving aggregation outputs from the executor. These types are registered as callbacks when requesting the execution of a protocol.
type CKGProtocol ¶
type CKGProtocol struct { drlwe.PublicKeyGenProtocol // contains filtered or unexported fields }
func NewCKGProtocol ¶
func NewCKGProtocol(params rlwe.Parameters, arg map[string]string) (*CKGProtocol, error)
func (*CKGProtocol) AggregatedShares ¶
func (ckg *CKGProtocol) AggregatedShares(dst Share, ss ...Share) error
func (*CKGProtocol) AllocateShare ¶
func (ckg *CKGProtocol) AllocateShare() Share
func (*CKGProtocol) Finalize ¶
func (ckg *CKGProtocol) Finalize(crp Input, aggShare Share, rec interface{}) error
type CKSProtocol ¶
type CKSProtocol struct { drlwe.KeySwitchProtocol // contains filtered or unexported fields }
func NewCKSProtocol ¶
func NewCKSProtocol(params rlwe.Parameters, args map[string]string) (*CKSProtocol, error)
func (*CKSProtocol) AggregatedShares ¶
func (cks *CKSProtocol) AggregatedShares(dst Share, ss ...Share) error
func (*CKSProtocol) AllocateShare ¶
func (cks *CKSProtocol) AllocateShare() Share
func (*CKSProtocol) Finalize ¶
func (cks *CKSProtocol) Finalize(in Input, aggShare Share, rec interface{}) error
type CRP ¶
type CRP interface{}
CRP is a type for the common reference polynomials used in the key generation protocol. A CRP is a polynomial that is sampled uniformly at random, yet is the same for all nodes. CRPs are expanded from the session's public seed.
type CompleteMap ¶
type CompleteMap struct {
// contains filtered or unexported fields
}
CompleteMap implements a concurrent map of completed protocols. It enables waiting for the completion of a protocol and retrieving the completed descriptor.
func NewCompletedProt ¶
func NewCompletedProt(sigs []Signature) *CompleteMap
NewCompletedProt creates a new CompleteMap. If sigs is empty, the CompleteMap will allow callers of the AwaitCompletedDescriptorFor method to wait for any protocol descriptor completion. Otherwise, awaiting on an unknown protocol signature will return an error.
func (*CompleteMap) AwaitCompletedDescriptorFor ¶
func (p *CompleteMap) AwaitCompletedDescriptorFor(sig Signature) (pdp *Descriptor, err error)
AwaitCompletedDescriptorFor waits for the completion of a protocol. This method will return an error if the map was created with a specific list of signatures and the provided signature is not in the list.
func (*CompleteMap) CompletedProtocol ¶
func (p *CompleteMap) CompletedProtocol(pd Descriptor) error
CompletedProtocol adds a completed protocol descriptor to the map.
func (*CompleteMap) Wait ¶
func (p *CompleteMap) Wait() error
Wait waits for all protocols to complete.
type Descriptor ¶
Descriptor is a complete description of a protocol's execution (i.e., a protocol), by complementing the Signature with a role assignment.
Multiple protocols can share the same signature, but have different descriptors (e.g., in the case of a failure). However, a protocol is uniquely identified by its descriptor.
func (Descriptor) HID ¶
func (pd Descriptor) HID() string
HID returns the human-readable (truncated) ID of the protocol, derived from the descriptor.
func (Descriptor) ID ¶
func (pd Descriptor) ID() ID
ID returns the ID of the protocol, derived from the descriptor.
func (Descriptor) MarshalBinary ¶
func (pd Descriptor) MarshalBinary() (b []byte, err error)
MarshalBinary returns the binary representation of the protocol descriptor.
func (Descriptor) String ¶
func (pd Descriptor) String() string
String returns the string representation of the protocol descriptor.
func (*Descriptor) UnmarshalBinary ¶
func (pd *Descriptor) UnmarshalBinary(b []byte) (err error)
UnmarshalBinary unmarshals the binary representation of the protocol descriptor.
type Event ¶
type Event struct { EventType Descriptor }
Event is a type for protocol-execution-related events.
func (Event) IsComputeEvent ¶
IsComputeEvent returns true if the event is a compute-related event.
func (Event) IsSetupEvent ¶
IsSetupEvent returns true if the event is a setup-related event.
type EventType ¶
type EventType int8
EventType defines the type of protocol-execution-related events.
const ( // Completed is the event type for a completed protocol. Completed EventType = iota // Started is the event type for a started protocol. Started // Executing is the event type for a protocol that is currently executing. It is currently not used. Executing // Failed is the event type for a protocol that has failed. Failed )
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor is a type for executing protocols. It enables concurrent execution of protocols and handles both running the protocol as a participant and as an aggregator/coordinator. As a participant, the executor will generate the share and send it to the aggregator. As an aggregator/coordinator, the executor will decide on the participant list based on the regsitered nodes, and perform the aggregation.
func NewExectutor ¶
func NewExectutor(config ExecutorConfig, ownID sessions.NodeID, sessProv sessions.Provider, upstream *coordinator.Channel[Event], ip InputProvider) (*Executor, error)
NewExectutor creates a new executor.
func (*Executor) GetOutput ¶
func (s *Executor) GetOutput(ctx context.Context, aggOut AggregationOutput, rec interface{}) error
func (*Executor) Register ¶
Register is called by the transport when a new peer register itself for the setup.
func (*Executor) RunDescriptorAsAggregator ¶
func (s *Executor) RunDescriptorAsAggregator(ctx context.Context, pd Descriptor) (aggOut *AggregationOutput, err error)
func (*Executor) RunSignature ¶
type ExecutorConfig ¶
type ExecutorConfig struct { // As coordinator // SigQueueSize is the size of the signature queue. If the queue is full the RunSignature method blocks. SigQueueSize int // MaxProtoPerNode is the maximum number of parallel proto participation per registered node. MaxProtoPerNode int // as aggregator // MaxAggregation is the maximum number of parallel proto aggrations for this executor. MaxAggregation int // as participant // MaxParticipation is the maximum number of parallel proto participation for this executor. MaxParticipation int }
ExecutorConfig is the configuration for the executor.
type ID ¶
type ID string
ID is a type for protocol IDs. Protocol IDs are unique identifiers for a protocol. Since a protocol is uniquely identified by its descriptor, the ID is derived from the descriptor.
type Input ¶
type Input interface{}
Input is a type for protocol inputs. Inputs are either:
- a CRP in the case of a key generation protocol (CKG, RTG, RKG_1)
- an aggregated share from a previous round (RKG)
- a KeySwitchInput for the key-switching protocols (DEC, CKS, PCKS)
type InputProvider ¶
type InputProvider func(ctx context.Context, pd Descriptor) (Input, error)
InputProvider is the interface the provision of protocol inputs. It is called by the executor to get the CRP (CKG, RTG, RKG) and ciphertexts (DEC, CKS, PCKS) for the protocols.
type KeySwitchInput ¶
type KeySwitchInput struct { // OutputKey is the target output key of the key-switching protocol, // it is a secret key (*rlwe.SecretKey) for the collective key-switching protocol (CKS) // and a public key (*rlwe.PublicKey) for the collective public-key switching protocol (PCKS). OutputKey ReceiverKey // InpuCt is the ciphertext to be re-encrpted under the output key. InpuCt *rlwe.Ciphertext }
KeySwitchInput is a type for the inputs to the key-switching protocols.
type LattigoShare ¶
type LattigoShare interface { encoding.BinaryMarshaler encoding.BinaryUnmarshaler }
LattigoShare is a common interface for all Lattigo shares
type Output ¶
type Output struct { Descriptor Result interface{} }
Output is a type for protocol outputs. It contains the result of the protocol execution or an error if the protocol execution has failed.
type PCKSProtocol ¶
type PCKSProtocol struct { drlwe.PublicKeySwitchProtocol // contains filtered or unexported fields }
func NewPCKSProtocol ¶
func NewPCKSProtocol(params rlwe.Parameters, args map[string]string) (*PCKSProtocol, error)
func (*PCKSProtocol) AggregatedShares ¶
func (cks *PCKSProtocol) AggregatedShares(dst Share, ss ...Share) error
func (*PCKSProtocol) AllocateShare ¶
func (cks *PCKSProtocol) AllocateShare() Share
func (*PCKSProtocol) Finalize ¶
func (cks *PCKSProtocol) Finalize(in Input, aggShare Share, rec interface{}) error
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
Protocol is a base struct for protocols.
func NewProtocol ¶
func NewProtocol(pd Descriptor, sess *sessions.Session) (*Protocol, error)
NewProtocol creates a new protocol from the provided protocol descriptor, session and inputs.
func (*Protocol) Aggregate ¶
func (p *Protocol) Aggregate(ctx context.Context, incoming <-chan Share) <-chan AggregationOutput
Aggregate is called by the aggregator node to aggregate the shares of the protocol. The method aggregates the shares received in the provided incoming channel in the background, and sends the aggregated share to the returned channel when the aggregation has completed. Upon receiving the aggregated share, the caller must check the Error field of the aggregation output to determine whether the aggregation has failed. The aggregation can be cancelled by cancelling the context. If the context is cancelled or the incoming channel is closed before the aggregation has completed, the method sends the aggregation output with the corresponding error to the returned channel. The method panics if called by a non-aggregator node.
func (*Protocol) AllocateShare ¶
AllocateShare returns a newly allocated share for the protocol.
func (*Protocol) Descriptor ¶
func (p *Protocol) Descriptor() Descriptor
Descriptor returns the protocol descriptor of the protocol.
func (*Protocol) GenShare ¶
GenShare is called by the session nodes to generate their share in the protocol, storing the result in the provided shareOut. The method returns an error if the node should not generate a share in the protocol.
func (*Protocol) HasRole ¶
HasRole returns whether the node is an aggregator or a participant in the protocol.
func (*Protocol) HasShareFrom ¶
HasShareFrom returns whether the protocol has already recieved a share from the specified node.
func (*Protocol) IsAggregator ¶
IsAggregator returns whether the node is the aggregator in the protocol.
func (*Protocol) IsParticipant ¶
IsParticipant returns whether the node is a participant in the protocol.
type RKGProtocol ¶
type RKGProtocol struct { drlwe.RelinearizationKeyGenProtocol // contains filtered or unexported fields }
func NewRKGProtocol ¶
func NewRKGProtocol(params rlwe.Parameters, ephSk *rlwe.SecretKey, round uint64, _ map[string]string) (*RKGProtocol, error)
func (*RKGProtocol) AggregatedShares ¶
func (rkg *RKGProtocol) AggregatedShares(dst Share, ss ...Share) error
func (*RKGProtocol) AllocateShare ¶
func (rkg *RKGProtocol) AllocateShare() (share Share)
func (*RKGProtocol) Finalize ¶
func (rkg *RKGProtocol) Finalize(round1 Input, aggShares Share, rec interface{}) error
type RTGProtocol ¶
type RTGProtocol struct { drlwe.GaloisKeyGenProtocol // contains filtered or unexported fields }
func NewRTGProtocol ¶
func NewRTGProtocol(params rlwe.Parameters, args map[string]string) (*RTGProtocol, error)
func (*RTGProtocol) AggregatedShares ¶
func (rtg *RTGProtocol) AggregatedShares(dst Share, ss ...Share) error
func (*RTGProtocol) AllocateShare ¶
func (rtg *RTGProtocol) AllocateShare() Share
func (*RTGProtocol) Finalize ¶
func (rtg *RTGProtocol) Finalize(crp Input, aggShare Share, rec interface{}) error
type ReceiverKey ¶
type ReceiverKey interface{}
ReceiverKey is a type for the output keys in the key switching protocols. Depending on the type of protocol, the receiver key can be either a *rlwe.SecretKey (collective key-switching, CKS) or a *rlwe.PublicKey (collective public-key switching, PCKS).
type SKGProtocol ¶
type SKGProtocol struct {
drlwe.Thresholdizer
}
type Share ¶
type Share struct {}
Share is a type for the nodes' protocol shares.
func (Share) MarshalBinary ¶
MarshalBinary returns the binary representation of the share.
func (Share) UnmarshalBinary ¶
UnmarshalBinary unmarshals the binary representation of the share.
type ShareMetadata ¶
type ShareMetadata struct {}
ShareMetadata retains the necessary information for the framework to identify the share and the protocol it belongs to.
type Signature ¶
Signature is a protocol prototype. In analogy to a function signature, it describes the type of the protocol and the arguments it expects.
type TestTransport ¶ added in v0.2.0
type TestTransport struct {
// contains filtered or unexported fields
}
func NewTestTransport ¶
func NewTestTransport() *TestTransport
func (*TestTransport) IncomingShares ¶ added in v0.2.0
func (tt *TestTransport) IncomingShares() <-chan Share
func (*TestTransport) OutgoingShares ¶ added in v0.2.0
func (tt *TestTransport) OutgoingShares() chan<- Share
func (*TestTransport) TransportFor ¶ added in v0.2.0
func (tt *TestTransport) TransportFor(nid sessions.NodeID) *TestTransport
type Transport ¶
type Transport interface {}
Transport defines the transport interface required for the executor.
type Type ¶
type Type uint
Type is an enumerated type for protocol types.
const ( // Unspecified is the default value for the protocol type. Unspecified Type = iota // SKG is the secret-key generation protocol. // TODO: unsupported SKG // CKG is the collective public-key generation protocol. CKG // RKG1 is the first round of the relinearization key generation protocol. RKG1 // RKG is the relinearization key generation protocol. RKG // RTG is the galois key generation protocol. RTG // CKS is the collective key-switching protocol. // TODO: unsupported CKS // DEC is the decryption protocol. DEC // PCKS is the collective public-key switching protocol. // TODO: unsupported PCKS )
func (Type) IsCompute ¶
IsCompute returns whether the protocol type is a secret-key operation ciphertext operation.
func (Type) Share ¶
func (t Type) Share() LattigoShare
Share returns a lattigo share with the correct go type for the protocol type.