Trait BGVModswitchStrategy

Source
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§

Source

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§

Source

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>,

Evaluates the given circuit homomorphically on the given encrypted inputs. This includes performing modulus-switches at suitable times.

The parameters are as follows:

  • circuit is the circuit to evaluate, with constants in a ring that supports plaintext-ciphertext operations, as specified by AsBGVPlaintext
  • ring is the ring that contains the constants of circuit
  • P is the plaintext ring w.r.t. which the inputs are encrypted; evaluate_circuit() does not support mixing different plaintext moduli
  • C_master is 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 factors
  • inputs contains 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) where ctxt is the ciphertext w.r.t. the RNS base that contains all RNS factors of C_master except those mentioned in drop_rns_fctors, and info should store the additional information associated to the ciphertext that is required to determine modulus-switching times.
  • rk should be the relinearization key w.r.t. C_master, can be None if the circuit contains no multiplication gates.
  • gks should 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.

Source

fn info_for_fresh_encryption( &self, P: &PlaintextRing<Params>, C: &CiphertextRing<Params>, sk_hwt: Option<usize>, ) -> Self::CiphertextInfo

Source

fn clone_info(&self, info: &Self::CiphertextInfo) -> Self::CiphertextInfo

Source

fn print_info( &self, P: &PlaintextRing<Params>, C_master: &CiphertextRing<Params>, ct: &ModulusAwareCiphertext<Params, Self>, )

Provided Methods§

Source

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.

Implementors§