pub trait BGVModswitchStrategy<Params: BGVCiphertextParams> {
type CiphertextInfo;
// Required methods
fn evaluate_circuit<R>(
&self,
circuit: &PlaintextCircuit<R::Type>,
ring: R,
P: &PlaintextRing<Params>,
C_master: &CiphertextRing<Params>,
inputs: &[ModulusAwareCiphertext<Params, Self>],
rk: Option<&RelinKey<'_, Params>>,
gks: &[(CyclotomicGaloisGroupEl, KeySwitchKey<'_, Params>)],
key_switches: &mut usize,
debug_sk: Option<&SecretKey<Params>>,
) -> Vec<ModulusAwareCiphertext<Params, Self>>
where R: RingStore,
R::Type: AsBGVPlaintext<Params>;
fn info_for_fresh_encryption(
&self,
P: &PlaintextRing<Params>,
C: &CiphertextRing<Params>,
sk_hwt: Option<usize>,
) -> Self::CiphertextInfo;
fn clone_info(&self, info: &Self::CiphertextInfo) -> Self::CiphertextInfo;
fn print_info(
&self,
P: &PlaintextRing<Params>,
C_master: &CiphertextRing<Params>,
ct: &ModulusAwareCiphertext<Params, Self>,
);
// Provided method
fn clone_ct(
&self,
P: &PlaintextRing<Params>,
C_master: &CiphertextRing<Params>,
ct: &ModulusAwareCiphertext<Params, Self>,
) -> ModulusAwareCiphertext<Params, Self> { ... }
}Expand description
Trait for different modulus-switching strategies in BGV, currently WIP.
Basically, a BGVModswitchStrategy should be able to determine when (and
how) to modulus-switch during the evaluation of an arithmetic circuit.
The most powerful way to do this is by delegating the evaluation of the
circuit completely to the BGVModswitchStrategy, which is our current
approach.
Required Associated Types§
Sourcetype CiphertextInfo
type CiphertextInfo
Additional information that is associated to a ciphertext and is used to determine when and how to modulus-switch. This will most likely be some form of estimate of the noise in the ciphertext.
Required Methods§
Sourcefn evaluate_circuit<R>(
&self,
circuit: &PlaintextCircuit<R::Type>,
ring: R,
P: &PlaintextRing<Params>,
C_master: &CiphertextRing<Params>,
inputs: &[ModulusAwareCiphertext<Params, Self>],
rk: Option<&RelinKey<'_, Params>>,
gks: &[(CyclotomicGaloisGroupEl, KeySwitchKey<'_, Params>)],
key_switches: &mut usize,
debug_sk: Option<&SecretKey<Params>>,
) -> Vec<ModulusAwareCiphertext<Params, Self>>
fn evaluate_circuit<R>( &self, circuit: &PlaintextCircuit<R::Type>, ring: R, P: &PlaintextRing<Params>, C_master: &CiphertextRing<Params>, inputs: &[ModulusAwareCiphertext<Params, Self>], rk: Option<&RelinKey<'_, Params>>, gks: &[(CyclotomicGaloisGroupEl, KeySwitchKey<'_, Params>)], key_switches: &mut usize, debug_sk: Option<&SecretKey<Params>>, ) -> Vec<ModulusAwareCiphertext<Params, Self>>
Evaluates the given circuit homomorphically on the given encrypted inputs. This includes performing modulus-switches at suitable times.
The parameters are as follows:
circuitis the circuit to evaluate, with constants in a ring that supports plaintext-ciphertext operations, as specified byAsBGVPlaintextringis the ring that contains the constants ofcircuitPis the plaintext ring w.r.t. which the inputs are encrypted;evaluate_circuit()does not support mixing different plaintext moduliC_masteris the ciphertext ring with the largest relevant RNS base, i.e. its RNS base should contain all RNS factors that are referenced by any ciphertext, and may have additional unused RNS factorsinputscontains all inputs to the circuit, i.e. must be of the same length as the circuit has input wires. Each entry should be of the form(drop_rns_factors, info, ctxt)wherectxtis the ciphertext w.r.t. the RNS base that contains all RNS factors ofC_masterexcept those mentioned indrop_rns_fctors, andinfoshould store the additional information associated to the ciphertext that is required to determine modulus-switching times.rkshould be the relinearization key w.r.t.C_master, can beNoneif the circuit contains no multiplication gates.gksshould contain all Galois keys used by the circuit (may also contain unused ones); if the circuit has no Galois gates, this may be an empty slice
Note that the BGVModswitchStrategy::CiphertextInfos currently cannot be created using
functions of the trait, but only via functions on the concrete implementation of
BGVModswitchStrategy.
fn info_for_fresh_encryption( &self, P: &PlaintextRing<Params>, C: &CiphertextRing<Params>, sk_hwt: Option<usize>, ) -> Self::CiphertextInfo
fn clone_info(&self, info: &Self::CiphertextInfo) -> Self::CiphertextInfo
fn print_info( &self, P: &PlaintextRing<Params>, C_master: &CiphertextRing<Params>, ct: &ModulusAwareCiphertext<Params, Self>, )
Provided Methods§
fn clone_ct( &self, P: &PlaintextRing<Params>, C_master: &CiphertextRing<Params>, ct: &ModulusAwareCiphertext<Params, Self>, ) -> ModulusAwareCiphertext<Params, Self>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.