Documentation ¶
Overview ¶
Package sessions implements helium sessions.
Index ¶
- Variables
- func ContextWithCircuitID(ctx context.Context, circID CircuitID) context.Context
- func ContextWithNodeID(ctx context.Context, nodeID NodeID) context.Context
- func GenTestSecretKeys(sessParams Parameters) (secs map[NodeID]*Secrets, err error)
- func NewBackgroundContext(sessID ID, circID ...CircuitID) context.Context
- func NewContext(ctx context.Context, sessID ID, circID ...CircuitID) context.Context
- type CachedKeyBackend
- func (ckb *CachedKeyBackend) GetCollectivePublicKey(ctx context.Context) (*rlwe.PublicKey, error)
- func (ckb *CachedKeyBackend) GetGaloisKey(ctx context.Context, galEl uint64) (*rlwe.GaloisKey, error)
- func (ckb *CachedKeyBackend) GetRelinearizationKey(ctx context.Context) (*rlwe.RelinearizationKey, error)
- type Ciphertext
- type CiphertextID
- type CiphertextMetadata
- type CiphertextType
- type CircuitID
- type FHEParamerersLiteralProvider
- type FHEParameters
- type ID
- type MemoryKeyStore
- func (pkb *MemoryKeyStore) GetCollectivePublicKey(ctx context.Context) (cpk *rlwe.PublicKey, err error)
- func (pkb *MemoryKeyStore) GetGaloisKey(ctx context.Context, galEl uint64) (gk *rlwe.GaloisKey, err error)
- func (pkb *MemoryKeyStore) GetRelinearizationKey(ctx context.Context) (rlk *rlwe.RelinearizationKey, err error)
- type NodeID
- type Parameters
- type Provider
- type PublicKeyProvider
- type Secrets
- type Session
- func (sess *Session) Contains(nodeID NodeID) bool
- func (sess *Session) GetRLKEphemeralSecretKey() (*rlwe.SecretKey, error)
- func (sess *Session) GetSecretKey() (*rlwe.SecretKey, error)
- func (sess *Session) GetSecretKeyForGroup(parties []NodeID) (sk *rlwe.SecretKey, err error)
- func (sess *Session) GetSessionFromContext(ctx context.Context) (*Session, bool)
- func (sess *Session) GetSessionFromID(sessionID ID) (*Session, bool)
- func (sess *Session) GetShamirPublicPoints() map[NodeID]drlwe.ShamirPublicPoint
- func (sess *Session) GetShamirPublicPointsList() []drlwe.ShamirPublicPoint
- func (sess *Session) GetThresholdSecretKey() (*drlwe.ShamirSecretShare, error)
- func (sess *Session) String() string
- type Store
- type TestKeyProvider
- func (tkb *TestKeyProvider) GetCollectivePublicKey(ctx context.Context) (*rlwe.PublicKey, error)
- func (tkb *TestKeyProvider) GetGaloisKey(ctx context.Context, galEl uint64) (*rlwe.GaloisKey, error)
- func (tkb *TestKeyProvider) GetRelinearizationKey(ctx context.Context) (*rlwe.RelinearizationKey, error)
- type TestSession
Constants ¶
This section is empty.
Variables ¶
var ( // CtxNodeID is the context key for the node ID. CtxNodeID ctxKey = "node_id" // 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 ¶
ContextWithCircuitID returns a new context derived from ctx with the given session ID.
func ContextWithNodeID ¶
ContextWithNodeID returns a new context derived from ctx with the given node ID.
func GenTestSecretKeys ¶
func GenTestSecretKeys(sessParams Parameters) (secs map[NodeID]*Secrets, err error)
func NewBackgroundContext ¶
NewBackgroundContext returns a new context derived from context.Background 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 ¶
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 FHEParamerersLiteralProvider ¶
type FHEParamerersLiteralProvider interface {
GetRLWEParametersLiteral() rlwe.ParametersLiteral
}
type FHEParameters ¶
type FHEParameters interface {
GetRLWEParameters() *rlwe.Parameters
}
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 Parameters ¶
type Parameters struct { ID ID Nodes []NodeID FHEParameters FHEParamerersLiteralProvider Threshold int ShamirPks map[NodeID]drlwe.ShamirPublicPoint PublicSeed []byte *Secrets }
Parameters contains data used to initialize a Session.
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 Secrets ¶
type Secrets struct { PrivateSeed []byte ThresholdSecretKey *drlwe.ShamirSecretShare }
type Session ¶
type Session struct { Parameters NodeID NodeID Params FHEParameters // contains filtered or unexported fields }
Session holds the session's critical state.
func NewSession ¶
func NewSession(sessParams Parameters, nodeID NodeID) (sess *Session, err error)
NewSession creates a new session.
func (*Session) GetRLKEphemeralSecretKey ¶
func (*Session) GetSecretKey ¶
GetSecretKey loads the secret key from the ObjectStore.
func (*Session) GetSecretKeyForGroup ¶
func (*Session) GetSessionFromContext ¶
func (*Session) GetSessionFromID ¶
func (*Session) GetShamirPublicPoints ¶
func (sess *Session) GetShamirPublicPoints() map[NodeID]drlwe.ShamirPublicPoint
func (*Session) GetShamirPublicPointsList ¶
func (sess *Session) GetShamirPublicPointsList() []drlwe.ShamirPublicPoint
func (*Session) GetThresholdSecretKey ¶
func (sess *Session) GetThresholdSecretKey() (*drlwe.ShamirSecretShare, error)
GetThresholdSecretKey loads the secret key from the ObjectStore.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) NewRLWESession ¶
func (s *Store) NewRLWESession(sessParams Parameters, nodeID NodeID) (sess *Session, err error)
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 ¶
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 TestSession ¶
type TestSession struct { SessParams Parameters RlweParams rlwe.Parameters SkIdeal *rlwe.SecretKey NodeSessions map[NodeID]*Session HelperSession *Session // key backend *CachedKeyBackend // lattigo helpers //Encoder *bgv.Encoder Encryptor *rlwe.Encryptor Decrpytor *rlwe.Decryptor }
func NewTestSession ¶
func NewTestSession(N, T int, rlweparams FHEParamerersLiteralProvider, helperID NodeID) (*TestSession, error)
func NewTestSessionFromParams ¶
func NewTestSessionFromParams(sp Parameters, helperID NodeID) (*TestSession, error)