updated repo for publishing (#74)

This commit is contained in:
Jean-Philippe Bossuat
2025-08-17 14:57:39 +02:00
committed by GitHub
parent 0be569eca0
commit 62eb87cc07
244 changed files with 374 additions and 539 deletions

4
.gitmodules vendored
View File

@@ -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

119
Cargo.lock generated
View File

@@ -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"

View File

@@ -1,5 +1,5 @@
[workspace]
members = ["backend", "core", "sampling", "schemes", "poulpy"]
members = ["poulpy-backend", "poulpy-core", "poulpy-schemes"]
resolver = "3"
[workspace.dependencies]

View File

@@ -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

View File

@@ -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"

View File

@@ -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;

View File

@@ -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.

View File

@@ -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<B: Backend> {

View File

@@ -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.

View File

@@ -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<B> VecZnxNormalizeTmpBytes for Module<B>

View File

@@ -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<B> VecZnxBigAlloc<B> for Module<B>

View File

@@ -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<D: Data> {

View File

@@ -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,
},
};

View File

@@ -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<D: Data> {
pub(crate) data: D,
@@ -220,10 +224,6 @@ impl<D: DataMut> VecZnxToMut for VecZnx<D> {
}
}
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use rand::RngCore;
use sampling::source::Source;
impl<D: DataMut> ReaderFrom for VecZnx<D> {
fn read_from<R: std::io::Read>(&mut self, reader: &mut R) -> std::io::Result<()> {
self.n = reader.read_u64::<LittleEndian>()? as usize;

View File

@@ -2,4 +2,5 @@ pub mod api;
pub mod delegates;
pub mod layouts;
pub mod oep;
pub mod source;
pub mod tests;

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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() {

View File

@@ -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<B: Backend>(module: &Module<B>)

View File

@@ -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,

View File

@@ -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},
};

View File

@@ -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}

View File

@@ -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");

View File

@@ -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");

View File

@@ -1,4 +1,4 @@
use backend::hal::{
use poulpy_backend::hal::{
api::{
ScratchAvailable, TakeVecZnxDft, VecZnxAutomorphism, VecZnxAutomorphismInplace, VecZnxBigAddSmallInplace,
VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume,

View File

@@ -1,4 +1,4 @@
use backend::hal::{
use poulpy_backend::hal::{
api::{
ScratchAvailable, TakeVecZnxBig, TakeVecZnxDft, VecZnxAutomorphismInplace, VecZnxBigAddSmallInplace, VecZnxBigAllocBytes,
VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxDftAddInplace, VecZnxDftAllocBytes, VecZnxDftCopy,

View File

@@ -1,4 +1,4 @@
use backend::hal::{
use poulpy_backend::hal::{
api::{
ScratchAvailable, TakeVecZnxDft, VecZnxAutomorphismInplace, VecZnxBigAddSmallInplace, VecZnxBigAutomorphismInplace,
VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxBigSubSmallAInplace, VecZnxBigSubSmallBInplace,

View File

@@ -1,4 +1,4 @@
use backend::hal::{
use poulpy_backend::hal::{
api::{
ScratchAvailable, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes,
VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VmpApply, VmpApplyAdd, VmpApplyTmpBytes, ZnxView,

View File

@@ -1,4 +1,4 @@
use backend::hal::{
use poulpy_backend::hal::{
api::{
ScratchAvailable, TakeVecZnxDft, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes,
VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VmpApply, VmpApplyAdd, VmpApplyTmpBytes, ZnxView,

View File

@@ -1,4 +1,4 @@
use backend::hal::{
use poulpy_backend::hal::{
api::{
DataViewMut, SvpApplyInplace, TakeVecZnxBig, TakeVecZnxDft, VecZnxBigAddInplace, VecZnxBigAddSmallInplace,
VecZnxBigNormalize, VecZnxDftAllocBytes, VecZnxDftFromVecZnx, VecZnxDftToVecZnxBigConsume, VecZnxNormalizeTmpBytes,

View File

@@ -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},

View File

@@ -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,

View File

@@ -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<D: DataMut> GGLWECiphertextCompressed<D> {
{
#[cfg(debug_assertions)]
{
use backend::hal::api::ZnxInfos;
use poulpy_backend::hal::api::ZnxInfos;
assert_eq!(
self.rank_in(),

View File

@@ -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,

Some files were not shown because too many files have changed in this diff Show More