This commit is contained in:
Pro7ech
2025-10-22 16:43:46 +02:00
parent 5755aea58c
commit cedf7b9c59
26 changed files with 713 additions and 723 deletions

View File

@@ -192,7 +192,7 @@ pub trait GLWECompressedToRef {
impl<D: DataRef> GLWECompressedToRef for GLWECompressed<D> {
fn to_ref(&self) -> GLWECompressed<&[u8]> {
GLWECompressed {
seed: self.seed.clone(),
seed: self.seed,
base2k: self.base2k,
k: self.k,
rank: self.rank,
@@ -208,7 +208,7 @@ pub trait GLWECompressedToMut {
impl<D: DataMut> GLWECompressedToMut for GLWECompressed<D> {
fn to_mut(&mut self) -> GLWECompressed<&mut [u8]> {
GLWECompressed {
seed: self.seed.clone(),
seed: self.seed,
base2k: self.base2k,
k: self.k,
rank: self.rank,

View File

@@ -146,8 +146,8 @@ where {
impl<D: DataMut> ReaderFrom for GLWESwitchingKeyCompressed<D> {
fn read_from<R: std::io::Read>(&mut self, reader: &mut R) -> std::io::Result<()> {
self.input_degree = Degree(reader.read_u32::<LittleEndian>()? as u32);
self.output_degree = Degree(reader.read_u32::<LittleEndian>()? as u32);
self.input_degree = Degree(reader.read_u32::<LittleEndian>()?);
self.output_degree = Degree(reader.read_u32::<LittleEndian>()?);
self.key.read_from(reader)
}
}

View File

@@ -240,8 +240,8 @@ impl<D: DataMut> GLWESwitchingKey<D> {
impl<D: DataMut> ReaderFrom for GLWESwitchingKey<D> {
fn read_from<R: std::io::Read>(&mut self, reader: &mut R) -> std::io::Result<()> {
self.input_degree = Degree(reader.read_u32::<LittleEndian>()? as u32);
self.output_degree = Degree(reader.read_u32::<LittleEndian>()? as u32);
self.input_degree = Degree(reader.read_u32::<LittleEndian>()?);
self.output_degree = Degree(reader.read_u32::<LittleEndian>()?);
self.key.read_from(reader)
}
}

View File

@@ -43,7 +43,7 @@ pub trait GetDegree {
impl<B: Backend> GetDegree for Module<B> {
fn ring_degree(&self) -> Degree {
Self::n(&self).into()
Self::n(self).into()
}
}

View File

@@ -69,7 +69,7 @@ pub trait GLWEAutomorphismKeyPreparedFactory<B: Backend>
where
Self: GGLWEPreparedFactory<B>,
{
fn alloc_automorphism_key_prepared(
fn alloc_glwe_automorphism_key_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -83,7 +83,7 @@ where
}
}
fn alloc_automorphism_key_prepared_from_infos<A>(&self, infos: &A) -> GLWEAutomorphismKeyPrepared<Vec<u8>, B>
fn alloc_glwe_automorphism_key_prepared_from_infos<A>(&self, infos: &A) -> GLWEAutomorphismKeyPrepared<Vec<u8>, B>
where
A: GGLWEInfos,
{
@@ -92,7 +92,7 @@ where
infos.rank_out(),
"rank_in != rank_out is not supported for AutomorphismKeyPrepared"
);
self.alloc_automorphism_key_prepared(
self.alloc_glwe_automorphism_key_prepared(
infos.base2k(),
infos.k(),
infos.rank(),
@@ -101,7 +101,7 @@ where
)
}
fn bytes_of_automorphism_key_prepared(
fn bytes_of_glwe_automorphism_key_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -112,7 +112,7 @@ where
self.bytes_of_gglwe_prepared(base2k, k, rank, rank, dnum, dsize)
}
fn bytes_of_automorphism_key_prepared_from_infos<A>(&self, infos: &A) -> usize
fn bytes_of_glwe_automorphism_key_prepared_from_infos<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
@@ -121,7 +121,7 @@ where
infos.rank_out(),
"rank_in != rank_out is not supported for AutomorphismKeyPrepared"
);
self.bytes_of_automorphism_key_prepared(
self.bytes_of_glwe_automorphism_key_prepared(
infos.base2k(),
infos.k(),
infos.rank(),
@@ -130,14 +130,14 @@ where
)
}
fn prepare_automorphism_key_tmp_bytes<A>(&self, infos: &A) -> usize
fn prepare_glwe_automorphism_key_tmp_bytes<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
self.prepare_gglwe_tmp_bytes(infos)
}
fn prepare_automorphism_key<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
fn prepare_glwe_automorphism_key<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
where
R: GGLWEPreparedToMut<B> + SetGaloisElement,
O: GGLWEToRef + GetGaloisElement,
@@ -155,14 +155,14 @@ impl<B: Backend> GLWEAutomorphismKeyPrepared<Vec<u8>, B> {
A: GGLWEInfos,
M: GLWEAutomorphismKeyPreparedFactory<B>,
{
module.alloc_automorphism_key_prepared_from_infos(infos)
module.alloc_glwe_automorphism_key_prepared_from_infos(infos)
}
pub fn alloc<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> Self
where
M: GLWEAutomorphismKeyPreparedFactory<B>,
{
module.alloc_automorphism_key_prepared(base2k, k, rank, dnum, dsize)
module.alloc_glwe_automorphism_key_prepared(base2k, k, rank, dnum, dsize)
}
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
@@ -170,14 +170,14 @@ impl<B: Backend> GLWEAutomorphismKeyPrepared<Vec<u8>, B> {
A: GGLWEInfos,
M: GLWEAutomorphismKeyPreparedFactory<B>,
{
module.bytes_of_automorphism_key_prepared_from_infos(infos)
module.bytes_of_glwe_automorphism_key_prepared_from_infos(infos)
}
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize
where
M: GLWEAutomorphismKeyPreparedFactory<B>,
{
module.bytes_of_automorphism_key_prepared(base2k, k, rank, dnum, dsize)
module.bytes_of_glwe_automorphism_key_prepared(base2k, k, rank, dnum, dsize)
}
}
@@ -186,7 +186,7 @@ impl<B: Backend> GLWEAutomorphismKeyPrepared<Vec<u8>, B> {
where
M: GLWEAutomorphismKeyPreparedFactory<B>,
{
module.prepare_automorphism_key_tmp_bytes(self)
module.prepare_glwe_automorphism_key_tmp_bytes(self)
}
}
@@ -196,7 +196,7 @@ impl<D: DataMut, B: Backend> GLWEAutomorphismKeyPrepared<D, B> {
O: GGLWEToRef + GetGaloisElement,
M: GLWEAutomorphismKeyPreparedFactory<B>,
{
module.prepare_automorphism_key(self, other, scratch);
module.prepare_glwe_automorphism_key(self, other, scratch);
}
}

View File

@@ -166,7 +166,10 @@ impl<D: DataRef, B: Backend> GLWESecretPreparedToRef<B> for GLWESecretPrepared<D
}
}
pub trait GLWESecretPreparedToMut<B: Backend> {
pub trait GLWESecretPreparedToMut<B: Backend>
where
Self: GLWESecretPreparedToRef<B>,
{
fn to_mut(&mut self) -> GLWESecretPrepared<&mut [u8], B>;
}

View File

@@ -102,11 +102,11 @@ where
self.bytes_of_glwe_to_lwe_switching_key_prepared(infos.base2k(), infos.k(), infos.rank_in(), infos.dnum())
}
fn prepare_glwe_to_lwe_switching_key_tmp_bytes<A>(&self, infos: &A)
fn prepare_glwe_to_lwe_switching_key_tmp_bytes<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
self.prepare_glwe_switching_key_tmp_bytes(infos);
self.prepare_glwe_switching_key_tmp_bytes(infos)
}
fn prepare_glwe_to_lwe_switching_key<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)