Documentation ¶
Overview ¶
defines all protocols and entities for distributed refresh, key switch and oblivious decryption
Index ¶
- Variables
- func DeserializeKeys(path string, parties int) (sk *rlwe.SecretKey, skShares []*rlwe.SecretKey, rtks *rlwe.RotationKeySet)
- func DummyEncKeyGen(params ckks.Parameters, crs *lattigoUtils.KeyedPRNG, parties int) ([]*rlwe.SecretKey, *rlwe.SecretKey, *rlwe.PublicKey, ckks.KeyGenerator)
- func DummyRelinKeyGen(params ckks.Parameters, crs *lattigoUtils.KeyedPRNG, shares []*rlwe.SecretKey) *rlwe.RelinearizationKey
- func MarshalCrp(crp drlwe.CKSCRP) ([]byte, error)
- func ReadFrom(c io.Reader) ([]byte, error)
- func SerializeKeys(sk *rlwe.SecretKey, skshares []*rlwe.SecretKey, rtks *rlwe.RotationKeySet, ...)
- func UnMarshalCrp(buf []byte) (drlwe.CKSCRP, error)
- func WriteTo(c io.Writer, buf []byte) error
- type Client
- func (cl *Client) ClientSetup(serverAddr string, sk *rlwe.SecretKey)
- func (cl *Client) Dispatch(c net.Conn)
- func (cl *Client) DispatchMasking(resp ProtocolMsg)
- func (cl *Client) RunEnd()
- func (cl *Client) RunMasking(ctId int)
- func (cl *Client) StartProto(proto ProtocolType, X *cipherUtils.EncInput) *cipherUtils.PlainInput
- type DistributedBtp
- type LocalMaster
- func (lmst *LocalMaster) Dispatch(c net.Conn)
- func (lmst *LocalMaster) DispatchPCKS(resp ProtocolResp)
- func (lmst *LocalMaster) DispatchRef(resp ProtocolResp)
- func (lmst *LocalMaster) MasterSetup(playersAddr []string, parties int, skShares []*rlwe.SecretKey, ...)
- func (lmst *LocalMaster) RunEnd()
- func (lmst *LocalMaster) RunPubKeySwitch(proto *dckks.PCKSProtocol, pkQ *rlwe.PublicKey, ct *ckks.Ciphertext, ctId int)
- func (lmst *LocalMaster) RunRefresh(proto *dckks.RefreshProtocol, ct *ckks.Ciphertext, crp drlwe.CKSCRP, ...)
- func (lmst *LocalMaster) StartProto(proto ProtocolType, X *cipherUtils.EncInput, pkQ *rlwe.PublicKey, minLevel int, ...)
- type LocalPlayer
- type MaskProtocol
- type PCKSExt
- type Protocol
- type ProtocolMsg
- type ProtocolResp
- type ProtocolType
- type RefreshExt
- type Remote
- type Server
- type ServerMsg
- type SetupMsg
Constants ¶
This section is empty.
Variables ¶
var DELIM = []byte{'\r', '\n', '\r', '\n'}
var KB = 1024
var Lan = latency.Local //no overhead, used in real distributed env.
var Local = latency.Network{ Kbps: 1024 * 1024, Latency: 20 * time.Millisecond, MTU: 1500, }
var MAX_SIZE = 30 * MB //LogN = 15, setup included
var MB = 1024 * KB
var ServicePort = 9999 //port used by remote nodes to receive ProtocolMsg from master
var SetupPort = 7777 //port used by remote nodes to receive SetupMsg from master
var TYP = uint8(255)
var TYPES = []string{"PubKeySwitch", "Refresh", "End"}
Functions ¶
func DeserializeKeys ¶
func DeserializeKeys(path string, parties int) (sk *rlwe.SecretKey, skShares []*rlwe.SecretKey, rtks *rlwe.RotationKeySet)
reads keys from file
func DummyEncKeyGen ¶
func DummyEncKeyGen(params ckks.Parameters, crs *lattigoUtils.KeyedPRNG, parties int) ([]*rlwe.SecretKey, *rlwe.SecretKey, *rlwe.PublicKey, ckks.KeyGenerator)
Returns array of secret key shares, secret key and collective encryption key
func DummyRelinKeyGen ¶
func DummyRelinKeyGen(params ckks.Parameters, crs *lattigoUtils.KeyedPRNG, shares []*rlwe.SecretKey) *rlwe.RelinearizationKey
Dummy generation of relin keys
func SerializeKeys ¶
func SerializeKeys(sk *rlwe.SecretKey, skshares []*rlwe.SecretKey, rtks *rlwe.RotationKeySet, path string)
writes key from experiment to file
Types ¶
type Client ¶
type Client struct { ProtoBuf *sync.Map //ct id -> protocol instance *Protocol //comms ServerAddr *net.TCPAddr Network latency.Network Box cipherUtils.CkksBox // contains filtered or unexported fields }
Client in the 2PC oblivious decryption protocol
func NewClient ¶
func NewClient(ServerAddr string, Box cipherUtils.CkksBox, poolSize int, localhost bool) (*Client, error)
Creates new client. Client runs inference on plaintext data with encrypted model Set localhost to true if LAN is simulated on localhost
func (*Client) ClientSetup ¶
Invoked by client to setup server listening on setup port
func (*Client) DispatchMasking ¶
func (cl *Client) DispatchMasking(resp ProtocolMsg)
Listen for shares and aggregates
func (*Client) StartProto ¶
func (cl *Client) StartProto(proto ProtocolType, X *cipherUtils.EncInput) *cipherUtils.PlainInput
starts protocol instances in parallel
type DistributedBtp ¶
type DistributedBtp struct {
// contains filtered or unexported fields
}
distributed bootstrapper
func NewDistributedBootstrapper ¶
func NewDistributedBootstrapper(master *LocalMaster, minLevel int) *DistributedBtp
func (*DistributedBtp) Bootstrap ¶
func (Btp *DistributedBtp) Bootstrap(X *cipherUtils.EncInput, Box cipherUtils.CkksBox)
Starts refresh protocol with master
type LocalMaster ¶
type LocalMaster struct { ProtoBuf *sync.Map //ct id -> protocol instance *Protocol Cpk *rlwe.PublicKey Params ckks.Parameters Parties int Network latency.Network //comms Addr *net.TCPAddr PartiesAddr []*net.TCPAddr Done chan bool //flag caller that master is done with all instances // contains filtered or unexported fields }
Local master is the master node for LAN setting
func NewLocalMaster ¶
func NewLocalMaster(sk *rlwe.SecretKey, cpk *rlwe.PublicKey, params ckks.Parameters, parties int, partiesAddr []string, poolSize int, localhost bool) (*LocalMaster, error)
Creates and returns new master node. This node is in charge of the computations using the encrypted model and orchestrates the distributed bootstrap and refresh Set localhost to true if LAN is simulated on localhost
func (*LocalMaster) Dispatch ¶
func (lmst *LocalMaster) Dispatch(c net.Conn)
reads reply from open connection to player
func (*LocalMaster) DispatchPCKS ¶
func (lmst *LocalMaster) DispatchPCKS(resp ProtocolResp)
Listen for shares and aggregates
func (*LocalMaster) DispatchRef ¶
func (lmst *LocalMaster) DispatchRef(resp ProtocolResp)
Listen for shares and Finalize
func (*LocalMaster) MasterSetup ¶
func (lmst *LocalMaster) MasterSetup(playersAddr []string, parties int, skShares []*rlwe.SecretKey, pkP *rlwe.PublicKey)
Invoked by master to spawn players on remote servers
func (*LocalMaster) RunEnd ¶
func (lmst *LocalMaster) RunEnd()
func (*LocalMaster) RunPubKeySwitch ¶
func (lmst *LocalMaster) RunPubKeySwitch(proto *dckks.PCKSProtocol, pkQ *rlwe.PublicKey, ct *ckks.Ciphertext, ctId int)
Runs the PCKS protocol from master and sends messages to players
func (*LocalMaster) RunRefresh ¶
func (lmst *LocalMaster) RunRefresh(proto *dckks.RefreshProtocol, ct *ckks.Ciphertext, crp drlwe.CKSCRP, minLevel int, logBound int, ctId int)
Runs the Refresh protocol from master and sends messages to players
func (*LocalMaster) StartProto ¶
func (lmst *LocalMaster) StartProto(proto ProtocolType, X *cipherUtils.EncInput, pkQ *rlwe.PublicKey, minLevel int, Box cipherUtils.CkksBox)
starts protocol instances in parallel
type LocalPlayer ¶
type LocalPlayer struct { Remote PCKS *dckks.PCKSProtocol //PubKeySwitch BTP *dckks.RefreshProtocol //Bootstrap Cpk *rlwe.PublicKey Params ckks.Parameters Id int Addr *net.TCPAddr Conn net.Listener // contains filtered or unexported fields }
Local players hold sk shares for LAN Setting
func NewLocalPlayer ¶
func NewLocalPlayer(sk *rlwe.SecretKey, cpk *rlwe.PublicKey, params ckks.Parameters, id int, addr string, localhost bool) (*LocalPlayer, error)
Returns a player node, which will take part in distributed bootstrap and key switch protocol Set localhost to true if LAN is simulated on localhost
func (*LocalPlayer) Dispatch ¶
func (lp *LocalPlayer) Dispatch(c net.Conn)
Handler for the connection
func (*LocalPlayer) End ¶
func (lp *LocalPlayer) End(c net.Conn)
func (*LocalPlayer) Listen ¶
func (lp *LocalPlayer) Listen()
Accepts an incoming TCP connection and handles it (blocking)
func (*LocalPlayer) RunPubKeySwitch ¶
func (lp *LocalPlayer) RunPubKeySwitch(c net.Conn, msg ProtocolMsg)
Generates and send share to Master
func (*LocalPlayer) RunRefresh ¶
func (lp *LocalPlayer) RunRefresh(c net.Conn, msg ProtocolMsg)
Generate and send share to master
type MaskProtocol ¶
type MaskProtocol struct { Ct *ckks.Ciphertext //ct to be blindly decrypted //Mask *ckks.Plaintext //used for masking Mask *ring.Poly //used for masking Pt *ckks.Plaintext //result of decryption by server FeedbackChan chan *ckks.Plaintext }
Masking protocol for scenario data clear - model encrypted
type PCKSExt ¶
type PCKSExt struct {
Pk []byte `json:"pk"` //Pub Key from Querier -> PubKeySwitch
}
Extension for PCKS
type Protocol ¶
type Protocol struct { Protocol interface{} //instance of protocol Crp drlwe.CKSCRP //Common reference poly if any Ct *ckks.Ciphertext //ciphertext of the protocol Completion int //counter to completion FeedbackChan chan *ckks.Ciphertext //final result of protocol // contains filtered or unexported fields }
Wrapper for distributed key switch or refresh
type ProtocolMsg ¶
type ProtocolMsg struct { Type ProtocolType `json:"type"` Id int `json:"id"` //this is the id of the ct in the Enc Block Matrix, like i*row+j Ct []byte `json:"ct"` //ciphertext //Protocol Dependent Extension interface{} `json:"extension"` }
Master to player
type ProtocolResp ¶
type ProtocolResp struct { ProtoId int `json:"protoId"` Type ProtocolType `json:"type"` PlayerId int `json:"playerId"` }
Used by players for replying to master
type ProtocolType ¶
type ProtocolType int16
const ( CKSWITCH ProtocolType = iota REFRESH ProtocolType = iota MASKING ProtocolType = iota END ProtocolType = iota )
type RefreshExt ¶
type RefreshExt struct { Crp []byte `json:"crp"` //Common poly from CRS -> Refresh Precision int `json:"precision"` //Precision for instance of Refresh Protocol MinLevel int `json:"minlevel"` Scale float64 `json:"scale"` }
Extension for Refresh
type Remote ¶
type Remote interface {
Listen()
}
Interface implemented by player or server in distributed package
func ListenForSetup ¶
func ListenForSetup(addr string, params ckks.Parameters) Remote
Invoked by remote server for setup. The msg received will create either a player instance for the distributed bootstrap and keyswitch or a server instance for the oblivious decryption
type Server ¶
Server offers decryption as a service for oblivious decryption protocol