mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-11 07:38:08 -05:00
Compare commits
17 Commits
al/gpu_cou
...
ns/split_c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69c54b9b66 | ||
|
|
713867e782 | ||
|
|
4a8a99dcd8 | ||
|
|
2acb79c07c | ||
|
|
db211ec6f8 | ||
|
|
43a9c876d2 | ||
|
|
0a7052bd2f | ||
|
|
a4307ba4fb | ||
|
|
ffe6ee2cfd | ||
|
|
99c0680d00 | ||
|
|
e9ea672574 | ||
|
|
3496036078 | ||
|
|
3b94cf03dc | ||
|
|
b6a949e229 | ||
|
|
d6cbeb935c | ||
|
|
baaa3cc075 | ||
|
|
bb856d539e |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -12,8 +12,8 @@ target/
|
||||
**/*.bin
|
||||
|
||||
# Some of our bench outputs
|
||||
/tfhe/benchmarks_parameters
|
||||
/tfhe-zk-pok/benchmarks_parameters
|
||||
/crates/tfhe/benchmarks_parameters
|
||||
/crates/tfhe-zk-pok/benchmarks_parameters
|
||||
**/*.csv
|
||||
|
||||
# dieharder run log
|
||||
@@ -26,11 +26,11 @@ dieharder_run.log
|
||||
backends/tfhe-cuda-backend/cuda/cmake-build-debug/
|
||||
|
||||
# WASM tests
|
||||
tfhe/web_wasm_parallel_tests/server.PID
|
||||
crates/tfhe/tests/web_wasm_parallel/server.PID
|
||||
venv/
|
||||
web-test-runner/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
||||
# Dir used for backward compatibility test data
|
||||
tfhe/tfhe-backward-compat-data/
|
||||
crates/tfhe/tfhe-backward-compat-data/
|
||||
|
||||
24
Cargo.toml
24
Cargo.toml
@@ -1,23 +1,18 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
members = [
|
||||
"tfhe",
|
||||
"tfhe-fft",
|
||||
"tfhe-ntt",
|
||||
"tfhe-zk-pok",
|
||||
"crates/*",
|
||||
"tasks",
|
||||
"apps/trivium",
|
||||
"tfhe-csprng",
|
||||
"backends/tfhe-cuda-backend",
|
||||
"utils/tfhe-versionable",
|
||||
"utils/tfhe-versionable-derive",
|
||||
]
|
||||
|
||||
exclude = [
|
||||
"tfhe/backward_compatibility_tests",
|
||||
"crates/tfhe/backward_compatibility_tests",
|
||||
"utils/cargo-tfhe-lints-inner",
|
||||
"utils/cargo-tfhe-lints"
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
aligned-vec = { version = "0.5", default-features = false }
|
||||
bytemuck = "1.14.3"
|
||||
@@ -27,6 +22,19 @@ pulp = { version = "0.18.22", default-features = false }
|
||||
serde = { version = "1.0", default-features = false }
|
||||
wasm-bindgen = ">=0.2.86,<0.2.94"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.11.0"
|
||||
license = "BSD-3-Clause-Clear"
|
||||
repository = "https://github.com/zama-ai/tfhe-rs"
|
||||
documentation = "https://docs.zama.ai/tfhe-rs"
|
||||
|
||||
[workspace.lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = [
|
||||
'cfg(bench)',
|
||||
'cfg(tarpaulin)',
|
||||
'cfg(tfhe_lints)',
|
||||
] }
|
||||
|
||||
[profile.bench]
|
||||
lto = "fat"
|
||||
|
||||
|
||||
39
Makefile
39
Makefile
@@ -5,9 +5,10 @@ CARGO_RS_CHECK_TOOLCHAIN:=+$(RS_CHECK_TOOLCHAIN)
|
||||
TARGET_ARCH_FEATURE:=$(shell ./scripts/get_arch_feature.sh)
|
||||
CPU_COUNT=$(shell ./scripts/cpu_count.sh)
|
||||
RS_BUILD_TOOLCHAIN:=stable
|
||||
TFHE_SRC:=crates/tfhe
|
||||
CARGO_RS_BUILD_TOOLCHAIN:=+$(RS_BUILD_TOOLCHAIN)
|
||||
CARGO_PROFILE?=release
|
||||
MIN_RUST_VERSION:=$(shell grep '^rust-version[[:space:]]*=' tfhe/Cargo.toml | cut -d '=' -f 2 | xargs)
|
||||
MIN_RUST_VERSION:=$(shell grep '^rust-version[[:space:]]*=' $(TFHE_SRC)/Cargo.toml | cut -d '=' -f 2 | xargs)
|
||||
AVX512_SUPPORT?=OFF
|
||||
WASM_RUSTFLAGS:=
|
||||
BIG_TESTS_INSTANCE?=FALSE
|
||||
@@ -28,7 +29,7 @@ TFHE_SPEC:=tfhe
|
||||
# We are kind of hacking the cut here, the version cannot contain a quote '"'
|
||||
WASM_BINDGEN_VERSION:=$(shell grep '^wasm-bindgen[[:space:]]*=' Cargo.toml | cut -d '"' -f 2 | xargs)
|
||||
WEB_RUNNER_DIR=web-test-runner
|
||||
WEB_SERVER_DIR=tfhe/web_wasm_parallel_tests
|
||||
WEB_SERVER_DIR=tfhe/tests/web_wasm_parallel
|
||||
# This is done to avoid forgetting it, we still precise the RUSTFLAGS in the commands to be able to
|
||||
# copy paste the command in the terminal and change them if required without forgetting the flags
|
||||
export RUSTFLAGS?=-C target-cpu=native
|
||||
@@ -243,7 +244,7 @@ fmt_js: check_nvm_installed
|
||||
source ~/.nvm/nvm.sh && \
|
||||
nvm install $(NODE_VERSION) && \
|
||||
nvm use $(NODE_VERSION) && \
|
||||
$(MAKE) -C tfhe/web_wasm_parallel_tests fmt
|
||||
$(MAKE) -C $(TFHE_SRC)/tests/web_wasm_parallel fmt
|
||||
|
||||
.PHONY: fmt_gpu # Format rust and cuda code
|
||||
fmt_gpu: install_rs_check_toolchain
|
||||
@@ -252,7 +253,7 @@ fmt_gpu: install_rs_check_toolchain
|
||||
|
||||
.PHONY: fmt_c_tests # Format c tests
|
||||
fmt_c_tests:
|
||||
find tfhe/c_api_tests/ -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -exec clang-format -style=file -i {} \;
|
||||
find $(TFHE_SRC)/tests/c_api/ -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -exec clang-format -style=file -i {} \;
|
||||
|
||||
.PHONY: check_fmt # Check rust code format
|
||||
check_fmt: install_rs_check_toolchain
|
||||
@@ -260,7 +261,7 @@ check_fmt: install_rs_check_toolchain
|
||||
|
||||
.PHONY: check_fmt_c_tests # Check C tests format
|
||||
check_fmt_c_tests:
|
||||
find tfhe/c_api_tests/ -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -exec clang-format --dry-run --Werror -style=file {} \;
|
||||
find $(TFHE_SRC)/tests/c_api/ -regex '.*\.\(cpp\|hpp\|cu\|c\|h\)' -exec clang-format --dry-run --Werror -style=file {} \;
|
||||
|
||||
.PHONY: check_fmt_gpu # Check rust and cuda code format
|
||||
check_fmt_gpu: install_rs_check_toolchain
|
||||
@@ -272,7 +273,7 @@ check_fmt_js: check_nvm_installed
|
||||
source ~/.nvm/nvm.sh && \
|
||||
nvm install $(NODE_VERSION) && \
|
||||
nvm use $(NODE_VERSION) && \
|
||||
$(MAKE) -C tfhe/web_wasm_parallel_tests check_fmt
|
||||
$(MAKE) -C $(TFHE_SRC)/tests/web_wasm_parallel check_fmt
|
||||
|
||||
.PHONY: check_typos # Check for typos in codebase
|
||||
check_typos: install_typos_checker
|
||||
@@ -442,7 +443,7 @@ check_rust_bindings_did_not_change:
|
||||
|
||||
.PHONY: tfhe_lints # Run custom tfhe-rs lints
|
||||
tfhe_lints: install_tfhe_lints
|
||||
cd tfhe && RUSTFLAGS="$(RUSTFLAGS)" cargo tfhe-lints \
|
||||
cd $(TFHE_SRC) && RUSTFLAGS="$(RUSTFLAGS)" cargo tfhe-lints \
|
||||
--features=$(TARGET_ARCH_FEATURE),boolean,shortint,integer,zk-pok -- -D warnings
|
||||
|
||||
.PHONY: build_core # Build core_crypto without experimental features
|
||||
@@ -508,25 +509,25 @@ build_c_api_experimental_deterministic_fft: install_rs_check_toolchain
|
||||
|
||||
.PHONY: build_web_js_api # Build the js API targeting the web browser
|
||||
build_web_js_api: install_rs_build_toolchain install_wasm_pack
|
||||
cd tfhe && \
|
||||
cd $(TFHE_SRC) && \
|
||||
RUSTFLAGS="$(WASM_RUSTFLAGS)" rustup run "$(RS_BUILD_TOOLCHAIN)" \
|
||||
wasm-pack build --release --target=web \
|
||||
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,zk-pok
|
||||
|
||||
.PHONY: build_web_js_api_parallel # Build the js API targeting the web browser with parallelism support
|
||||
build_web_js_api_parallel: install_rs_check_toolchain install_wasm_pack
|
||||
cd tfhe && \
|
||||
cd $(TFHE_SRC) && \
|
||||
rustup component add rust-src --toolchain $(RS_CHECK_TOOLCHAIN) && \
|
||||
RUSTFLAGS="$(WASM_RUSTFLAGS) -C target-feature=+atomics,+bulk-memory,+mutable-globals" rustup run $(RS_CHECK_TOOLCHAIN) \
|
||||
wasm-pack build --release --target=web \
|
||||
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,parallel-wasm-api,zk-pok \
|
||||
-Z build-std=panic_abort,std && \
|
||||
find pkg/snippets -type f -iname workerHelpers.worker.js -exec sed -i "s|from '..\/..\/..\/';|from '..\/..\/..\/tfhe.js';|" {} \;
|
||||
jq '.files += ["snippets"]' tfhe/pkg/package.json > tmp_pkg.json && mv -f tmp_pkg.json tfhe/pkg/package.json
|
||||
jq '.files += ["snippets"]' $(TFHE_SRC)/pkg/package.json > tmp_pkg.json && mv -f tmp_pkg.json $(TFHE_SRC)/pkg/package.json
|
||||
|
||||
.PHONY: build_node_js_api # Build the js API targeting nodejs
|
||||
build_node_js_api: install_rs_build_toolchain install_wasm_pack
|
||||
cd tfhe && \
|
||||
cd $(TFHE_SRC) && \
|
||||
RUSTFLAGS="$(WASM_RUSTFLAGS)" rustup run "$(RS_BUILD_TOOLCHAIN)" \
|
||||
wasm-pack build --release --target=nodejs \
|
||||
-- --features=boolean-client-js-wasm-api,shortint-client-js-wasm-api,integer-client-js-wasm-api,zk-pok
|
||||
@@ -877,7 +878,7 @@ test_zk_wasm_x86_compat_ci: check_nvm_installed
|
||||
|
||||
.PHONY: test_zk_wasm_x86_compat # Check compatibility between wasm and x86_64 proofs
|
||||
test_zk_wasm_x86_compat: install_rs_build_toolchain build_node_js_api
|
||||
cd tfhe/tests/zk_wasm_x86_test && npm install
|
||||
cd $(TFHE_SRC)/tests/zk_wasm_x86_test && npm install
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
|
||||
-p tfhe --test zk_wasm_x86_test --features=$(TARGET_ARCH_FEATURE),integer,zk-pok
|
||||
|
||||
@@ -891,11 +892,11 @@ test_versionable: install_rs_build_toolchain
|
||||
.PHONY: test_backward_compatibility_ci
|
||||
test_backward_compatibility_ci: install_rs_build_toolchain
|
||||
TFHE_BACKWARD_COMPAT_DATA_DIR="$(BACKWARD_COMPAT_DATA_DIR)" RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --profile $(CARGO_PROFILE) \
|
||||
--config "patch.'$(BACKWARD_COMPAT_DATA_URL)'.$(BACKWARD_COMPAT_DATA_PROJECT).path=\"tfhe/$(BACKWARD_COMPAT_DATA_DIR)\"" \
|
||||
--config "patch.'$(BACKWARD_COMPAT_DATA_URL)'.$(BACKWARD_COMPAT_DATA_PROJECT).path=\"$(TFHE_SRC)/$(BACKWARD_COMPAT_DATA_DIR)\"" \
|
||||
--features=$(TARGET_ARCH_FEATURE),shortint,integer,zk-pok -p $(TFHE_SPEC) test_backward_compatibility -- --nocapture
|
||||
|
||||
.PHONY: test_backward_compatibility # Same as test_backward_compatibility_ci but tries to clone the data repo first if needed
|
||||
test_backward_compatibility: tfhe/$(BACKWARD_COMPAT_DATA_DIR) test_backward_compatibility_ci
|
||||
test_backward_compatibility: $(TFHE_SRC)/$(BACKWARD_COMPAT_DATA_DIR) test_backward_compatibility_ci
|
||||
|
||||
.PHONY: backward_compat_branch # Prints the required backward compatibility branch
|
||||
backward_compat_branch:
|
||||
@@ -938,11 +939,11 @@ check_md_docs_are_tested:
|
||||
|
||||
.PHONY: check_intra_md_links # Checks broken internal links in Markdown docs
|
||||
check_intra_md_links: install_mlc
|
||||
mlc --offline --match-file-extension tfhe/docs
|
||||
mlc --offline --match-file-extension $(TFHE_SRC)/docs
|
||||
|
||||
.PHONY: check_md_links # Checks all broken links in Markdown docs
|
||||
check_md_links: install_mlc
|
||||
mlc --match-file-extension tfhe/docs
|
||||
mlc --match-file-extension $(TFHE_SRC)/docs
|
||||
|
||||
.PHONY: check_compile_tests # Build tests in debug without running them
|
||||
check_compile_tests: install_rs_build_toolchain
|
||||
@@ -967,7 +968,7 @@ check_compile_tests_benches_gpu: install_rs_build_toolchain
|
||||
|
||||
.PHONY: test_nodejs_wasm_api # Run tests for the nodejs on wasm API
|
||||
test_nodejs_wasm_api: build_node_js_api
|
||||
cd tfhe/js_on_wasm_tests && npm install && npm run test
|
||||
cd $(TFHE_SRC)/tests/js_on_wasm && npm install && npm run test
|
||||
|
||||
.PHONY: test_nodejs_wasm_api_ci # Run tests for the nodejs on wasm API
|
||||
test_nodejs_wasm_api_ci: build_node_js_api
|
||||
@@ -1275,9 +1276,9 @@ write_params_to_file: install_rs_check_toolchain
|
||||
|
||||
.PHONY: clone_backward_compat_data # Clone the data repo needed for backward compatibility tests
|
||||
clone_backward_compat_data:
|
||||
./scripts/clone_backward_compat_data.sh $(BACKWARD_COMPAT_DATA_URL) $(BACKWARD_COMPAT_DATA_BRANCH) tfhe/$(BACKWARD_COMPAT_DATA_DIR)
|
||||
./scripts/clone_backward_compat_data.sh $(BACKWARD_COMPAT_DATA_URL) $(BACKWARD_COMPAT_DATA_BRANCH) $(TFHE_SRC)/$(BACKWARD_COMPAT_DATA_DIR)
|
||||
|
||||
tfhe/$(BACKWARD_COMPAT_DATA_DIR): clone_backward_compat_data
|
||||
$(TFHE_SRC)/$(BACKWARD_COMPAT_DATA_DIR): clone_backward_compat_data
|
||||
|
||||
#
|
||||
# Real use case examples
|
||||
|
||||
@@ -9,11 +9,11 @@ edition = "2021"
|
||||
rayon = { version = "1.7.0"}
|
||||
|
||||
[target.'cfg(target_arch = "x86_64")'.dependencies.tfhe]
|
||||
path = "../../tfhe"
|
||||
path = "../../crates/tfhe"
|
||||
features = [ "boolean", "shortint", "integer", "x86_64" ]
|
||||
|
||||
[target.'cfg(target_arch = "aarch64")'.dependencies.tfhe]
|
||||
path = "../../tfhe"
|
||||
path = "../../crates/tfhe"
|
||||
features = [ "boolean", "shortint", "integer", "aarch64-unix" ]
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -72,7 +72,7 @@ parser.add_argument(
|
||||
parser.add_argument(
|
||||
"--index-path",
|
||||
dest="index_path",
|
||||
default="tfhe/web_wasm_parallel_tests/index.html",
|
||||
default="crates/tfhe/tests/web_wasm_parallel/index.html",
|
||||
help="Path to HTML index file containing all the tests/benchmarks",
|
||||
)
|
||||
parser.add_argument(
|
||||
@@ -376,7 +376,7 @@ def dump_benchmark_results(results, browser_kind):
|
||||
key.replace("mean", "_".join((browser_kind.name, "mean"))): val
|
||||
for key, val in results.items()
|
||||
}
|
||||
pathlib.Path("tfhe/wasm_benchmark_results.json").write_text(json.dumps(results))
|
||||
pathlib.Path("crates/tfhe/wasm_benchmark_results.json").write_text(json.dumps(results))
|
||||
|
||||
|
||||
def start_web_server(
|
||||
|
||||
82
crates/tfhe-core-crypto/Cargo.toml
Normal file
82
crates/tfhe-core-crypto/Cargo.toml
Normal file
@@ -0,0 +1,82 @@
|
||||
[package]
|
||||
name = "tfhe-core-crypto"
|
||||
version.workspace = true
|
||||
edition = "2021"
|
||||
license.workspace = true
|
||||
description = "Low level cryptographic primitives used in the TFHE-rs library."
|
||||
homepage = "https://zama.ai/"
|
||||
documentation.workspace = true
|
||||
repository.workspace = true
|
||||
keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"]
|
||||
rust-version = "1.73"
|
||||
|
||||
[dependencies]
|
||||
serde = { workspace = true, features = ["default", "derive"] }
|
||||
pulp = { workspace = true, features = ["default"] }
|
||||
aligned-vec = { workspace = true, features = ["default", "serde"] }
|
||||
dyn-stack = { workspace = true, features = ["default"] }
|
||||
# While we wait for repeat_n in rust standard library
|
||||
itertools = "0.11.0"
|
||||
rand_core = { version = "0.6.4", features = ["std"] }
|
||||
rayon = { version = "1.5.0" }
|
||||
bytemuck = { workspace = true }
|
||||
paste = "1.0.7"
|
||||
bincode = "1.3.3"
|
||||
fs2 = { version = "0.4.3", optional = true }
|
||||
lazy_static = { version = "1.4.0", optional = true }
|
||||
|
||||
tfhe-csprng = { version = "0.4.1", path = "../tfhe-csprng", features = [
|
||||
"generator_fallback",
|
||||
"parallel",
|
||||
] }
|
||||
tfhe-fft = { version = "0.6.0", path = "../tfhe-fft", features = [
|
||||
"serde",
|
||||
"fft128",
|
||||
] }
|
||||
tfhe-ntt = { version = "0.3.0", path = "../tfhe-ntt" }
|
||||
tfhe-cuda-backend = { version = "0.6.0", path = "../../backends/tfhe-cuda-backend", optional = true }
|
||||
tfhe-zk-pok = { version = "0.3.1", path = "../tfhe-zk-pok", optional = true }
|
||||
tfhe-versionable = { version = "0.3.2", path = "../tfhe-versionable" }
|
||||
tfhe-safe-serialization = { version = "0.11.0", path = "../tfhe-safe-serialization" }
|
||||
|
||||
getrandom = { version = "0.2.8", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.8.5"
|
||||
# For erf and normality test
|
||||
libm = "0.2.6"
|
||||
rand_distr = "0.4.3"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[features]
|
||||
nightly-avx512 = ["tfhe-fft/nightly", "tfhe-ntt/nightly", "pulp/nightly"]
|
||||
gpu = ["dep:tfhe-cuda-backend"]
|
||||
zk-pok = ["dep:tfhe-zk-pok"]
|
||||
|
||||
internal-keycache = ["dep:lazy_static", "dep:fs2"]
|
||||
|
||||
# Experimental section
|
||||
experimental = []
|
||||
experimental-force_fft_algo_dif4 = []
|
||||
|
||||
# Private features
|
||||
__profiling = []
|
||||
|
||||
__c_api = []
|
||||
__wasm_api = ["dep:getrandom", "getrandom/js"]
|
||||
|
||||
# Make some internal mut getters pub for testing purpose
|
||||
__test_core_getters = []
|
||||
|
||||
# Enable the x86_64 specific accelerated implementation of the random generator for the default
|
||||
# backend
|
||||
generator_x86_64_aesni = ["tfhe-csprng/generator_x86_64_aesni"]
|
||||
|
||||
# Enable the aarch64 specific accelerated implementation of the random generator for the default
|
||||
# backend
|
||||
generator_aarch64_aes = ["tfhe-csprng/generator_aarch64_aes"]
|
||||
|
||||
seeder_unix = ["tfhe-csprng/seeder_unix"]
|
||||
seeder_x86_64_rdseed = ["tfhe-csprng/seeder_x86_64_rdseed"]
|
||||
@@ -2,11 +2,11 @@
|
||||
//! [`standard GGSW ciphertexts`](`GgswCiphertext`) to various representations/numerical domains
|
||||
//! like the Fourier domain.
|
||||
|
||||
use crate::core_crypto::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::ggsw::fill_with_forward_fourier_scratch;
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::{Fft, FftView};
|
||||
use crate::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use crate::fft_impl::fft64::crypto::ggsw::fill_with_forward_fourier_scratch;
|
||||
use crate::fft_impl::fft64::math::fft::{Fft, FftView};
|
||||
use dyn_stack::{PodStack, SizeOverflow, StackReq};
|
||||
use tfhe_fft::c64;
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn convert_standard_ggsw_ciphertext_to_fourier<Scalar, InputCont, OutputCont
|
||||
|
||||
/// Memory optimized version of [`convert_standard_ggsw_ciphertext_to_fourier`].
|
||||
///
|
||||
/// See [`cmux_assign_mem_optimized`](`crate::core_crypto::algorithms::cmux_assign_mem_optimized`)
|
||||
/// See [`cmux_assign_mem_optimized`](`crate::algorithms::cmux_assign_mem_optimized`)
|
||||
/// for usage.
|
||||
pub fn convert_standard_ggsw_ciphertext_to_fourier_mem_optimized<Scalar, InputCont, OutputCont>(
|
||||
input_ggsw: &GgswCiphertext<InputCont>,
|
||||
@@ -1,18 +1,18 @@
|
||||
//! Module containing primitives pertaining to [`GGSW ciphertext
|
||||
//! encryption`](`GgswCiphertext#ggsw-encryption`).
|
||||
|
||||
use crate::core_crypto::algorithms::misc::divide_round;
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::ciphertext_modulus::{CiphertextModulus, CiphertextModulusKind};
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::decomposition::{
|
||||
use crate::algorithms::misc::divide_round;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::ciphertext_modulus::{CiphertextModulus, CiphertextModulusKind};
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::decomposition::{
|
||||
DecompositionLevel, DecompositionTerm, DecompositionTermNonNative, SignedDecomposer,
|
||||
};
|
||||
use crate::core_crypto::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::{DecompositionBaseLog, PlaintextCount};
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::commons::parameters::{DecompositionBaseLog, PlaintextCount};
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Compute the multiplicative factor for a GGSW encryption based on an input value and GGSW
|
||||
@@ -1,16 +1,16 @@
|
||||
//! Module containing primitives pertaining to [`GLWE ciphertext
|
||||
//! encryption`](`GlweCiphertext#glwe-encryption`).
|
||||
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::*;
|
||||
use crate::core_crypto::algorithms::slice_algorithms::{
|
||||
use crate::algorithms::polynomial_algorithms::*;
|
||||
use crate::algorithms::slice_algorithms::{
|
||||
slice_wrapping_scalar_div_assign, slice_wrapping_scalar_mul_assign,
|
||||
};
|
||||
use crate::core_crypto::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Convenience function to share the core logic of the GLWE assign encryption between all functions
|
||||
/// needing it.
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module containing primitives pertaining to [`GLWE ciphertext`](`GlweCiphertext`) linear algebra,
|
||||
//! like addition, multiplication, etc.
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Add the right-hand side [`GLWE ciphertext`](`GlweCiphertext`) to the left-hand side [`GLWE
|
||||
/// ciphertext`](`GlweCiphertext`) updating it in-place.
|
||||
@@ -2,10 +2,10 @@
|
||||
//! _sample extract_ in the literature. Allowing to extract a single
|
||||
//! [`LWE Ciphertext`](`LweCiphertext`) from a given [`GLWE ciphertext`](`GlweCiphertext`).
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Extract the nth coefficient from the body of a [`GLWE Ciphertext`](`GlweCiphertext`) as an
|
||||
@@ -1,11 +1,11 @@
|
||||
//! Module containing primitives pertaining to the generation of
|
||||
//! [`GLWE secret keys`](`GlweSecretKey`).
|
||||
|
||||
use crate::core_crypto::commons::generators::SecretRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::{RandomGenerable, UniformBinary};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::commons::generators::SecretRandomGenerator;
|
||||
use crate::commons::math::random::{RandomGenerable, UniformBinary};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Allocate a new [`GLWE secret key`](`GlweSecretKey`) and fill it with uniformly random binary
|
||||
/// coefficients.
|
||||
@@ -2,13 +2,13 @@
|
||||
//! [`standard LWE bootstrap keys`](`LweBootstrapKey`) to various representations/numerical domains
|
||||
//! like the Fourier domain.
|
||||
|
||||
use crate::core_crypto::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::core_crypto::commons::math::ntt::ntt64::Ntt64;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::fft128::math::fft::Fft128;
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::bootstrap::fill_with_forward_fourier_scratch;
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::{Fft, FftView};
|
||||
use crate::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::commons::math::ntt::ntt64::Ntt64;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use crate::fft_impl::fft128::math::fft::Fft128;
|
||||
use crate::fft_impl::fft64::crypto::bootstrap::fill_with_forward_fourier_scratch;
|
||||
use crate::fft_impl::fft64::math::fft::{Fft, FftView};
|
||||
use dyn_stack::{PodStack, SizeOverflow, StackReq};
|
||||
use rayon::prelude::*;
|
||||
use tfhe_fft::c64;
|
||||
@@ -16,7 +16,7 @@ use tfhe_fft::c64;
|
||||
/// Convert an [`LWE bootstrap key`](`LweBootstrapKey`) with standard coefficients to the Fourier
|
||||
/// domain.
|
||||
///
|
||||
/// See [`programmable_bootstrap_lwe_ciphertext`](`crate::core_crypto::algorithms::programmable_bootstrap_lwe_ciphertext`) for usage.
|
||||
/// See [`programmable_bootstrap_lwe_ciphertext`](`crate::algorithms::programmable_bootstrap_lwe_ciphertext`) for usage.
|
||||
pub fn convert_standard_lwe_bootstrap_key_to_fourier<Scalar, InputCont, OutputCont>(
|
||||
input_bsk: &LweBootstrapKey<InputCont>,
|
||||
output_bsk: &mut FourierLweBootstrapKey<OutputCont>,
|
||||
@@ -159,7 +159,7 @@ pub fn convert_standard_lwe_bootstrap_key_to_fourier_mem_optimized_requirement(
|
||||
/// Convert an [`LWE bootstrap key`](`LweBootstrapKey`) with standard coefficients to the Fourier
|
||||
/// domain.
|
||||
///
|
||||
/// See [`programmable_bootstrap_f128_lwe_ciphertext`](`crate::core_crypto::algorithms::programmable_bootstrap_f128_lwe_ciphertext`) for usage.
|
||||
/// See [`programmable_bootstrap_f128_lwe_ciphertext`](`crate::algorithms::programmable_bootstrap_f128_lwe_ciphertext`) for usage.
|
||||
pub fn convert_standard_lwe_bootstrap_key_to_fourier_128<Scalar, InputCont, OutputCont>(
|
||||
input_bsk: &LweBootstrapKey<InputCont>,
|
||||
output_bsk: &mut Fourier128LweBootstrapKey<OutputCont>,
|
||||
@@ -215,7 +215,7 @@ pub fn convert_standard_lwe_bootstrap_key_to_fourier_128<Scalar, InputCont, Outp
|
||||
/// Convert an [`LWE bootstrap key`](`LweBootstrapKey`) with standard coefficients to the NTT
|
||||
/// domain using a 64 bits NTT.
|
||||
///
|
||||
/// See [`programmable_bootstrap_ntt64_lwe_ciphertext_mem_optimized`](`crate::core_crypto::algorithms::programmable_bootstrap_ntt64_lwe_ciphertext_mem_optimized`) for usage.
|
||||
/// See [`programmable_bootstrap_ntt64_lwe_ciphertext_mem_optimized`](`crate::algorithms::programmable_bootstrap_ntt64_lwe_ciphertext_mem_optimized`) for usage.
|
||||
pub fn convert_standard_lwe_bootstrap_key_to_ntt64<InputCont, OutputCont>(
|
||||
input_bsk: &LweBootstrapKey<InputCont>,
|
||||
output_bsk: &mut NttLweBootstrapKey<OutputCont>,
|
||||
@@ -2,12 +2,12 @@
|
||||
//! [`standard LWE bootstrap keys`](`LweBootstrapKey`) and [`seeded standard LWE bootstrap
|
||||
//! keys`](`SeededLweBootstrapKey`).
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Fill an [`LWE bootstrap key`](`LweBootstrapKey`) with an actual bootstrapping key constructed
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module with primitives pertaining to [`LweCompactCiphertextList`] expansion.
|
||||
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::polynomial_wrapping_monic_monomial_mul_assign;
|
||||
use crate::core_crypto::commons::parameters::MonomialDegree;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::polynomial_algorithms::polynomial_wrapping_monic_monomial_mul_assign;
|
||||
use crate::commons::parameters::MonomialDegree;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Expand an [`LweCompactCiphertextList`] into an [`LweCiphertextList`].
|
||||
@@ -1,13 +1,13 @@
|
||||
//! Module containing primitives pertaining to [`LWE compact public key
|
||||
//! generation`](`LweCompactPublicKey`).
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::ciphertext_modulus::CiphertextModulus;
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::{Distribution, Uniform};
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::prelude::ActivatedRandomGenerator;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::ciphertext_modulus::CiphertextModulus;
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::random::{Distribution, Uniform};
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use crate::prelude::ActivatedRandomGenerator;
|
||||
use slice_algorithms::*;
|
||||
|
||||
/// Fill an [`LWE compact public key`](`LweCompactPublicKey`) with an actual public key constructed
|
||||
@@ -1,22 +1,20 @@
|
||||
//! Module containing primitives pertaining to [`LWE ciphertext encryption and
|
||||
//! decryption`](`LweCiphertext#lwe-encryption`).
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::core_crypto::commons::generators::{EncryptionRandomGenerator, SecretRandomGenerator};
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::commons::generators::{EncryptionRandomGenerator, SecretRandomGenerator};
|
||||
#[cfg(feature = "zk-pok")]
|
||||
use crate::core_crypto::commons::math::random::BoundedDistribution;
|
||||
use crate::core_crypto::commons::math::random::{
|
||||
use crate::commons::math::random::BoundedDistribution;
|
||||
use crate::commons::math::random::{
|
||||
ActivatedRandomGenerator, Distribution, RandomGenerable, RandomGenerator, Uniform,
|
||||
UniformBinary,
|
||||
};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
#[cfg(feature = "zk-pok")]
|
||||
use tfhe_zk_pok::proofs::pke::{commit, prove};
|
||||
|
||||
/// Convenience function to share the core logic of the LWE encryption between all functions needing
|
||||
/// it.
|
||||
@@ -1858,8 +1856,7 @@ where
|
||||
BodyDistribution: BoundedDistribution<Scalar::Signed>,
|
||||
KeyCont: Container<Element = Scalar>,
|
||||
{
|
||||
let public_params = crs.public_params();
|
||||
let exclusive_max = public_params.exclusive_max_noise();
|
||||
let exclusive_max = crs.exclusive_max_noise();
|
||||
if Scalar::BITS < 64 && (1u64 << Scalar::BITS) >= exclusive_max {
|
||||
return Err(
|
||||
"The given random distribution would create random values out \
|
||||
@@ -1893,28 +1890,23 @@ where
|
||||
return Err("Zero knowledge proof do not support moduli greater than 2**64".into());
|
||||
}
|
||||
|
||||
let expected_q = if Scalar::BITS == 64 {
|
||||
0u64
|
||||
} else {
|
||||
164 << Scalar::BITS
|
||||
};
|
||||
|
||||
if expected_q != public_params.q {
|
||||
if ciphertext_modulus != crs.ciphertext_modulus() {
|
||||
return Err("Mismatched modulus between CRS and ciphertexts".into());
|
||||
}
|
||||
|
||||
if ciphertext_count.0 > public_params.k {
|
||||
if ciphertext_count > crs.max_num_messages() {
|
||||
return Err(format!(
|
||||
"CRS allows at most {} ciphertexts to be proven at once, {} contained in the list",
|
||||
public_params.k, ciphertext_count.0
|
||||
crs.max_num_messages().0,
|
||||
ciphertext_count.0
|
||||
)
|
||||
.into());
|
||||
}
|
||||
|
||||
if lwe_compact_public_key.lwe_dimension().0 > public_params.d {
|
||||
if lwe_compact_public_key.lwe_dimension() > crs.lwe_dimension() {
|
||||
return Err(format!(
|
||||
"CRS allows a LweDimension of at most {}, current dimension: {}",
|
||||
public_params.d,
|
||||
crs.lwe_dimension().0,
|
||||
lwe_compact_public_key.lwe_dimension().0
|
||||
)
|
||||
.into());
|
||||
@@ -1922,10 +1914,10 @@ where
|
||||
|
||||
// 2**64 /delta == ((2**63) / delta) *2
|
||||
let plaintext_modulus = ((1u64 << (u64::BITS - 1) as usize) / u64::cast_from(delta)) * 2;
|
||||
if plaintext_modulus != public_params.t {
|
||||
if plaintext_modulus != crs.plaintext_modulus() {
|
||||
return Err(format!(
|
||||
"Mismatched plaintext modulus: CRS expects {}, requested modulus: {plaintext_modulus:?}",
|
||||
public_params.t
|
||||
crs.plaintext_modulus()
|
||||
).into());
|
||||
}
|
||||
|
||||
@@ -2291,52 +2283,18 @@ where
|
||||
encryption_generator,
|
||||
);
|
||||
|
||||
let (c1, c2) = output.get_mask_and_body();
|
||||
|
||||
let (public_commit, private_commit) = commit(
|
||||
lwe_compact_public_key
|
||||
.get_mask()
|
||||
.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
lwe_compact_public_key
|
||||
.get_body()
|
||||
.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
c1.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
vec![i64::cast_from(*c2.data)],
|
||||
binary_random_vector
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
mask_noise
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
vec![i64::cast_from(message.0)],
|
||||
body_noise
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
crs.public_params(),
|
||||
random_generator,
|
||||
);
|
||||
|
||||
Ok(prove(
|
||||
(crs.public_params(), &public_commit),
|
||||
&private_commit,
|
||||
Ok(crs.prove(
|
||||
lwe_compact_public_key,
|
||||
&vec![message.0],
|
||||
&LweCompactCiphertextList::from_container(
|
||||
output.as_ref(),
|
||||
output.lwe_size(),
|
||||
LweCiphertextCount(1),
|
||||
output.ciphertext_modulus(),
|
||||
),
|
||||
&binary_random_vector,
|
||||
&mask_noise,
|
||||
&body_noise,
|
||||
metadata,
|
||||
load,
|
||||
random_generator,
|
||||
@@ -2807,61 +2765,13 @@ where
|
||||
encryption_generator,
|
||||
);
|
||||
|
||||
let (c1, c2) = output.get_mask_and_body_list();
|
||||
|
||||
let (public_commit, private_commit) = commit(
|
||||
lwe_compact_public_key
|
||||
.get_mask()
|
||||
.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
lwe_compact_public_key
|
||||
.get_body()
|
||||
.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
c1.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
c2.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
binary_random_vector
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
mask_noise
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
messages
|
||||
.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
body_noise
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
crs.public_params(),
|
||||
random_generator,
|
||||
);
|
||||
|
||||
Ok(prove(
|
||||
(crs.public_params(), &public_commit),
|
||||
&private_commit,
|
||||
Ok(crs.prove(
|
||||
lwe_compact_public_key,
|
||||
messages,
|
||||
output,
|
||||
&binary_random_vector,
|
||||
&mask_noise,
|
||||
&body_noise,
|
||||
metadata,
|
||||
load,
|
||||
random_generator,
|
||||
@@ -3341,61 +3251,13 @@ where
|
||||
encryption_generator,
|
||||
);
|
||||
|
||||
let (c1, c2) = output.get_mask_and_body_list();
|
||||
|
||||
let (public_commit, private_commit) = commit(
|
||||
lwe_compact_public_key
|
||||
.get_mask()
|
||||
.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
lwe_compact_public_key
|
||||
.get_body()
|
||||
.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
c1.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
c2.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
binary_random_vector
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
mask_noise
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
messages
|
||||
.as_ref()
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
body_noise
|
||||
.iter()
|
||||
.copied()
|
||||
.map(CastFrom::cast_from)
|
||||
.collect::<Vec<_>>(),
|
||||
crs.public_params(),
|
||||
random_generator,
|
||||
);
|
||||
|
||||
Ok(prove(
|
||||
(crs.public_params(), &public_commit),
|
||||
&private_commit,
|
||||
Ok(crs.prove(
|
||||
lwe_compact_public_key,
|
||||
messages,
|
||||
output,
|
||||
&binary_random_vector,
|
||||
&mask_noise,
|
||||
&body_noise,
|
||||
metadata,
|
||||
load,
|
||||
random_generator,
|
||||
@@ -3404,9 +3266,9 @@ where
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::core_crypto::commons::generators::DeterministicSeeder;
|
||||
use crate::core_crypto::commons::test_tools;
|
||||
use crate::core_crypto::prelude::*;
|
||||
use crate::commons::generators::DeterministicSeeder;
|
||||
use crate::commons::test_tools;
|
||||
use crate::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn test_compact_public_key_encryption() {
|
||||
@@ -1,16 +1,12 @@
|
||||
//! Module containing primitives pertaining to [`LWE ciphertext
|
||||
//! keyswitch`](`LweKeyswitchKey#lwe-keyswitch`).
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::core_crypto::commons::math::decomposition::{
|
||||
SignedDecomposer, SignedDecomposerNonNative,
|
||||
};
|
||||
use crate::core_crypto::commons::parameters::{
|
||||
DecompositionBaseLog, DecompositionLevelCount, ThreadCount,
|
||||
};
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::commons::math::decomposition::{SignedDecomposer, SignedDecomposerNonNative};
|
||||
use crate::commons::parameters::{DecompositionBaseLog, DecompositionLevelCount, ThreadCount};
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Keyswitch an [`LWE ciphertext`](`LweCiphertext`) encrypted under an
|
||||
@@ -326,8 +322,8 @@ pub fn keyswitch_lwe_ciphertext_other_mod<Scalar, KSKCont, InputCont, OutputCont
|
||||
/// `input_bits` to a a smaller OutputScalar with `output_bits` and `output_bits` < `input_bits`.
|
||||
///
|
||||
/// The product of the `lwe_keyswitch_key`'s
|
||||
/// [`DecompositionBaseLog`](`crate::core_crypto::commons::parameters::DecompositionBaseLog`) and
|
||||
/// [`DecompositionLevelCount`](`crate::core_crypto::commons::parameters::DecompositionLevelCount`)
|
||||
/// [`DecompositionBaseLog`](`crate::commons::parameters::DecompositionBaseLog`) and
|
||||
/// [`DecompositionLevelCount`](`crate::commons::parameters::DecompositionLevelCount`)
|
||||
/// needs to be smaller than `output_bits`.
|
||||
pub fn keyswitch_lwe_ciphertext_with_scalar_change<
|
||||
InputScalar,
|
||||
@@ -2,15 +2,15 @@
|
||||
//! generation`](`LweKeyswitchKey#key-switching-key`) and [`seeded LWE keyswitch keys
|
||||
//! generation`](`SeededLweKeyswitchKey`).
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::decomposition::{
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::decomposition::{
|
||||
DecompositionLevel, DecompositionTerm, DecompositionTermNonNative,
|
||||
};
|
||||
use crate::core_crypto::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Fill an [`LWE keyswitch key`](`LweKeyswitchKey`) with an actual keyswitching key constructed
|
||||
/// from an input and an output key [`LWE secret key`](`LweSecretKey`).
|
||||
@@ -1,10 +1,10 @@
|
||||
//! Module containing primitives pertaining to [`LWE ciphertext`](`LweCiphertext`) linear algebra,
|
||||
//! like addition, multiplication, etc.
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Add the right-hand side [`LWE ciphertext`](`LweCiphertext`) to the left-hand side [`LWE
|
||||
/// ciphertext`](`LweCiphertext`) updating it in-place.
|
||||
@@ -2,19 +2,17 @@
|
||||
//! [`standard LWE multi_bit bootstrap keys`](`LweMultiBitBootstrapKey`) to various
|
||||
//! representations/numerical domains like the Fourier domain.
|
||||
|
||||
use crate::core_crypto::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::{
|
||||
par_convert_polynomials_list_to_fourier, Fft, FftView,
|
||||
};
|
||||
use crate::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use crate::fft_impl::fft64::math::fft::{par_convert_polynomials_list_to_fourier, Fft, FftView};
|
||||
use dyn_stack::{PodStack, ReborrowMut, SizeOverflow, StackReq};
|
||||
use tfhe_fft::c64;
|
||||
|
||||
/// Convert an [`LWE multi_bit bootstrap key`](`LweMultiBitBootstrapKey`) with standard
|
||||
/// coefficients to the Fourier domain.
|
||||
///
|
||||
/// See [`multi_bit_programmable_bootstrap_lwe_ciphertext`](`crate::core_crypto::algorithms::multi_bit_programmable_bootstrap_lwe_ciphertext`) for usage.
|
||||
/// See [`multi_bit_programmable_bootstrap_lwe_ciphertext`](`crate::algorithms::multi_bit_programmable_bootstrap_lwe_ciphertext`) for usage.
|
||||
pub fn convert_standard_lwe_multi_bit_bootstrap_key_to_fourier<Scalar, InputCont, OutputCont>(
|
||||
input_bsk: &LweMultiBitBootstrapKey<InputCont>,
|
||||
output_bsk: &mut FourierLweMultiBitBootstrapKey<OutputCont>,
|
||||
@@ -1,12 +1,12 @@
|
||||
//! Module containing primitives pertaining to the generation of
|
||||
//! [`standard LWE multi_bit bootstrap keys`](`LweMultiBitBootstrapKey`).
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// ```rust
|
||||
@@ -1,16 +1,16 @@
|
||||
use crate::core_crypto::algorithms::extract_lwe_sample_from_glwe_ciphertext;
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::*;
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::core_crypto::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::common::modulus_switch;
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::ggsw::{
|
||||
use crate::algorithms::extract_lwe_sample_from_glwe_ciphertext;
|
||||
use crate::algorithms::polynomial_algorithms::*;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use crate::fft_impl::common::modulus_switch;
|
||||
use crate::fft_impl::fft64::crypto::ggsw::{
|
||||
add_external_product_assign, add_external_product_assign_scratch, update_with_fmadd_factor,
|
||||
};
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::{Fft, FftView};
|
||||
use crate::fft_impl::fft64::math::fft::{Fft, FftView};
|
||||
use aligned_vec::ABox;
|
||||
use itertools::Itertools;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
@@ -1,13 +1,11 @@
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::polynomial_wrapping_monic_monomial_mul_assign;
|
||||
use crate::core_crypto::algorithms::slice_algorithms::{
|
||||
use crate::algorithms::polynomial_algorithms::polynomial_wrapping_monic_monomial_mul_assign;
|
||||
use crate::algorithms::slice_algorithms::{
|
||||
slice_wrapping_add_assign, slice_wrapping_sub_scalar_mul_assign,
|
||||
};
|
||||
use crate::core_crypto::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::{
|
||||
GlweCiphertext, LweCiphertext, LweCiphertextList, LwePackingKeyswitchKey,
|
||||
};
|
||||
use crate::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::{GlweCiphertext, LweCiphertext, LweCiphertextList, LwePackingKeyswitchKey};
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Apply a keyswitch on an input [`LWE ciphertext`](`LweCiphertext`) and
|
||||
@@ -2,15 +2,15 @@
|
||||
//! generation`](`LwePackingKeyswitchKey`) and [`seeded LWE packing keyswitch keys
|
||||
//! generation`](`SeededLwePackingKeyswitchKey`).
|
||||
|
||||
use crate::core_crypto::algorithms::{
|
||||
use crate::algorithms::{
|
||||
encrypt_glwe_ciphertext_list, encrypt_seeded_glwe_ciphertext_list_with_existing_generator,
|
||||
};
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::decomposition::{DecompositionLevel, DecompositionTerm};
|
||||
use crate::core_crypto::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::{
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::decomposition::{DecompositionLevel, DecompositionTerm};
|
||||
use crate::commons::math::random::{ActivatedRandomGenerator, Distribution, Uniform};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::{
|
||||
GlweSecretKey, LwePackingKeyswitchKey, LwePackingKeyswitchKeyOwned, LweSecretKey,
|
||||
PlaintextListOwned, SeededLwePackingKeyswitchKey, SeededLwePackingKeyswitchKeyOwned,
|
||||
};
|
||||
@@ -7,12 +7,12 @@
|
||||
//! J. Cryptol 33, 34–91 (2020). \
|
||||
//! <https://doi.org/10.1007/s00145-019-09319-x>
|
||||
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::*;
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::polynomial_algorithms::*;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Apply a private functional keyswitch on an input [`LWE ciphertext`](`LweCiphertext`) and write
|
||||
@@ -1,14 +1,14 @@
|
||||
//! Module containing primitives pertaining to [`LWE private functional packing keyswitch key
|
||||
//! generation`](`LwePrivateFunctionalPackingKeyswitchKey`).
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::decomposition::{DecompositionLevel, DecompositionTerm};
|
||||
use crate::core_crypto::commons::math::random::{Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::decomposition::{DecompositionLevel, DecompositionTerm};
|
||||
use crate::commons::math::random::{Distribution, Uniform};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Fill an [`LWE private functional packing keyswitch
|
||||
@@ -249,9 +249,9 @@ pub fn par_generate_lwe_private_functional_packing_keyswitch_key<
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::core_crypto::commons::generators::DeterministicSeeder;
|
||||
use crate::core_crypto::commons::math::random::Seed;
|
||||
use crate::core_crypto::prelude::*;
|
||||
use crate::commons::generators::DeterministicSeeder;
|
||||
use crate::commons::math::random::Seed;
|
||||
use crate::prelude::*;
|
||||
|
||||
const NB_TESTS: usize = 10;
|
||||
|
||||
@@ -261,19 +261,17 @@ mod test {
|
||||
// DISCLAIMER: these toy example parameters are not guaranteed to be secure or yield
|
||||
// correct computations
|
||||
let glwe_dimension =
|
||||
GlweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
let polynomial_size = PolynomialSize(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(5..10),
|
||||
);
|
||||
let pfpksk_level_count = DecompositionLevelCount(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let pfpksk_base_log = DecompositionBaseLog(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
GlweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let polynomial_size =
|
||||
PolynomialSize(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let pfpksk_level_count =
|
||||
DecompositionLevelCount(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let pfpksk_base_log =
|
||||
DecompositionBaseLog(crate::commons::test_tools::random_usize_between(2..5));
|
||||
|
||||
let common_encryption_seed =
|
||||
Seed(crate::core_crypto::commons::test_tools::random_uint_between(0..u128::MAX));
|
||||
let common_encryption_seed = Seed(crate::commons::test_tools::random_uint_between(
|
||||
0..u128::MAX,
|
||||
));
|
||||
|
||||
let var_small = Variance::from_variance(2f64.powf(-80.0));
|
||||
let gaussian_small = Gaussian::from_dispersion_parameter(var_small, 0.0);
|
||||
@@ -1,13 +1,13 @@
|
||||
//! Module containing primitives pertaining to the [`LWE programmable
|
||||
//! bootstrap`](`crate::core_crypto::entities::LweBootstrapKey#programmable-bootstrapping`) using
|
||||
//! bootstrap`](`crate::entities::LweBootstrapKey#programmable-bootstrapping`) using
|
||||
//! 128 bits FFT for polynomial multiplication.
|
||||
|
||||
use crate::core_crypto::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::fft128::crypto::bootstrap::bootstrap_scratch as bootstrap_scratch_f128;
|
||||
use crate::core_crypto::fft_impl::fft128::math::fft::{Fft128, Fft128View};
|
||||
use crate::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use crate::fft_impl::fft128::crypto::bootstrap::bootstrap_scratch as bootstrap_scratch_f128;
|
||||
use crate::fft_impl::fft128::math::fft::{Fft128, Fft128View};
|
||||
use dyn_stack::{PodStack, SizeOverflow, StackReq};
|
||||
|
||||
/// Perform a programmable bootstrap given an input [`LWE ciphertext`](`LweCiphertext`), a
|
||||
@@ -1,21 +1,21 @@
|
||||
//! Module containing primitives pertaining to the [`LWE programmable
|
||||
//! bootstrap`](`crate::core_crypto::entities::LweBootstrapKey#programmable-bootstrapping`) using 64
|
||||
//! bootstrap`](`crate::entities::LweBootstrapKey#programmable-bootstrapping`) using 64
|
||||
//! bits FFT for polynomial multiplication.
|
||||
|
||||
use crate::core_crypto::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::core_crypto::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::bootstrap::{
|
||||
use crate::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::commons::math::decomposition::SignedDecomposer;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use crate::fft_impl::fft64::crypto::bootstrap::{
|
||||
batch_bootstrap_scratch, blind_rotate_assign_scratch, bootstrap_scratch,
|
||||
};
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::ggsw::{
|
||||
use crate::fft_impl::fft64::crypto::ggsw::{
|
||||
add_external_product_assign as impl_add_external_product_assign,
|
||||
add_external_product_assign_scratch as impl_add_external_product_assign_scratch, cmux,
|
||||
cmux_scratch,
|
||||
};
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::{Fft, FftView};
|
||||
use crate::fft_impl::fft64::math::fft::{Fft, FftView};
|
||||
use dyn_stack::{PodStack, SizeOverflow, StackReq};
|
||||
use tfhe_fft::c64;
|
||||
|
||||
@@ -6,10 +6,10 @@ pub use fft128::*;
|
||||
pub use fft64::*;
|
||||
pub use ntt64::*;
|
||||
|
||||
use crate::core_crypto::algorithms::glwe_encryption::allocate_and_trivially_encrypt_new_glwe_ciphertext;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::glwe_encryption::allocate_and_trivially_encrypt_new_glwe_ciphertext;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Helper function to generate an accumulator for a PBS
|
||||
///
|
||||
@@ -1,22 +1,22 @@
|
||||
//! Module containing primitives pertaining to the [`LWE programmable
|
||||
//! bootstrap`](`crate::core_crypto::entities::LweBootstrapKey#programmable-bootstrapping`) using 64
|
||||
//! bootstrap`](`crate::entities::LweBootstrapKey#programmable-bootstrapping`) using 64
|
||||
//! bits NTT for polynomial multiplication.
|
||||
|
||||
use crate::core_crypto::algorithms::glwe_sample_extraction::extract_lwe_sample_from_glwe_ciphertext;
|
||||
use crate::core_crypto::algorithms::misc::divide_round;
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::{
|
||||
use crate::algorithms::glwe_sample_extraction::extract_lwe_sample_from_glwe_ciphertext;
|
||||
use crate::algorithms::misc::divide_round;
|
||||
use crate::algorithms::polynomial_algorithms::{
|
||||
polynomial_wrapping_monic_monomial_div_assign_custom_mod,
|
||||
polynomial_wrapping_monic_monomial_mul_assign_custom_mod,
|
||||
};
|
||||
use crate::core_crypto::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::core_crypto::commons::math::decomposition::{
|
||||
use crate::commons::computation_buffers::ComputationBuffers;
|
||||
use crate::commons::math::decomposition::{
|
||||
SignedDecomposerNonNative, TensorSignedDecompositionLendingIterNonNative,
|
||||
};
|
||||
use crate::core_crypto::commons::math::ntt::ntt64::{Ntt64, Ntt64View};
|
||||
use crate::core_crypto::commons::parameters::{GlweSize, MonomialDegree, PolynomialSize};
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::commons::utils::izip;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::commons::math::ntt::ntt64::{Ntt64, Ntt64View};
|
||||
use crate::commons::parameters::{GlweSize, MonomialDegree, PolynomialSize};
|
||||
use crate::commons::traits::*;
|
||||
use crate::commons::utils::izip;
|
||||
use crate::entities::*;
|
||||
use aligned_vec::CACHELINE_ALIGN;
|
||||
use dyn_stack::{PodStack, ReborrowMut, SizeOverflow, StackReq};
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
//! generation`](`LwePublicKey#lwe-public-key`) and [`seeded LWE public key
|
||||
//! generation`](`SeededLwePublicKey#lwe-public-key`).
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::{CompressionSeed, Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::random::{CompressionSeed, Distribution, Uniform};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Fill an [`LWE public key`](`LwePublicKey`) with an actual public key constructed from a private
|
||||
/// [`LWE secret key`](`LweSecretKey`).
|
||||
@@ -1,11 +1,11 @@
|
||||
//! Module containing primitives pertaining to the generation of
|
||||
//! [`LWE secret keys`](`LweSecretKey`).
|
||||
|
||||
use crate::core_crypto::commons::generators::SecretRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::{RandomGenerable, UniformBinary};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::commons::generators::SecretRandomGenerator;
|
||||
use crate::commons::math::random::{RandomGenerable, UniformBinary};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Allocate a new [`LWE secret key`](`LweSecretKey`) and fill it with uniformly random binary
|
||||
/// coefficients.
|
||||
@@ -1,16 +1,16 @@
|
||||
//! Module containing primitives pertaining to the Wopbs (WithOut padding PBS).
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::{Distribution, Uniform};
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::fft_impl::fft64::crypto::wop_pbs::{
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::EncryptionRandomGenerator;
|
||||
use crate::commons::math::random::{Distribution, Uniform};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use crate::fft_impl::fft64::crypto::wop_pbs::{
|
||||
circuit_bootstrap_boolean_vertical_packing, circuit_bootstrap_boolean_vertical_packing_scratch,
|
||||
extract_bits, extract_bits_scratch,
|
||||
};
|
||||
use crate::core_crypto::fft_impl::fft64::math::fft::FftView;
|
||||
use crate::fft_impl::fft64::math::fft::FftView;
|
||||
use dyn_stack::{PodStack, SizeOverflow, StackReq};
|
||||
use rayon::prelude::*;
|
||||
use tfhe_fft::c64;
|
||||
@@ -0,0 +1,48 @@
|
||||
use crate::entities::{LweCompactCiphertextList, LweCompactPublicKey};
|
||||
use crate::prelude::{CastFrom, Container, LweCiphertext, LweCiphertextCount, UnsignedInteger};
|
||||
use crate::zk::{CompactPkeCrs, CompactPkeProof, ZkVerificationOutcome};
|
||||
|
||||
/// Verifies with the given proof that a [`LweCompactCiphertextList`]
|
||||
/// is valid.
|
||||
pub fn verify_lwe_compact_ciphertext_list<Scalar, ListCont, KeyCont>(
|
||||
lwe_compact_list: &LweCompactCiphertextList<ListCont>,
|
||||
compact_public_key: &LweCompactPublicKey<KeyCont>,
|
||||
proof: &CompactPkeProof,
|
||||
crs: &CompactPkeCrs,
|
||||
metadata: &[u8],
|
||||
) -> ZkVerificationOutcome
|
||||
where
|
||||
Scalar: UnsignedInteger,
|
||||
i64: CastFrom<Scalar>,
|
||||
ListCont: Container<Element = Scalar>,
|
||||
KeyCont: Container<Element = Scalar>,
|
||||
{
|
||||
crs.verify(lwe_compact_list, compact_public_key, proof, metadata)
|
||||
}
|
||||
|
||||
/// Verifies with the given proof that a single [`LweCiphertext`] is valid.
|
||||
pub fn verify_lwe_ciphertext<Scalar, Cont, KeyCont>(
|
||||
lwe_ciphertext: &LweCiphertext<Cont>,
|
||||
compact_public_key: &LweCompactPublicKey<KeyCont>,
|
||||
proof: &CompactPkeProof,
|
||||
crs: &CompactPkeCrs,
|
||||
metadata: &[u8],
|
||||
) -> ZkVerificationOutcome
|
||||
where
|
||||
Scalar: UnsignedInteger,
|
||||
i64: CastFrom<Scalar>,
|
||||
Cont: Container<Element = Scalar>,
|
||||
KeyCont: Container<Element = Scalar>,
|
||||
{
|
||||
crs.verify(
|
||||
&LweCompactCiphertextList::from_container(
|
||||
lwe_ciphertext.as_ref(),
|
||||
lwe_ciphertext.lwe_size(),
|
||||
LweCiphertextCount(1),
|
||||
lwe_ciphertext.ciphertext_modulus(),
|
||||
),
|
||||
compact_public_key,
|
||||
proof,
|
||||
metadata,
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Miscellaneous algorithms.
|
||||
|
||||
use crate::core_crypto::prelude::*;
|
||||
use crate::prelude::*;
|
||||
|
||||
#[inline]
|
||||
pub fn divide_round<Scalar: UnsignedInteger>(numerator: Scalar, denominator: Scalar) -> Scalar {
|
||||
@@ -49,7 +49,7 @@ pub mod slice_algorithms;
|
||||
pub(crate) mod test;
|
||||
|
||||
// No pub use for slice and polynomial algorithms which would not interest higher level users
|
||||
// They can still be used via `use crate::core_crypto::algorithms::slice_algorithms::*;`
|
||||
// They can still be used via `use crate::algorithms::slice_algorithms::*;`
|
||||
pub use ggsw_conversion::*;
|
||||
pub use ggsw_encryption::*;
|
||||
pub use glwe_encryption::*;
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module providing algorithms to perform computations on polynomials modulo $X^{N} + 1$.
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::*;
|
||||
use crate::core_crypto::commons::parameters::MonomialDegree;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::*;
|
||||
use crate::commons::parameters::MonomialDegree;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Add a polynomial to the output polynomial.
|
||||
///
|
||||
@@ -1247,9 +1247,9 @@ fn induction_karatsuba_custom_mod<Scalar>(
|
||||
mod test {
|
||||
use rand::Rng;
|
||||
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::*;
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::commons::test_tools::*;
|
||||
use crate::algorithms::polynomial_algorithms::*;
|
||||
use crate::commons::parameters::*;
|
||||
use crate::commons::test_tools::*;
|
||||
|
||||
fn test_multiply_divide_unit_monomial<T: UnsignedTorus>() {
|
||||
//! tests if multiply_by_monomial and divide_by_monomial cancel each other
|
||||
@@ -1,10 +1,10 @@
|
||||
//! Module with primitives pertaining to [`SeededGgswCiphertext`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::Uniform;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::math::random::Uniform;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
@@ -1,10 +1,10 @@
|
||||
//! Module with primitives pertaining to [`SeededGgswCiphertextList`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::Uniform;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::math::random::Uniform;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module with primitives pertaining to [`SeededGlweCiphertext`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::slice_wrapping_scalar_mul_assign;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::slice_wrapping_scalar_mul_assign;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
/// [`SeededGlweCiphertext`] between all functions needing it.
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module with primitives pertaining to [`SeededGlweCiphertextList`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::slice_wrapping_scalar_mul_assign;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::slice_wrapping_scalar_mul_assign;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
/// [`SeededGlweCiphertextList`] between all functions needing it.
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module with primitives pertaining to [`SeededLweBootstrapKey`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
/// [`SeededLweBootstrapKey`] between all functions needing it.
|
||||
@@ -1,10 +1,10 @@
|
||||
//! Module with primitives pertaining to [`SeededLweCiphertext`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::slice_wrapping_scalar_mul_assign;
|
||||
use crate::core_crypto::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::slice_wrapping_scalar_mul_assign;
|
||||
use crate::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
/// [`SeededLweCiphertext`] between all functions needing it.
|
||||
@@ -1,11 +1,11 @@
|
||||
//! Module with primitives pertaining to [`SeededLweCiphertextList`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::slice_algorithms::slice_wrapping_scalar_mul_assign;
|
||||
use crate::core_crypto::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::Uniform;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::slice_algorithms::slice_wrapping_scalar_mul_assign;
|
||||
use crate::commons::ciphertext_modulus::CiphertextModulusKind;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::math::random::Uniform;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module with primitives pertaining to [`SeededLweCompactPublicKey`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
/// [`SeededLweCompactPublicKey`] between all functions needing it.
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module with primitives pertaining to [`SeededLweKeyswitchKey`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
/// [`SeededLweKeyswitchKey`] between all functions needing it.
|
||||
@@ -1,10 +1,10 @@
|
||||
//! Module with primitives pertaining to [`SeededLweMultiBitBootstrapKey`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::math::random::Uniform;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::math::random::Uniform;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
use rayon::prelude::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module with primitives pertaining to [`SeededLwePackingKeyswitchKey`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Convenience function to share the core logic of the decompression algorithm for
|
||||
/// [`SeededLwePackingKeyswitchKey`] between all functions needing it.
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Module with primitives pertaining to [`SeededLwePublicKey`] decompression.
|
||||
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::generators::MaskRandomGenerator;
|
||||
use crate::core_crypto::commons::traits::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::generators::MaskRandomGenerator;
|
||||
use crate::commons::traits::*;
|
||||
use crate::entities::*;
|
||||
|
||||
/// Decompress a [`SeededLwePublicKey`], without consuming it, into a standard
|
||||
/// [`LwePublicKey`].
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Module providing algorithms to perform computations on raw slices.
|
||||
|
||||
use crate::core_crypto::algorithms::polynomial_algorithms::polynomial_wrapping_add_mul_assign;
|
||||
use crate::core_crypto::commons::numeric::UnsignedInteger;
|
||||
use crate::core_crypto::entities::Polynomial;
|
||||
use crate::algorithms::polynomial_algorithms::polynomial_wrapping_add_mul_assign;
|
||||
use crate::commons::numeric::UnsignedInteger;
|
||||
use crate::entities::Polynomial;
|
||||
|
||||
/// Compute a dot product between two slices containing unsigned integers.
|
||||
///
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::commons::generators::DeterministicSeeder;
|
||||
use crate::core_crypto::commons::math::random::CompressionSeed;
|
||||
use crate::core_crypto::commons::test_tools;
|
||||
use crate::commons::generators::DeterministicSeeder;
|
||||
use crate::commons::math::random::CompressionSeed;
|
||||
use crate::commons::test_tools;
|
||||
|
||||
#[cfg(not(tarpaulin))]
|
||||
const NB_TESTS: usize = 10;
|
||||
@@ -1,16 +1,14 @@
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::dispersion::StandardDev;
|
||||
use crate::core_crypto::commons::generators::{DeterministicSeeder, EncryptionRandomGenerator};
|
||||
use crate::core_crypto::commons::math::random::{
|
||||
ActivatedRandomGenerator, DynamicDistribution, Seed,
|
||||
};
|
||||
use crate::core_crypto::commons::math::torus::UnsignedTorus;
|
||||
use crate::core_crypto::commons::parameters::{
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::dispersion::StandardDev;
|
||||
use crate::commons::generators::{DeterministicSeeder, EncryptionRandomGenerator};
|
||||
use crate::commons::math::random::{ActivatedRandomGenerator, DynamicDistribution, Seed};
|
||||
use crate::commons::math::torus::UnsignedTorus;
|
||||
use crate::commons::parameters::{
|
||||
CiphertextModulus, DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension,
|
||||
PolynomialSize,
|
||||
};
|
||||
use crate::core_crypto::commons::test_tools::new_secret_random_generator;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::commons::test_tools::new_secret_random_generator;
|
||||
use crate::entities::*;
|
||||
|
||||
#[cfg(not(tarpaulin))]
|
||||
const NB_TESTS: usize = 10;
|
||||
@@ -21,21 +19,13 @@ fn test_parallel_and_seeded_bsk_gen_equivalence<T: UnsignedTorus + Sync + Send>(
|
||||
ciphertext_modulus: CiphertextModulus<T>,
|
||||
) {
|
||||
for _ in 0..NB_TESTS {
|
||||
let lwe_dim =
|
||||
LweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
let glwe_dim =
|
||||
GlweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
let poly_size =
|
||||
PolynomialSize(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
let level = DecompositionLevelCount(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let base_log = DecompositionBaseLog(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let mask_seed = Seed(crate::core_crypto::commons::test_tools::any_usize() as u128);
|
||||
let deterministic_seeder_seed =
|
||||
Seed(crate::core_crypto::commons::test_tools::any_usize() as u128);
|
||||
let lwe_dim = LweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let glwe_dim = GlweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let poly_size = PolynomialSize(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let level = DecompositionLevelCount(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let base_log = DecompositionBaseLog(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let mask_seed = Seed(crate::commons::test_tools::any_usize() as u128);
|
||||
let deterministic_seeder_seed = Seed(crate::commons::test_tools::any_usize() as u128);
|
||||
|
||||
let noise_distribution =
|
||||
DynamicDistribution::new_gaussian_from_std_dev(StandardDev::from_standard_dev(10.));
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::commons::generators::DeterministicSeeder;
|
||||
use crate::commons::generators::DeterministicSeeder;
|
||||
|
||||
#[cfg(not(tarpaulin))]
|
||||
const NB_TESTS: usize = 10;
|
||||
@@ -1,8 +1,8 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::commons::generators::DeterministicSeeder;
|
||||
use crate::commons::generators::DeterministicSeeder;
|
||||
#[cfg(feature = "zk-pok")]
|
||||
use crate::core_crypto::commons::math::random::RandomGenerator;
|
||||
use crate::core_crypto::commons::test_tools;
|
||||
use crate::commons::math::random::RandomGenerator;
|
||||
use crate::commons::test_tools;
|
||||
#[cfg(feature = "zk-pok")]
|
||||
use rand::Rng;
|
||||
|
||||
@@ -1022,7 +1022,8 @@ fn lwe_compact_public_encrypt_prove_verify_decrypt_custom_mod<Scalar>(
|
||||
let mut msg = msg_modulus;
|
||||
let delta: Scalar = encoding_with_padding / msg_modulus;
|
||||
|
||||
let crs = CompactPkeCrs::new(
|
||||
// Test zk scheme v1 and v2
|
||||
let crs_v2 = CompactPkeCrs::new(
|
||||
lwe_dimension,
|
||||
1,
|
||||
glwe_noise_distribution,
|
||||
@@ -1033,68 +1034,81 @@ fn lwe_compact_public_encrypt_prove_verify_decrypt_custom_mod<Scalar>(
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
while msg != Scalar::ZERO {
|
||||
msg = msg.wrapping_sub(Scalar::ONE);
|
||||
for _ in 0..NB_TESTS {
|
||||
let lwe_sk = allocate_and_generate_new_binary_lwe_secret_key(
|
||||
lwe_dimension,
|
||||
&mut rsc.secret_random_generator,
|
||||
);
|
||||
let crs_v1 = CompactPkeCrs::new_legacy_v1(
|
||||
lwe_dimension,
|
||||
1,
|
||||
glwe_noise_distribution,
|
||||
ciphertext_modulus,
|
||||
msg_modulus * Scalar::TWO,
|
||||
ZkMSBZeroPaddingBitCount(1),
|
||||
&mut random_generator,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let pk = allocate_and_generate_new_lwe_compact_public_key(
|
||||
&lwe_sk,
|
||||
glwe_noise_distribution,
|
||||
ciphertext_modulus,
|
||||
&mut rsc.encryption_random_generator,
|
||||
);
|
||||
for crs in [&crs_v2, &crs_v1] {
|
||||
while msg != Scalar::ZERO {
|
||||
msg = msg.wrapping_sub(Scalar::ONE);
|
||||
for _ in 0..NB_TESTS {
|
||||
let lwe_sk = allocate_and_generate_new_binary_lwe_secret_key(
|
||||
lwe_dimension,
|
||||
&mut rsc.secret_random_generator,
|
||||
);
|
||||
|
||||
let mut ct = LweCiphertext::new(
|
||||
Scalar::ZERO,
|
||||
lwe_dimension.to_lwe_size(),
|
||||
ciphertext_modulus,
|
||||
);
|
||||
let pk = allocate_and_generate_new_lwe_compact_public_key(
|
||||
&lwe_sk,
|
||||
glwe_noise_distribution,
|
||||
ciphertext_modulus,
|
||||
&mut rsc.encryption_random_generator,
|
||||
);
|
||||
|
||||
let proof = encrypt_and_prove_lwe_ciphertext_with_compact_public_key(
|
||||
&pk,
|
||||
&mut ct,
|
||||
Cleartext(msg),
|
||||
delta,
|
||||
glwe_noise_distribution,
|
||||
glwe_noise_distribution,
|
||||
&mut rsc.secret_random_generator,
|
||||
&mut rsc.encryption_random_generator,
|
||||
&mut random_generator,
|
||||
&crs,
|
||||
&metadata,
|
||||
ZkComputeLoad::Proof,
|
||||
)
|
||||
.unwrap();
|
||||
let mut ct = LweCiphertext::new(
|
||||
Scalar::ZERO,
|
||||
lwe_dimension.to_lwe_size(),
|
||||
ciphertext_modulus,
|
||||
);
|
||||
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&ct,
|
||||
ciphertext_modulus,
|
||||
));
|
||||
let proof = encrypt_and_prove_lwe_ciphertext_with_compact_public_key(
|
||||
&pk,
|
||||
&mut ct,
|
||||
Cleartext(msg),
|
||||
delta,
|
||||
glwe_noise_distribution,
|
||||
glwe_noise_distribution,
|
||||
&mut rsc.secret_random_generator,
|
||||
&mut rsc.encryption_random_generator,
|
||||
&mut random_generator,
|
||||
crs,
|
||||
&metadata,
|
||||
ZkComputeLoad::Proof,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let decrypted = decrypt_lwe_ciphertext(&lwe_sk, &ct);
|
||||
assert!(check_encrypted_content_respects_mod(
|
||||
&ct,
|
||||
ciphertext_modulus,
|
||||
));
|
||||
|
||||
let decoded = round_decode(decrypted.0, delta) % msg_modulus;
|
||||
let decrypted = decrypt_lwe_ciphertext(&lwe_sk, &ct);
|
||||
|
||||
assert_eq!(msg, decoded);
|
||||
let decoded = round_decode(decrypted.0, delta) % msg_modulus;
|
||||
|
||||
// Verify the proof
|
||||
assert!(verify_lwe_ciphertext(&ct, &pk, &proof, &crs, &metadata).is_valid());
|
||||
assert_eq!(msg, decoded);
|
||||
|
||||
// verify proof with invalid ciphertext
|
||||
let index = random_generator.gen::<usize>() % ct.as_ref().len();
|
||||
let value_to_add = random_generator.gen::<Scalar>();
|
||||
ct.as_mut()[index] = ct.as_mut()[index].wrapping_add(value_to_add);
|
||||
assert!(verify_lwe_ciphertext(&ct, &pk, &proof, &crs, &metadata).is_invalid());
|
||||
// Verify the proof
|
||||
assert!(verify_lwe_ciphertext(&ct, &pk, &proof, crs, &metadata).is_valid());
|
||||
|
||||
// verify proof with invalid ciphertext
|
||||
let index = random_generator.gen::<usize>() % ct.as_ref().len();
|
||||
let value_to_add = random_generator.gen::<Scalar>();
|
||||
ct.as_mut()[index] = ct.as_mut()[index].wrapping_add(value_to_add);
|
||||
assert!(verify_lwe_ciphertext(&ct, &pk, &proof, crs, &metadata).is_invalid());
|
||||
}
|
||||
|
||||
// In coverage, we break after one while loop iteration, changing message values does
|
||||
// not yield higher coverage
|
||||
#[cfg(tarpaulin)]
|
||||
break;
|
||||
}
|
||||
|
||||
// In coverage, we break after one while loop iteration, changing message values does not
|
||||
// yield higher coverage
|
||||
#[cfg(tarpaulin)]
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::commons::generators::DeterministicSeeder;
|
||||
use crate::commons::generators::DeterministicSeeder;
|
||||
|
||||
#[cfg(not(tarpaulin))]
|
||||
const NB_TESTS: usize = 10;
|
||||
@@ -1,17 +1,15 @@
|
||||
use crate::core_crypto::algorithms::*;
|
||||
use crate::core_crypto::commons::dispersion::StandardDev;
|
||||
use crate::core_crypto::commons::generators::{DeterministicSeeder, EncryptionRandomGenerator};
|
||||
use crate::core_crypto::commons::math::random::{
|
||||
ActivatedRandomGenerator, DynamicDistribution, Seed,
|
||||
};
|
||||
use crate::core_crypto::commons::math::torus::UnsignedTorus;
|
||||
use crate::core_crypto::commons::parameters::{
|
||||
use crate::algorithms::*;
|
||||
use crate::commons::dispersion::StandardDev;
|
||||
use crate::commons::generators::{DeterministicSeeder, EncryptionRandomGenerator};
|
||||
use crate::commons::math::random::{ActivatedRandomGenerator, DynamicDistribution, Seed};
|
||||
use crate::commons::math::torus::UnsignedTorus;
|
||||
use crate::commons::parameters::{
|
||||
CiphertextModulus, DecompositionBaseLog, DecompositionLevelCount, GlweDimension,
|
||||
LweBskGroupingFactor, LweDimension, PolynomialSize,
|
||||
};
|
||||
use crate::core_crypto::commons::test_tools::new_secret_random_generator;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::prelude::CastFrom;
|
||||
use crate::commons::test_tools::new_secret_random_generator;
|
||||
use crate::entities::*;
|
||||
use crate::prelude::CastFrom;
|
||||
|
||||
#[cfg(not(tarpaulin))]
|
||||
const NB_TESTS: usize = 10;
|
||||
@@ -24,24 +22,15 @@ fn test_parallel_and_seeded_multi_bit_bsk_gen_equivalence<
|
||||
ciphertext_modulus: CiphertextModulus<T>,
|
||||
) {
|
||||
for _ in 0..NB_TESTS {
|
||||
let mut lwe_dim =
|
||||
LweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
let glwe_dim =
|
||||
GlweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
let poly_size =
|
||||
PolynomialSize(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
let level = DecompositionLevelCount(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let base_log = DecompositionBaseLog(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let grouping_factor = LweBskGroupingFactor(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..4),
|
||||
);
|
||||
let mask_seed = Seed(crate::core_crypto::commons::test_tools::any_usize() as u128);
|
||||
let deterministic_seeder_seed =
|
||||
Seed(crate::core_crypto::commons::test_tools::any_usize() as u128);
|
||||
let mut lwe_dim = LweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let glwe_dim = GlweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let poly_size = PolynomialSize(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let level = DecompositionLevelCount(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let base_log = DecompositionBaseLog(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let grouping_factor =
|
||||
LweBskGroupingFactor(crate::commons::test_tools::random_usize_between(2..4));
|
||||
let mask_seed = Seed(crate::commons::test_tools::any_usize() as u128);
|
||||
let deterministic_seeder_seed = Seed(crate::commons::test_tools::any_usize() as u128);
|
||||
|
||||
let noise_distribution =
|
||||
DynamicDistribution::new_gaussian_from_std_dev(StandardDev::from_standard_dev(10.));
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::commons::generators::DeterministicSeeder;
|
||||
use crate::commons::generators::DeterministicSeeder;
|
||||
|
||||
#[cfg(not(tarpaulin))]
|
||||
const NB_TESTS: usize = 10;
|
||||
@@ -100,20 +100,17 @@ fn test_parallel_pfpks_equivalence<Scalar: UnsignedTorus + Send + Sync>(
|
||||
// Small sizes
|
||||
{
|
||||
for _ in 0..NB_TESTS {
|
||||
let decomp_base_log = DecompositionBaseLog(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let decomp_level_count = DecompositionLevelCount(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let decomp_base_log =
|
||||
DecompositionBaseLog(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let decomp_level_count =
|
||||
DecompositionLevelCount(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let input_key_lwe_dimension =
|
||||
LweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
LweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let output_glwe_dimension =
|
||||
GlweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
GlweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let output_glwe_size = output_glwe_dimension.to_glwe_size();
|
||||
let output_polynomial_size = PolynomialSize(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(5..10),
|
||||
);
|
||||
let output_polynomial_size =
|
||||
PolynomialSize(crate::commons::test_tools::random_usize_between(5..10));
|
||||
// ~ 2^-20
|
||||
let noise_distribution = DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
|
||||
0.0000006791658447437413,
|
||||
@@ -305,20 +302,17 @@ fn test_parallel_pfpks_lwe_list_equivalence<Scalar: UnsignedTorus + Send + Sync>
|
||||
// Small sizes
|
||||
{
|
||||
for _ in 0..NB_TESTS {
|
||||
let decomp_base_log = DecompositionBaseLog(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let decomp_level_count = DecompositionLevelCount(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(2..5),
|
||||
);
|
||||
let decomp_base_log =
|
||||
DecompositionBaseLog(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let decomp_level_count =
|
||||
DecompositionLevelCount(crate::commons::test_tools::random_usize_between(2..5));
|
||||
let input_key_lwe_dimension =
|
||||
LweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
LweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let output_glwe_dimension =
|
||||
GlweDimension(crate::core_crypto::commons::test_tools::random_usize_between(5..10));
|
||||
GlweDimension(crate::commons::test_tools::random_usize_between(5..10));
|
||||
let output_glwe_size = output_glwe_dimension.to_glwe_size();
|
||||
let output_polynomial_size = PolynomialSize(
|
||||
crate::core_crypto::commons::test_tools::random_usize_between(5..10),
|
||||
);
|
||||
let output_polynomial_size =
|
||||
PolynomialSize(crate::commons::test_tools::random_usize_between(5..10));
|
||||
// ~ 2^-20
|
||||
let noise_distribution = DynamicDistribution::new_gaussian_from_std_dev(StandardDev(
|
||||
0.0000006791658447437413,
|
||||
@@ -756,7 +756,7 @@ fn lwe_encrypt_pbs_ntt64_decrypt_custom_mod(params: ClassicTestParams<u64>) {
|
||||
ciphertext_modulus
|
||||
));
|
||||
|
||||
use crate::core_crypto::commons::math::ntt::ntt64::Ntt64;
|
||||
use crate::commons::math::ntt::ntt64::Ntt64;
|
||||
|
||||
let mut nbsk = NttLweBootstrapKeyOwned::new(
|
||||
0u64,
|
||||
@@ -2,9 +2,9 @@ pub mod params;
|
||||
pub(crate) use params::*;
|
||||
|
||||
pub(crate) use super::misc::check_encrypted_content_respects_mod;
|
||||
pub(crate) use crate::core_crypto::algorithms::misc::divide_round;
|
||||
pub(crate) use crate::core_crypto::keycache::KeyCacheAccess;
|
||||
pub(crate) use crate::core_crypto::prelude::*;
|
||||
pub(crate) use crate::algorithms::misc::divide_round;
|
||||
pub(crate) use crate::keycache::core::KeyCacheAccess;
|
||||
pub(crate) use crate::prelude::*;
|
||||
pub(crate) use std::fmt::Debug;
|
||||
|
||||
mod ggsw_encryption;
|
||||
@@ -452,7 +452,7 @@ pub(crate) fn gen_keys_or_get_from_cache_if_enabled<
|
||||
) -> K {
|
||||
#[cfg(feature = "internal-keycache")]
|
||||
{
|
||||
crate::core_crypto::keycache::KEY_CACHE.get_key_with_closure(params, keygen_func)
|
||||
crate::keycache::core::KEY_CACHE.get_key_with_closure(params, keygen_func)
|
||||
}
|
||||
#[cfg(not(feature = "internal-keycache"))]
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::fft_impl::common::modulus_switch;
|
||||
use crate::fft_impl::common::modulus_switch;
|
||||
use itertools::Itertools;
|
||||
|
||||
#[cfg(not(tarpaulin))]
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::algorithms::misc::check_clear_content_respects_mod;
|
||||
use crate::core_crypto::commons::test_tools::{
|
||||
use crate::algorithms::misc::check_clear_content_respects_mod;
|
||||
use crate::commons::test_tools::{
|
||||
modular_distance, modular_distance_custom_mod, torus_modular_diff, variance,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::commons::noise_formulas::lwe_keyswitch::keyswitch_additive_variance_132_bits_security_gaussian;
|
||||
use crate::core_crypto::commons::noise_formulas::secure_noise::minimal_lwe_variance_for_132_bits_security_gaussian;
|
||||
use crate::core_crypto::commons::test_tools::{torus_modular_diff, variance};
|
||||
use crate::commons::noise_formulas::lwe_keyswitch::keyswitch_additive_variance_132_bits_security_gaussian;
|
||||
use crate::commons::noise_formulas::secure_noise::minimal_lwe_variance_for_132_bits_security_gaussian;
|
||||
use crate::commons::test_tools::{torus_modular_diff, variance};
|
||||
use rayon::prelude::*;
|
||||
|
||||
// This is 1 / 16 which is exactly representable in an f64 (even an f32)
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::*;
|
||||
use crate::core_crypto::commons::noise_formulas::lwe_programmable_bootstrap::pbs_variance_132_bits_security_gaussian;
|
||||
use crate::core_crypto::commons::noise_formulas::secure_noise::minimal_lwe_variance_for_132_bits_security_gaussian;
|
||||
use crate::core_crypto::commons::test_tools::{torus_modular_diff, variance};
|
||||
use crate::commons::noise_formulas::lwe_programmable_bootstrap::pbs_variance_132_bits_security_gaussian;
|
||||
use crate::commons::noise_formulas::secure_noise::minimal_lwe_variance_for_132_bits_security_gaussian;
|
||||
use crate::commons::test_tools::{torus_modular_diff, variance};
|
||||
use rayon::prelude::*;
|
||||
|
||||
// This is 1 / 16 which is exactly representable in an f64 (even an f32)
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::core_crypto::entities::*;
|
||||
use crate::core_crypto::prelude::{CastFrom, CastInto, UnsignedInteger};
|
||||
use crate::commons::parameters::*;
|
||||
use crate::entities::*;
|
||||
use crate::keycache::NamedParam;
|
||||
use crate::prelude::{CastFrom, CastInto, UnsignedInteger};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::commons::ciphertext_modulus::SerializableCiphertextModulus;
|
||||
use crate::commons::ciphertext_modulus::SerializableCiphertextModulus;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum SerializableCiphertextModulusVersions {
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::core_crypto::commons::dispersion::StandardDev;
|
||||
use crate::commons::dispersion::StandardDev;
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
@@ -1,7 +1,7 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::commons::math::random::*;
|
||||
use crate::core_crypto::prelude::{FloatingPoint, UnsignedInteger};
|
||||
use crate::commons::math::random::*;
|
||||
use crate::prelude::{FloatingPoint, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum TUniformVersions<T: UnsignedInteger> {
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::commons::parameters::*;
|
||||
use crate::commons::parameters::*;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum PlaintextCountVersions {
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Cleartext, Numeric};
|
||||
use crate::prelude::{Cleartext, Numeric};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CleartextVersions<T: Numeric> {
|
||||
@@ -1,7 +1,7 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::compressed_modulus_switched_glwe_ciphertext::CompressedModulusSwitchedGlweCiphertext;
|
||||
use crate::core_crypto::prelude::UnsignedInteger;
|
||||
use crate::prelude::compressed_modulus_switched_glwe_ciphertext::CompressedModulusSwitchedGlweCiphertext;
|
||||
use crate::prelude::UnsignedInteger;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum CompressedModulusSwitchedGlweCiphertextVersions<Scalar: UnsignedInteger> {
|
||||
@@ -2,11 +2,9 @@ use std::convert::Infallible;
|
||||
|
||||
use tfhe_versionable::{Upgrade, Version, VersionsDispatch};
|
||||
|
||||
use crate::core_crypto::prelude::compressed_modulus_switched_lwe_ciphertext::CompressedModulusSwitchedLweCiphertext;
|
||||
use crate::core_crypto::prelude::packed_integers::PackedIntegers;
|
||||
use crate::core_crypto::prelude::{
|
||||
CiphertextModulus, CiphertextModulusLog, LweDimension, UnsignedInteger,
|
||||
};
|
||||
use crate::prelude::compressed_modulus_switched_lwe_ciphertext::CompressedModulusSwitchedLweCiphertext;
|
||||
use crate::prelude::packed_integers::PackedIntegers;
|
||||
use crate::prelude::{CiphertextModulus, CiphertextModulusLog, LweDimension, UnsignedInteger};
|
||||
|
||||
#[derive(Version)]
|
||||
pub struct CompressedModulusSwitchedLweCiphertextV0<Scalar: UnsignedInteger> {
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{
|
||||
use crate::prelude::{
|
||||
CastFrom, CastInto, CompressedModulusSwitchedMultiBitLweCiphertext, UnsignedInteger,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use tfhe_versionable::deprecation::{Deprecable, Deprecated};
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, GgswCiphertext, UnsignedInteger};
|
||||
use crate::prelude::{Container, GgswCiphertext, UnsignedInteger};
|
||||
|
||||
impl<C: Container> Deprecable for GgswCiphertext<C>
|
||||
where
|
||||
@@ -1,7 +1,7 @@
|
||||
use tfhe_versionable::deprecation::{Deprecable, Deprecated};
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, GgswCiphertextList, UnsignedInteger};
|
||||
use crate::prelude::{Container, GgswCiphertextList, UnsignedInteger};
|
||||
|
||||
impl<C: Container> Deprecable for GgswCiphertextList<C>
|
||||
where
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, GlweCiphertext, UnsignedInteger};
|
||||
use crate::prelude::{Container, GlweCiphertext, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum GlweCiphertextVersions<C: Container>
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, GlweCiphertextList, UnsignedInteger};
|
||||
use crate::prelude::{Container, GlweCiphertextList, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum GlweCiphertextListVersions<C: Container>
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, GlweSecretKey};
|
||||
use crate::prelude::{Container, GlweSecretKey};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum GlweSecretKeyVersions<C: Container> {
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, GswCiphertext};
|
||||
use crate::prelude::{Container, GswCiphertext};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum GswCiphertextVersions<C: Container> {
|
||||
@@ -1,7 +1,7 @@
|
||||
use tfhe_versionable::deprecation::{Deprecable, Deprecated};
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, LweBootstrapKey, UnsignedInteger};
|
||||
use crate::prelude::{Container, LweBootstrapKey, UnsignedInteger};
|
||||
|
||||
impl<C: Container> Deprecable for LweBootstrapKey<C>
|
||||
where
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, LweCiphertext, UnsignedInteger};
|
||||
use crate::prelude::{Container, LweCiphertext, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum LweCiphertextVersions<C: Container>
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, LweCiphertextList, UnsignedInteger};
|
||||
use crate::prelude::{Container, LweCiphertextList, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum LweCiphertextListVersions<C: Container>
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, LweCompactCiphertextList, UnsignedInteger};
|
||||
use crate::prelude::{Container, LweCompactCiphertextList, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum LweCompactCiphertextListVersions<C: Container>
|
||||
@@ -1,6 +1,6 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, LweCompactPublicKey, UnsignedInteger};
|
||||
use crate::prelude::{Container, LweCompactPublicKey, UnsignedInteger};
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum LweCompactPublicKeyVersions<C: Container>
|
||||
@@ -1,7 +1,7 @@
|
||||
use tfhe_versionable::deprecation::{Deprecable, Deprecated};
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, LweKeyswitchKey, UnsignedInteger};
|
||||
use crate::prelude::{Container, LweKeyswitchKey, UnsignedInteger};
|
||||
|
||||
impl<C: Container> Deprecable for LweKeyswitchKey<C>
|
||||
where
|
||||
@@ -2,7 +2,7 @@ use tfhe_fft::c64;
|
||||
use tfhe_versionable::deprecation::{Deprecable, Deprecated};
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{
|
||||
use crate::prelude::{
|
||||
Container, FourierLweMultiBitBootstrapKey, LweMultiBitBootstrapKey, UnsignedInteger,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use tfhe_versionable::deprecation::{Deprecable, Deprecated};
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{Container, LwePackingKeyswitchKey, UnsignedInteger};
|
||||
use crate::prelude::{Container, LwePackingKeyswitchKey, UnsignedInteger};
|
||||
|
||||
impl<C: Container> Deprecable for LwePackingKeyswitchKey<C>
|
||||
where
|
||||
@@ -1,9 +1,7 @@
|
||||
use tfhe_versionable::deprecation::{Deprecable, Deprecated};
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{
|
||||
Container, LwePrivateFunctionalPackingKeyswitchKey, UnsignedInteger,
|
||||
};
|
||||
use crate::prelude::{Container, LwePrivateFunctionalPackingKeyswitchKey, UnsignedInteger};
|
||||
|
||||
impl<C: Container> Deprecable for LwePrivateFunctionalPackingKeyswitchKey<C>
|
||||
where
|
||||
@@ -1,9 +1,7 @@
|
||||
use tfhe_versionable::deprecation::{Deprecable, Deprecated};
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::core_crypto::prelude::{
|
||||
Container, LwePrivateFunctionalPackingKeyswitchKeyList, UnsignedInteger,
|
||||
};
|
||||
use crate::prelude::{Container, LwePrivateFunctionalPackingKeyswitchKeyList, UnsignedInteger};
|
||||
|
||||
impl<C: Container> Deprecable for LwePrivateFunctionalPackingKeyswitchKeyList<C>
|
||||
where
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user