diff --git a/.gitmodules b/.gitmodules index 58601f7..2582894 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "backend/src/implementation/cpu_spqlios/spqlios-arithmetic"] - path = backend/src/implementation/cpu_spqlios/spqlios-arithmetic +[submodule "poulpy-backend/src/implementation/cpu_spqlios/spqlios-arithmetic"] + path = poulpy-backend/src/implementation/cpu_spqlios/spqlios-arithmetic url = https://github.com/phantomzone-org/spqlios-arithmetic diff --git a/Cargo.lock b/Cargo.lock index e4516a3..07d00a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,21 +35,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973" -[[package]] -name = "backend" -version = "0.1.0" -dependencies = [ - "byteorder", - "cmake", - "criterion", - "itertools 0.14.0", - "rand", - "rand_core", - "rand_distr", - "rug", - "sampling", -] - [[package]] name = "bitflags" version = "2.9.0" @@ -150,20 +135,6 @@ dependencies = [ "cc", ] -[[package]] -name = "core" -version = "0.1.0" -dependencies = [ - "backend", - "byteorder", - "criterion", - "itertools 0.14.0", - "rand_core", - "rand_distr", - "rug", - "sampling", -] - [[package]] name = "criterion" version = "0.7.0" @@ -375,13 +346,73 @@ dependencies = [ ] [[package]] -name = "poulpy" +name = "poulpy-backend" version = "0.1.0" dependencies = [ - "backend", - "core", - "sampling", - "schemes", + "byteorder", + "cmake", + "criterion", + "itertools 0.14.0", + "rand", + "rand_chacha", + "rand_core", + "rand_distr", + "rug", +] + +[[package]] +name = "poulpy-backend" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d47fbc27d0c03c2bfffd972795c62a243e4a3a3068acdb95ef55fb335a58d00f" +dependencies = [ + "byteorder", + "cmake", + "criterion", + "itertools 0.14.0", + "rand", + "rand_chacha", + "rand_core", + "rand_distr", + "rug", +] + +[[package]] +name = "poulpy-core" +version = "0.1.0" +dependencies = [ + "byteorder", + "criterion", + "itertools 0.14.0", + "poulpy-backend 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core", + "rand_distr", + "rug", +] + +[[package]] +name = "poulpy-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ff4e1acd3f4a84e861b07184fd28fe3143a57360bd51e923aeadbc94b8b38d0" +dependencies = [ + "byteorder", + "criterion", + "itertools 0.14.0", + "poulpy-backend 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core", + "rand_distr", + "rug", +] + +[[package]] +name = "poulpy-schemes" +version = "0.1.0" +dependencies = [ + "byteorder", + "itertools 0.14.0", + "poulpy-backend 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "poulpy-core 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -532,26 +563,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "sampling" -version = "0.1.0" -dependencies = [ - "rand_chacha", - "rand_core", - "rand_distr", -] - -[[package]] -name = "schemes" -version = "0.1.0" -dependencies = [ - "backend", - "byteorder", - "core", - "itertools 0.14.0", - "sampling", -] - [[package]] name = "serde" version = "1.0.219" diff --git a/Cargo.toml b/Cargo.toml index b0e3d5b..8774029 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["backend", "core", "sampling", "schemes", "poulpy"] +members = ["poulpy-backend", "poulpy-core", "poulpy-schemes"] resolver = "3" [workspace.dependencies] diff --git a/README.md b/README.md index 402f551..8d19123 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ Please see [SECURITY](./SECURITY.md). ## License -Poulpy is licensed under the Apache 2.0 License. See [NOTICE](./NOTICE) & [LICENSE](./LICENSE). +Poulpy is licensed under the Apache-2.0 License. See [NOTICE](./NOTICE) & [LICENSE](./LICENSE). ## Acknowledgement diff --git a/backend/Cargo.toml b/poulpy-backend/Cargo.toml similarity index 56% rename from backend/Cargo.toml rename to poulpy-backend/Cargo.toml index e447821..e23ee54 100644 --- a/backend/Cargo.toml +++ b/poulpy-backend/Cargo.toml @@ -1,8 +1,13 @@ [package] -name = "backend" +name = "poulpy-backend" version = "0.1.0" edition = "2024" license = "Apache-2.0" +readme = "README.md" +description = "A crate implementing bivariate polynomial arithmetic" +repository = "https://github.com/phantomzone-org/poulpy" +homepage = "https://github.com/phantomzone-org/poulpy" +documentation = "https://docs.rs/poulpy" [dependencies] rug = {workspace = true} @@ -11,8 +16,8 @@ itertools = {workspace = true} rand = {workspace = true} rand_distr = {workspace = true} rand_core = {workspace = true} -sampling = { path = "../sampling" } byteorder = {workspace = true} +rand_chacha = "0.9.0" [build-dependencies] cmake = "0.1.54" diff --git a/backend/README.md b/poulpy-backend/README.md similarity index 100% rename from backend/README.md rename to poulpy-backend/README.md diff --git a/backend/build.rs b/poulpy-backend/build.rs similarity index 100% rename from backend/build.rs rename to poulpy-backend/build.rs diff --git a/backend/builds/cpu_spqlios.rs b/poulpy-backend/builds/cpu_spqlios.rs similarity index 100% rename from backend/builds/cpu_spqlios.rs rename to poulpy-backend/builds/cpu_spqlios.rs diff --git a/backend/docs/backend_safety_contract.md b/poulpy-backend/docs/backend_safety_contract.md similarity index 100% rename from backend/docs/backend_safety_contract.md rename to poulpy-backend/docs/backend_safety_contract.md diff --git a/backend/examples/rlwe_encrypt.rs b/poulpy-backend/examples/rlwe_encrypt.rs similarity index 99% rename from backend/examples/rlwe_encrypt.rs rename to poulpy-backend/examples/rlwe_encrypt.rs index 94a49b3..392b673 100644 --- a/backend/examples/rlwe_encrypt.rs +++ b/poulpy-backend/examples/rlwe_encrypt.rs @@ -1,4 +1,5 @@ -use backend::{ +use itertools::izip; +use poulpy_backend::{ hal::{ api::{ ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPrepare, VecZnxAddNormal, @@ -6,11 +7,10 @@ use backend::{ VecZnxDftAlloc, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigTmpA, VecZnxFillUniform, VecZnxNormalizeInplace, ZnxInfos, }, layouts::{Module, ScalarZnx, ScratchOwned, SvpPPol, VecZnx, VecZnxBig, VecZnxDft}, + source::Source, }, implementation::cpu_spqlios::FFT64, }; -use itertools::izip; -use sampling::source::Source; fn main() { let n: usize = 16; diff --git a/backend/src/hal/api/mod.rs b/poulpy-backend/src/hal/api/mod.rs similarity index 100% rename from backend/src/hal/api/mod.rs rename to poulpy-backend/src/hal/api/mod.rs diff --git a/backend/src/hal/api/module.rs b/poulpy-backend/src/hal/api/module.rs similarity index 100% rename from backend/src/hal/api/module.rs rename to poulpy-backend/src/hal/api/module.rs diff --git a/backend/src/hal/api/scratch.rs b/poulpy-backend/src/hal/api/scratch.rs similarity index 100% rename from backend/src/hal/api/scratch.rs rename to poulpy-backend/src/hal/api/scratch.rs diff --git a/backend/src/hal/api/svp_ppol.rs b/poulpy-backend/src/hal/api/svp_ppol.rs similarity index 100% rename from backend/src/hal/api/svp_ppol.rs rename to poulpy-backend/src/hal/api/svp_ppol.rs diff --git a/backend/src/hal/api/vec_znx.rs b/poulpy-backend/src/hal/api/vec_znx.rs similarity index 98% rename from backend/src/hal/api/vec_znx.rs rename to poulpy-backend/src/hal/api/vec_znx.rs index fa645a6..cc1525f 100644 --- a/backend/src/hal/api/vec_znx.rs +++ b/poulpy-backend/src/hal/api/vec_znx.rs @@ -1,7 +1,9 @@ use rand_distr::Distribution; -use sampling::source::Source; -use crate::hal::layouts::{Backend, ScalarZnxToRef, Scratch, VecZnxToMut, VecZnxToRef}; +use crate::hal::{ + layouts::{Backend, ScalarZnxToRef, Scratch, VecZnxToMut, VecZnxToRef}, + source::Source, +}; pub trait VecZnxNormalizeTmpBytes { /// Returns the minimum number of bytes necessary for normalization. diff --git a/backend/src/hal/api/vec_znx_big.rs b/poulpy-backend/src/hal/api/vec_znx_big.rs similarity index 97% rename from backend/src/hal/api/vec_znx_big.rs rename to poulpy-backend/src/hal/api/vec_znx_big.rs index e376116..2f6ee4c 100644 --- a/backend/src/hal/api/vec_znx_big.rs +++ b/poulpy-backend/src/hal/api/vec_znx_big.rs @@ -1,7 +1,9 @@ use rand_distr::Distribution; -use sampling::source::Source; -use crate::hal::layouts::{Backend, Scratch, VecZnxBigOwned, VecZnxBigToMut, VecZnxBigToRef, VecZnxToMut, VecZnxToRef}; +use crate::hal::{ + layouts::{Backend, Scratch, VecZnxBigOwned, VecZnxBigToMut, VecZnxBigToRef, VecZnxToMut, VecZnxToRef}, + source::Source, +}; /// Allocates as [crate::hal::layouts::VecZnxBig]. pub trait VecZnxBigAlloc { diff --git a/backend/src/hal/api/vec_znx_dft.rs b/poulpy-backend/src/hal/api/vec_znx_dft.rs similarity index 100% rename from backend/src/hal/api/vec_znx_dft.rs rename to poulpy-backend/src/hal/api/vec_znx_dft.rs diff --git a/backend/src/hal/api/vmp_pmat.rs b/poulpy-backend/src/hal/api/vmp_pmat.rs similarity index 100% rename from backend/src/hal/api/vmp_pmat.rs rename to poulpy-backend/src/hal/api/vmp_pmat.rs diff --git a/backend/src/hal/api/znx_base.rs b/poulpy-backend/src/hal/api/znx_base.rs similarity index 97% rename from backend/src/hal/api/znx_base.rs rename to poulpy-backend/src/hal/api/znx_base.rs index bd94512..bc15acc 100644 --- a/backend/src/hal/api/znx_base.rs +++ b/poulpy-backend/src/hal/api/znx_base.rs @@ -1,6 +1,8 @@ -use crate::hal::layouts::{Data, DataMut, DataRef}; +use crate::hal::{ + layouts::{Data, DataMut, DataRef}, + source::Source, +}; use rand_distr::num_traits::Zero; -use sampling::source::Source; pub trait ZnxInfos { /// Returns the ring degree of the polynomials. diff --git a/backend/src/hal/delegates/mod.rs b/poulpy-backend/src/hal/delegates/mod.rs similarity index 100% rename from backend/src/hal/delegates/mod.rs rename to poulpy-backend/src/hal/delegates/mod.rs diff --git a/backend/src/hal/delegates/module.rs b/poulpy-backend/src/hal/delegates/module.rs similarity index 100% rename from backend/src/hal/delegates/module.rs rename to poulpy-backend/src/hal/delegates/module.rs diff --git a/backend/src/hal/delegates/scratch.rs b/poulpy-backend/src/hal/delegates/scratch.rs similarity index 100% rename from backend/src/hal/delegates/scratch.rs rename to poulpy-backend/src/hal/delegates/scratch.rs diff --git a/backend/src/hal/delegates/svp_ppol.rs b/poulpy-backend/src/hal/delegates/svp_ppol.rs similarity index 100% rename from backend/src/hal/delegates/svp_ppol.rs rename to poulpy-backend/src/hal/delegates/svp_ppol.rs diff --git a/backend/src/hal/delegates/vec_znx.rs b/poulpy-backend/src/hal/delegates/vec_znx.rs similarity index 99% rename from backend/src/hal/delegates/vec_znx.rs rename to poulpy-backend/src/hal/delegates/vec_znx.rs index 68d0290..db53467 100644 --- a/backend/src/hal/delegates/vec_znx.rs +++ b/poulpy-backend/src/hal/delegates/vec_znx.rs @@ -1,5 +1,3 @@ -use sampling::source::Source; - use crate::hal::{ api::{ VecZnxAdd, VecZnxAddDistF64, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, @@ -17,6 +15,7 @@ use crate::hal::{ VecZnxRotateImpl, VecZnxRotateInplaceImpl, VecZnxRshInplaceImpl, VecZnxSplitImpl, VecZnxSubABInplaceImpl, VecZnxSubBAInplaceImpl, VecZnxSubImpl, VecZnxSubScalarInplaceImpl, VecZnxSwithcDegreeImpl, }, + source::Source, }; impl VecZnxNormalizeTmpBytes for Module diff --git a/backend/src/hal/delegates/vec_znx_big.rs b/poulpy-backend/src/hal/delegates/vec_znx_big.rs similarity index 99% rename from backend/src/hal/delegates/vec_znx_big.rs rename to poulpy-backend/src/hal/delegates/vec_znx_big.rs index fc48d42..1d00c72 100644 --- a/backend/src/hal/delegates/vec_znx_big.rs +++ b/poulpy-backend/src/hal/delegates/vec_znx_big.rs @@ -1,5 +1,4 @@ use rand_distr::Distribution; -use sampling::source::Source; use crate::hal::{ api::{ @@ -18,6 +17,7 @@ use crate::hal::{ VecZnxBigSubBAInplaceImpl, VecZnxBigSubImpl, VecZnxBigSubSmallAImpl, VecZnxBigSubSmallAInplaceImpl, VecZnxBigSubSmallBImpl, VecZnxBigSubSmallBInplaceImpl, }, + source::Source, }; impl VecZnxBigAlloc for Module diff --git a/backend/src/hal/delegates/vec_znx_dft.rs b/poulpy-backend/src/hal/delegates/vec_znx_dft.rs similarity index 100% rename from backend/src/hal/delegates/vec_znx_dft.rs rename to poulpy-backend/src/hal/delegates/vec_znx_dft.rs diff --git a/backend/src/hal/delegates/vmp_pmat.rs b/poulpy-backend/src/hal/delegates/vmp_pmat.rs similarity index 100% rename from backend/src/hal/delegates/vmp_pmat.rs rename to poulpy-backend/src/hal/delegates/vmp_pmat.rs diff --git a/backend/src/hal/layouts/encoding.rs b/poulpy-backend/src/hal/layouts/encoding.rs similarity index 100% rename from backend/src/hal/layouts/encoding.rs rename to poulpy-backend/src/hal/layouts/encoding.rs diff --git a/backend/src/hal/layouts/mat_znx.rs b/poulpy-backend/src/hal/layouts/mat_znx.rs similarity index 99% rename from backend/src/hal/layouts/mat_znx.rs rename to poulpy-backend/src/hal/layouts/mat_znx.rs index 467dd12..acd4ec3 100644 --- a/backend/src/hal/layouts/mat_znx.rs +++ b/poulpy-backend/src/hal/layouts/mat_znx.rs @@ -3,13 +3,13 @@ use crate::{ hal::{ api::{DataView, DataViewMut, FillUniform, Reset, ZnxInfos, ZnxSliceSize, ZnxView, ZnxViewMut, ZnxZero}, layouts::{Data, DataMut, DataRef, ReaderFrom, ToOwnedDeep, VecZnx, WriterTo}, + source::Source, }, }; use std::fmt; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use rand::RngCore; -use sampling::source::Source; #[derive(PartialEq, Eq, Clone)] pub struct MatZnx { diff --git a/backend/src/hal/layouts/mod.rs b/poulpy-backend/src/hal/layouts/mod.rs similarity index 100% rename from backend/src/hal/layouts/mod.rs rename to poulpy-backend/src/hal/layouts/mod.rs diff --git a/backend/src/hal/layouts/module.rs b/poulpy-backend/src/hal/layouts/module.rs similarity index 100% rename from backend/src/hal/layouts/module.rs rename to poulpy-backend/src/hal/layouts/module.rs diff --git a/backend/src/hal/layouts/scalar_znx.rs b/poulpy-backend/src/hal/layouts/scalar_znx.rs similarity index 99% rename from backend/src/hal/layouts/scalar_znx.rs rename to poulpy-backend/src/hal/layouts/scalar_znx.rs index 1277df9..137eaae 100644 --- a/backend/src/hal/layouts/scalar_znx.rs +++ b/poulpy-backend/src/hal/layouts/scalar_znx.rs @@ -1,13 +1,13 @@ use rand::seq::SliceRandom; use rand_core::RngCore; use rand_distr::{Distribution, weighted::WeightedIndex}; -use sampling::source::Source; use crate::{ alloc_aligned, hal::{ api::{DataView, DataViewMut, FillUniform, Reset, ZnxInfos, ZnxSliceSize, ZnxView, ZnxViewMut, ZnxZero}, layouts::{Data, DataMut, DataRef, ReaderFrom, ToOwnedDeep, VecZnx, WriterTo}, + source::Source, }, }; diff --git a/backend/src/hal/layouts/scratch.rs b/poulpy-backend/src/hal/layouts/scratch.rs similarity index 100% rename from backend/src/hal/layouts/scratch.rs rename to poulpy-backend/src/hal/layouts/scratch.rs diff --git a/backend/src/hal/layouts/serialization.rs b/poulpy-backend/src/hal/layouts/serialization.rs similarity index 100% rename from backend/src/hal/layouts/serialization.rs rename to poulpy-backend/src/hal/layouts/serialization.rs diff --git a/backend/src/hal/layouts/stats.rs b/poulpy-backend/src/hal/layouts/stats.rs similarity index 100% rename from backend/src/hal/layouts/stats.rs rename to poulpy-backend/src/hal/layouts/stats.rs diff --git a/backend/src/hal/layouts/svp_ppol.rs b/poulpy-backend/src/hal/layouts/svp_ppol.rs similarity index 100% rename from backend/src/hal/layouts/svp_ppol.rs rename to poulpy-backend/src/hal/layouts/svp_ppol.rs diff --git a/backend/src/hal/layouts/vec_znx.rs b/poulpy-backend/src/hal/layouts/vec_znx.rs similarity index 99% rename from backend/src/hal/layouts/vec_znx.rs rename to poulpy-backend/src/hal/layouts/vec_znx.rs index acb64aa..765f095 100644 --- a/backend/src/hal/layouts/vec_znx.rs +++ b/poulpy-backend/src/hal/layouts/vec_znx.rs @@ -5,9 +5,13 @@ use crate::{ hal::{ api::{DataView, DataViewMut, FillUniform, Reset, ZnxInfos, ZnxSliceSize, ZnxView, ZnxViewMut, ZnxZero}, layouts::{Data, DataMut, DataRef, ReaderFrom, ToOwnedDeep, WriterTo}, + source::Source, }, }; +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; +use rand::RngCore; + #[derive(PartialEq, Eq, Clone, Copy)] pub struct VecZnx { pub(crate) data: D, @@ -220,10 +224,6 @@ impl VecZnxToMut for VecZnx { } } -use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; -use rand::RngCore; -use sampling::source::Source; - impl ReaderFrom for VecZnx { fn read_from(&mut self, reader: &mut R) -> std::io::Result<()> { self.n = reader.read_u64::()? as usize; diff --git a/backend/src/hal/layouts/vec_znx_big.rs b/poulpy-backend/src/hal/layouts/vec_znx_big.rs similarity index 100% rename from backend/src/hal/layouts/vec_znx_big.rs rename to poulpy-backend/src/hal/layouts/vec_znx_big.rs diff --git a/backend/src/hal/layouts/vec_znx_dft.rs b/poulpy-backend/src/hal/layouts/vec_znx_dft.rs similarity index 100% rename from backend/src/hal/layouts/vec_znx_dft.rs rename to poulpy-backend/src/hal/layouts/vec_znx_dft.rs diff --git a/backend/src/hal/layouts/vmp_pmat.rs b/poulpy-backend/src/hal/layouts/vmp_pmat.rs similarity index 100% rename from backend/src/hal/layouts/vmp_pmat.rs rename to poulpy-backend/src/hal/layouts/vmp_pmat.rs diff --git a/backend/src/hal/mod.rs b/poulpy-backend/src/hal/mod.rs similarity index 82% rename from backend/src/hal/mod.rs rename to poulpy-backend/src/hal/mod.rs index 5ecf38d..e94b4e2 100644 --- a/backend/src/hal/mod.rs +++ b/poulpy-backend/src/hal/mod.rs @@ -2,4 +2,5 @@ pub mod api; pub mod delegates; pub mod layouts; pub mod oep; +pub mod source; pub mod tests; diff --git a/backend/src/hal/oep/mod.rs b/poulpy-backend/src/hal/oep/mod.rs similarity index 100% rename from backend/src/hal/oep/mod.rs rename to poulpy-backend/src/hal/oep/mod.rs diff --git a/backend/src/hal/oep/module.rs b/poulpy-backend/src/hal/oep/module.rs similarity index 100% rename from backend/src/hal/oep/module.rs rename to poulpy-backend/src/hal/oep/module.rs diff --git a/backend/src/hal/oep/scratch.rs b/poulpy-backend/src/hal/oep/scratch.rs similarity index 100% rename from backend/src/hal/oep/scratch.rs rename to poulpy-backend/src/hal/oep/scratch.rs diff --git a/backend/src/hal/oep/svp_ppol.rs b/poulpy-backend/src/hal/oep/svp_ppol.rs similarity index 100% rename from backend/src/hal/oep/svp_ppol.rs rename to poulpy-backend/src/hal/oep/svp_ppol.rs diff --git a/backend/src/hal/oep/vec_znx.rs b/poulpy-backend/src/hal/oep/vec_znx.rs similarity index 99% rename from backend/src/hal/oep/vec_znx.rs rename to poulpy-backend/src/hal/oep/vec_znx.rs index e921491..975a8b8 100644 --- a/backend/src/hal/oep/vec_znx.rs +++ b/poulpy-backend/src/hal/oep/vec_znx.rs @@ -1,7 +1,9 @@ use rand_distr::Distribution; -use sampling::source::Source; -use crate::hal::layouts::{Backend, Module, ScalarZnxToRef, Scratch, VecZnxToMut, VecZnxToRef}; +use crate::hal::{ + layouts::{Backend, Module, ScalarZnxToRef, Scratch, VecZnxToMut, VecZnxToRef}, + source::Source, +}; /// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe) /// * See [vec_znx_normalize_base2k_tmp_bytes_ref](https://github.com/phantomzone-org/spqlios-arithmetic/blob/32a3f5fcce9863b58e949f2dfd5abc1bfbaa09b4/spqlios/arithmetic/vec_znx.c#L245C17-L245C55) for reference code. diff --git a/backend/src/hal/oep/vec_znx_big.rs b/poulpy-backend/src/hal/oep/vec_znx_big.rs similarity index 98% rename from backend/src/hal/oep/vec_znx_big.rs rename to poulpy-backend/src/hal/oep/vec_znx_big.rs index 7cf1396..7420be8 100644 --- a/backend/src/hal/oep/vec_znx_big.rs +++ b/poulpy-backend/src/hal/oep/vec_znx_big.rs @@ -1,7 +1,9 @@ use rand_distr::Distribution; -use sampling::source::Source; -use crate::hal::layouts::{Backend, Module, Scratch, VecZnxBigOwned, VecZnxBigToMut, VecZnxBigToRef, VecZnxToMut, VecZnxToRef}; +use crate::hal::{ + layouts::{Backend, Module, Scratch, VecZnxBigOwned, VecZnxBigToMut, VecZnxBigToRef, VecZnxToMut, VecZnxToRef}, + source::Source, +}; /// # THIS TRAIT IS AN OPEN EXTENSION POINT (unsafe) /// * See TODO for reference code. diff --git a/backend/src/hal/oep/vec_znx_dft.rs b/poulpy-backend/src/hal/oep/vec_znx_dft.rs similarity index 100% rename from backend/src/hal/oep/vec_znx_dft.rs rename to poulpy-backend/src/hal/oep/vec_znx_dft.rs diff --git a/backend/src/hal/oep/vmp_pmat.rs b/poulpy-backend/src/hal/oep/vmp_pmat.rs similarity index 100% rename from backend/src/hal/oep/vmp_pmat.rs rename to poulpy-backend/src/hal/oep/vmp_pmat.rs diff --git a/sampling/src/source.rs b/poulpy-backend/src/hal/source.rs similarity index 100% rename from sampling/src/source.rs rename to poulpy-backend/src/hal/source.rs diff --git a/backend/src/hal/tests/mod.rs b/poulpy-backend/src/hal/tests/mod.rs similarity index 100% rename from backend/src/hal/tests/mod.rs rename to poulpy-backend/src/hal/tests/mod.rs diff --git a/backend/src/hal/tests/serialization.rs b/poulpy-backend/src/hal/tests/serialization.rs similarity index 98% rename from backend/src/hal/tests/serialization.rs rename to poulpy-backend/src/hal/tests/serialization.rs index b052eb0..2943726 100644 --- a/backend/src/hal/tests/serialization.rs +++ b/poulpy-backend/src/hal/tests/serialization.rs @@ -1,10 +1,9 @@ use std::fmt::Debug; -use sampling::source::Source; - use crate::hal::{ api::{FillUniform, Reset}, layouts::{ReaderFrom, WriterTo}, + source::Source, }; /// Generic test for serialization and deserialization. diff --git a/backend/src/hal/tests/vec_znx/encoding.rs b/poulpy-backend/src/hal/tests/vec_znx/encoding.rs similarity index 98% rename from backend/src/hal/tests/vec_znx/encoding.rs rename to poulpy-backend/src/hal/tests/vec_znx/encoding.rs index e878ef0..1885a82 100644 --- a/backend/src/hal/tests/vec_znx/encoding.rs +++ b/poulpy-backend/src/hal/tests/vec_znx/encoding.rs @@ -1,8 +1,7 @@ -use sampling::source::Source; - use crate::hal::{ api::{ZnxInfos, ZnxViewMut}, layouts::VecZnx, + source::Source, }; pub fn test_vec_znx_encode_vec_i64_lo_norm() { diff --git a/backend/src/hal/tests/vec_znx/generics.rs b/poulpy-backend/src/hal/tests/vec_znx/generics.rs similarity index 98% rename from backend/src/hal/tests/vec_znx/generics.rs rename to poulpy-backend/src/hal/tests/vec_znx/generics.rs index ec2e68b..1d2f714 100644 --- a/backend/src/hal/tests/vec_znx/generics.rs +++ b/poulpy-backend/src/hal/tests/vec_znx/generics.rs @@ -1,8 +1,7 @@ -use sampling::source::Source; - use crate::hal::{ api::{VecZnxAddNormal, VecZnxFillUniform, ZnxView}, layouts::{Backend, Module, VecZnx}, + source::Source, }; pub fn test_vec_znx_fill_uniform(module: &Module) diff --git a/backend/src/hal/tests/vec_znx/mod.rs b/poulpy-backend/src/hal/tests/vec_znx/mod.rs similarity index 100% rename from backend/src/hal/tests/vec_znx/mod.rs rename to poulpy-backend/src/hal/tests/vec_znx/mod.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/cnv.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/cnv.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/cnv.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/cnv.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/mod.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/mod.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/mod.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/mod.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/module.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/module.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/module.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/module.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/reim.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/reim.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/reim.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/reim.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/svp.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/svp.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/svp.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/svp.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/vec_znx.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/vec_znx.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/vec_znx.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/vec_znx.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/vec_znx_big.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/vec_znx_big.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/vec_znx_big.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/vec_znx_big.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/vec_znx_dft.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/vec_znx_dft.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/vec_znx_dft.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/vec_znx_dft.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/vmp.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/vmp.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/vmp.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/vmp.rs diff --git a/backend/src/implementation/cpu_spqlios/ffi/znx.rs b/poulpy-backend/src/implementation/cpu_spqlios/ffi/znx.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/ffi/znx.rs rename to poulpy-backend/src/implementation/cpu_spqlios/ffi/znx.rs diff --git a/backend/src/implementation/cpu_spqlios/mod.rs b/poulpy-backend/src/implementation/cpu_spqlios/mod.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/mod.rs rename to poulpy-backend/src/implementation/cpu_spqlios/mod.rs diff --git a/backend/src/implementation/cpu_spqlios/module_fft64.rs b/poulpy-backend/src/implementation/cpu_spqlios/module_fft64.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/module_fft64.rs rename to poulpy-backend/src/implementation/cpu_spqlios/module_fft64.rs diff --git a/backend/src/implementation/cpu_spqlios/module_ntt120.rs b/poulpy-backend/src/implementation/cpu_spqlios/module_ntt120.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/module_ntt120.rs rename to poulpy-backend/src/implementation/cpu_spqlios/module_ntt120.rs diff --git a/backend/src/implementation/cpu_spqlios/scratch.rs b/poulpy-backend/src/implementation/cpu_spqlios/scratch.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/scratch.rs rename to poulpy-backend/src/implementation/cpu_spqlios/scratch.rs diff --git a/backend/src/implementation/cpu_spqlios/spqlios-arithmetic b/poulpy-backend/src/implementation/cpu_spqlios/spqlios-arithmetic similarity index 100% rename from backend/src/implementation/cpu_spqlios/spqlios-arithmetic rename to poulpy-backend/src/implementation/cpu_spqlios/spqlios-arithmetic diff --git a/backend/src/implementation/cpu_spqlios/svp_ppol_fft64.rs b/poulpy-backend/src/implementation/cpu_spqlios/svp_ppol_fft64.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/svp_ppol_fft64.rs rename to poulpy-backend/src/implementation/cpu_spqlios/svp_ppol_fft64.rs diff --git a/backend/src/implementation/cpu_spqlios/svp_ppol_ntt120.rs b/poulpy-backend/src/implementation/cpu_spqlios/svp_ppol_ntt120.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/svp_ppol_ntt120.rs rename to poulpy-backend/src/implementation/cpu_spqlios/svp_ppol_ntt120.rs diff --git a/backend/src/implementation/cpu_spqlios/test/mod.rs b/poulpy-backend/src/implementation/cpu_spqlios/test/mod.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/test/mod.rs rename to poulpy-backend/src/implementation/cpu_spqlios/test/mod.rs diff --git a/backend/src/implementation/cpu_spqlios/test/vec_znx_fft64.rs b/poulpy-backend/src/implementation/cpu_spqlios/test/vec_znx_fft64.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/test/vec_znx_fft64.rs rename to poulpy-backend/src/implementation/cpu_spqlios/test/vec_znx_fft64.rs diff --git a/backend/src/implementation/cpu_spqlios/vec_znx.rs b/poulpy-backend/src/implementation/cpu_spqlios/vec_znx.rs similarity index 99% rename from backend/src/implementation/cpu_spqlios/vec_znx.rs rename to poulpy-backend/src/implementation/cpu_spqlios/vec_znx.rs index db8a9c6..b928b9c 100644 --- a/backend/src/implementation/cpu_spqlios/vec_znx.rs +++ b/poulpy-backend/src/implementation/cpu_spqlios/vec_znx.rs @@ -1,6 +1,5 @@ use itertools::izip; use rand_distr::Normal; -use sampling::source::Source; use crate::{ hal::{ @@ -18,6 +17,7 @@ use crate::{ VecZnxRshInplaceImpl, VecZnxSplitImpl, VecZnxSubABInplaceImpl, VecZnxSubBAInplaceImpl, VecZnxSubImpl, VecZnxSubScalarInplaceImpl, VecZnxSwithcDegreeImpl, }, + source::Source, }, implementation::cpu_spqlios::{ CPUAVX, diff --git a/backend/src/implementation/cpu_spqlios/vec_znx_big_fft64.rs b/poulpy-backend/src/implementation/cpu_spqlios/vec_znx_big_fft64.rs similarity index 99% rename from backend/src/implementation/cpu_spqlios/vec_znx_big_fft64.rs rename to poulpy-backend/src/implementation/cpu_spqlios/vec_znx_big_fft64.rs index e4edf5c..7c499d1 100644 --- a/backend/src/implementation/cpu_spqlios/vec_znx_big_fft64.rs +++ b/poulpy-backend/src/implementation/cpu_spqlios/vec_znx_big_fft64.rs @@ -1,7 +1,6 @@ use std::fmt; use rand_distr::{Distribution, Normal}; -use sampling::source::Source; use crate::{ hal::{ @@ -21,6 +20,7 @@ use crate::{ VecZnxBigSubBAInplaceImpl, VecZnxBigSubImpl, VecZnxBigSubSmallAImpl, VecZnxBigSubSmallAInplaceImpl, VecZnxBigSubSmallBImpl, VecZnxBigSubSmallBInplaceImpl, }, + source::Source, }, implementation::cpu_spqlios::{ffi::vec_znx, module_fft64::FFT64}, }; diff --git a/backend/src/implementation/cpu_spqlios/vec_znx_big_ntt120.rs b/poulpy-backend/src/implementation/cpu_spqlios/vec_znx_big_ntt120.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/vec_znx_big_ntt120.rs rename to poulpy-backend/src/implementation/cpu_spqlios/vec_znx_big_ntt120.rs diff --git a/backend/src/implementation/cpu_spqlios/vec_znx_dft_fft64.rs b/poulpy-backend/src/implementation/cpu_spqlios/vec_znx_dft_fft64.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/vec_znx_dft_fft64.rs rename to poulpy-backend/src/implementation/cpu_spqlios/vec_znx_dft_fft64.rs diff --git a/backend/src/implementation/cpu_spqlios/vec_znx_dft_ntt120.rs b/poulpy-backend/src/implementation/cpu_spqlios/vec_znx_dft_ntt120.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/vec_znx_dft_ntt120.rs rename to poulpy-backend/src/implementation/cpu_spqlios/vec_znx_dft_ntt120.rs diff --git a/backend/src/implementation/cpu_spqlios/vmp_pmat_fft64.rs b/poulpy-backend/src/implementation/cpu_spqlios/vmp_pmat_fft64.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/vmp_pmat_fft64.rs rename to poulpy-backend/src/implementation/cpu_spqlios/vmp_pmat_fft64.rs diff --git a/backend/src/implementation/cpu_spqlios/vmp_pmat_ntt120.rs b/poulpy-backend/src/implementation/cpu_spqlios/vmp_pmat_ntt120.rs similarity index 100% rename from backend/src/implementation/cpu_spqlios/vmp_pmat_ntt120.rs rename to poulpy-backend/src/implementation/cpu_spqlios/vmp_pmat_ntt120.rs diff --git a/backend/src/implementation/mod.rs b/poulpy-backend/src/implementation/mod.rs similarity index 100% rename from backend/src/implementation/mod.rs rename to poulpy-backend/src/implementation/mod.rs diff --git a/backend/src/lib.rs b/poulpy-backend/src/lib.rs similarity index 100% rename from backend/src/lib.rs rename to poulpy-backend/src/lib.rs diff --git a/core/Cargo.toml b/poulpy-core/Cargo.toml similarity index 58% rename from core/Cargo.toml rename to poulpy-core/Cargo.toml index 8210bb8..b1d7310 100644 --- a/core/Cargo.toml +++ b/poulpy-core/Cargo.toml @@ -1,14 +1,17 @@ [package] -name = "core" +name = "poulpy-core" version = "0.1.0" edition = "2024" license = "Apache-2.0" +description = "A crate implementing RLWE-based encrypted arithmetic" +repository = "https://github.com/phantomzone-org/poulpy" +homepage = "https://github.com/phantomzone-org/poulpy" +documentation = "https://docs.rs/poulpy" [dependencies] rug = {workspace = true} criterion = {workspace = true} -backend = {path="../backend"} -sampling = {path="../sampling"} +poulpy-backend = "0.1.0" rand_distr = {workspace = true} itertools = {workspace = true} byteorder = {workspace = true} diff --git a/core/benches/external_product_glwe_fft64.rs b/poulpy-core/benches/external_product_glwe_fft64.rs similarity index 98% rename from core/benches/external_product_glwe_fft64.rs rename to poulpy-core/benches/external_product_glwe_fft64.rs index 90a88d4..121e748 100644 --- a/core/benches/external_product_glwe_fft64.rs +++ b/poulpy-core/benches/external_product_glwe_fft64.rs @@ -1,18 +1,18 @@ -use core::layouts::{ +use poulpy_core::layouts::{ GGSWCiphertext, GLWECiphertext, GLWESecret, Infos, prepared::{GGSWCiphertextPrepared, GLWESecretPrepared, PrepareAlloc}, }; use std::hint::black_box; -use backend::{ +use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; +use poulpy_backend::{ hal::{ api::{ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow}, layouts::{Module, ScalarZnx, ScratchOwned}, + source::Source, }, implementation::cpu_spqlios::FFT64, }; -use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; -use sampling::source::Source; fn bench_external_product_glwe_fft64(c: &mut Criterion) { let mut group = c.benchmark_group("external_product_glwe_fft64"); diff --git a/core/benches/keyswitch_glwe_fft64.rs b/poulpy-core/benches/keyswitch_glwe_fft64.rs similarity index 98% rename from core/benches/keyswitch_glwe_fft64.rs rename to poulpy-core/benches/keyswitch_glwe_fft64.rs index 85e66e2..e731c33 100644 --- a/core/benches/keyswitch_glwe_fft64.rs +++ b/poulpy-core/benches/keyswitch_glwe_fft64.rs @@ -1,18 +1,18 @@ -use core::layouts::{ +use poulpy_core::layouts::{ GGLWEAutomorphismKey, GGLWESwitchingKey, GLWECiphertext, GLWESecret, Infos, prepared::{GGLWEAutomorphismKeyPrepared, GGLWESwitchingKeyPrepared, GLWESecretPrepared, PrepareAlloc}, }; use std::{hint::black_box, time::Duration}; -use backend::{ +use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; +use poulpy_backend::{ hal::{ api::{ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow}, layouts::{Module, ScratchOwned}, + source::Source, }, implementation::cpu_spqlios::FFT64, }; -use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; -use sampling::source::Source; fn bench_keyswitch_glwe_fft64(c: &mut Criterion) { let mut group = c.benchmark_group("keyswitch_glwe_fft64"); diff --git a/core/src/automorphism/gglwe_atk.rs b/poulpy-core/src/automorphism/gglwe_atk.rs similarity index 99% rename from core/src/automorphism/gglwe_atk.rs rename to poulpy-core/src/automorphism/gglwe_atk.rs index 0a321d2..1243738 100644 --- a/core/src/automorphism/gglwe_atk.rs +++ b/poulpy-core/src/automorphism/gglwe_atk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnxDft, VecZnxAutomorphism, VecZnxAutomorphismInplace, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, diff --git a/core/src/automorphism/ggsw_ct.rs b/poulpy-core/src/automorphism/ggsw_ct.rs similarity index 99% rename from core/src/automorphism/ggsw_ct.rs rename to poulpy-core/src/automorphism/ggsw_ct.rs index cbcb755..355b5c0 100644 --- a/core/src/automorphism/ggsw_ct.rs +++ b/poulpy-core/src/automorphism/ggsw_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnxBig, TakeVecZnxDft, VecZnxAutomorphismInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAddInplace, VecZnxDftAllocBytes, VecZnxDftCopy, diff --git a/core/src/automorphism/glwe_ct.rs b/poulpy-core/src/automorphism/glwe_ct.rs similarity index 99% rename from core/src/automorphism/glwe_ct.rs rename to poulpy-core/src/automorphism/glwe_ct.rs index 64f8af9..f4781d5 100644 --- a/core/src/automorphism/glwe_ct.rs +++ b/poulpy-core/src/automorphism/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnxDft, VecZnxAutomorphismInplace, VecZnxBigAddSmallInplace, VecZnxBigAutomorphismInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxBigSubSmallAInplace, VecZnxBigSubSmallBInplace, diff --git a/core/src/automorphism/mod.rs b/poulpy-core/src/automorphism/mod.rs similarity index 100% rename from core/src/automorphism/mod.rs rename to poulpy-core/src/automorphism/mod.rs diff --git a/core/src/conversion/glwe_to_lwe.rs b/poulpy-core/src/conversion/glwe_to_lwe.rs similarity index 98% rename from core/src/conversion/glwe_to_lwe.rs rename to poulpy-core/src/conversion/glwe_to_lwe.rs index 189c2df..557698c 100644 --- a/core/src/conversion/glwe_to_lwe.rs +++ b/poulpy-core/src/conversion/glwe_to_lwe.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VmpApply, VmpApplyAdd, VmpApplyTmpBytes, ZnxView, diff --git a/core/src/conversion/lwe_to_glwe.rs b/poulpy-core/src/conversion/lwe_to_glwe.rs similarity index 98% rename from core/src/conversion/lwe_to_glwe.rs rename to poulpy-core/src/conversion/lwe_to_glwe.rs index 5f023fb..7e4cc7b 100644 --- a/core/src/conversion/lwe_to_glwe.rs +++ b/poulpy-core/src/conversion/lwe_to_glwe.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VmpApply, VmpApplyAdd, VmpApplyTmpBytes, ZnxView, diff --git a/core/src/conversion/mod.rs b/poulpy-core/src/conversion/mod.rs similarity index 100% rename from core/src/conversion/mod.rs rename to poulpy-core/src/conversion/mod.rs diff --git a/core/src/decryption/glwe_ct.rs b/poulpy-core/src/decryption/glwe_ct.rs similarity index 99% rename from core/src/decryption/glwe_ct.rs rename to poulpy-core/src/decryption/glwe_ct.rs index a18f86f..89eb894 100644 --- a/core/src/decryption/glwe_ct.rs +++ b/poulpy-core/src/decryption/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ DataViewMut, SvpApplyInplace, TakeVecZnxBig, TakeVecZnxDft, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxNormalizeTmpBytes, diff --git a/core/src/decryption/lwe_ct.rs b/poulpy-core/src/decryption/lwe_ct.rs similarity index 98% rename from core/src/decryption/lwe_ct.rs rename to poulpy-core/src/decryption/lwe_ct.rs index 98cdaae..d257726 100644 --- a/core/src/decryption/lwe_ct.rs +++ b/poulpy-core/src/decryption/lwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ScratchOwnedAlloc, ScratchOwnedBorrow, VecZnxNormalizeInplace, ZnxView, ZnxViewMut}, layouts::{Backend, DataMut, DataRef, Module, ScratchOwned}, oep::{ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl}, diff --git a/core/src/decryption/mod.rs b/poulpy-core/src/decryption/mod.rs similarity index 100% rename from core/src/decryption/mod.rs rename to poulpy-core/src/decryption/mod.rs diff --git a/core/src/dist.rs b/poulpy-core/src/dist.rs similarity index 100% rename from core/src/dist.rs rename to poulpy-core/src/dist.rs diff --git a/core/src/encryption/compressed/gglwe_atk.rs b/poulpy-core/src/encryption/compressed/gglwe_atk.rs similarity index 98% rename from core/src/encryption/compressed/gglwe_atk.rs rename to poulpy-core/src/encryption/compressed/gglwe_atk.rs index 7fa23cc..14f6dc5 100644 --- a/core/src/encryption/compressed/gglwe_atk.rs +++ b/poulpy-core/src/encryption/compressed/gglwe_atk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, SvpPPolAllocBytes, SvpPrepare, TakeScalarZnx, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxBigNormalize, VecZnxDftAllocBytes, @@ -6,8 +6,8 @@ use backend::hal::{ VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, VecZnxSwithcDegree, }, layouts::{Backend, DataMut, DataRef, Module, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWESecret, TakeGLWESecretPrepared, diff --git a/core/src/encryption/compressed/gglwe_ct.rs b/poulpy-core/src/encryption/compressed/gglwe_ct.rs similarity index 98% rename from core/src/encryption/compressed/gglwe_ct.rs rename to poulpy-core/src/encryption/compressed/gglwe_ct.rs index 5308d08..4166497 100644 --- a/core/src/encryption/compressed/gglwe_ct.rs +++ b/poulpy-core/src/encryption/compressed/gglwe_ct.rs @@ -1,12 +1,12 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxFillUniform, VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, ZnxZero, }, layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWEPt, @@ -53,7 +53,7 @@ impl GGLWECiphertextCompressed { { #[cfg(debug_assertions)] { - use backend::hal::api::ZnxInfos; + use poulpy_backend::hal::api::ZnxInfos; assert_eq!( self.rank_in(), diff --git a/core/src/encryption/compressed/gglwe_ksk.rs b/poulpy-core/src/encryption/compressed/gglwe_ksk.rs similarity index 98% rename from core/src/encryption/compressed/gglwe_ksk.rs rename to poulpy-core/src/encryption/compressed/gglwe_ksk.rs index a98da59..971e9e4 100644 --- a/core/src/encryption/compressed/gglwe_ksk.rs +++ b/poulpy-core/src/encryption/compressed/gglwe_ksk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, SvpPPolAllocBytes, SvpPrepare, TakeScalarZnx, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, @@ -6,8 +6,8 @@ use backend::hal::{ VecZnxSub, VecZnxSubABInplace, VecZnxSwithcDegree, }, layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWESecretPrepared, diff --git a/core/src/encryption/compressed/gglwe_tsk.rs b/poulpy-core/src/encryption/compressed/gglwe_tsk.rs similarity index 98% rename from core/src/encryption/compressed/gglwe_tsk.rs rename to poulpy-core/src/encryption/compressed/gglwe_tsk.rs index 4607361..f2373aa 100644 --- a/core/src/encryption/compressed/gglwe_tsk.rs +++ b/poulpy-core/src/encryption/compressed/gglwe_tsk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApply, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, TakeScalarZnx, TakeVecZnx, TakeVecZnxBig, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAllocBytes, @@ -7,8 +7,8 @@ use backend::hal::{ VecZnxSwithcDegree, }, layouts::{Backend, DataMut, DataRef, Module, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWESecret, TakeGLWESecretPrepared, diff --git a/core/src/encryption/compressed/ggsw_ct.rs b/poulpy-core/src/encryption/compressed/ggsw_ct.rs similarity index 97% rename from core/src/encryption/compressed/ggsw_ct.rs rename to poulpy-core/src/encryption/compressed/ggsw_ct.rs index b329891..bec3abf 100644 --- a/core/src/encryption/compressed/ggsw_ct.rs +++ b/poulpy-core/src/encryption/compressed/ggsw_ct.rs @@ -1,12 +1,12 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxFillUniform, VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, ZnxZero, }, layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWEPt, @@ -53,7 +53,7 @@ impl GGSWCiphertextCompressed { { #[cfg(debug_assertions)] { - use backend::hal::api::ZnxInfos; + use poulpy_backend::hal::api::ZnxInfos; assert_eq!(self.rank(), sk.rank()); assert_eq!(self.n(), sk.n()); diff --git a/core/src/encryption/compressed/glwe_ct.rs b/poulpy-core/src/encryption/compressed/glwe_ct.rs similarity index 98% rename from core/src/encryption/compressed/glwe_ct.rs rename to poulpy-core/src/encryption/compressed/glwe_ct.rs index 4d2275f..bfaa081 100644 --- a/core/src/encryption/compressed/glwe_ct.rs +++ b/poulpy-core/src/encryption/compressed/glwe_ct.rs @@ -1,12 +1,12 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxFillUniform, VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, }, layouts::{Backend, DataMut, DataRef, Module, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ encryption::glwe_ct::glwe_encrypt_sk_internal, diff --git a/core/src/encryption/compressed/mod.rs b/poulpy-core/src/encryption/compressed/mod.rs similarity index 100% rename from core/src/encryption/compressed/mod.rs rename to poulpy-core/src/encryption/compressed/mod.rs diff --git a/core/src/encryption/gglwe_atk.rs b/poulpy-core/src/encryption/gglwe_atk.rs similarity index 98% rename from core/src/encryption/gglwe_atk.rs rename to poulpy-core/src/encryption/gglwe_atk.rs index f848393..bfb9da2 100644 --- a/core/src/encryption/gglwe_atk.rs +++ b/poulpy-core/src/encryption/gglwe_atk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, SvpPPolAllocBytes, SvpPrepare, TakeScalarZnx, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxBigNormalize, VecZnxDftAllocBytes, @@ -6,8 +6,8 @@ use backend::hal::{ VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, VecZnxSwithcDegree, }, layouts::{Backend, DataMut, DataRef, Module, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWESecret, TakeGLWESecretPrepared, diff --git a/core/src/encryption/gglwe_ct.rs b/poulpy-core/src/encryption/gglwe_ct.rs similarity index 98% rename from core/src/encryption/gglwe_ct.rs rename to poulpy-core/src/encryption/gglwe_ct.rs index f4c4adc..386b938 100644 --- a/core/src/encryption/gglwe_ct.rs +++ b/poulpy-core/src/encryption/gglwe_ct.rs @@ -1,12 +1,12 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxFillUniform, VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, ZnxZero, }, layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWEPt, @@ -57,7 +57,7 @@ impl GGLWECiphertext { { #[cfg(debug_assertions)] { - use backend::hal::api::ZnxInfos; + use poulpy_backend::hal::api::ZnxInfos; assert_eq!( self.rank_in(), diff --git a/core/src/encryption/gglwe_ksk.rs b/poulpy-core/src/encryption/gglwe_ksk.rs similarity index 98% rename from core/src/encryption/gglwe_ksk.rs rename to poulpy-core/src/encryption/gglwe_ksk.rs index 195003b..5230d99 100644 --- a/core/src/encryption/gglwe_ksk.rs +++ b/poulpy-core/src/encryption/gglwe_ksk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, SvpPPolAllocBytes, SvpPrepare, TakeScalarZnx, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, @@ -6,8 +6,8 @@ use backend::hal::{ VecZnxSub, VecZnxSubABInplace, VecZnxSwithcDegree, }, layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWESecretPrepared, diff --git a/core/src/encryption/gglwe_tsk.rs b/poulpy-core/src/encryption/gglwe_tsk.rs similarity index 98% rename from core/src/encryption/gglwe_tsk.rs rename to poulpy-core/src/encryption/gglwe_tsk.rs index b28c259..cb794dc 100644 --- a/core/src/encryption/gglwe_tsk.rs +++ b/poulpy-core/src/encryption/gglwe_tsk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApply, SvpApplyInplace, SvpPPolAllocBytes, SvpPrepare, TakeScalarZnx, TakeVecZnx, TakeVecZnxBig, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAllocBytes, VecZnxBigNormalize, @@ -6,8 +6,8 @@ use backend::hal::{ VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, VecZnxSwithcDegree, }, layouts::{Backend, DataMut, DataRef, Module, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWESecret, TakeGLWESecretPrepared, diff --git a/core/src/encryption/ggsw_ct.rs b/poulpy-core/src/encryption/ggsw_ct.rs similarity index 97% rename from core/src/encryption/ggsw_ct.rs rename to poulpy-core/src/encryption/ggsw_ct.rs index 56fcf13..9d2b4dd 100644 --- a/core/src/encryption/ggsw_ct.rs +++ b/poulpy-core/src/encryption/ggsw_ct.rs @@ -1,12 +1,12 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxFillUniform, VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, ZnxZero, }, layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, Scratch, VecZnx}, + source::Source, }; -use sampling::source::Source; use crate::{ TakeGLWEPt, @@ -56,7 +56,7 @@ impl GGSWCiphertext { { #[cfg(debug_assertions)] { - use backend::hal::api::ZnxInfos; + use poulpy_backend::hal::api::ZnxInfos; assert_eq!(self.rank(), sk.rank()); assert_eq!(self.n(), sk.n()); diff --git a/core/src/encryption/glwe_ct.rs b/poulpy-core/src/encryption/glwe_ct.rs similarity index 99% rename from core/src/encryption/glwe_ct.rs rename to poulpy-core/src/encryption/glwe_ct.rs index a25b287..3b5cf12 100644 --- a/core/src/encryption/glwe_ct.rs +++ b/poulpy-core/src/encryption/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApply, SvpApplyInplace, SvpPPolAllocBytes, SvpPrepare, TakeScalarZnx, TakeSvpPPol, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxBigAddNormal, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, @@ -6,8 +6,8 @@ use backend::hal::{ VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, ZnxInfos, ZnxZero, }, layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, Scratch, VecZnx, VecZnxBig}, + source::Source, }; -use sampling::source::Source; use crate::{ SIX_SIGMA, @@ -356,7 +356,7 @@ pub(crate) fn glwe_encrypt_sk_internal GLWECiphertext { #[cfg(debug_assertions)] { - use backend::hal::api::ScratchAvailable; + use poulpy_backend::hal::api::ScratchAvailable; assert_eq!(rhs.rank(), lhs.rank()); assert_eq!(rhs.rank(), self.rank()); diff --git a/core/src/external_product/mod.rs b/poulpy-core/src/external_product/mod.rs similarity index 100% rename from core/src/external_product/mod.rs rename to poulpy-core/src/external_product/mod.rs diff --git a/core/src/glwe_packing.rs b/poulpy-core/src/glwe_packing.rs similarity index 99% rename from core/src/glwe_packing.rs rename to poulpy-core/src/glwe_packing.rs index 79e1f2b..488f54b 100644 --- a/core/src/glwe_packing.rs +++ b/poulpy-core/src/glwe_packing.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAutomorphismInplace, VecZnxBigAddSmallInplace, VecZnxBigAutomorphismInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxBigSubSmallBInplace, VecZnxCopy, diff --git a/core/src/glwe_trace.rs b/poulpy-core/src/glwe_trace.rs similarity index 99% rename from core/src/glwe_trace.rs rename to poulpy-core/src/glwe_trace.rs index 92b7e82..6a34045 100644 --- a/core/src/glwe_trace.rs +++ b/poulpy-core/src/glwe_trace.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigAutomorphismInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxCopy, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, diff --git a/core/src/keyswitching/gglwe_ct.rs b/poulpy-core/src/keyswitching/gglwe_ct.rs similarity index 99% rename from core/src/keyswitching/gglwe_ct.rs rename to poulpy-core/src/keyswitching/gglwe_ct.rs index ad00bd6..092967f 100644 --- a/core/src/keyswitching/gglwe_ct.rs +++ b/poulpy-core/src/keyswitching/gglwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VmpApply, VmpApplyAdd, VmpApplyTmpBytes, ZnxZero, diff --git a/core/src/keyswitching/ggsw_ct.rs b/poulpy-core/src/keyswitching/ggsw_ct.rs similarity index 99% rename from core/src/keyswitching/ggsw_ct.rs rename to poulpy-core/src/keyswitching/ggsw_ct.rs index ea40fec..7fd40a7 100644 --- a/core/src/keyswitching/ggsw_ct.rs +++ b/poulpy-core/src/keyswitching/ggsw_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnxBig, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxCopy, VecZnxDftAddInplace, VecZnxDftAllocBytes, VecZnxDftCopy, VecZnxDftFromVecZnx, diff --git a/core/src/keyswitching/glwe_ct.rs b/poulpy-core/src/keyswitching/glwe_ct.rs similarity index 99% rename from core/src/keyswitching/glwe_ct.rs rename to poulpy-core/src/keyswitching/glwe_ct.rs index 1830d4c..4395128 100644 --- a/core/src/keyswitching/glwe_ct.rs +++ b/poulpy-core/src/keyswitching/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ DataViewMut, ScratchAvailable, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VmpApply, VmpApplyAdd, VmpApplyTmpBytes, ZnxInfos, diff --git a/core/src/keyswitching/lwe_ct.rs b/poulpy-core/src/keyswitching/lwe_ct.rs similarity index 99% rename from core/src/keyswitching/lwe_ct.rs rename to poulpy-core/src/keyswitching/lwe_ct.rs index deb4697..5daa9ce 100644 --- a/core/src/keyswitching/lwe_ct.rs +++ b/poulpy-core/src/keyswitching/lwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeVecZnx, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VmpApply, VmpApplyAdd, VmpApplyTmpBytes, ZnxView, diff --git a/core/src/keyswitching/mod.rs b/poulpy-core/src/keyswitching/mod.rs similarity index 100% rename from core/src/keyswitching/mod.rs rename to poulpy-core/src/keyswitching/mod.rs diff --git a/core/src/layouts/compressed/gglwe_atk.rs b/poulpy-core/src/layouts/compressed/gglwe_atk.rs similarity index 96% rename from core/src/layouts/compressed/gglwe_atk.rs rename to poulpy-core/src/layouts/compressed/gglwe_atk.rs index 8f788e6..819c150 100644 --- a/core/src/layouts/compressed/gglwe_atk.rs +++ b/poulpy-core/src/layouts/compressed/gglwe_atk.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset, VecZnxCopy, VecZnxFillUniform}, layouts::{Backend, Data, DataMut, DataRef, MatZnx, Module, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{ @@ -23,7 +24,7 @@ impl fmt::Debug for GGLWEAutomorphismKeyCompressed { } impl FillUniform for GGLWEAutomorphismKeyCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.key.fill_uniform(source); } } diff --git a/core/src/layouts/compressed/gglwe_ct.rs b/poulpy-core/src/layouts/compressed/gglwe_ct.rs similarity index 97% rename from core/src/layouts/compressed/gglwe_ct.rs rename to poulpy-core/src/layouts/compressed/gglwe_ct.rs index 4b232c8..8265350 100644 --- a/core/src/layouts/compressed/gglwe_ct.rs +++ b/poulpy-core/src/layouts/compressed/gglwe_ct.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset, VecZnxCopy, VecZnxFillUniform}, layouts::{Backend, Data, DataMut, DataRef, MatZnx, Module, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{ @@ -27,7 +28,7 @@ impl fmt::Debug for GGLWECiphertextCompressed { } impl FillUniform for GGLWECiphertextCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.data.fill_uniform(source); } } @@ -200,7 +201,7 @@ impl Decompress fmt::Debug for GGLWESwitchingKeyCompressed { } impl FillUniform for GGLWESwitchingKeyCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.key.fill_uniform(source); } } diff --git a/core/src/layouts/compressed/gglwe_tsk.rs b/poulpy-core/src/layouts/compressed/gglwe_tsk.rs similarity index 97% rename from core/src/layouts/compressed/gglwe_tsk.rs rename to poulpy-core/src/layouts/compressed/gglwe_tsk.rs index 9e1d00f..45a763e 100644 --- a/core/src/layouts/compressed/gglwe_tsk.rs +++ b/poulpy-core/src/layouts/compressed/gglwe_tsk.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset, VecZnxCopy, VecZnxFillUniform}, layouts::{Backend, Data, DataMut, DataRef, MatZnx, Module, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{ @@ -22,7 +23,7 @@ impl fmt::Debug for GGLWETensorKeyCompressed { } impl FillUniform for GGLWETensorKeyCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.keys .iter_mut() .for_each(|key: &mut GGLWESwitchingKeyCompressed| key.fill_uniform(source)) diff --git a/core/src/layouts/compressed/ggsw_ct.rs b/poulpy-core/src/layouts/compressed/ggsw_ct.rs similarity index 98% rename from core/src/layouts/compressed/ggsw_ct.rs rename to poulpy-core/src/layouts/compressed/ggsw_ct.rs index 07c9e15..7da675c 100644 --- a/core/src/layouts/compressed/ggsw_ct.rs +++ b/poulpy-core/src/layouts/compressed/ggsw_ct.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset, VecZnxCopy, VecZnxFillUniform}, layouts::{Backend, Data, DataMut, DataRef, MatZnx, Module, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{ @@ -48,7 +49,7 @@ impl Reset for GGSWCiphertextCompressed { } impl FillUniform for GGSWCiphertextCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.data.fill_uniform(source); } } diff --git a/core/src/layouts/compressed/glwe_ct.rs b/poulpy-core/src/layouts/compressed/glwe_ct.rs similarity index 98% rename from core/src/layouts/compressed/glwe_ct.rs rename to poulpy-core/src/layouts/compressed/glwe_ct.rs index 9b5aede..ef72f89 100644 --- a/core/src/layouts/compressed/glwe_ct.rs +++ b/poulpy-core/src/layouts/compressed/glwe_ct.rs @@ -1,8 +1,8 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset, VecZnxCopy, VecZnxFillUniform}, layouts::{Backend, Data, DataMut, DataRef, Module, ReaderFrom, VecZnx, WriterTo}, + source::Source, }; -use sampling::source::Source; use crate::layouts::{GLWECiphertext, Infos, compressed::Decompress}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; @@ -118,7 +118,7 @@ impl Decompress fmt::Debug for GLWEToLWESwitchingKeyCompressed { } impl FillUniform for GLWEToLWESwitchingKeyCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.0.fill_uniform(source); } } diff --git a/core/src/layouts/compressed/lwe_ct.rs b/poulpy-core/src/layouts/compressed/lwe_ct.rs similarity index 98% rename from core/src/layouts/compressed/lwe_ct.rs rename to poulpy-core/src/layouts/compressed/lwe_ct.rs index ff08ca6..38fff5b 100644 --- a/core/src/layouts/compressed/lwe_ct.rs +++ b/poulpy-core/src/layouts/compressed/lwe_ct.rs @@ -1,10 +1,10 @@ use std::fmt; -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset, VecZnxFillUniform, ZnxInfos, ZnxView, ZnxViewMut}, layouts::{Backend, Data, DataMut, DataRef, Module, ReaderFrom, VecZnx, WriterTo}, + source::Source, }; -use sampling::source::Source; use crate::layouts::{Infos, LWECiphertext, SetMetaData, compressed::Decompress}; diff --git a/core/src/layouts/compressed/lwe_ksk.rs b/poulpy-core/src/layouts/compressed/lwe_ksk.rs similarity index 97% rename from core/src/layouts/compressed/lwe_ksk.rs rename to poulpy-core/src/layouts/compressed/lwe_ksk.rs index 4a6c9fd..b35b47c 100644 --- a/core/src/layouts/compressed/lwe_ksk.rs +++ b/poulpy-core/src/layouts/compressed/lwe_ksk.rs @@ -1,10 +1,11 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ FillUniform, Reset, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxBigNormalize, VecZnxCopy, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxFillUniform, VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, }, layouts::{Backend, Data, DataMut, DataRef, MatZnx, Module, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{ @@ -23,7 +24,7 @@ impl fmt::Debug for LWESwitchingKeyCompressed { } impl FillUniform for LWESwitchingKeyCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.0.fill_uniform(source); } } diff --git a/core/src/layouts/compressed/lwe_to_glwe_ksk.rs b/poulpy-core/src/layouts/compressed/lwe_to_glwe_ksk.rs similarity index 97% rename from core/src/layouts/compressed/lwe_to_glwe_ksk.rs rename to poulpy-core/src/layouts/compressed/lwe_to_glwe_ksk.rs index 7ede80a..1b852b8 100644 --- a/core/src/layouts/compressed/lwe_to_glwe_ksk.rs +++ b/poulpy-core/src/layouts/compressed/lwe_to_glwe_ksk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, api::{ SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxBigNormalize, @@ -6,6 +6,7 @@ use backend::hal::{ VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubABInplace, }, layouts::{Backend, Data, DataMut, DataRef, MatZnx, Module, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{ @@ -24,7 +25,7 @@ impl fmt::Debug for LWEToGLWESwitchingKeyCompressed { } impl FillUniform for LWEToGLWESwitchingKeyCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.0.fill_uniform(source); } } diff --git a/core/src/layouts/compressed/mod.rs b/poulpy-core/src/layouts/compressed/mod.rs similarity index 95% rename from core/src/layouts/compressed/mod.rs rename to poulpy-core/src/layouts/compressed/mod.rs index 16bd4cd..d6f14fd 100644 --- a/core/src/layouts/compressed/mod.rs +++ b/poulpy-core/src/layouts/compressed/mod.rs @@ -20,7 +20,7 @@ pub use lwe_ct::*; pub use lwe_ksk::*; pub use lwe_to_glwe_ksk::*; -use backend::hal::{ +use poulpy_backend::hal::{ api::{VecZnxCopy, VecZnxFillUniform}, layouts::{Backend, Module}, }; diff --git a/core/src/layouts/gglwe_atk.rs b/poulpy-core/src/layouts/gglwe_atk.rs similarity index 96% rename from core/src/layouts/gglwe_atk.rs rename to poulpy-core/src/layouts/gglwe_atk.rs index 6440cbe..d59864b 100644 --- a/core/src/layouts/gglwe_atk.rs +++ b/poulpy-core/src/layouts/gglwe_atk.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{GGLWESwitchingKey, GLWECiphertext, Infos}; @@ -21,7 +22,7 @@ impl fmt::Debug for GGLWEAutomorphismKey { } impl FillUniform for GGLWEAutomorphismKey { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.key.fill_uniform(source); } } diff --git a/core/src/layouts/gglwe_ct.rs b/poulpy-core/src/layouts/gglwe_ct.rs similarity index 97% rename from core/src/layouts/gglwe_ct.rs rename to poulpy-core/src/layouts/gglwe_ct.rs index 73ec651..0480e73 100644 --- a/core/src/layouts/gglwe_ct.rs +++ b/poulpy-core/src/layouts/gglwe_ct.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{GLWECiphertext, Infos}; @@ -23,7 +24,7 @@ impl fmt::Debug for GGLWECiphertext { } impl FillUniform for GGLWECiphertext { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.data.fill_uniform(source); } } diff --git a/core/src/layouts/gglwe_ksk.rs b/poulpy-core/src/layouts/gglwe_ksk.rs similarity index 97% rename from core/src/layouts/gglwe_ksk.rs rename to poulpy-core/src/layouts/gglwe_ksk.rs index bce023b..366efe0 100644 --- a/core/src/layouts/gglwe_ksk.rs +++ b/poulpy-core/src/layouts/gglwe_ksk.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{GGLWECiphertext, GLWECiphertext, Infos}; @@ -32,7 +33,7 @@ impl fmt::Display for GGLWESwitchingKey { } impl FillUniform for GGLWESwitchingKey { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.key.fill_uniform(source); } } diff --git a/core/src/layouts/gglwe_tsk.rs b/poulpy-core/src/layouts/gglwe_tsk.rs similarity index 97% rename from core/src/layouts/gglwe_tsk.rs rename to poulpy-core/src/layouts/gglwe_tsk.rs index c47f88f..70f2b09 100644 --- a/core/src/layouts/gglwe_tsk.rs +++ b/poulpy-core/src/layouts/gglwe_tsk.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{GGLWESwitchingKey, Infos}; @@ -20,7 +21,7 @@ impl fmt::Debug for GGLWETensorKey { } impl FillUniform for GGLWETensorKey { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.keys .iter_mut() .for_each(|key: &mut GGLWESwitchingKey| key.fill_uniform(source)) diff --git a/core/src/layouts/ggsw_ct.rs b/poulpy-core/src/layouts/ggsw_ct.rs similarity index 97% rename from core/src/layouts/ggsw_ct.rs rename to poulpy-core/src/layouts/ggsw_ct.rs index 6bec38d..60b8eda 100644 --- a/core/src/layouts/ggsw_ct.rs +++ b/poulpy-core/src/layouts/ggsw_ct.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, + source::Source, }; use std::fmt; @@ -40,7 +41,7 @@ impl Reset for GGSWCiphertext { } impl FillUniform for GGSWCiphertext { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.data.fill_uniform(source); } } diff --git a/core/src/layouts/glwe_ct.rs b/poulpy-core/src/layouts/glwe_ct.rs similarity index 98% rename from core/src/layouts/glwe_ct.rs rename to poulpy-core/src/layouts/glwe_ct.rs index 9c2f594..6f596fb 100644 --- a/core/src/layouts/glwe_ct.rs +++ b/poulpy-core/src/layouts/glwe_ct.rs @@ -1,8 +1,8 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, ReaderFrom, ToOwnedDeep, VecZnx, VecZnxToMut, VecZnxToRef, WriterTo}, + source::Source, }; -use sampling::source::Source; use crate::layouts::{Infos, SetMetaData}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; diff --git a/core/src/layouts/glwe_pk.rs b/poulpy-core/src/layouts/glwe_pk.rs similarity index 95% rename from core/src/layouts/glwe_pk.rs rename to poulpy-core/src/layouts/glwe_pk.rs index 5390b97..9a11f01 100644 --- a/core/src/layouts/glwe_pk.rs +++ b/poulpy-core/src/layouts/glwe_pk.rs @@ -1,4 +1,4 @@ -use backend::hal::layouts::{Data, DataMut, DataRef, ReaderFrom, VecZnx, WriterTo}; +use poulpy_backend::hal::layouts::{Data, DataMut, DataRef, ReaderFrom, VecZnx, WriterTo}; use crate::{dist::Distribution, layouts::Infos}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; diff --git a/core/src/layouts/glwe_pt.rs b/poulpy-core/src/layouts/glwe_pt.rs similarity index 94% rename from core/src/layouts/glwe_pt.rs rename to poulpy-core/src/layouts/glwe_pt.rs index bf5ed9b..2ddbdc0 100644 --- a/core/src/layouts/glwe_pt.rs +++ b/poulpy-core/src/layouts/glwe_pt.rs @@ -1,6 +1,6 @@ use std::fmt; -use backend::hal::layouts::{Data, DataMut, DataRef, VecZnx, VecZnxToMut, VecZnxToRef}; +use poulpy_backend::hal::layouts::{Data, DataMut, DataRef, VecZnx, VecZnxToMut, VecZnxToRef}; use crate::layouts::{GLWECiphertext, GLWECiphertextToMut, GLWECiphertextToRef, Infos, SetMetaData}; diff --git a/core/src/layouts/glwe_sk.rs b/poulpy-core/src/layouts/glwe_sk.rs similarity index 98% rename from core/src/layouts/glwe_sk.rs rename to poulpy-core/src/layouts/glwe_sk.rs index 399d098..bac3036 100644 --- a/core/src/layouts/glwe_sk.rs +++ b/poulpy-core/src/layouts/glwe_sk.rs @@ -1,8 +1,8 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ZnxInfos, ZnxZero}, layouts::{Data, DataMut, DataRef, ReaderFrom, ScalarZnx, WriterTo}, + source::Source, }; -use sampling::source::Source; use crate::dist::Distribution; diff --git a/core/src/layouts/glwe_to_lwe_ksk.rs b/poulpy-core/src/layouts/glwe_to_lwe_ksk.rs similarity index 95% rename from core/src/layouts/glwe_to_lwe_ksk.rs rename to poulpy-core/src/layouts/glwe_to_lwe_ksk.rs index 79920a0..497bace 100644 --- a/core/src/layouts/glwe_to_lwe_ksk.rs +++ b/poulpy-core/src/layouts/glwe_to_lwe_ksk.rs @@ -1,6 +1,7 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{GGLWESwitchingKey, Infos}; @@ -18,7 +19,7 @@ impl fmt::Debug for GLWEToLWESwitchingKey { } impl FillUniform for GLWEToLWESwitchingKey { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.0.fill_uniform(source); } } diff --git a/core/src/layouts/infos.rs b/poulpy-core/src/layouts/infos.rs similarity index 96% rename from core/src/layouts/infos.rs rename to poulpy-core/src/layouts/infos.rs index 6de038b..af57f7d 100644 --- a/core/src/layouts/infos.rs +++ b/poulpy-core/src/layouts/infos.rs @@ -1,4 +1,4 @@ -use backend::hal::api::ZnxInfos; +use poulpy_backend::hal::api::ZnxInfos; pub trait Infos { type Inner: ZnxInfos; diff --git a/core/src/layouts/lwe_ct.rs b/poulpy-core/src/layouts/lwe_ct.rs similarity index 98% rename from core/src/layouts/lwe_ct.rs rename to poulpy-core/src/layouts/lwe_ct.rs index 1f495e7..77d8a69 100644 --- a/core/src/layouts/lwe_ct.rs +++ b/poulpy-core/src/layouts/lwe_ct.rs @@ -1,10 +1,10 @@ use std::fmt; -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset, ZnxInfos}, layouts::{Data, DataMut, DataRef, ReaderFrom, VecZnx, VecZnxToMut, VecZnxToRef, WriterTo}, + source::Source, }; -use sampling::source::Source; #[derive(PartialEq, Eq, Clone)] pub struct LWECiphertext { diff --git a/core/src/layouts/lwe_ksk.rs b/poulpy-core/src/layouts/lwe_ksk.rs similarity index 94% rename from core/src/layouts/lwe_ksk.rs rename to poulpy-core/src/layouts/lwe_ksk.rs index d18720b..0832673 100644 --- a/core/src/layouts/lwe_ksk.rs +++ b/poulpy-core/src/layouts/lwe_ksk.rs @@ -1,8 +1,9 @@ use std::fmt; -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{GGLWESwitchingKey, Infos}; @@ -23,7 +24,7 @@ impl fmt::Debug for LWESwitchingKey { } impl FillUniform for LWESwitchingKey { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.0.fill_uniform(source); } } diff --git a/core/src/layouts/lwe_pt.rs b/poulpy-core/src/layouts/lwe_pt.rs similarity index 95% rename from core/src/layouts/lwe_pt.rs rename to poulpy-core/src/layouts/lwe_pt.rs index 5fc397e..2f1ac17 100644 --- a/core/src/layouts/lwe_pt.rs +++ b/poulpy-core/src/layouts/lwe_pt.rs @@ -1,6 +1,6 @@ use std::fmt; -use backend::hal::layouts::{Data, DataMut, DataRef, VecZnx, VecZnxToMut, VecZnxToRef}; +use poulpy_backend::hal::layouts::{Data, DataMut, DataRef, VecZnx, VecZnxToMut, VecZnxToRef}; use crate::layouts::{Infos, SetMetaData}; diff --git a/core/src/layouts/lwe_sk.rs b/poulpy-core/src/layouts/lwe_sk.rs similarity index 97% rename from core/src/layouts/lwe_sk.rs rename to poulpy-core/src/layouts/lwe_sk.rs index 0444b85..de0f28b 100644 --- a/core/src/layouts/lwe_sk.rs +++ b/poulpy-core/src/layouts/lwe_sk.rs @@ -1,8 +1,8 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ZnxInfos, ZnxView, ZnxZero}, layouts::{Data, DataMut, DataRef, ScalarZnx}, + source::Source, }; -use sampling::source::Source; use crate::dist::Distribution; diff --git a/core/src/layouts/lwe_to_glwe_ksk.rs b/poulpy-core/src/layouts/lwe_to_glwe_ksk.rs similarity index 95% rename from core/src/layouts/lwe_to_glwe_ksk.rs rename to poulpy-core/src/layouts/lwe_to_glwe_ksk.rs index 686081e..75973a8 100644 --- a/core/src/layouts/lwe_to_glwe_ksk.rs +++ b/poulpy-core/src/layouts/lwe_to_glwe_ksk.rs @@ -1,8 +1,9 @@ use std::fmt; -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, MatZnx, ReaderFrom, WriterTo}, + source::Source, }; use crate::layouts::{GGLWESwitchingKey, Infos}; @@ -17,7 +18,7 @@ impl fmt::Debug for LWEToGLWESwitchingKey { } impl FillUniform for LWEToGLWESwitchingKey { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.0.fill_uniform(source); } } diff --git a/core/src/layouts/mod.rs b/poulpy-core/src/layouts/mod.rs similarity index 100% rename from core/src/layouts/mod.rs rename to poulpy-core/src/layouts/mod.rs diff --git a/core/src/layouts/prepared/gglwe_atk.rs b/poulpy-core/src/layouts/prepared/gglwe_atk.rs similarity index 99% rename from core/src/layouts/prepared/gglwe_atk.rs rename to poulpy-core/src/layouts/prepared/gglwe_atk.rs index ecc2554..9108441 100644 --- a/core/src/layouts/prepared/gglwe_atk.rs +++ b/poulpy-core/src/layouts/prepared/gglwe_atk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat}, }; diff --git a/core/src/layouts/prepared/gglwe_ct.rs b/poulpy-core/src/layouts/prepared/gglwe_ct.rs similarity index 99% rename from core/src/layouts/prepared/gglwe_ct.rs rename to poulpy-core/src/layouts/prepared/gglwe_ct.rs index 3f7195b..b665060 100644 --- a/core/src/layouts/prepared/gglwe_ct.rs +++ b/poulpy-core/src/layouts/prepared/gglwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat}, }; diff --git a/core/src/layouts/prepared/gglwe_ksk.rs b/poulpy-core/src/layouts/prepared/gglwe_ksk.rs similarity index 99% rename from core/src/layouts/prepared/gglwe_ksk.rs rename to poulpy-core/src/layouts/prepared/gglwe_ksk.rs index 36f52e6..716cbf1 100644 --- a/core/src/layouts/prepared/gglwe_ksk.rs +++ b/poulpy-core/src/layouts/prepared/gglwe_ksk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat}, }; diff --git a/core/src/layouts/prepared/gglwe_tsk.rs b/poulpy-core/src/layouts/prepared/gglwe_tsk.rs similarity index 99% rename from core/src/layouts/prepared/gglwe_tsk.rs rename to poulpy-core/src/layouts/prepared/gglwe_tsk.rs index 0ef0186..e58b86c 100644 --- a/core/src/layouts/prepared/gglwe_tsk.rs +++ b/poulpy-core/src/layouts/prepared/gglwe_tsk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat}, }; diff --git a/core/src/layouts/prepared/ggsw_ct.rs b/poulpy-core/src/layouts/prepared/ggsw_ct.rs similarity index 99% rename from core/src/layouts/prepared/ggsw_ct.rs rename to poulpy-core/src/layouts/prepared/ggsw_ct.rs index a1fd05a..7641694 100644 --- a/core/src/layouts/prepared/ggsw_ct.rs +++ b/poulpy-core/src/layouts/prepared/ggsw_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat}, }; diff --git a/core/src/layouts/prepared/glwe_ct.rs b/poulpy-core/src/layouts/prepared/glwe_ct.rs similarity index 98% rename from core/src/layouts/prepared/glwe_ct.rs rename to poulpy-core/src/layouts/prepared/glwe_ct.rs index 9b5aede..c8185f9 100644 --- a/core/src/layouts/prepared/glwe_ct.rs +++ b/poulpy-core/src/layouts/prepared/glwe_ct.rs @@ -1,8 +1,8 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset, VecZnxCopy, VecZnxFillUniform}, layouts::{Backend, Data, DataMut, DataRef, Module, ReaderFrom, VecZnx, WriterTo}, }; -use sampling::source::Source; + use crate::layouts::{GLWECiphertext, Infos, compressed::Decompress}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; @@ -118,7 +118,7 @@ impl Decompress, - scratch: &mut backend::hal::layouts::Scratch, + scratch: &mut poulpy_backend::hal::layouts::Scratch, ) -> GLWESecretPrepared, B> { let mut sk_dft: GLWESecretPrepared, B> = GLWESecretPrepared::alloc(module, self.n(), self.rank()); sk_dft.prepare(module, self, scratch); @@ -68,7 +68,7 @@ impl Prepare> for GLWESe where Module: SvpPrepare, { - fn prepare(&mut self, module: &Module, other: &GLWESecret, _scratch: &mut backend::hal::layouts::Scratch) { + fn prepare(&mut self, module: &Module, other: &GLWESecret, _scratch: &mut poulpy_backend::hal::layouts::Scratch) { (0..self.rank()).for_each(|i| { module.svp_prepare(&mut self.data, i, &other.data, i); }); diff --git a/core/src/layouts/prepared/glwe_to_lwe_ksk.rs b/poulpy-core/src/layouts/prepared/glwe_to_lwe_ksk.rs similarity index 98% rename from core/src/layouts/prepared/glwe_to_lwe_ksk.rs rename to poulpy-core/src/layouts/prepared/glwe_to_lwe_ksk.rs index 0da24e8..e3fc88d 100644 --- a/core/src/layouts/prepared/glwe_to_lwe_ksk.rs +++ b/poulpy-core/src/layouts/prepared/glwe_to_lwe_ksk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat}, }; diff --git a/core/src/layouts/prepared/lwe_ksk.rs b/poulpy-core/src/layouts/prepared/lwe_ksk.rs similarity index 98% rename from core/src/layouts/prepared/lwe_ksk.rs rename to poulpy-core/src/layouts/prepared/lwe_ksk.rs index 0fe12ab..522c713 100644 --- a/core/src/layouts/prepared/lwe_ksk.rs +++ b/poulpy-core/src/layouts/prepared/lwe_ksk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat}, }; diff --git a/core/src/layouts/prepared/lwe_to_glwe_ksk.rs b/poulpy-core/src/layouts/prepared/lwe_to_glwe_ksk.rs similarity index 99% rename from core/src/layouts/prepared/lwe_to_glwe_ksk.rs rename to poulpy-core/src/layouts/prepared/lwe_to_glwe_ksk.rs index eb9b45d..e7692a1 100644 --- a/core/src/layouts/prepared/lwe_to_glwe_ksk.rs +++ b/poulpy-core/src/layouts/prepared/lwe_to_glwe_ksk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat}, }; diff --git a/core/src/layouts/prepared/mod.rs b/poulpy-core/src/layouts/prepared/mod.rs similarity index 90% rename from core/src/layouts/prepared/mod.rs rename to poulpy-core/src/layouts/prepared/mod.rs index 454d5c7..240c11f 100644 --- a/core/src/layouts/prepared/mod.rs +++ b/poulpy-core/src/layouts/prepared/mod.rs @@ -9,7 +9,6 @@ mod glwe_to_lwe_ksk; mod lwe_ksk; mod lwe_to_glwe_ksk; -use backend::hal::layouts::{Backend, Module, Scratch}; pub use gglwe_atk::*; pub use gglwe_ct::*; pub use gglwe_ksk::*; @@ -20,6 +19,7 @@ pub use glwe_sk::*; pub use glwe_to_lwe_ksk::*; pub use lwe_ksk::*; pub use lwe_to_glwe_ksk::*; +use poulpy_backend::hal::layouts::{Backend, Module, Scratch}; pub trait PrepareAlloc { fn prepare_alloc(&self, module: &Module, scratch: &mut Scratch) -> T; diff --git a/core/src/lib.rs b/poulpy-core/src/lib.rs similarity index 100% rename from core/src/lib.rs rename to poulpy-core/src/lib.rs diff --git a/core/src/noise/gglwe_ct.rs b/poulpy-core/src/noise/gglwe_ct.rs similarity index 98% rename from core/src/noise/gglwe_ct.rs rename to poulpy-core/src/noise/gglwe_ct.rs index d8f0768..572c409 100644 --- a/core/src/noise/gglwe_ct.rs +++ b/poulpy-core/src/noise/gglwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, diff --git a/core/src/noise/ggsw_ct.rs b/poulpy-core/src/noise/ggsw_ct.rs similarity index 99% rename from core/src/noise/ggsw_ct.rs rename to poulpy-core/src/noise/ggsw_ct.rs index a2895a1..0405dc1 100644 --- a/core/src/noise/ggsw_ct.rs +++ b/poulpy-core/src/noise/ggsw_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAlloc, VecZnxBigAllocBytes, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, diff --git a/core/src/noise/glwe_ct.rs b/poulpy-core/src/noise/glwe_ct.rs similarity index 98% rename from core/src/noise/glwe_ct.rs rename to poulpy-core/src/noise/glwe_ct.rs index 0ed72f4..d675e22 100644 --- a/core/src/noise/glwe_ct.rs +++ b/poulpy-core/src/noise/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, diff --git a/core/src/noise/mod.rs b/poulpy-core/src/noise/mod.rs similarity index 100% rename from core/src/noise/mod.rs rename to poulpy-core/src/noise/mod.rs diff --git a/core/src/operations/glwe.rs b/poulpy-core/src/operations/glwe.rs similarity index 99% rename from core/src/operations/glwe.rs rename to poulpy-core/src/operations/glwe.rs index 0c115b6..8df1d19 100644 --- a/core/src/operations/glwe.rs +++ b/poulpy-core/src/operations/glwe.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ VecZnxAdd, VecZnxAddInplace, VecZnxCopy, VecZnxMulXpMinusOne, VecZnxMulXpMinusOneInplace, VecZnxNegateInplace, VecZnxNormalize, VecZnxNormalizeInplace, VecZnxRotate, VecZnxRotateInplace, VecZnxRshInplace, VecZnxSub, diff --git a/core/src/operations/mod.rs b/poulpy-core/src/operations/mod.rs similarity index 100% rename from core/src/operations/mod.rs rename to poulpy-core/src/operations/mod.rs diff --git a/core/src/scratch.rs b/poulpy-core/src/scratch.rs similarity index 99% rename from core/src/scratch.rs rename to poulpy-core/src/scratch.rs index f6a3e3b..f21c080 100644 --- a/core/src/scratch.rs +++ b/poulpy-core/src/scratch.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{TakeMatZnx, TakeScalarZnx, TakeSvpPPol, TakeVecZnx, TakeVecZnxDft, TakeVmpPMat}, layouts::{Backend, DataRef, Scratch}, oep::{TakeMatZnxImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, TakeVmpPMatImpl}, diff --git a/core/src/tests/generics/automorphism/gglwe_atk.rs b/poulpy-core/src/tests/generics/automorphism/gglwe_atk.rs similarity index 99% rename from core/src/tests/generics/automorphism/gglwe_atk.rs rename to poulpy-core/src/tests/generics/automorphism/gglwe_atk.rs index a2cc1bf..43022c4 100644 --- a/core/src/tests/generics/automorphism/gglwe_atk.rs +++ b/poulpy-core/src/tests/generics/automorphism/gglwe_atk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxAutomorphismInplace, VecZnxBigAddInplace, @@ -12,8 +12,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/automorphism/ggsw_ct.rs b/poulpy-core/src/tests/generics/automorphism/ggsw_ct.rs similarity index 99% rename from core/src/tests/generics/automorphism/ggsw_ct.rs rename to poulpy-core/src/tests/generics/automorphism/ggsw_ct.rs index aa7b43f..e8aeca5 100644 --- a/core/src/tests/generics/automorphism/ggsw_ct.rs +++ b/poulpy-core/src/tests/generics/automorphism/ggsw_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApply, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxAutomorphismInplace, @@ -13,8 +13,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/automorphism/glwe_ct.rs b/poulpy-core/src/tests/generics/automorphism/glwe_ct.rs similarity index 99% rename from core/src/tests/generics/automorphism/glwe_ct.rs rename to poulpy-core/src/tests/generics/automorphism/glwe_ct.rs index 39cfc75..30367c3 100644 --- a/core/src/tests/generics/automorphism/glwe_ct.rs +++ b/poulpy-core/src/tests/generics/automorphism/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxAutomorphismInplace, VecZnxBigAddInplace, @@ -12,8 +12,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/automorphism/mod.rs b/poulpy-core/src/tests/generics/automorphism/mod.rs similarity index 100% rename from core/src/tests/generics/automorphism/mod.rs rename to poulpy-core/src/tests/generics/automorphism/mod.rs diff --git a/core/src/tests/generics/conversion.rs b/poulpy-core/src/tests/generics/conversion.rs similarity index 99% rename from core/src/tests/generics/conversion.rs rename to poulpy-core/src/tests/generics/conversion.rs index b821579..beca378 100644 --- a/core/src/tests/generics/conversion.rs +++ b/poulpy-core/src/tests/generics/conversion.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphismInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, @@ -12,8 +12,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::layouts::{ GLWECiphertext, GLWEPlaintext, GLWESecret, GLWEToLWESwitchingKey, Infos, LWECiphertext, LWEPlaintext, LWESecret, diff --git a/core/src/tests/generics/encryption/gglwe_atk.rs b/poulpy-core/src/tests/generics/encryption/gglwe_atk.rs similarity index 99% rename from core/src/tests/generics/encryption/gglwe_atk.rs rename to poulpy-core/src/tests/generics/encryption/gglwe_atk.rs index 85bfebd..8e494cf 100644 --- a/core/src/tests/generics/encryption/gglwe_atk.rs +++ b/poulpy-core/src/tests/generics/encryption/gglwe_atk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxAutomorphismInplace, VecZnxBigAddInplace, @@ -12,8 +12,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::layouts::{ GGLWEAutomorphismKey, GLWESecret, diff --git a/core/src/tests/generics/encryption/gglwe_ct.rs b/poulpy-core/src/tests/generics/encryption/gglwe_ct.rs similarity index 99% rename from core/src/tests/generics/encryption/gglwe_ct.rs rename to poulpy-core/src/tests/generics/encryption/gglwe_ct.rs index 1c3e7b1..56c3e67 100644 --- a/core/src/tests/generics/encryption/gglwe_ct.rs +++ b/poulpy-core/src/tests/generics/encryption/gglwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, @@ -11,8 +11,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl, }, + source::Source, }; -use sampling::source::Source; use crate::layouts::{ GGLWESwitchingKey, GLWESecret, diff --git a/core/src/tests/generics/encryption/ggsw_ct.rs b/poulpy-core/src/tests/generics/encryption/ggsw_ct.rs similarity index 99% rename from core/src/tests/generics/encryption/ggsw_ct.rs rename to poulpy-core/src/tests/generics/encryption/ggsw_ct.rs index 1c82198..66b4abc 100644 --- a/core/src/tests/generics/encryption/ggsw_ct.rs +++ b/poulpy-core/src/tests/generics/encryption/ggsw_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAlloc, @@ -11,8 +11,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl, }, + source::Source, }; -use sampling::source::Source; use crate::layouts::{ GGSWCiphertext, GLWESecret, diff --git a/core/src/tests/generics/encryption/glwe_ct.rs b/poulpy-core/src/tests/generics/encryption/glwe_ct.rs similarity index 99% rename from core/src/tests/generics/encryption/glwe_ct.rs rename to poulpy-core/src/tests/generics/encryption/glwe_ct.rs index 9293a6b..71de183 100644 --- a/core/src/tests/generics/encryption/glwe_ct.rs +++ b/poulpy-core/src/tests/generics/encryption/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApply, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxBigAddInplace, VecZnxBigAddNormal, VecZnxBigAddSmallInplace, @@ -11,8 +11,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/encryption/glwe_tsk.rs b/poulpy-core/src/tests/generics/encryption/glwe_tsk.rs similarity index 99% rename from core/src/tests/generics/encryption/glwe_tsk.rs rename to poulpy-core/src/tests/generics/encryption/glwe_tsk.rs index c1890ef..9cf4592 100644 --- a/core/src/tests/generics/encryption/glwe_tsk.rs +++ b/poulpy-core/src/tests/generics/encryption/glwe_tsk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApply, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAlloc, @@ -11,8 +11,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl, }, + source::Source, }; -use sampling::source::Source; use crate::layouts::{ GGLWETensorKey, GLWEPlaintext, GLWESecret, Infos, diff --git a/core/src/tests/generics/encryption/mod.rs b/poulpy-core/src/tests/generics/encryption/mod.rs similarity index 100% rename from core/src/tests/generics/encryption/mod.rs rename to poulpy-core/src/tests/generics/encryption/mod.rs diff --git a/core/src/tests/generics/external_product/gglwe_ksk.rs b/poulpy-core/src/tests/generics/external_product/gglwe_ksk.rs similarity index 99% rename from core/src/tests/generics/external_product/gglwe_ksk.rs rename to poulpy-core/src/tests/generics/external_product/gglwe_ksk.rs index 9847214..3c07b27 100644 --- a/core/src/tests/generics/external_product/gglwe_ksk.rs +++ b/poulpy-core/src/tests/generics/external_product/gglwe_ksk.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, @@ -12,8 +12,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/external_product/ggsw_ct.rs b/poulpy-core/src/tests/generics/external_product/ggsw_ct.rs similarity index 99% rename from core/src/tests/generics/external_product/ggsw_ct.rs rename to poulpy-core/src/tests/generics/external_product/ggsw_ct.rs index 4811e73..8ae50e7 100644 --- a/core/src/tests/generics/external_product/ggsw_ct.rs +++ b/poulpy-core/src/tests/generics/external_product/ggsw_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAlloc, @@ -12,8 +12,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/external_product/glwe_ct.rs b/poulpy-core/src/tests/generics/external_product/glwe_ct.rs similarity index 99% rename from core/src/tests/generics/external_product/glwe_ct.rs rename to poulpy-core/src/tests/generics/external_product/glwe_ct.rs index ca044c8..d99a2d9 100644 --- a/core/src/tests/generics/external_product/glwe_ct.rs +++ b/poulpy-core/src/tests/generics/external_product/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, @@ -11,8 +11,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/external_product/mod.rs b/poulpy-core/src/tests/generics/external_product/mod.rs similarity index 100% rename from core/src/tests/generics/external_product/mod.rs rename to poulpy-core/src/tests/generics/external_product/mod.rs diff --git a/core/src/tests/generics/keyswitch/gglwe_ct.rs b/poulpy-core/src/tests/generics/keyswitch/gglwe_ct.rs similarity index 99% rename from core/src/tests/generics/keyswitch/gglwe_ct.rs rename to poulpy-core/src/tests/generics/keyswitch/gglwe_ct.rs index 6461283..f854d0d 100644 --- a/core/src/tests/generics/keyswitch/gglwe_ct.rs +++ b/poulpy-core/src/tests/generics/keyswitch/gglwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, @@ -11,8 +11,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/keyswitch/ggsw_ct.rs b/poulpy-core/src/tests/generics/keyswitch/ggsw_ct.rs similarity index 99% rename from core/src/tests/generics/keyswitch/ggsw_ct.rs rename to poulpy-core/src/tests/generics/keyswitch/ggsw_ct.rs index 43835fb..92b1eb9 100644 --- a/core/src/tests/generics/keyswitch/ggsw_ct.rs +++ b/poulpy-core/src/tests/generics/keyswitch/ggsw_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApply, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAlloc, @@ -12,8 +12,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/keyswitch/glwe_ct.rs b/poulpy-core/src/tests/generics/keyswitch/glwe_ct.rs similarity index 99% rename from core/src/tests/generics/keyswitch/glwe_ct.rs rename to poulpy-core/src/tests/generics/keyswitch/glwe_ct.rs index edea772..1daf445 100644 --- a/core/src/tests/generics/keyswitch/glwe_ct.rs +++ b/poulpy-core/src/tests/generics/keyswitch/glwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, @@ -11,8 +11,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/generics/keyswitch/lwe_ct.rs b/poulpy-core/src/tests/generics/keyswitch/lwe_ct.rs similarity index 98% rename from core/src/tests/generics/keyswitch/lwe_ct.rs rename to poulpy-core/src/tests/generics/keyswitch/lwe_ct.rs index 9dcccb7..fd028a8 100644 --- a/core/src/tests/generics/keyswitch/lwe_ct.rs +++ b/poulpy-core/src/tests/generics/keyswitch/lwe_ct.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphismInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, @@ -12,8 +12,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::layouts::{ Infos, LWECiphertext, LWEPlaintext, LWESecret, LWESwitchingKey, diff --git a/core/src/tests/generics/keyswitch/mod.rs b/poulpy-core/src/tests/generics/keyswitch/mod.rs similarity index 100% rename from core/src/tests/generics/keyswitch/mod.rs rename to poulpy-core/src/tests/generics/keyswitch/mod.rs diff --git a/core/src/tests/generics/mod.rs b/poulpy-core/src/tests/generics/mod.rs similarity index 100% rename from core/src/tests/generics/mod.rs rename to poulpy-core/src/tests/generics/mod.rs diff --git a/core/src/tests/generics/packing.rs b/poulpy-core/src/tests/generics/packing.rs similarity index 99% rename from core/src/tests/generics/packing.rs rename to poulpy-core/src/tests/generics/packing.rs index e92687f..fb9f834 100644 --- a/core/src/tests/generics/packing.rs +++ b/poulpy-core/src/tests/generics/packing.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxAutomorphismInplace, VecZnxBigAddInplace, @@ -15,8 +15,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ GLWEOperations, GLWEPacker, diff --git a/core/src/tests/generics/trace.rs b/poulpy-core/src/tests/generics/trace.rs similarity index 99% rename from core/src/tests/generics/trace.rs rename to poulpy-core/src/tests/generics/trace.rs index 54af462..84f369f 100644 --- a/core/src/tests/generics/trace.rs +++ b/poulpy-core/src/tests/generics/trace.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, @@ -15,8 +15,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, }, + source::Source, }; -use sampling::source::Source; use crate::{ layouts::{ diff --git a/core/src/tests/implementation/cpu_spqlios/fft64/gglwe.rs b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/gglwe.rs similarity index 99% rename from core/src/tests/implementation/cpu_spqlios/fft64/gglwe.rs rename to poulpy-core/src/tests/implementation/cpu_spqlios/fft64/gglwe.rs index ee6a3ab..2397b0b 100644 --- a/core/src/tests/implementation/cpu_spqlios/fft64/gglwe.rs +++ b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/gglwe.rs @@ -1,4 +1,4 @@ -use backend::{ +use poulpy_backend::{ hal::{api::ModuleNew, layouts::Module}, implementation::cpu_spqlios::FFT64, }; diff --git a/core/src/tests/implementation/cpu_spqlios/fft64/ggws.rs b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/ggws.rs similarity index 99% rename from core/src/tests/implementation/cpu_spqlios/fft64/ggws.rs rename to poulpy-core/src/tests/implementation/cpu_spqlios/fft64/ggws.rs index 9dcb11b..fa62380 100644 --- a/core/src/tests/implementation/cpu_spqlios/fft64/ggws.rs +++ b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/ggws.rs @@ -1,4 +1,4 @@ -use backend::{ +use poulpy_backend::{ hal::{api::ModuleNew, layouts::Module}, implementation::cpu_spqlios::FFT64, }; diff --git a/core/src/tests/implementation/cpu_spqlios/fft64/glwe.rs b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/glwe.rs similarity index 99% rename from core/src/tests/implementation/cpu_spqlios/fft64/glwe.rs rename to poulpy-core/src/tests/implementation/cpu_spqlios/fft64/glwe.rs index 1a8b399..95b7717 100644 --- a/core/src/tests/implementation/cpu_spqlios/fft64/glwe.rs +++ b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/glwe.rs @@ -1,4 +1,4 @@ -use backend::{ +use poulpy_backend::{ hal::{api::ModuleNew, layouts::Module}, implementation::cpu_spqlios::FFT64, }; diff --git a/core/src/tests/implementation/cpu_spqlios/fft64/lwe.rs b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/lwe.rs similarity index 96% rename from core/src/tests/implementation/cpu_spqlios/fft64/lwe.rs rename to poulpy-core/src/tests/implementation/cpu_spqlios/fft64/lwe.rs index c1ea6d5..c8e0a7f 100644 --- a/core/src/tests/implementation/cpu_spqlios/fft64/lwe.rs +++ b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/lwe.rs @@ -1,4 +1,4 @@ -use backend::{ +use poulpy_backend::{ hal::{api::ModuleNew, layouts::Module}, implementation::cpu_spqlios::FFT64, }; diff --git a/core/src/tests/implementation/cpu_spqlios/fft64/mod.rs b/poulpy-core/src/tests/implementation/cpu_spqlios/fft64/mod.rs similarity index 100% rename from core/src/tests/implementation/cpu_spqlios/fft64/mod.rs rename to poulpy-core/src/tests/implementation/cpu_spqlios/fft64/mod.rs diff --git a/core/src/tests/implementation/cpu_spqlios/mod.rs b/poulpy-core/src/tests/implementation/cpu_spqlios/mod.rs similarity index 100% rename from core/src/tests/implementation/cpu_spqlios/mod.rs rename to poulpy-core/src/tests/implementation/cpu_spqlios/mod.rs diff --git a/core/src/tests/implementation/mod.rs b/poulpy-core/src/tests/implementation/mod.rs similarity index 100% rename from core/src/tests/implementation/mod.rs rename to poulpy-core/src/tests/implementation/mod.rs diff --git a/core/src/tests/mod.rs b/poulpy-core/src/tests/mod.rs similarity index 100% rename from core/src/tests/mod.rs rename to poulpy-core/src/tests/mod.rs diff --git a/core/src/tests/serialization.rs b/poulpy-core/src/tests/serialization.rs similarity index 96% rename from core/src/tests/serialization.rs rename to poulpy-core/src/tests/serialization.rs index 545bdca..8c4a359 100644 --- a/core/src/tests/serialization.rs +++ b/poulpy-core/src/tests/serialization.rs @@ -1,4 +1,4 @@ -use backend::hal::tests::serialization::test_reader_writer_interface; +use poulpy_backend::hal::tests::serialization::test_reader_writer_interface; use crate::layouts::{ GGLWEAutomorphismKey, GGLWECiphertext, GGLWESwitchingKey, GGLWETensorKey, GGSWCiphertext, GLWECiphertext, @@ -21,7 +21,7 @@ const DIGITS: usize = 1; #[test] fn glwe_serialization() { let original: GLWECiphertext> = GLWECiphertext::alloc(N_GLWE, BASEK, K, RANK); - backend::hal::tests::serialization::test_reader_writer_interface(original); + poulpy_backend::hal::tests::serialization::test_reader_writer_interface(original); } #[test] diff --git a/core/src/utils.rs b/poulpy-core/src/utils.rs similarity index 96% rename from core/src/utils.rs rename to poulpy-core/src/utils.rs index 076a910..883b57d 100644 --- a/core/src/utils.rs +++ b/poulpy-core/src/utils.rs @@ -1,5 +1,5 @@ use crate::layouts::{GLWEPlaintext, Infos, LWEPlaintext}; -use backend::hal::layouts::{DataMut, DataRef}; +use poulpy_backend::hal::layouts::{DataMut, DataRef}; use rug::Float; impl GLWEPlaintext { diff --git a/poulpy-schemes/Cargo.toml b/poulpy-schemes/Cargo.toml new file mode 100644 index 0000000..cb6a11a --- /dev/null +++ b/poulpy-schemes/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "poulpy-schemes" +version = "0.1.0" +edition = "2024" +license = "Apache-2.0" +readme = "README.md" +description = "A crate implementing FHE schemes" +repository = "https://github.com/phantomzone-org/poulpy" +homepage = "https://github.com/phantomzone-org/poulpy" +documentation = "https://docs.rs/poulpy" + +[dependencies] +poulpy-backend = "0.1.0" +poulpy-core = "0.1.0" +itertools = "0.14.0" +byteorder = "1.5.0" \ No newline at end of file diff --git a/poulpy-schemes/README.md b/poulpy-schemes/README.md new file mode 100644 index 0000000..e69de29 diff --git a/poulpy/examples/circuit_bootstrapping.rs b/poulpy-schemes/examples/circuit_bootstrapping.rs similarity index 98% rename from poulpy/examples/circuit_bootstrapping.rs rename to poulpy-schemes/examples/circuit_bootstrapping.rs index 4ec2c9d..7812d95 100644 --- a/poulpy/examples/circuit_bootstrapping.rs +++ b/poulpy-schemes/examples/circuit_bootstrapping.rs @@ -1,4 +1,4 @@ -use core::{ +use poulpy_core::{ GLWEOperations, layouts::{ GGSWCiphertext, GLWECiphertext, GLWEPlaintext, GLWESecret, Infos, LWECiphertext, LWEPlaintext, LWESecret, @@ -7,16 +7,16 @@ use core::{ }; use std::time::Instant; -use backend::{ +use poulpy_backend::{ hal::{ api::{ModuleNew, ScratchOwnedAlloc, ScratchOwnedBorrow, VecZnxNormalizeInplace, ZnxView, ZnxViewMut}, layouts::{Module, ScalarZnx, ScratchOwned}, + source::Source, }, implementation::cpu_spqlios::FFT64, }; -use sampling::source::Source; -use schemes::tfhe::{ +use poulpy_schemes::tfhe::{ blind_rotation::CGGI, circuit_bootstrapping::{ CircuitBootstrappingKey, CircuitBootstrappingKeyEncryptSk, CircuitBootstrappingKeyPrepared, CirtuitBootstrappingExecute, diff --git a/schemes/src/lib.rs b/poulpy-schemes/src/lib.rs similarity index 100% rename from schemes/src/lib.rs rename to poulpy-schemes/src/lib.rs diff --git a/schemes/src/tfhe/blind_rotation/cggi_algo.rs b/poulpy-schemes/src/tfhe/blind_rotation/cggi_algo.rs similarity index 99% rename from schemes/src/tfhe/blind_rotation/cggi_algo.rs rename to poulpy-schemes/src/tfhe/blind_rotation/cggi_algo.rs index 8d2c867..7ef921a 100644 --- a/schemes/src/tfhe/blind_rotation/cggi_algo.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/cggi_algo.rs @@ -1,4 +1,5 @@ -use backend::hal::{ +use itertools::izip; +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApply, SvpPPolAllocBytes, TakeVecZnx, TakeVecZnxBig, TakeVecZnxDft, TakeVecZnxDftSlice, TakeVecZnxSlice, VecZnxAddInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, VecZnxBigNormalize, @@ -9,9 +10,8 @@ use backend::hal::{ }, layouts::{Backend, DataMut, DataRef, Module, Scratch, SvpPPol, VecZnx}, }; -use itertools::izip; -use core::{ +use poulpy_core::{ Distribution, GLWEOperations, TakeGLWECt, layouts::{GLWECiphertext, GLWECiphertextToMut, Infos, LWECiphertext, LWECiphertextToRef}, }; diff --git a/schemes/src/tfhe/blind_rotation/cggi_key.rs b/poulpy-schemes/src/tfhe/blind_rotation/cggi_key.rs similarity index 99% rename from schemes/src/tfhe/blind_rotation/cggi_key.rs rename to poulpy-schemes/src/tfhe/blind_rotation/cggi_key.rs index f2a170c..db30ad0 100644 --- a/schemes/src/tfhe/blind_rotation/cggi_key.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/cggi_key.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApplyInplace, TakeVecZnx, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxFillUniform, @@ -6,12 +6,12 @@ use backend::hal::{ VmpPrepare, ZnxView, ZnxViewMut, }, layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, ScalarZnxToRef, Scratch}, + source::Source, }; -use sampling::source::Source; use std::marker::PhantomData; -use core::{ +use poulpy_core::{ Distribution, layouts::{ GGSWCiphertext, LWESecret, diff --git a/schemes/src/tfhe/blind_rotation/key.rs b/poulpy-schemes/src/tfhe/blind_rotation/key.rs similarity index 97% rename from schemes/src/tfhe/blind_rotation/key.rs rename to poulpy-schemes/src/tfhe/blind_rotation/key.rs index 9382e4e..9fc0fa5 100644 --- a/schemes/src/tfhe/blind_rotation/key.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/key.rs @@ -1,12 +1,12 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Backend, Data, DataMut, DataRef, Module, ReaderFrom, Scratch, WriterTo}, + source::Source, }; -use sampling::source::Source; use std::{fmt, marker::PhantomData}; -use core::{ +use poulpy_core::{ Distribution, layouts::{GGSWCiphertext, Infos, LWESecret, prepared::GLWESecretPrepared}, }; @@ -82,7 +82,7 @@ impl Reset for BlindRotationKey { } impl FillUniform for BlindRotationKey { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.keys .iter_mut() .for_each(|key| key.fill_uniform(source)); diff --git a/schemes/src/tfhe/blind_rotation/key_compressed.rs b/poulpy-schemes/src/tfhe/blind_rotation/key_compressed.rs similarity index 97% rename from schemes/src/tfhe/blind_rotation/key_compressed.rs rename to poulpy-schemes/src/tfhe/blind_rotation/key_compressed.rs index e6f75c3..fe8fdf2 100644 --- a/schemes/src/tfhe/blind_rotation/key_compressed.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/key_compressed.rs @@ -1,12 +1,13 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{FillUniform, Reset}, layouts::{Data, DataMut, DataRef, ReaderFrom, WriterTo}, + source::Source, }; use std::{fmt, marker::PhantomData}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; -use core::{ +use poulpy_core::{ Distribution, layouts::{Infos, compressed::GGSWCiphertextCompressed}, }; @@ -59,7 +60,7 @@ impl Reset for BlindRotationKeyCompressed FillUniform for BlindRotationKeyCompressed { - fn fill_uniform(&mut self, source: &mut sampling::source::Source) { + fn fill_uniform(&mut self, source: &mut Source) { self.keys .iter_mut() .for_each(|key| key.fill_uniform(source)); diff --git a/schemes/src/tfhe/blind_rotation/key_prepared.rs b/poulpy-schemes/src/tfhe/blind_rotation/key_prepared.rs similarity index 98% rename from schemes/src/tfhe/blind_rotation/key_prepared.rs rename to poulpy-schemes/src/tfhe/blind_rotation/key_prepared.rs index 17e3241..d90a137 100644 --- a/schemes/src/tfhe/blind_rotation/key_prepared.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/key_prepared.rs @@ -1,11 +1,11 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{SvpPPolAlloc, SvpPrepare, VmpPMatAlloc, VmpPrepare}, layouts::{Backend, Data, DataMut, DataRef, Module, ScalarZnx, Scratch, SvpPPol}, }; use std::marker::PhantomData; -use core::{ +use poulpy_core::{ Distribution, layouts::{ Infos, diff --git a/schemes/src/tfhe/blind_rotation/lut.rs b/poulpy-schemes/src/tfhe/blind_rotation/lut.rs similarity index 99% rename from schemes/src/tfhe/blind_rotation/lut.rs rename to poulpy-schemes/src/tfhe/blind_rotation/lut.rs index a2d89b1..c955ed6 100644 --- a/schemes/src/tfhe/blind_rotation/lut.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/lut.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, VecZnxCopy, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxRotateInplace, VecZnxSwithcDegree, ZnxInfos, ZnxViewMut, diff --git a/schemes/src/tfhe/blind_rotation/mod.rs b/poulpy-schemes/src/tfhe/blind_rotation/mod.rs similarity index 81% rename from schemes/src/tfhe/blind_rotation/mod.rs rename to poulpy-schemes/src/tfhe/blind_rotation/mod.rs index 42ef4b8..25c31bd 100644 --- a/schemes/src/tfhe/blind_rotation/mod.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/mod.rs @@ -14,8 +14,8 @@ pub use lut::*; pub mod tests; -use backend::hal::layouts::{Backend, DataMut, DataRef, Module, Scratch}; -use core::layouts::{GLWECiphertext, LWECiphertext}; +use poulpy_backend::hal::layouts::{Backend, DataMut, DataRef, Module, Scratch}; +use poulpy_core::layouts::{GLWECiphertext, LWECiphertext}; pub trait BlindRotationAlgo {} diff --git a/schemes/src/tfhe/blind_rotation/tests/generic_blind_rotation.rs b/poulpy-schemes/src/tfhe/blind_rotation/tests/generic_blind_rotation.rs similarity index 98% rename from schemes/src/tfhe/blind_rotation/tests/generic_blind_rotation.rs rename to poulpy-schemes/src/tfhe/blind_rotation/tests/generic_blind_rotation.rs index 0cb5121..c344a7d 100644 --- a/schemes/src/tfhe/blind_rotation/tests/generic_blind_rotation.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/tests/generic_blind_rotation.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApply, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, @@ -13,15 +13,15 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxDftSliceImpl, TakeVecZnxImpl, TakeVecZnxSliceImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl, }, + source::Source, }; -use sampling::source::Source; use crate::tfhe::blind_rotation::{ BlincRotationExecute, BlindRotationKey, BlindRotationKeyAlloc, BlindRotationKeyEncryptSk, BlindRotationKeyPrepared, CGGI, LookUpTable, cggi_blind_rotate_scratch_space, mod_switch_2n, }; -use core::layouts::{ +use poulpy_core::layouts::{ GLWECiphertext, GLWEPlaintext, GLWESecret, Infos, LWECiphertext, LWECiphertextToRef, LWEPlaintext, LWESecret, prepared::{GLWESecretPrepared, PrepareAlloc}, }; diff --git a/schemes/src/tfhe/blind_rotation/tests/generic_lut.rs b/poulpy-schemes/src/tfhe/blind_rotation/tests/generic_lut.rs similarity index 99% rename from schemes/src/tfhe/blind_rotation/tests/generic_lut.rs rename to poulpy-schemes/src/tfhe/blind_rotation/tests/generic_lut.rs index 01c108b..9516e84 100644 --- a/schemes/src/tfhe/blind_rotation/tests/generic_lut.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/tests/generic_lut.rs @@ -1,6 +1,6 @@ use std::vec; -use backend::hal::{ +use poulpy_backend::hal::{ api::{VecZnxCopy, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxRotateInplace, VecZnxSwithcDegree}, layouts::{Backend, Module}, oep::{ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl}, diff --git a/schemes/src/tfhe/blind_rotation/tests/generic_serialization.rs b/poulpy-schemes/src/tfhe/blind_rotation/tests/generic_serialization.rs similarity index 87% rename from schemes/src/tfhe/blind_rotation/tests/generic_serialization.rs rename to poulpy-schemes/src/tfhe/blind_rotation/tests/generic_serialization.rs index f099bb0..16f5b66 100644 --- a/schemes/src/tfhe/blind_rotation/tests/generic_serialization.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/tests/generic_serialization.rs @@ -1,4 +1,4 @@ -use backend::hal::tests::serialization::test_reader_writer_interface; +use poulpy_backend::hal::tests::serialization::test_reader_writer_interface; use crate::tfhe::blind_rotation::{BlindRotationKey, BlindRotationKeyAlloc, BlindRotationKeyCompressed, CGGI}; diff --git a/schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/fft64.rs b/poulpy-schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/fft64.rs similarity index 97% rename from schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/fft64.rs rename to poulpy-schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/fft64.rs index 18cfe91..9003e89 100644 --- a/schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/fft64.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/fft64.rs @@ -1,4 +1,4 @@ -use backend::{ +use poulpy_backend::{ hal::{api::ModuleNew, layouts::Module}, implementation::cpu_spqlios::FFT64, }; diff --git a/schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/mod.rs b/poulpy-schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/mod.rs similarity index 100% rename from schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/mod.rs rename to poulpy-schemes/src/tfhe/blind_rotation/tests/implementation/cpu_spqlios/mod.rs diff --git a/schemes/src/tfhe/blind_rotation/tests/implementation/mod.rs b/poulpy-schemes/src/tfhe/blind_rotation/tests/implementation/mod.rs similarity index 100% rename from schemes/src/tfhe/blind_rotation/tests/implementation/mod.rs rename to poulpy-schemes/src/tfhe/blind_rotation/tests/implementation/mod.rs diff --git a/schemes/src/tfhe/blind_rotation/tests/mod.rs b/poulpy-schemes/src/tfhe/blind_rotation/tests/mod.rs similarity index 100% rename from schemes/src/tfhe/blind_rotation/tests/mod.rs rename to poulpy-schemes/src/tfhe/blind_rotation/tests/mod.rs diff --git a/schemes/src/tfhe/blind_rotation/utils.rs b/poulpy-schemes/src/tfhe/blind_rotation/utils.rs similarity index 96% rename from schemes/src/tfhe/blind_rotation/utils.rs rename to poulpy-schemes/src/tfhe/blind_rotation/utils.rs index 2917a14..cfdd309 100644 --- a/schemes/src/tfhe/blind_rotation/utils.rs +++ b/poulpy-schemes/src/tfhe/blind_rotation/utils.rs @@ -1,4 +1,4 @@ -use backend::hal::{ +use poulpy_backend::hal::{ api::{SvpPrepare, ZnxInfos, ZnxViewMut}, layouts::{Backend, DataMut, Module, ScalarZnx, SvpPPol}, }; diff --git a/schemes/src/tfhe/circuit_bootstrapping/circuit.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs similarity index 98% rename from schemes/src/tfhe/circuit_bootstrapping/circuit.rs rename to poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs index f7b03ef..afda315 100644 --- a/schemes/src/tfhe/circuit_bootstrapping/circuit.rs +++ b/poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, TakeMatZnx, TakeVecZnx, TakeVecZnxBig, TakeVecZnxDft, TakeVecZnxDftSlice, TakeVecZnxSlice, VecZnxAddInplace, VecZnxAutomorphismInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes, VecZnxBigAutomorphismInplace, @@ -13,9 +13,9 @@ use backend::hal::{ oep::{ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl}, }; -use core::{GLWEOperations, TakeGGLWE, TakeGLWECt, layouts::Infos}; +use poulpy_core::{GLWEOperations, TakeGGLWE, TakeGLWECt, layouts::Infos}; -use core::layouts::{GGSWCiphertext, GLWECiphertext, LWECiphertext, prepared::GGLWEAutomorphismKeyPrepared}; +use poulpy_core::layouts::{GGSWCiphertext, GLWECiphertext, LWECiphertext, prepared::GGLWEAutomorphismKeyPrepared}; use crate::tfhe::{ blind_rotation::{ diff --git a/schemes/src/tfhe/circuit_bootstrapping/key.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/key.rs similarity index 98% rename from schemes/src/tfhe/circuit_bootstrapping/key.rs rename to poulpy-schemes/src/tfhe/circuit_bootstrapping/key.rs index 619a496..0ec79ec 100644 --- a/schemes/src/tfhe/circuit_bootstrapping/key.rs +++ b/poulpy-schemes/src/tfhe/circuit_bootstrapping/key.rs @@ -1,10 +1,10 @@ -use core::layouts::{ +use poulpy_core::layouts::{ GGLWEAutomorphismKey, GGLWETensorKey, GLWECiphertext, GLWESecret, LWESecret, prepared::{GGLWEAutomorphismKeyPrepared, GGLWETensorKeyPrepared, GLWESecretPrepared, PrepareAlloc}, }; use std::collections::HashMap; -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchAvailable, SvpApply, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, TakeScalarZnx, TakeSvpPPol, TakeVecZnx, TakeVecZnxBig, TakeVecZnxDft, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, @@ -13,8 +13,8 @@ use backend::hal::{ VecZnxSwithcDegree, VmpPMatAlloc, VmpPrepare, }, layouts::{Backend, Data, DataRef, Module, Scratch}, + source::Source, }; -use sampling::source::Source; use crate::tfhe::blind_rotation::{ BlindRotationAlgo, BlindRotationKey, BlindRotationKeyAlloc, BlindRotationKeyEncryptSk, BlindRotationKeyPrepared, diff --git a/schemes/src/tfhe/circuit_bootstrapping/mod.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/mod.rs similarity index 84% rename from schemes/src/tfhe/circuit_bootstrapping/mod.rs rename to poulpy-schemes/src/tfhe/circuit_bootstrapping/mod.rs index 827156c..e3a79f6 100644 --- a/schemes/src/tfhe/circuit_bootstrapping/mod.rs +++ b/poulpy-schemes/src/tfhe/circuit_bootstrapping/mod.rs @@ -5,9 +5,9 @@ pub mod tests; pub use circuit::*; pub use key::*; -use core::layouts::{GGSWCiphertext, LWECiphertext}; +use poulpy_core::layouts::{GGSWCiphertext, LWECiphertext}; -use backend::hal::layouts::{Backend, DataMut, DataRef, Module, Scratch}; +use poulpy_backend::hal::layouts::{Backend, DataMut, DataRef, Module, Scratch}; pub trait CirtuitBootstrappingExecute { fn execute_to_constant( diff --git a/schemes/src/tfhe/circuit_bootstrapping/tests/circuit_bootstrapping.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/circuit_bootstrapping.rs similarity index 99% rename from schemes/src/tfhe/circuit_bootstrapping/tests/circuit_bootstrapping.rs rename to poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/circuit_bootstrapping.rs index c38533c..2763e5c 100644 --- a/schemes/src/tfhe/circuit_bootstrapping/tests/circuit_bootstrapping.rs +++ b/poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/circuit_bootstrapping.rs @@ -1,6 +1,6 @@ use std::time::Instant; -use backend::hal::{ +use poulpy_backend::hal::{ api::{ ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApply, SvpApplyInplace, SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare, VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxAutomorphism, VecZnxAutomorphismInplace, @@ -16,8 +16,8 @@ use backend::hal::{ ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeMatZnxImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxDftSliceImpl, TakeVecZnxImpl, TakeVecZnxSliceImpl, }, + source::Source, }; -use sampling::source::Source; use crate::tfhe::{ blind_rotation::{ @@ -29,9 +29,9 @@ use crate::tfhe::{ }, }; -use core::layouts::prepared::PrepareAlloc; +use poulpy_core::layouts::prepared::PrepareAlloc; -use core::layouts::{ +use poulpy_core::layouts::{ GGSWCiphertext, GLWECiphertext, GLWEPlaintext, GLWESecret, LWECiphertext, LWEPlaintext, LWESecret, prepared::{GGSWCiphertextPrepared, GLWESecretPrepared}, }; diff --git a/schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/fft64.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/fft64.rs similarity index 96% rename from schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/fft64.rs rename to poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/fft64.rs index be1fd95..8319d92 100644 --- a/schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/fft64.rs +++ b/poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/fft64.rs @@ -1,4 +1,4 @@ -use backend::{ +use poulpy_backend::{ hal::{api::ModuleNew, layouts::Module}, implementation::cpu_spqlios::FFT64, }; diff --git a/schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/mod.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/mod.rs similarity index 100% rename from schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/mod.rs rename to poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/implementation/cpu_spqlios/mod.rs diff --git a/schemes/src/tfhe/circuit_bootstrapping/tests/implementation/mod.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/implementation/mod.rs similarity index 100% rename from schemes/src/tfhe/circuit_bootstrapping/tests/implementation/mod.rs rename to poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/implementation/mod.rs diff --git a/schemes/src/tfhe/circuit_bootstrapping/tests/mod.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/mod.rs similarity index 100% rename from schemes/src/tfhe/circuit_bootstrapping/tests/mod.rs rename to poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/mod.rs diff --git a/schemes/src/tfhe/mod.rs b/poulpy-schemes/src/tfhe/mod.rs similarity index 100% rename from schemes/src/tfhe/mod.rs rename to poulpy-schemes/src/tfhe/mod.rs diff --git a/poulpy/Cargo.toml b/poulpy/Cargo.toml deleted file mode 100644 index 20e445d..0000000 --- a/poulpy/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "poulpy" -version = "0.1.0" -edition = "2024" -description = "An efficient & modular FHE library using bivariate polynomial representation" -licence = "Apache 2.0" -readme = "README.md" -repository = "https://github.com/phantomzone-org/poulpy" -homepage = "https://github.com/phantomzone-org/poulpy" -documentation = "https://docs.rs/poulpy" - -[dependencies] -backend = {path="../backend"} -core = {path="../core"} -schemes = {path="../schemes"} -sampling = {path="../sampling"} \ No newline at end of file diff --git a/poulpy/README.md b/poulpy/README.md deleted file mode 100644 index 402f551..0000000 --- a/poulpy/README.md +++ /dev/null @@ -1,171 +0,0 @@ -# 🐙 Poulpy - -

- -

- -[![CI](https://github.com/phantomzone-org/poulpy/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/phantomzone-org/poulpy/actions/workflows/ci.yml) - -**Poulpy** is a fast & modular FHE library that implements Ring-Learning-With-Errors based homomorphic encryption. It adopts the bivariate polynomial representation proposed in [Revisiting Key Decomposition Techniques for FHE: Simpler, Faster and More Generic](https://eprint.iacr.org/2023/771). In addition to simpler and more efficient arithmetic than the residue number system (RNS), this representation provides a common plaintext space for all schemes and allows easy switching between any two schemes. Poulpy also decouples the schemes implementations from the polynomial arithmetic backend by being built around a hardware abstraction layer (HAL). This enables user to easily provide or use a custom backend. - -### Bivariate Polynomial Representation - -Existing FHE implementations (such as [Lattigo](https://github.com/tuneinsight/lattigo) or [OpenFHE](https://github.com/openfheorg/openfhe-development)) use the [residue-number-system](https://en.wikipedia.org/wiki/Residue_number_system) (RNS) to represent large integers. Although the parallelism and carry-less arithmetic provided by the RNS representation provides a very efficient modular arithmetic over large-integers, it suffers from various drawbacks when used in the context of FHE. The main idea behind the bivariate representation is to decouple the cyclotomic arithmetic from the large number arithmetic. Instead of using the RNS representation for large integer, integers are decomposed in base $2^{-K}$ over the Torus $\mathbb{T}_{N}[X]$. - -This provides the following benefits: - -- **Intuitive, efficient and reusable parameterization & instances:** Only the bit-size of the modulus is required from the user (i.e. Torus precision). As such, parameterization is natural and generic, and instances can be reused for any circuit consuming the same homomorphic capacity, without loss of efficiency. With the RNS representation, individual NTT friendly primes needs to be specified for each level, making the parameterization not user friendly and circuit-specific. - -- **Optimal and granular rescaling:** Ciphertext rescaling is carried out with bit-shifting, enabling a bit-level granular rescaling and optimal noise/homomorphic capacity management. In the RNS representation, ciphertext division can only be done by one of the primes composing the modulus, leading to difficult scaling management and frequent inefficient noise/homomorphic capacity management. - -- **Linear number of DFT in the half external product:** The bivariate representation of the coefficients implicitly provides the digit decomposition, as such the number of DFT is linear in the number of limbs, contrary to the RNS representation where it is quadratic due to the RNS basis conversion. This enables a much more efficient key-switching, which is the **most used and expensive** FHE operation. - -- **Unified plaintext space:** The bivariate polynomial representation is by essence a high precision discretized representation of the Torus $\mathbb{T}_{N}[X]$. Using the Torus as the common plaintext space for all schemes achieves the vision of [CHIMERA: Combining Ring-LWE-based Fully Homomorphic Encryption Schemes](https://eprint.iacr.org/2018/758) which is to unify all RLWE-based FHE schemes (TFHE, FHEW, BGV, BFV, CLPX, GBFV, CKKS, ...) under a single scheme with different encodings, enabling native and efficient scheme-switching functionalities. - -- **Simpler implementation**: Since the cyclotomic arithmetic is decoupled from the coefficient representation, the same pipeline (including DFT) can be reused for all limbs (unlike in the RNS representation), making this representation a prime target for hardware acceleration. - -- **Deterministic computation**: Although being defined on the Torus, bivariate arithmetic remains integer polynomial arithmetic, ensuring all computations are deterministic, the contract being that output should be reproducible and identical, regardless of the backend or hardware. - -### Hardware Abstraction Layer - -In addition to providing a general purpose FHE library over a unified plaintext space, Poulpy is also designed from the ground up around a **hardware abstraction layer** that closely matches the API of [spqlios-arithmetic](https://github.com/tfhe/spqlios-arithmetic). The bivariate representation is by itself hardware friendly as it uses flat, aligned & vectorized memory layout. Finally, generic opaque write only structs (prepared versions) are provided, making it easy for developers to provide hardware focused/optimized operations. This makes possible for anyone to provide or use a custom backend. - -## Library Overview - -- **`backend/hal`**: hardware abstraction layer. This layer targets users that want to provide their own backend or use a third party backend. - - - **`api`**: fixed public low-level polynomial level arithmetic API closely matching spqlios-arithmetic. The goal is to eventually freeze this API, in order to decouple it from the OEP traits, ensuring that changes to implementations do not affect the front end API. - - ```rust - pub trait SvpPrepare { - fn svp_prepare(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) - where - R: SvpPPolToMut, - A: ScalarZnxToRef; - } - ```` - - - **`delegates`**: link between the user facing API and implementation OEP. Each trait of `api` is implemented by calling its corresponding trait on the `oep`. - - ```rust - impl SvpPrepare for Module - where - B: Backend + SvpPrepareImpl, - { - fn svp_prepare(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) - where - R: SvpPPolToMut, - A: ScalarZnxToRef, - { - B::svp_prepare_impl(self, res, res_col, a, a_col); - } - } - ``` - - - **`layouts`**: defines the layouts of the front-end algebraic structs matching spqlios-arithmetic definitions, such as `ScalarZnx`, `VecZnx` or opaque backend prepared struct such as `SvpPPol` and `VmpPMat`. - - ```rust - pub struct SvpPPol { - data: D, - n: usize, - cols: usize, - _phantom: PhantomData, - } - ``` - - - **`oep`**: open extension points, which can be implemented by the user to provide a custom backend. - - ```rust - pub unsafe trait SvpPrepareImpl { - fn svp_prepare_impl(module: &Module, res: &mut R, res_col: usize, a: &A, a_col: usize) - where - R: SvpPPolToMut, - A: ScalarZnxToRef; - } - ``` - - - **`tests`**: exported generic tests for the OEP/structs. Their goal is to enable a user to automatically be able to test its backend implementation, without having to re-implement any tests. - -- **`backend/implementation`**: - - **`cpu_spqlios`**: concrete cpu implementation of the hal through the oep using bindings on spqlios-arithmetic. This implementation currently supports the `FFT64` backend and will be extended to support the `NTT120` backend once it is available in spqlios-arithmetic. - - ```rust - unsafe impl SvpPrepareImpl for FFT64 { - fn svp_prepare_impl(module: &Module, res: &mut R, res_col: usize, a: &A, a_col: usize) - where - R: SvpPPolToMut, - A: ScalarZnxToRef, - { - unsafe { - svp::svp_prepare( - module.ptr(), - res.to_mut().at_mut_ptr(res_col, 0) as *mut svp::svp_ppol_t, - a.to_ref().at_ptr(a_col, 0), - ) - } - } - } - ``` - -- **`core`**: core of the FHE library, implementing scheme agnostic RLWE arithmetic for LWE, GLWE, GGLWE and GGSW ciphertexts. It notably includes all possible cross-ciphertext operations, for example applying an external product on a GGLWE or an automorphism on a GGSW, as well as blind rotation. This crate is entirely implemented using the hardware abstraction layer API, and is thus solely defined over generic and traits (including tests). As such it will work over any backend, as long as it implements the necessary traits defined in the OEP. - - ```rust - pub struct GLWESecret { - pub(crate) data: ScalarZnx, - pub(crate) dist: Distribution, - } - - pub struct GLWESecrecPrepared { - pub(crate) data: SvpPPol, - pub(crate) dist: Distribution, - } - - impl GLWESecretPrepared { - pub fn prepare(&mut self, module: &Module, sk: &GLWESecret) - where - O: DataRef, - Module: SvpPrepare, - { - (0..self.rank()).for_each(|i| { - module.svp_prepare(&mut self.data, i, &sk.data, i); - }); - self.dist = sk.dist - } - } - ``` - -## Installation - -TBD — currently not published on crates.io. Clone the repository and use via path-based dependencies. - -## Documentation - -* Full `cargo doc` documentation is coming soon. -* Architecture diagrams and design notes will be added in the [`/doc`](./doc) folder. - -## Contributing - -We welcome external contributions, please see [CONTRIBUTING](./CONTRIBUTING.md). - -## Security - -Please see [SECURITY](./SECURITY.md). - -## License - -Poulpy is licensed under the Apache 2.0 License. See [NOTICE](./NOTICE) & [LICENSE](./LICENSE). - -## Acknowledgement - -**Poulpy** is inspired by the modular architecture of [Lattigo](https://github.com/tuneinsight/lattigo) and [TFHE-go](https://github.com/sp301415/tfhe-go), and its development is lead by Lattigo’s co-author and main contributor [@Pro7ech](https://github.com/Pro7ech). Poulpy reflects the experience gained from over five years of designing and maintaining Lattigo, and represents the next evolution in architecture, performance, and backend philosophy. - -## Citing -Please use the following BibTex entry for citing Lattigo - - @misc{poulpy, - title = {Poulpy v0.1.0}, - howpublished = {Online: \url{https://github.com/phantomzone-org/poulpy}}, - month = Aug, - year = 2025, - note = {Phantom Zone} - } diff --git a/poulpy/poulpy.png b/poulpy/poulpy.png deleted file mode 100644 index 23b4935..0000000 Binary files a/poulpy/poulpy.png and /dev/null differ diff --git a/poulpy/src/lib.rs b/poulpy/src/lib.rs deleted file mode 100644 index 56688b7..0000000 --- a/poulpy/src/lib.rs +++ /dev/null @@ -1,15 +0,0 @@ -pub mod backend { - pub use ::backend::*; -} - -pub mod core { - pub use ::core::*; -} - -pub mod sampling { - pub use ::sampling::*; -} - -pub mod schemes { - pub use ::schemes::*; -} diff --git a/sampling/Cargo.toml b/sampling/Cargo.toml deleted file mode 100644 index d2752e8..0000000 --- a/sampling/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "sampling" -version = "0.1.0" -edition = "2021" -license = "Apache-2.0" - -[dependencies] -rand_distr = {workspace = true} -rand_chacha = { workspace = true } -rand_core = { workspace = true } \ No newline at end of file diff --git a/sampling/src/lib.rs b/sampling/src/lib.rs deleted file mode 100644 index 1779b0b..0000000 --- a/sampling/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod source; diff --git a/schemes/Cargo.toml b/schemes/Cargo.toml deleted file mode 100644 index c1634e7..0000000 --- a/schemes/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "schemes" -version = "0.1.0" -edition = "2024" - -[dependencies] -backend = {path="../backend"} -core = {path="../core"} -sampling = {path="../sampling"} -itertools = "0.14.0" -byteorder = "1.5.0" \ No newline at end of file