Replace hasmap of glweautomorphismkeys by helper trait, enabling not having to pass, for example, but full CBT key for ops that do not require it

This commit is contained in:
Pro7ech
2025-10-30 10:42:28 +01:00
parent f03bb4931b
commit 201a1f64eb
11 changed files with 148 additions and 112 deletions

View File

@@ -1,10 +1,28 @@
use std::collections::HashMap;
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch};
use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GGLWEPrepared, GGLWEPreparedFactory, GGLWEPreparedToMut, GGLWEPreparedToRef,
GGLWEToRef, GLWEInfos, GetGaloisElement, LWEInfos, Rank, SetGaloisElement, TorusPrecision,
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GGLWELayout, GGLWEPrepared, GGLWEPreparedFactory, GGLWEPreparedToMut,
GGLWEPreparedToRef, GGLWEToRef, GLWEAutomorphismKeyHelper, GLWEInfos, GetGaloisElement, LWEInfos, Rank, SetGaloisElement,
TorusPrecision,
};
impl<K, BE: Backend> GLWEAutomorphismKeyHelper<K, BE> for HashMap<i64, K>
where
K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
{
fn get_automorphism_key(&self, k: i64) -> Option<&K> {
self.get(&k)
}
fn automorphism_key_infos(&self) -> GGLWELayout {
self.get(self.keys().next().unwrap())
.unwrap()
.gglwe_layout()
}
}
#[derive(PartialEq, Eq)]
pub struct GLWEAutomorphismKeyPrepared<D: Data, B: Backend> {
pub(crate) key: GGLWEPrepared<D, B>,