mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
working on adding rank to glwe (all test passing)
This commit is contained in:
53
core/src/glwe_plaintext.rs
Normal file
53
core/src/glwe_plaintext.rs
Normal file
@@ -0,0 +1,53 @@
|
||||
use base2k::{Backend, Module, VecZnx, VecZnxAlloc, VecZnxToMut, VecZnxToRef};
|
||||
|
||||
use crate::{elem::Infos, utils::derive_size};
|
||||
|
||||
pub struct GLWEPlaintext<C> {
|
||||
pub data: VecZnx<C>,
|
||||
pub basek: usize,
|
||||
pub k: usize,
|
||||
}
|
||||
|
||||
impl<T> Infos for GLWEPlaintext<T> {
|
||||
type Inner = VecZnx<T>;
|
||||
|
||||
fn inner(&self) -> &Self::Inner {
|
||||
&self.data
|
||||
}
|
||||
|
||||
fn basek(&self) -> usize {
|
||||
self.basek
|
||||
}
|
||||
|
||||
fn k(&self) -> usize {
|
||||
self.k
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> VecZnxToMut for GLWEPlaintext<C>
|
||||
where
|
||||
VecZnx<C>: VecZnxToMut,
|
||||
{
|
||||
fn to_mut(&mut self) -> VecZnx<&mut [u8]> {
|
||||
self.data.to_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl<C> VecZnxToRef for GLWEPlaintext<C>
|
||||
where
|
||||
VecZnx<C>: VecZnxToRef,
|
||||
{
|
||||
fn to_ref(&self) -> VecZnx<&[u8]> {
|
||||
self.data.to_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl GLWEPlaintext<Vec<u8>> {
|
||||
pub fn new<B: Backend>(module: &Module<B>, base2k: usize, k: usize) -> Self {
|
||||
Self {
|
||||
data: module.new_vec_znx(1, derive_size(base2k, k)),
|
||||
basek: base2k,
|
||||
k,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user