wip on generic traits

This commit is contained in:
Jean-Philippe Bossuat
2025-02-18 17:15:24 +01:00
parent d486e89761
commit 71f33f5983
7 changed files with 104 additions and 182 deletions

View File

@@ -1,7 +1,7 @@
use crate::ciphertext::Ciphertext;
use crate::elem::{Elem, ElemVecZnx, VecZnxCommon};
use crate::parameters::Parameters;
use base2k::{Infos, Module, VecZnx, VecZnxApi};
use base2k::{Module, VecZnx};
pub struct Plaintext<T>(pub Elem<T>);
@@ -12,16 +12,16 @@ impl Parameters {
pub fn bytes_of_plaintext<T>(&self, log_q: usize) -> usize
where
T: VecZnxCommon,
Elem<T>: Infos + ElemVecZnx<T>,
T: VecZnxCommon<Owned = T>,
Elem<T>: ElemVecZnx<T>,
{
Elem::<T>::bytes_of(self.module(), self.log_base2k(), log_q, 1)
}
pub fn plaintext_from_bytes<T>(&self, log_q: usize, bytes: &mut [u8]) -> Plaintext<T>
where
T: VecZnxCommon,
Elem<T>: Infos + ElemVecZnx<T>,
T: VecZnxCommon<Owned = T>,
Elem<T>: ElemVecZnx<T>,
{
Plaintext::<T>(self.elem_from_bytes::<T>(log_q, 1, bytes))
}
@@ -35,8 +35,8 @@ impl Plaintext<VecZnx> {
impl<T> Plaintext<T>
where
T: VecZnxCommon,
Elem<T>: Infos + ElemVecZnx<T>,
T: VecZnxCommon<Owned = T>,
Elem<T>: ElemVecZnx<T>,
{
pub fn bytes_of(module: &Module, log_base2k: usize, log_q: usize) -> usize {
Elem::<T>::bytes_of(module, log_base2k, log_q, 1)