mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-06 21:34:05 -05:00
feat: add 2^-128 parameters
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -32,5 +32,8 @@ web-test-runner/
|
||||
node_modules/
|
||||
package-lock.json
|
||||
|
||||
# Python .env
|
||||
.env
|
||||
|
||||
# Dir used for backward compatibility test data
|
||||
tests/tfhe-backward-compat-data/
|
||||
|
||||
31
Makefile
31
Makefile
@@ -363,7 +363,18 @@ clippy_rustdoc: install_rs_check_toolchain
|
||||
fi && \
|
||||
CLIPPYFLAGS="-D warnings" RUSTDOCFLAGS="--no-run --nocapture --test-builder ./scripts/clippy_driver.sh -Z unstable-options" \
|
||||
cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" test --doc \
|
||||
--features=boolean,shortint,integer,zk-pok,pbs-stats,strings \
|
||||
--features=boolean,shortint,integer,zk-pok,pbs-stats,strings,experimental \
|
||||
-p $(TFHE_SPEC)
|
||||
|
||||
.PHONY: clippy_rustdoc_gpu # Run clippy lints on doctests enabling the boolean, shortint, integer and zk-pok
|
||||
clippy_rustdoc_gpu: install_rs_check_toolchain
|
||||
if [[ "$(OS)" != "Linux" ]]; then \
|
||||
echo "WARNING: skipped clippy_rustdoc_gpu, unsupported OS $(OS)"; \
|
||||
exit 0; \
|
||||
fi && \
|
||||
CLIPPYFLAGS="-D warnings" RUSTDOCFLAGS="--no-run --nocapture --test-builder ./scripts/clippy_driver.sh -Z unstable-options" \
|
||||
cargo "$(CARGO_RS_CHECK_TOOLCHAIN)" test --doc \
|
||||
--features=boolean,shortint,integer,zk-pok,pbs-stats,strings,experimental,gpu \
|
||||
-p $(TFHE_SPEC)
|
||||
|
||||
.PHONY: clippy_c_api # Run clippy lints enabling the boolean, shortint and the C API
|
||||
@@ -956,6 +967,10 @@ check_intra_md_links: install_mlc
|
||||
check_md_links: install_mlc
|
||||
mlc --match-file-extension tfhe/docs
|
||||
|
||||
.PHONY: check_parameter_export_ok # Checks exported "current" shortint parameter module is correct
|
||||
check_parameter_export_ok:
|
||||
python3 ./scripts/check_current_param_export.py
|
||||
|
||||
.PHONY: check_compile_tests # Build tests in debug without running them
|
||||
check_compile_tests: install_rs_build_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_BUILD_TOOLCHAIN) test --no-run \
|
||||
@@ -1281,7 +1296,7 @@ parse_wasm_benchmarks: install_rs_check_toolchain
|
||||
|
||||
.PHONY: write_params_to_file # Gather all crypto parameters into a file with a Sage readable format.
|
||||
write_params_to_file: install_rs_check_toolchain
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run --profile $(CARGO_PROFILE) \
|
||||
RUSTFLAGS="$(RUSTFLAGS)" cargo $(CARGO_RS_CHECK_TOOLCHAIN) run \
|
||||
--example write_params_to_file --features=boolean,shortint,internal-keycache
|
||||
|
||||
.PHONY: clone_backward_compat_data # Clone the data repo needed for backward compatibility tests
|
||||
@@ -1313,15 +1328,17 @@ sha256_bool: install_rs_check_toolchain
|
||||
--example sha256_bool --features=boolean
|
||||
|
||||
.PHONY: pcc # pcc stands for pre commit checks (except GPU)
|
||||
pcc: no_tfhe_typo no_dbg_log check_fmt check_typos lint_doc check_md_docs_are_tested check_intra_md_links \
|
||||
clippy_all check_compile_tests test_tfhe_lints tfhe_lints
|
||||
pcc: no_tfhe_typo no_dbg_log check_parameter_export_ok check_fmt check_typos lint_doc \
|
||||
check_md_docs_are_tested check_intra_md_links clippy_all check_compile_tests test_tfhe_lints \
|
||||
tfhe_lints
|
||||
|
||||
.PHONY: pcc_gpu # pcc stands for pre commit checks for GPU compilation
|
||||
pcc_gpu: clippy_gpu clippy_cuda_backend check_compile_tests_benches_gpu check_rust_bindings_did_not_change
|
||||
pcc_gpu: check_rust_bindings_did_not_change clippy_rustdoc_gpu \
|
||||
clippy_gpu clippy_cuda_backend check_compile_tests_benches_gpu
|
||||
|
||||
.PHONY: fpcc # pcc stands for pre commit checks, the f stands for fast
|
||||
fpcc: no_tfhe_typo no_dbg_log check_fmt check_typos lint_doc check_md_docs_are_tested clippy_fast \
|
||||
check_compile_tests
|
||||
fpcc: no_tfhe_typo no_dbg_log check_parameter_export_ok check_fmt check_typos lint_doc \
|
||||
check_md_docs_are_tested clippy_fast check_compile_tests
|
||||
|
||||
.PHONY: conformance # Automatically fix problems that can be fixed
|
||||
conformance: fix_newline fmt fmt_js
|
||||
|
||||
@@ -18,102 +18,102 @@ use tfhe::prelude::*;
|
||||
use tfhe_trivium::TriviumStream;
|
||||
|
||||
fn get_hexadecimal_string_from_lsb_first_stream(a: Vec<bool>) -> String {
|
||||
assert!(a.len() % 8 == 0);
|
||||
let mut hexadecimal: String = "".to_string();
|
||||
for test in a.chunks(8) {
|
||||
// Encoding is bytes in LSB order
|
||||
match test[4..8] {
|
||||
[false, false, false, false] => hexadecimal.push('0'),
|
||||
[true, false, false, false] => hexadecimal.push('1'),
|
||||
[false, true, false, false] => hexadecimal.push('2'),
|
||||
[true, true, false, false] => hexadecimal.push('3'),
|
||||
assert!(a.len() % 8 == 0);
|
||||
let mut hexadecimal: String = "".to_string();
|
||||
for test in a.chunks(8) {
|
||||
// Encoding is bytes in LSB order
|
||||
match test[4..8] {
|
||||
[false, false, false, false] => hexadecimal.push('0'),
|
||||
[true, false, false, false] => hexadecimal.push('1'),
|
||||
[false, true, false, false] => hexadecimal.push('2'),
|
||||
[true, true, false, false] => hexadecimal.push('3'),
|
||||
|
||||
[false, false, true, false] => hexadecimal.push('4'),
|
||||
[true, false, true, false] => hexadecimal.push('5'),
|
||||
[false, true, true, false] => hexadecimal.push('6'),
|
||||
[true, true, true, false] => hexadecimal.push('7'),
|
||||
[false, false, true, false] => hexadecimal.push('4'),
|
||||
[true, false, true, false] => hexadecimal.push('5'),
|
||||
[false, true, true, false] => hexadecimal.push('6'),
|
||||
[true, true, true, false] => hexadecimal.push('7'),
|
||||
|
||||
[false, false, false, true] => hexadecimal.push('8'),
|
||||
[true, false, false, true] => hexadecimal.push('9'),
|
||||
[false, true, false, true] => hexadecimal.push('A'),
|
||||
[true, true, false, true] => hexadecimal.push('B'),
|
||||
[false, false, false, true] => hexadecimal.push('8'),
|
||||
[true, false, false, true] => hexadecimal.push('9'),
|
||||
[false, true, false, true] => hexadecimal.push('A'),
|
||||
[true, true, false, true] => hexadecimal.push('B'),
|
||||
|
||||
[false, false, true, true] => hexadecimal.push('C'),
|
||||
[true, false, true, true] => hexadecimal.push('D'),
|
||||
[false, true, true, true] => hexadecimal.push('E'),
|
||||
[true, true, true, true] => hexadecimal.push('F'),
|
||||
_ => ()
|
||||
};
|
||||
match test[0..4] {
|
||||
[false, false, false, false] => hexadecimal.push('0'),
|
||||
[true, false, false, false] => hexadecimal.push('1'),
|
||||
[false, true, false, false] => hexadecimal.push('2'),
|
||||
[true, true, false, false] => hexadecimal.push('3'),
|
||||
[false, false, true, true] => hexadecimal.push('C'),
|
||||
[true, false, true, true] => hexadecimal.push('D'),
|
||||
[false, true, true, true] => hexadecimal.push('E'),
|
||||
[true, true, true, true] => hexadecimal.push('F'),
|
||||
_ => ()
|
||||
};
|
||||
match test[0..4] {
|
||||
[false, false, false, false] => hexadecimal.push('0'),
|
||||
[true, false, false, false] => hexadecimal.push('1'),
|
||||
[false, true, false, false] => hexadecimal.push('2'),
|
||||
[true, true, false, false] => hexadecimal.push('3'),
|
||||
|
||||
[false, false, true, false] => hexadecimal.push('4'),
|
||||
[true, false, true, false] => hexadecimal.push('5'),
|
||||
[false, true, true, false] => hexadecimal.push('6'),
|
||||
[true, true, true, false] => hexadecimal.push('7'),
|
||||
[false, false, true, false] => hexadecimal.push('4'),
|
||||
[true, false, true, false] => hexadecimal.push('5'),
|
||||
[false, true, true, false] => hexadecimal.push('6'),
|
||||
[true, true, true, false] => hexadecimal.push('7'),
|
||||
|
||||
[false, false, false, true] => hexadecimal.push('8'),
|
||||
[true, false, false, true] => hexadecimal.push('9'),
|
||||
[false, true, false, true] => hexadecimal.push('A'),
|
||||
[true, true, false, true] => hexadecimal.push('B'),
|
||||
[false, false, false, true] => hexadecimal.push('8'),
|
||||
[true, false, false, true] => hexadecimal.push('9'),
|
||||
[false, true, false, true] => hexadecimal.push('A'),
|
||||
[true, true, false, true] => hexadecimal.push('B'),
|
||||
|
||||
[false, false, true, true] => hexadecimal.push('C'),
|
||||
[true, false, true, true] => hexadecimal.push('D'),
|
||||
[false, true, true, true] => hexadecimal.push('E'),
|
||||
[true, true, true, true] => hexadecimal.push('F'),
|
||||
_ => ()
|
||||
};
|
||||
}
|
||||
return hexadecimal;
|
||||
[false, false, true, true] => hexadecimal.push('C'),
|
||||
[true, false, true, true] => hexadecimal.push('D'),
|
||||
[false, true, true, true] => hexadecimal.push('E'),
|
||||
[true, true, true, true] => hexadecimal.push('F'),
|
||||
_ => ()
|
||||
};
|
||||
}
|
||||
return hexadecimal;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
let config = ConfigBuilder::default().build();
|
||||
let (client_key, server_key) = generate_keys(config);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
let mut key = [false; 80];
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
let mut key = [false; 80];
|
||||
|
||||
for i in (0..key_string.len()).step_by(2) {
|
||||
let mut val: u8 = u8::from_str_radix(&key_string[i..i+2], 16).unwrap();
|
||||
for j in 0..8 {
|
||||
key[8*(i>>1) + j] = val % 2 == 1;
|
||||
val >>= 1;
|
||||
}
|
||||
}
|
||||
for i in (0..key_string.len()).step_by(2) {
|
||||
let mut val: u8 = u8::from_str_radix(&key_string[i..i+2], 16).unwrap();
|
||||
for j in 0..8 {
|
||||
key[8*(i>>1) + j] = val % 2 == 1;
|
||||
val >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
let iv_string = "0D74DB42A91077DE45AC".to_string();
|
||||
let mut iv = [false; 80];
|
||||
let iv_string = "0D74DB42A91077DE45AC".to_string();
|
||||
let mut iv = [false; 80];
|
||||
|
||||
for i in (0..iv_string.len()).step_by(2) {
|
||||
let mut val: u8 = u8::from_str_radix(&iv_string[i..i+2], 16).unwrap();
|
||||
for j in 0..8 {
|
||||
iv[8*(i>>1) + j] = val % 2 == 1;
|
||||
val >>= 1;
|
||||
}
|
||||
}
|
||||
for i in (0..iv_string.len()).step_by(2) {
|
||||
let mut val: u8 = u8::from_str_radix(&iv_string[i..i+2], 16).unwrap();
|
||||
for j in 0..8 {
|
||||
iv[8*(i>>1) + j] = val % 2 == 1;
|
||||
val >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
let output_0_63 = "F4CD954A717F26A7D6930830C4E7CF0819F80E03F25F342C64ADC66ABA7F8A8E6EAA49F23632AE3CD41A7BD290A0132F81C6D4043B6E397D7388F3A03B5FE358".to_string();
|
||||
let output_0_63 = "F4CD954A717F26A7D6930830C4E7CF0819F80E03F25F342C64ADC66ABA7F8A8E6EAA49F23632AE3CD41A7BD290A0132F81C6D4043B6E397D7388F3A03B5FE358".to_string();
|
||||
|
||||
let cipher_key = key.map(|x| FheBool::encrypt(x, &client_key));
|
||||
let cipher_iv = iv.map(|x| FheBool::encrypt(x, &client_key));
|
||||
let cipher_key = key.map(|x| FheBool::encrypt(x, &client_key));
|
||||
let cipher_iv = iv.map(|x| FheBool::encrypt(x, &client_key));
|
||||
|
||||
|
||||
let mut trivium = TriviumStream::<FheBool>::new(cipher_key, cipher_iv, &server_key);
|
||||
let mut trivium = TriviumStream::<FheBool>::new(cipher_key, cipher_iv, &server_key);
|
||||
|
||||
let mut vec = Vec::<bool>::with_capacity(64*8);
|
||||
while vec.len() < 64*8 {
|
||||
let cipher_outputs = trivium.next_64();
|
||||
for c in cipher_outputs {
|
||||
vec.push(c.decrypt(&client_key))
|
||||
}
|
||||
}
|
||||
let mut vec = Vec::<bool>::with_capacity(64*8);
|
||||
while vec.len() < 64*8 {
|
||||
let cipher_outputs = trivium.next_64();
|
||||
for c in cipher_outputs {
|
||||
vec.push(c.decrypt(&client_key))
|
||||
}
|
||||
}
|
||||
|
||||
let hexadecimal = get_hexadecimal_string_from_lsb_first_stream(vec);
|
||||
assert_eq!(output_0_63, hexadecimal[0..64*2]);
|
||||
let hexadecimal = get_hexadecimal_string_from_lsb_first_stream(vec);
|
||||
assert_eq!(output_0_63, hexadecimal[0..64*2]);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -129,7 +129,7 @@ Other sizes than 64 bit are expected to be available in the future.
|
||||
|
||||
# FHE shortint Trivium implementation
|
||||
|
||||
The same implementation is also available for generic Ciphertexts representing bits (meant to be used with parameters `V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64`).
|
||||
The same implementation is also available for generic Ciphertexts representing bits (meant to be used with parameters `V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128`).
|
||||
It uses a lower level API of tfhe-rs, so the syntax is a little bit different. It also implements the `TransCiphering` trait. For optimization purposes, it does not internally run
|
||||
on the same cryptographic parameters as the high level API of tfhe-rs. As such, it requires the usage of a casting key, to switch from one parameter space to another, which makes
|
||||
its setup a little more intricate.
|
||||
@@ -137,67 +137,68 @@ its setup a little more intricate.
|
||||
Example code:
|
||||
```rust
|
||||
use tfhe::shortint::prelude::*;
|
||||
use tfhe::shortint::parameters::{
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
use tfhe::shortint::parameters::v1_0::{
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
};
|
||||
use tfhe::{ConfigBuilder, generate_keys, FheUint64};
|
||||
use tfhe::prelude::*;
|
||||
use tfhe_trivium::TriviumStreamShortint;
|
||||
|
||||
fn test_shortint() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) = gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
let (client_key, server_key): (ClientKey, ServerKey) = gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
let mut key = [0; 80];
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
let mut key = [0; 80];
|
||||
|
||||
for i in (0..key_string.len()).step_by(2) {
|
||||
let mut val = u64::from_str_radix(&key_string[i..i+2], 16).unwrap();
|
||||
for j in 0..8 {
|
||||
key[8*(i>>1) + j] = val % 2;
|
||||
val >>= 1;
|
||||
}
|
||||
}
|
||||
for i in (0..key_string.len()).step_by(2) {
|
||||
let mut val = u64::from_str_radix(&key_string[i..i+2], 16).unwrap();
|
||||
for j in 0..8 {
|
||||
key[8*(i>>1) + j] = val % 2;
|
||||
val >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
let iv_string = "0D74DB42A91077DE45AC".to_string();
|
||||
let mut iv = [0; 80];
|
||||
let iv_string = "0D74DB42A91077DE45AC".to_string();
|
||||
let mut iv = [0; 80];
|
||||
|
||||
for i in (0..iv_string.len()).step_by(2) {
|
||||
let mut val = u64::from_str_radix(&iv_string[i..i+2], 16).unwrap();
|
||||
for j in 0..8 {
|
||||
iv[8*(i>>1) + j] = val % 2;
|
||||
val >>= 1;
|
||||
}
|
||||
}
|
||||
let output_0_63 = "F4CD954A717F26A7D6930830C4E7CF0819F80E03F25F342C64ADC66ABA7F8A8E6EAA49F23632AE3CD41A7BD290A0132F81C6D4043B6E397D7388F3A03B5FE358".to_string();
|
||||
for i in (0..iv_string.len()).step_by(2) {
|
||||
let mut val = u64::from_str_radix(&iv_string[i..i+2], 16).unwrap();
|
||||
for j in 0..8 {
|
||||
iv[8*(i>>1) + j] = val % 2;
|
||||
val >>= 1;
|
||||
}
|
||||
}
|
||||
let output_0_63 = "F4CD954A717F26A7D6930830C4E7CF0819F80E03F25F342C64ADC66ABA7F8A8E6EAA49F23632AE3CD41A7BD290A0132F81C6D4043B6E397D7388F3A03B5FE358".to_string();
|
||||
|
||||
let cipher_key = key.map(|x| client_key.encrypt(x));
|
||||
let cipher_iv = iv.map(|x| client_key.encrypt(x));
|
||||
let cipher_key = key.map(|x| client_key.encrypt(x));
|
||||
let cipher_iv = iv.map(|x| client_key.encrypt(x));
|
||||
|
||||
let mut ciphered_message = vec![FheUint64::try_encrypt(0u64, &hl_client_key).unwrap(); 9];
|
||||
let mut ciphered_message = vec![FheUint64::try_encrypt(0u64, &hl_client_key).unwrap(); 9];
|
||||
|
||||
let mut trivium = TriviumStreamShortint::new(cipher_key, cipher_iv, &server_key, &ksk);
|
||||
let mut trivium = TriviumStreamShortint::new(cipher_key, cipher_iv, &server_key, &ksk);
|
||||
|
||||
let mut vec = Vec::<u64>::with_capacity(8);
|
||||
while vec.len() < 8 {
|
||||
let trans_ciphered_message = trivium.trans_encrypt_64(ciphered_message.pop().unwrap(), &hl_server_key);
|
||||
vec.push(trans_ciphered_message.decrypt(&hl_client_key));
|
||||
}
|
||||
let mut vec = Vec::<u64>::with_capacity(8);
|
||||
while vec.len() < 8 {
|
||||
let trans_ciphered_message = trivium.trans_encrypt_64(ciphered_message.pop().unwrap(), &hl_server_key);
|
||||
vec.push(trans_ciphered_message.decrypt(&hl_client_key));
|
||||
}
|
||||
|
||||
let hexadecimal = get_hexagonal_string_from_u64(vec);
|
||||
assert_eq!(output_0_63, hexadecimal[0..64*2]);
|
||||
let hexadecimal = get_hexagonal_string_from_u64(vec);
|
||||
assert_eq!(output_0_63, hexadecimal[0..64*2]);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use criterion::Criterion;
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::shortint::parameters::{
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
use tfhe::shortint::parameters::v1_0::{
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
};
|
||||
use tfhe::shortint::prelude::*;
|
||||
use tfhe::{generate_keys, ConfigBuilder, FheUint64};
|
||||
@@ -10,19 +11,19 @@ use tfhe_trivium::{KreyviumStreamShortint, TransCiphering};
|
||||
|
||||
pub fn kreyvium_shortint_warmup(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
|
||||
@@ -63,19 +64,19 @@ pub fn kreyvium_shortint_warmup(c: &mut Criterion) {
|
||||
|
||||
pub fn kreyvium_shortint_gen(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
|
||||
@@ -111,19 +112,19 @@ pub fn kreyvium_shortint_gen(c: &mut Criterion) {
|
||||
|
||||
pub fn kreyvium_shortint_trans(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use criterion::Criterion;
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::shortint::parameters::{
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
use tfhe::shortint::parameters::v1_0::{
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
};
|
||||
use tfhe::shortint::prelude::*;
|
||||
use tfhe::{generate_keys, ConfigBuilder, FheUint64};
|
||||
@@ -10,19 +11,19 @@ use tfhe_trivium::{TransCiphering, TriviumStreamShortint};
|
||||
|
||||
pub fn trivium_shortint_warmup(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
@@ -63,19 +64,19 @@ pub fn trivium_shortint_warmup(c: &mut Criterion) {
|
||||
|
||||
pub fn trivium_shortint_gen(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
@@ -111,19 +112,19 @@ pub fn trivium_shortint_gen(c: &mut Criterion) {
|
||||
|
||||
pub fn trivium_shortint_trans(c: &mut Criterion) {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use crate::{KreyviumStream, KreyviumStreamByte, KreyviumStreamShortint, TransCiphering};
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::shortint::parameters::{
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
use tfhe::shortint::parameters::v1_0::{
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
};
|
||||
use tfhe::{generate_keys, ConfigBuilder, FheBool, FheUint64, FheUint8};
|
||||
// Values for these tests come from the github repo renaud1239/Kreyvium,
|
||||
@@ -220,19 +221,19 @@ use tfhe::shortint::prelude::*;
|
||||
#[test]
|
||||
fn kreyvium_test_shortint_long() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB000000000000".to_string();
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use crate::{TransCiphering, TriviumStream, TriviumStreamByte, TriviumStreamShortint};
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::shortint::parameters::{
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
use tfhe::shortint::parameters::v1_0::{
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
};
|
||||
use tfhe::{generate_keys, ConfigBuilder, FheBool, FheUint64, FheUint8};
|
||||
// Values for these tests come from the github repo cantora/avr-crypto-lib, commit 2a5b018,
|
||||
@@ -356,19 +357,19 @@ use tfhe::shortint::prelude::*;
|
||||
#[test]
|
||||
fn trivium_test_shortint_long() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (hl_client_key, hl_server_key) = generate_keys(config);
|
||||
let underlying_ck: tfhe::shortint::ClientKey = (*hl_client_key.as_ref()).clone().into();
|
||||
let underlying_sk: tfhe::shortint::ServerKey = (*hl_server_key.as_ref()).clone().into();
|
||||
|
||||
let (client_key, server_key): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key, Some(&server_key)),
|
||||
(&underlying_ck, &underlying_sk),
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
);
|
||||
|
||||
let key_string = "0053A6F94C9FF24598EB".to_string();
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import tomllib
|
||||
try:
|
||||
import tomllib # Python v3.11+
|
||||
except ModuleNotFoundError:
|
||||
import pip._vendor.tomli as tomllib # the same tomllib that's now included in Python v3.11+
|
||||
|
||||
|
||||
fname = "tests/Cargo.toml"
|
||||
with open(fname, "rb") as f:
|
||||
data = tomllib.load(f)
|
||||
|
||||
dev_dependencies = data.get("dev-dependencies")
|
||||
dev_dependencies = data["dev-dependencies"]
|
||||
|
||||
branch_name = dev_dependencies["tfhe-backward-compat-data"].get("branch")
|
||||
branch_name = dev_dependencies["tfhe-backward-compat-data"]["branch"]
|
||||
|
||||
print(branch_name)
|
||||
|
||||
34
scripts/check_current_param_export.py
Normal file
34
scripts/check_current_param_export.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from utils import get_repo_root, format_version_major_minor, get_tfhe_version
|
||||
|
||||
|
||||
def main():
|
||||
repo_root = get_repo_root()
|
||||
tfhe_current_version = format_version_major_minor(get_tfhe_version())
|
||||
shortint_param_file = repo_root / "tfhe/src/shortint/parameters/mod.rs"
|
||||
|
||||
with open(shortint_param_file, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if "as current_params;" in line:
|
||||
print("Content:", line)
|
||||
expected = f"use {tfhe_current_version} as current_params;"
|
||||
print("Expected use:", expected)
|
||||
if not line.endswith(expected):
|
||||
print(
|
||||
"Use clause for current parameters does not match current TFHE-rs version"
|
||||
)
|
||||
exit(1)
|
||||
else:
|
||||
print("OK")
|
||||
return
|
||||
print("Did not find import line.")
|
||||
exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
68
scripts/generate_all_vec_for_lattice_estimator.py
Normal file
68
scripts/generate_all_vec_for_lattice_estimator.py
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
from collections import defaultdict
|
||||
from typing import List
|
||||
from utils import get_repo_root, format_version_major_minor, get_tfhe_version
|
||||
|
||||
|
||||
pascal_to_snake = lambda s: re.sub(r"(?<!^)(?=[A-Z])", "_", s).lower()
|
||||
|
||||
|
||||
# Example format
|
||||
# /// All [`ClassicPBSParameters`] in this module.
|
||||
# pub const VEC_ALL_CLASSIC_PARAMETERS: [&ClassicPBSParameters; 1] =
|
||||
# [&V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128];
|
||||
def format_all_param_vec(param_type: str, param_names: List[str]) -> str:
|
||||
joined_params = ",\n ".join(
|
||||
f"""(&{param_name}, "{param_name}")""" for param_name in param_names
|
||||
)
|
||||
let_param_type_for_const = pascal_to_snake(param_type).upper()
|
||||
let_param_type_for_const = let_param_type_for_const.replace("P_B_S", "PBS")
|
||||
return f"""/// All [`{param_type}`] in this module.
|
||||
pub const VEC_ALL_{let_param_type_for_const}: [(&{param_type}, &str); {len(param_names)}] =
|
||||
[
|
||||
{joined_params}
|
||||
];
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
all_vec_params = defaultdict(list)
|
||||
tfhe_rs_version = format_version_major_minor(get_tfhe_version())
|
||||
tfhe_rs_version_capitalized = tfhe_rs_version.upper()
|
||||
params_dir_path = get_repo_root() / f"tfhe/src/shortint/parameters/{tfhe_rs_version}"
|
||||
for p in params_dir_path.rglob("*"):
|
||||
if not p.is_file():
|
||||
continue
|
||||
|
||||
file_content = None
|
||||
with open(p, "r", encoding="utf-8") as f:
|
||||
file_content = f.read()
|
||||
|
||||
matches = re.finditer(
|
||||
f"pub const {tfhe_rs_version_capitalized}([^=]+)", file_content, re.MULTILINE
|
||||
)
|
||||
|
||||
for match in matches:
|
||||
match = match.group(0)
|
||||
match = match.replace("\n", " ")
|
||||
|
||||
(pub_const_param_name, param_type) = match.split(":")
|
||||
pub_const_param_name = pub_const_param_name.strip()
|
||||
param_type = param_type.strip()
|
||||
param_name = pub_const_param_name.rsplit(" ", maxsplit=1)[1]
|
||||
|
||||
# print(param_name, param_type)
|
||||
|
||||
all_vec_params[param_type].append(param_name)
|
||||
|
||||
# print(all_vec_params)
|
||||
|
||||
for param_type, param_names in all_vec_params.items():
|
||||
print(format_all_param_vec(param_type, param_names))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
1
scripts/utils/__init__.py
Normal file
1
scripts/utils/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .utils import *
|
||||
29
scripts/utils/utils.py
Normal file
29
scripts/utils/utils.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
import tomllib # Python v3.11+
|
||||
except ModuleNotFoundError:
|
||||
import pip._vendor.tomli as tomllib # the same tomllib that's now included in Python v3.11+
|
||||
|
||||
|
||||
def get_repo_root() -> Path:
|
||||
current_file = Path(__file__)
|
||||
return current_file.parent.parent.parent
|
||||
|
||||
|
||||
def get_tfhe_version() -> str:
|
||||
repo_root = get_repo_root()
|
||||
tfhe_cargo_toml_file = "tfhe/Cargo.toml"
|
||||
|
||||
with open(repo_root / tfhe_cargo_toml_file, "rb") as f:
|
||||
tfhe_cargo_toml = tomllib.load(f)
|
||||
return tfhe_cargo_toml["package"]["version"]
|
||||
|
||||
|
||||
def format_version_major_minor(version: str) -> str:
|
||||
hyphenated_version = "v" + version.replace(".", "_")
|
||||
|
||||
if hyphenated_version.count("_") == 1:
|
||||
return hyphenated_version
|
||||
else:
|
||||
return hyphenated_version.rsplit("_", maxsplit=1)[0]
|
||||
@@ -7,12 +7,24 @@ use serde::Serialize;
|
||||
use tfhe::boolean::prelude::*;
|
||||
use tfhe::core_crypto::prelude::*;
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::parameters::current_params::{
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
};
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
use tfhe::shortint::parameters::current_params::{
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
use tfhe::shortint::parameters::{
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
#[cfg(feature = "gpu")]
|
||||
use tfhe::shortint::parameters::{
|
||||
@@ -21,44 +33,34 @@ use tfhe::shortint::parameters::{
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
use tfhe::shortint::parameters::{
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
use tfhe::shortint::prelude::*;
|
||||
use tfhe::shortint::{MultiBitPBSParameters, PBSParameters};
|
||||
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
const SHORTINT_BENCH_PARAMS: [ClassicPBSParameters; 5] = [
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
];
|
||||
|
||||
#[cfg(feature = "gpu")]
|
||||
const SHORTINT_BENCH_PARAMS: [ClassicPBSParameters; 4] = [
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
];
|
||||
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
const SHORTINT_MULTI_BIT_BENCH_PARAMS: [MultiBitPBSParameters; 6] = [
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
];
|
||||
|
||||
#[cfg(feature = "gpu")]
|
||||
@@ -112,10 +114,10 @@ fn benchmark_parameters_32bits() -> Vec<(String, CryptoParametersRecord<u32>)> {
|
||||
|
||||
fn benchmark_compression_parameters() -> Vec<(String, CryptoParametersRecord<u64>)> {
|
||||
vec![(
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.name(),
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.name(),
|
||||
(
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.into(),
|
||||
)]
|
||||
|
||||
@@ -11,16 +11,17 @@ use tfhe::boolean::parameters::{
|
||||
use tfhe::core_crypto::commons::math::ntt::ntt64::Ntt64;
|
||||
use tfhe::core_crypto::prelude::*;
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::parameters::current_params::*;
|
||||
use tfhe::shortint::parameters::*;
|
||||
|
||||
const SHORTINT_BENCH_PARAMS_TUNIFORM: [ClassicPBSParameters; 1] =
|
||||
[PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64];
|
||||
[PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128];
|
||||
|
||||
const SHORTINT_BENCH_PARAMS_GAUSSIAN: [ClassicPBSParameters; 4] = [
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
];
|
||||
|
||||
const BOOLEAN_BENCH_PARAMS: [(&str, BooleanParameters); 2] = [
|
||||
@@ -56,18 +57,18 @@ fn benchmark_parameters_32bits() -> Vec<(String, CryptoParametersRecord<u32>)> {
|
||||
fn throughput_benchmark_parameters_64bits() -> Vec<(String, CryptoParametersRecord<u64>)> {
|
||||
let parameters = if cfg!(feature = "gpu") {
|
||||
vec![
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
]
|
||||
};
|
||||
|
||||
@@ -102,12 +103,12 @@ fn multi_bit_benchmark_parameters_64bits(
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
]
|
||||
};
|
||||
|
||||
@@ -831,41 +832,27 @@ mod cuda {
|
||||
};
|
||||
use tfhe::core_crypto::prelude::*;
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::parameters::{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_5_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_6_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_7_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
use tfhe::shortint::parameters::current_params::*;
|
||||
use tfhe::shortint::parameters::*;
|
||||
use tfhe::shortint::{ClassicPBSParameters, PBSParameters};
|
||||
|
||||
const SHORTINT_CUDA_BENCH_PARAMS: [ClassicPBSParameters; 14] = [
|
||||
// TUniform
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// Gaussian
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_5_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_6_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_7_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_6_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_7_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
];
|
||||
|
||||
fn cuda_benchmark_parameters_64bits() -> Vec<(String, CryptoParametersRecord<u64>)> {
|
||||
|
||||
@@ -271,7 +271,7 @@ use tfhe_cuda_backend::cuda_bind::cuda_get_number_of_gpus;
|
||||
|
||||
fn main() {
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
#[cfg(feature = "gpu")]
|
||||
let params = PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS;
|
||||
|
||||
|
||||
@@ -9,8 +9,10 @@ use rayon::prelude::*;
|
||||
use tfhe::integer::ciphertext::CompressedCiphertextListBuilder;
|
||||
use tfhe::integer::{ClientKey, RadixCiphertext};
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::{
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
|
||||
fn cpu_glwe_packing(c: &mut Criterion) {
|
||||
let bench_name = "integer::packing_compression";
|
||||
@@ -19,8 +21,8 @@ fn cpu_glwe_packing(c: &mut Criterion) {
|
||||
.sample_size(15)
|
||||
.measurement_time(std::time::Duration::from_secs(30));
|
||||
|
||||
let param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let comp_param = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let comp_param = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let cks = ClientKey::new(param);
|
||||
|
||||
@@ -154,7 +156,7 @@ mod cuda {
|
||||
use tfhe::integer::gpu::ciphertext::compressed_ciphertext_list::CudaCompressedCiphertextListBuilder;
|
||||
use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
use tfhe::shortint::parameters::V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::current_params::*;
|
||||
|
||||
fn gpu_glwe_packing(c: &mut Criterion) {
|
||||
let bench_name = "integer::cuda::packing_compression";
|
||||
@@ -166,7 +168,7 @@ mod cuda {
|
||||
let stream = CudaStreams::new_multi_gpu();
|
||||
|
||||
let param = V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let comp_param = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let comp_param = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let log_message_modulus = param.message_modulus.0.ilog2() as usize;
|
||||
|
||||
|
||||
@@ -13,16 +13,8 @@ use tfhe::integer::key_switching_key::KeySwitchingKey;
|
||||
use tfhe::integer::parameters::IntegerCompactCiphertextListExpansionMode;
|
||||
use tfhe::integer::{ClientKey, CompactPrivateKey, CompactPublicKey, ServerKey};
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::parameters::classic::tuniform::p_fail_2_minus_64::ks_pbs::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::{
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1,
|
||||
};
|
||||
use tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::{
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1,
|
||||
};
|
||||
use tfhe::shortint::parameters::PBSParameters;
|
||||
use tfhe::shortint::parameters::current_params::*;
|
||||
use tfhe::shortint::parameters::*;
|
||||
use tfhe::zk::{CompactPkeCrs, ZkComputeLoad};
|
||||
use utilities::{write_to_json, OperatorType};
|
||||
|
||||
@@ -41,14 +33,15 @@ fn pke_zk_proof(c: &mut Criterion) {
|
||||
|
||||
for (param_pke, _param_casting, param_fhe) in [
|
||||
(
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
),
|
||||
// Non default params use the V1_0 prefix
|
||||
(
|
||||
V0_11_PARAM_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1,
|
||||
V0_11_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1,
|
||||
V1_0_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
),
|
||||
] {
|
||||
let param_name = param_fhe.name();
|
||||
@@ -173,14 +166,14 @@ fn pke_zk_verify(c: &mut Criterion, results_file: &Path) {
|
||||
|
||||
for (param_pke, param_casting, param_fhe) in [
|
||||
(
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
),
|
||||
(
|
||||
V0_11_PARAM_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1,
|
||||
V0_11_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1,
|
||||
V1_0_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
),
|
||||
] {
|
||||
let param_name = param_fhe.name();
|
||||
|
||||
@@ -7,48 +7,49 @@ use rand::Rng;
|
||||
use std::env;
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::keycache::KEY_CACHE;
|
||||
use tfhe::shortint::parameters::current_params::*;
|
||||
use tfhe::shortint::parameters::*;
|
||||
use tfhe::shortint::{Ciphertext, CompressedServerKey, ServerKey};
|
||||
|
||||
const SERVER_KEY_BENCH_PARAMS: [ClassicPBSParameters; 5] = [
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
];
|
||||
|
||||
const SERVER_KEY_BENCH_PARAMS_EXTENDED: [ClassicPBSParameters; 16] = [
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_5_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_6_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_7_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_8_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_6_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_7_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_8_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
];
|
||||
|
||||
const SERVER_KEY_MULTI_BIT_BENCH_PARAMS: [MultiBitPBSParameters; 2] = [
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
];
|
||||
|
||||
const SERVER_KEY_MULTI_BIT_BENCH_PARAMS_EXTENDED: [MultiBitPBSParameters; 6] = [
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
];
|
||||
|
||||
enum BenchParamsSet {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::utilities::{write_to_json, OperatorType};
|
||||
use criterion::Criterion;
|
||||
use rayon::prelude::*;
|
||||
use tfhe::shortint::parameters::{
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
use tfhe::shortint::parameters::current_params::{
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
};
|
||||
use tfhe::shortint::prelude::*;
|
||||
|
||||
@@ -12,12 +12,12 @@ pub fn pack_cast_64(c: &mut Criterion) {
|
||||
let mut bench_group = c.benchmark_group(bench_name);
|
||||
|
||||
let (client_key_1, server_key_1): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
let (client_key_2, server_key_2): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ks_param = V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
|
||||
let ks_param_name = "V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";
|
||||
let ks_param = V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128;
|
||||
let ks_param_name = "V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128";
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key_1, Some(&server_key_1)),
|
||||
@@ -63,12 +63,12 @@ pub fn pack_cast(c: &mut Criterion) {
|
||||
let mut bench_group = c.benchmark_group(bench_name);
|
||||
|
||||
let (client_key_1, server_key_1): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
let (client_key_2, server_key_2): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ks_param = V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
|
||||
let ks_param_name = "V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";
|
||||
let ks_param = V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128;
|
||||
let ks_param_name = "V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128";
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key_1, Some(&server_key_1)),
|
||||
@@ -104,12 +104,12 @@ pub fn cast(c: &mut Criterion) {
|
||||
let mut bench_group = c.benchmark_group(bench_name);
|
||||
|
||||
let (client_key_1, server_key_1): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128);
|
||||
let (client_key_2, server_key_2): (ClientKey, ServerKey) =
|
||||
gen_keys(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
gen_keys(V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
|
||||
let ks_param = V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
|
||||
let ks_param_name = "V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS";
|
||||
let ks_param = V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128;
|
||||
let ks_param_name = "V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128";
|
||||
|
||||
let ksk = KeySwitchingKey::new(
|
||||
(&client_key_1, Some(&server_key_1)),
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
use criterion::{black_box, criterion_group, Criterion};
|
||||
use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
||||
use tfhe::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::{
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
use tfhe::shortint::prelude::*;
|
||||
|
||||
fn glwe_packing(c: &mut Criterion) {
|
||||
let param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let comp_param = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let comp_param = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let number_to_pack = 256;
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ pub mod shortint_utils {
|
||||
use itertools::iproduct;
|
||||
use std::vec::IntoIter;
|
||||
use tfhe::shortint::parameters::compact_public_key_only::CompactPublicKeyEncryptionParameters;
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
use tfhe::shortint::parameters::current_params::V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
use tfhe::shortint::parameters::list_compression::CompressionParameters;
|
||||
#[cfg(feature = "gpu")]
|
||||
use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS;
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
use tfhe::shortint::parameters::V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
use tfhe::shortint::parameters::{
|
||||
ShortintKeySwitchingParameters, PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
ShortintKeySwitchingParameters, PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
use tfhe::shortint::{
|
||||
ClassicPBSParameters, MultiBitPBSParameters, PBSParameters, ShortintParameterSet,
|
||||
@@ -66,7 +66,7 @@ pub mod shortint_utils {
|
||||
let params = vec![PARAM_GPU_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_3_KS_PBS.into()];
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
let params = vec![
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
];
|
||||
|
||||
let params_and_bit_sizes = iproduct!(params, env_config.bit_sizes());
|
||||
@@ -76,7 +76,7 @@ pub mod shortint_utils {
|
||||
} else {
|
||||
// FIXME One set of parameter is tested since we want to benchmark only quickest
|
||||
// operations.
|
||||
let params = vec![PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into()];
|
||||
let params = vec![PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into()];
|
||||
|
||||
let params_and_bit_sizes = iproduct!(params, env_config.bit_sizes());
|
||||
Self {
|
||||
|
||||
@@ -20,11 +20,11 @@ int main(void) {
|
||||
assert(ok == 0);
|
||||
|
||||
ok = config_builder_use_custom_parameters(
|
||||
&builder, SHORTINT_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
&builder, SHORTINT_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
assert(ok == 0);
|
||||
|
||||
ok = config_builder_enable_compression(
|
||||
&builder, &SHORTINT_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
&builder, &SHORTINT_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
assert(ok == 0);
|
||||
|
||||
ok = config_builder_build(builder, &config);
|
||||
|
||||
@@ -146,10 +146,10 @@ int main(void) {
|
||||
ok = config_builder_default(&builder);
|
||||
assert(ok == 0);
|
||||
ok = config_builder_use_custom_parameters(
|
||||
&builder, SHORTINT_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
&builder, SHORTINT_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
assert(ok == 0);
|
||||
ok = use_dedicated_compact_public_key_parameters(
|
||||
&builder, SHORTINT_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
&builder, SHORTINT_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
assert(ok == 0);
|
||||
ok = config_builder_build(builder, &config);
|
||||
assert(ok == 0);
|
||||
|
||||
@@ -215,7 +215,7 @@ int main(void) {
|
||||
|
||||
config_builder_default(&builder);
|
||||
config_builder_use_custom_parameters(&builder,
|
||||
SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64);
|
||||
SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128);
|
||||
config_builder_build(builder, &config);
|
||||
|
||||
ClientKey *client_key = NULL;
|
||||
@@ -243,7 +243,7 @@ int main(void) {
|
||||
|
||||
config_builder_default(&builder);
|
||||
config_builder_use_custom_parameters(&builder,
|
||||
SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64);
|
||||
SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M128);
|
||||
config_builder_build(builder, &config);
|
||||
|
||||
ClientKey *client_key = NULL;
|
||||
|
||||
@@ -647,7 +647,7 @@ int main(void) {
|
||||
assert(ok == 0);
|
||||
// Then use small parameters, those are gaussians as we don't have small TUniform params
|
||||
ok = config_builder_use_custom_parameters(
|
||||
&builder, SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64);
|
||||
&builder, SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128);
|
||||
ok = config_builder_build(builder, &config);
|
||||
assert(ok == 0);
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ int main(void) {
|
||||
|
||||
// Note that simply changing parameters like this does not yield secure parameters
|
||||
// Its only done for the example / tests
|
||||
ShortintPBSParameters params = SHORTINT_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
ShortintPBSParameters params = SHORTINT_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
assert(params.encryption_key_choice == ShortintEncryptionKeyChoiceBig);
|
||||
|
||||
ShortintCompactPublicKeyEncryptionParameters pke_params = SHORTINT_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
ShortintCompactPublicKeyEncryptionParameters pke_params = SHORTINT_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
int status;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ void test_predefined_keygen_w_serde(void) {
|
||||
ShortintCompressedCiphertext *cct = NULL;
|
||||
ShortintCompressedCiphertext *deser_cct = NULL;
|
||||
ShortintCiphertext *decompressed_ct = NULL;
|
||||
ShortintPBSParameters params = SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
ShortintPBSParameters params = SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
|
||||
int gen_keys_ok = shortint_gen_keys_with_parameters(params, &cks, &sks);
|
||||
assert(gen_keys_ok == 0);
|
||||
@@ -79,7 +79,7 @@ void test_server_key_trivial_encrypt(void) {
|
||||
ShortintClientKey *cks = NULL;
|
||||
ShortintServerKey *sks = NULL;
|
||||
ShortintCiphertext *ct = NULL;
|
||||
ShortintPBSParameters params = SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
ShortintPBSParameters params = SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
|
||||
int gen_keys_ok = shortint_gen_keys_with_parameters(params, &cks, &sks);
|
||||
assert(gen_keys_ok == 0);
|
||||
@@ -219,10 +219,10 @@ void test_compressed_public_keygen(ShortintPBSParameters params) {
|
||||
int main(void) {
|
||||
test_predefined_keygen_w_serde();
|
||||
test_custom_keygen();
|
||||
test_public_keygen(SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
test_public_keygen(SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64);
|
||||
test_compressed_public_keygen(SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
test_compressed_public_keygen(SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64);
|
||||
test_public_keygen(SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
test_public_keygen(SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128);
|
||||
test_compressed_public_keygen(SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
test_compressed_public_keygen(SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128);
|
||||
test_server_key_trivial_encrypt();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ void test_shortint_pbs_2_bits_message(void) {
|
||||
ShortintPBSLookupTable *lookup_table = NULL;
|
||||
ShortintClientKey *cks = NULL;
|
||||
ShortintServerKey *sks = NULL;
|
||||
ShortintPBSParameters params = SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
ShortintPBSParameters params = SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
|
||||
int gen_keys_ok = shortint_gen_keys_with_parameters(params, &cks, &sks);
|
||||
assert(gen_keys_ok == 0);
|
||||
@@ -115,7 +115,7 @@ void test_shortint_bivariate_pbs_2_bits_message(void) {
|
||||
ShortintBivariatePBSLookupTable *lookup_table = NULL;
|
||||
ShortintClientKey *cks = NULL;
|
||||
ShortintServerKey *sks = NULL;
|
||||
ShortintPBSParameters params = SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
ShortintPBSParameters params = SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
|
||||
int gen_keys_ok = shortint_gen_keys_with_parameters(params, &cks, &sks);
|
||||
assert(gen_keys_ok == 0);
|
||||
|
||||
@@ -539,9 +539,9 @@ void test_server_key(void) {
|
||||
const uint32_t message_bits = 2;
|
||||
const uint32_t carry_bits = 2;
|
||||
|
||||
ShortintPBSParameters params = SHORTINT_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
ShortintPBSParameters params = SHORTINT_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
// We don't have TUniform small params, use gaussian instead
|
||||
ShortintPBSParameters params_small = SHORTINT_V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintPBSParameters params_small = SHORTINT_V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
|
||||
assert(params.message_modulus == 1 << message_bits);
|
||||
assert(params.carry_modulus == 1 << carry_bits);
|
||||
|
||||
@@ -214,7 +214,7 @@ use tfhe::{
|
||||
fn main() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64,
|
||||
tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
@@ -55,7 +55,9 @@ Here is a more complete example:
|
||||
use tfhe::conformance::ParameterSetConformant;
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::safe_serialization::{safe_serialize, safe_deserialize_conformant};
|
||||
use tfhe::shortint::parameters::{PARAM_MESSAGE_2_CARRY_2_KS_PBS, V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64};
|
||||
use tfhe::shortint::parameters::{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128};
|
||||
use tfhe::conformance::ListSizeConstraint;
|
||||
use tfhe::{
|
||||
generate_keys, FheUint8, CompactCiphertextList, FheUint8ConformanceParams,
|
||||
@@ -63,8 +65,10 @@ use tfhe::{
|
||||
};
|
||||
|
||||
fn main() {
|
||||
let params_1 = PARAM_MESSAGE_2_CARRY_2_KS_PBS;
|
||||
let params_2 = V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
let params_1 = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params_2 = PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128;
|
||||
|
||||
assert_ne!(params_1, params_2);
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(params_1).build();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ function fhe_uint32_example() {
|
||||
// the error message will be displayed in the console
|
||||
init_panic_hook();
|
||||
|
||||
const block_params = new ShortintParameters(ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64);
|
||||
const block_params = new ShortintParameters(ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64);
|
||||
let config = TfheConfigBuilder.default()
|
||||
.build();
|
||||
|
||||
@@ -79,7 +79,7 @@ async function example() {
|
||||
await initThreadPool(navigator.hardwareConcurrency);
|
||||
await init_panic_hook();
|
||||
|
||||
const block_params = new ShortintParameters(ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64);
|
||||
const block_params = new ShortintParameters(ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64);
|
||||
// ....
|
||||
}
|
||||
```
|
||||
@@ -172,7 +172,7 @@ const { Shortint, ShortintParametersName, ShortintParameters } = require("/path/
|
||||
function shortint_example() {
|
||||
// Get pre-defined parameters from the shortint module to manage messages with 4 bits of useful
|
||||
// information in total (2 bits of "message" and 2 bits of "carry")
|
||||
let params_name = ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params_name = ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = new ShortintParameters(params_name);
|
||||
// Create a new secret ClientKey, this must not be shared
|
||||
console.log("Generating client keys...")
|
||||
|
||||
@@ -13,12 +13,11 @@ The following example shows how to use parallelized bootstrapping by choosing mu
|
||||
```rust
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32};
|
||||
use tfhe::shortint::parameters::v1_0::V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
tfhe::shortint::parameters::V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
)
|
||||
.use_custom_parameters(V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64)
|
||||
.build();
|
||||
|
||||
let (keys, server_keys) = generate_keys(config);
|
||||
@@ -46,11 +45,12 @@ Here's an example:
|
||||
```rust
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32};
|
||||
use tfhe::shortint::parameters::v1_0::V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
tfhe::shortint::parameters::V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.with_deterministic_execution(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.with_deterministic_execution(),
|
||||
)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ use tfhe::{
|
||||
fn main() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64,
|
||||
tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
@@ -25,11 +25,11 @@ use tfhe::zk::{CompactPkeCrs, ZkComputeLoad};
|
||||
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut rng = thread_rng();
|
||||
|
||||
let params = tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
// Indicate which parameters to use for the Compact Public Key encryption
|
||||
let cpk_params = tfhe::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let cpk_params = tfhe::shortint::parameters::PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
// And parameters allowing to keyswitch/cast to the computation parameters.
|
||||
let casting_params = tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let casting_params = tfhe::shortint::parameters::PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
// Enable the dedicated parameters on the config
|
||||
let config = tfhe::ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params)).build();
|
||||
@@ -102,11 +102,11 @@ use tfhe::zk::{CompactPkeCrs, ZkComputeLoad};
|
||||
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut rng = thread_rng();
|
||||
|
||||
let params = tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = tfhe::shortint::parameters::v1_0::V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
// Indicate which parameters to use for the Compact Public Key encryption
|
||||
let cpk_params = tfhe::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1;
|
||||
let cpk_params = tfhe::shortint::parameters::v1_0::compact_public_key_only::p_fail_2_minus_128::ks_pbs::V1_0_PARAM_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1;
|
||||
// And parameters allowing to keyswitch/cast to the computation parameters.
|
||||
let casting_params = tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1;
|
||||
let casting_params = tfhe::shortint::parameters::v1_0::key_switching::p_fail_2_minus_128::ks_pbs::V1_0_PARAM_KEYSWITCH_PKE_TO_SMALL_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1;
|
||||
// Enable the dedicated parameters on the config
|
||||
let config = tfhe::ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params)).build();
|
||||
|
||||
@@ -4,7 +4,10 @@ use std::io::{stdin, Read};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::{array, iter};
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::shortint::parameters::*;
|
||||
use tfhe::shortint::parameters::v1_0::{
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
use tfhe::{set_server_key, ClientKey, CompressedServerKey, ConfigBuilder, Device, FheUint32};
|
||||
|
||||
// might improve error message on type error
|
||||
@@ -187,10 +190,10 @@ fn main() -> Result<(), std::io::Error> {
|
||||
let config = match args.multibit {
|
||||
None => ConfigBuilder::default(),
|
||||
Some(2) => ConfigBuilder::with_custom_parameters(
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
),
|
||||
Some(3) => ConfigBuilder::with_custom_parameters(
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
),
|
||||
Some(v) => {
|
||||
panic!("Invalid multibit setting {v}");
|
||||
|
||||
@@ -13,32 +13,11 @@ use tfhe::shortint::parameters::coverage_parameters::{
|
||||
COVERAGE_PARAM_MESSAGE_5_CARRY_1_KS_PBS,
|
||||
COVERAGE_PARAM_MULTI_BIT_MESSAGE_2_CARRY_2_GROUP_2_KS_PBS,
|
||||
};
|
||||
use tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS;
|
||||
use tfhe::shortint::parameters::key_switching::ShortintKeySwitchingParameters;
|
||||
|
||||
use tfhe::shortint::parameters::multi_bit::gaussian::p_fail_2_minus_64::ks_pbs::{
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
use tfhe::shortint::parameters::current_params::*;
|
||||
use tfhe::shortint::parameters::{
|
||||
ClassicPBSParameters, PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_5_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_6_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
ClassicPBSParameters, PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
#[cfg(feature = "experimental")]
|
||||
use tfhe::shortint::parameters::{
|
||||
@@ -106,25 +85,18 @@ fn client_server_keys() {
|
||||
ClassicPBSParameters,
|
||||
ClassicPBSParameters,
|
||||
ShortintKeySwitchingParameters,
|
||||
); 2] = [
|
||||
(
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
),
|
||||
(
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS,
|
||||
),
|
||||
];
|
||||
); 1] = [(
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_KEYSWITCH_1_1_KS_PBS_TO_2_2_KS_PBS_GAUSSIAN_2M128,
|
||||
)];
|
||||
|
||||
generate_ksk_keys(&KSK_PARAMS);
|
||||
|
||||
#[cfg(feature = "experimental")]
|
||||
{
|
||||
const WOPBS_PARAMS: [(ClassicPBSParameters, WopbsParameters); 1] = [(
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
LEGACY_WOPBS_PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
)];
|
||||
generate_wopbs_keys(&WOPBS_PARAMS);
|
||||
@@ -134,23 +106,25 @@ fn client_server_keys() {
|
||||
[DEFAULT_PARAMETERS, DEFAULT_PARAMETERS_KS_PBS];
|
||||
generate_boolean_keys(&BOOLEAN_PARAMS);
|
||||
} else {
|
||||
const PBS_KEYS: [ClassicPBSParameters; 14] = [
|
||||
const PBS_KEYS: [ClassicPBSParameters; 15] = [
|
||||
// TUniform
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// Gaussian
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_5_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_6_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_5_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_6_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
// 2M64 as backup as 2M128 is too slow
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
];
|
||||
generate_pbs_keys(&PBS_KEYS);
|
||||
|
||||
@@ -158,19 +132,19 @@ fn client_server_keys() {
|
||||
{
|
||||
const WOPBS_PARAMS: [(ClassicPBSParameters, WopbsParameters); 4] = [
|
||||
(
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
LEGACY_WOPBS_PARAM_MESSAGE_1_CARRY_1_KS_PBS,
|
||||
),
|
||||
(
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
LEGACY_WOPBS_PARAM_MESSAGE_2_CARRY_2_KS_PBS,
|
||||
),
|
||||
(
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
LEGACY_WOPBS_PARAM_MESSAGE_3_CARRY_3_KS_PBS,
|
||||
),
|
||||
(
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
LEGACY_WOPBS_PARAM_MESSAGE_4_CARRY_4_KS_PBS,
|
||||
),
|
||||
];
|
||||
|
||||
@@ -9,9 +9,9 @@ use std::path::Path;
|
||||
use tfhe::integer::U256;
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::prelude::*;
|
||||
use tfhe::shortint::parameters::classic::compact_pk::{
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
use tfhe::shortint::parameters::current_params::{
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M128,
|
||||
};
|
||||
use tfhe::shortint::PBSParameters;
|
||||
use tfhe::{
|
||||
@@ -40,7 +40,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
|
||||
let operator = OperatorType::Atomic;
|
||||
|
||||
{
|
||||
let params = V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64;
|
||||
let params = V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128;
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params)
|
||||
.build();
|
||||
@@ -98,7 +98,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
|
||||
}
|
||||
|
||||
{
|
||||
let params = V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64;
|
||||
let params = V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M128;
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params)
|
||||
.build();
|
||||
@@ -157,7 +157,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
|
||||
|
||||
// 256 bits
|
||||
{
|
||||
let params = V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64;
|
||||
let params = V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128;
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params)
|
||||
.build();
|
||||
@@ -205,7 +205,7 @@ pub fn cpk_and_cctl_sizes(results_file: &Path) {
|
||||
}
|
||||
|
||||
{
|
||||
let params = V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64;
|
||||
let params = V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M128;
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params)
|
||||
.build();
|
||||
|
||||
@@ -6,14 +6,12 @@ use tfhe::boolean::parameters::{BooleanParameters, VEC_BOOLEAN_PARAM};
|
||||
use tfhe::core_crypto::commons::parameters::{GlweDimension, LweDimension, PolynomialSize};
|
||||
use tfhe::core_crypto::prelude::{DynamicDistribution, TUniform, UnsignedInteger};
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::parameters::classic::compact_pk::ALL_PARAMETER_VEC_COMPACT_PK;
|
||||
use tfhe::shortint::parameters::classic::gaussian::ALL_PARAMETER_VEC_GAUSSIAN;
|
||||
use tfhe::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::multi_bit::ALL_MULTI_BIT_PARAMETER_VEC;
|
||||
use tfhe::shortint::parameters::current_params::{
|
||||
VEC_ALL_CLASSIC_PBS_PARAMETERS, VEC_ALL_COMPACT_PUBLIC_KEY_ENCRYPTION_PARAMETERS,
|
||||
VEC_ALL_COMPRESSION_PARAMETERS, VEC_ALL_MULTI_BIT_PBS_PARAMETERS,
|
||||
};
|
||||
use tfhe::shortint::parameters::{
|
||||
CompactPublicKeyEncryptionParameters, CompressionParameters, ShortintParameterSet,
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
};
|
||||
|
||||
pub trait ParamDetails<T: UnsignedInteger> {
|
||||
@@ -151,15 +149,10 @@ struct ParamGroupKey {
|
||||
///Function to print in the lattice_estimator format the parameters
|
||||
/// Format: LWE.Parameters(n=722, q=2^32, Xs=ND.UniformMod(2),
|
||||
/// Xe=ND.DiscreteGaussian(56139.60810663548), tag='test_lattice_estimator')
|
||||
pub fn format_lwe_parameters_to_lattice_estimator<
|
||||
U: UnsignedInteger,
|
||||
T: ParamDetails<U> + NamedParam,
|
||||
>(
|
||||
param: &T,
|
||||
similar_params: Vec<String>,
|
||||
pub fn format_lwe_parameters_to_lattice_estimator<U: UnsignedInteger, T: ParamDetails<U>>(
|
||||
(param, name): (&T, &str),
|
||||
similar_params: &[&str],
|
||||
) -> String {
|
||||
let name = param.name();
|
||||
|
||||
match param.lwe_noise_distribution() {
|
||||
DynamicDistribution::Gaussian(distrib) => {
|
||||
let modular_std_dev =
|
||||
@@ -180,15 +173,10 @@ pub fn format_lwe_parameters_to_lattice_estimator<
|
||||
///Function to print in the lattice_estimator format the parameters
|
||||
/// Format: LWE.Parameters(n=722, q=2^32, Xs=ND.UniformMod(2),
|
||||
/// Xe=ND.DiscreteGaussian(56139.60810663548), tag='test_lattice_estimator')
|
||||
pub fn format_glwe_parameters_to_lattice_estimator<
|
||||
U: UnsignedInteger,
|
||||
T: ParamDetails<U> + NamedParam,
|
||||
>(
|
||||
param: &T,
|
||||
similar_params: Vec<String>,
|
||||
pub fn format_glwe_parameters_to_lattice_estimator<U: UnsignedInteger, T: ParamDetails<U>>(
|
||||
(param, name): (&T, &str),
|
||||
similar_params: &[&str],
|
||||
) -> String {
|
||||
let name = param.name();
|
||||
|
||||
match param.glwe_noise_distribution() {
|
||||
DynamicDistribution::Gaussian(distrib) => {
|
||||
let modular_std_dev =
|
||||
@@ -218,7 +206,7 @@ fn write_file(file: &mut File, filename: &Path, line: impl Into<String>) {
|
||||
|
||||
fn write_all_params_in_file<U: UnsignedInteger, T: ParamDetails<U> + Copy + NamedParam>(
|
||||
filename: &str,
|
||||
params: &[T],
|
||||
params: &[(T, Option<&str>)],
|
||||
format: ParametersFormat,
|
||||
) {
|
||||
let path = Path::new(filename);
|
||||
@@ -228,9 +216,9 @@ fn write_all_params_in_file<U: UnsignedInteger, T: ParamDetails<U> + Copy + Name
|
||||
.open(path)
|
||||
.expect("cannot open parsed results file");
|
||||
|
||||
let mut params_groups: HashMap<ParamGroupKey, Vec<T>> = HashMap::new();
|
||||
let mut params_groups: HashMap<ParamGroupKey, Vec<(T, String)>> = HashMap::new();
|
||||
|
||||
for params in params.iter() {
|
||||
for (params, optional_name) in params.iter() {
|
||||
let keys = match format {
|
||||
ParametersFormat::LweGlwe => vec![
|
||||
ParamGroupKey {
|
||||
@@ -267,10 +255,19 @@ fn write_all_params_in_file<U: UnsignedInteger, T: ParamDetails<U> + Copy + Name
|
||||
for key in keys.into_iter() {
|
||||
match params_groups.get_mut(&key) {
|
||||
Some(vec) => {
|
||||
vec.push(*params);
|
||||
vec.push((
|
||||
*params,
|
||||
optional_name.map_or_else(|| params.name(), |name| name.to_string()),
|
||||
));
|
||||
}
|
||||
None => {
|
||||
params_groups.insert(key, vec![*params]);
|
||||
params_groups.insert(
|
||||
key,
|
||||
vec![(
|
||||
*params,
|
||||
optional_name.map_or_else(|| params.name(), |name| name.to_string()),
|
||||
)],
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -279,16 +276,22 @@ fn write_all_params_in_file<U: UnsignedInteger, T: ParamDetails<U> + Copy + Name
|
||||
let mut param_names_augmented = Vec::new();
|
||||
|
||||
for (key, group) in params_groups.iter() {
|
||||
let similar_params = group.iter().map(|p| p.name()).collect::<Vec<String>>();
|
||||
let ref_param = group[0];
|
||||
let similar_params = group.iter().map(|p| p.1.as_str()).collect::<Vec<_>>();
|
||||
let (ref_param, ref_param_name) = &group[0];
|
||||
let formatted_param = match key.parameters_format {
|
||||
ParametersFormat::Lwe => {
|
||||
param_names_augmented.push(format!("{}_LWE", ref_param.name()));
|
||||
format_lwe_parameters_to_lattice_estimator(&ref_param, similar_params)
|
||||
param_names_augmented.push(format!("{}_LWE", ref_param_name));
|
||||
format_lwe_parameters_to_lattice_estimator(
|
||||
(ref_param, ref_param_name.as_str()),
|
||||
&similar_params,
|
||||
)
|
||||
}
|
||||
ParametersFormat::Glwe => {
|
||||
param_names_augmented.push(format!("{}_GLWE", ref_param.name()));
|
||||
format_glwe_parameters_to_lattice_estimator(&ref_param, similar_params)
|
||||
param_names_augmented.push(format!("{}_GLWE", ref_param_name));
|
||||
format_glwe_parameters_to_lattice_estimator(
|
||||
(ref_param, ref_param_name.as_str()),
|
||||
&similar_params,
|
||||
)
|
||||
}
|
||||
ParametersFormat::LweGlwe => panic!("formatted parameters cannot be LweGlwe"),
|
||||
};
|
||||
@@ -305,47 +308,50 @@ fn main() {
|
||||
new_work_dir.push("ci");
|
||||
std::env::set_current_dir(new_work_dir).unwrap();
|
||||
|
||||
let boolean_params: Vec<_> = VEC_BOOLEAN_PARAM.into_iter().map(|p| (p, None)).collect();
|
||||
write_all_params_in_file(
|
||||
"boolean_parameters_lattice_estimator.sage",
|
||||
&VEC_BOOLEAN_PARAM,
|
||||
&boolean_params,
|
||||
ParametersFormat::LweGlwe,
|
||||
);
|
||||
|
||||
let all_classic_pbs = [
|
||||
ALL_PARAMETER_VEC_GAUSSIAN.to_vec(),
|
||||
ALL_PARAMETER_VEC_COMPACT_PK.to_vec(),
|
||||
vec![PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64],
|
||||
]
|
||||
.concat();
|
||||
let classic_pbs = all_classic_pbs
|
||||
.iter()
|
||||
.map(|p| ShortintParameterSet::from(*p))
|
||||
.collect::<Vec<_>>();
|
||||
let classic_pbs: Vec<_> = VEC_ALL_CLASSIC_PBS_PARAMETERS
|
||||
.into_iter()
|
||||
.map(|p| (ShortintParameterSet::from(*p.0), Some(p.1)))
|
||||
.collect();
|
||||
write_all_params_in_file(
|
||||
"shortint_classic_parameters_lattice_estimator.sage",
|
||||
&classic_pbs,
|
||||
ParametersFormat::LweGlwe,
|
||||
);
|
||||
|
||||
let multi_bit_pbs = ALL_MULTI_BIT_PARAMETER_VEC
|
||||
.iter()
|
||||
.map(|p| ShortintParameterSet::from(*p))
|
||||
.collect::<Vec<_>>();
|
||||
let multi_bit_pbs: Vec<_> = VEC_ALL_MULTI_BIT_PBS_PARAMETERS
|
||||
.into_iter()
|
||||
.map(|p| (ShortintParameterSet::from(*p.0), Some(p.1)))
|
||||
.collect();
|
||||
write_all_params_in_file(
|
||||
"shortint_multi_bit_parameters_lattice_estimator.sage",
|
||||
&multi_bit_pbs,
|
||||
ParametersFormat::LweGlwe,
|
||||
);
|
||||
|
||||
let cpk_params: Vec<_> = VEC_ALL_COMPACT_PUBLIC_KEY_ENCRYPTION_PARAMETERS
|
||||
.into_iter()
|
||||
.map(|p| (*p.0, Some(p.1)))
|
||||
.collect();
|
||||
write_all_params_in_file(
|
||||
"shortint_cpke_parameters_lattice_estimator.sage",
|
||||
&[V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64],
|
||||
&cpk_params,
|
||||
ParametersFormat::Lwe,
|
||||
);
|
||||
|
||||
let comp_params: Vec<_> = VEC_ALL_COMPRESSION_PARAMETERS
|
||||
.into_iter()
|
||||
.map(|p| (*p.0, Some(p.1)))
|
||||
.collect();
|
||||
write_all_params_in_file(
|
||||
"shortint_list_compression_parameters_lattice_estimator.sage",
|
||||
&[COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64],
|
||||
&comp_params,
|
||||
ParametersFormat::Glwe,
|
||||
);
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::parameters::classic::tuniform::p_fail_2_minus_64::ks_pbs::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::multi_bit::tuniform::p_fail_2_minus_64::ks_pbs_gpu::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::{
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
|
||||
pub fn main() {
|
||||
println!("CPU Integer parameters:\n");
|
||||
println!("{}", PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.name());
|
||||
println!("{PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:?}");
|
||||
println!("{}", PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.name());
|
||||
println!("{PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128:?}");
|
||||
|
||||
println!("\n\n===========================================================================\n\n");
|
||||
|
||||
@@ -21,7 +23,7 @@ pub fn main() {
|
||||
println!("\n\n===========================================================================\n\n");
|
||||
|
||||
println!("CPU PBS parameters:\n");
|
||||
let param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let bits = (param.message_modulus.0 * param.carry_modulus.0).ilog2();
|
||||
println!("Precision {bits} bits");
|
||||
println!("{}", param.name());
|
||||
@@ -43,21 +45,21 @@ pub fn main() {
|
||||
println!("Compact Public Key parameters (encryption + ZK):");
|
||||
println!(
|
||||
"{}",
|
||||
stringify!(V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
stringify!(PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
|
||||
);
|
||||
println!("{V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:?}\n");
|
||||
println!("{PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128:?}\n");
|
||||
|
||||
println!("Corresponding compute FHE parameters:");
|
||||
println!(
|
||||
"{}",
|
||||
stringify!(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
stringify!(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
|
||||
);
|
||||
println!("{PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:?}\n");
|
||||
println!("{PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128:?}\n");
|
||||
|
||||
println!("Keyswitch from encryption + ZK to compute parameters:");
|
||||
println!(
|
||||
"{}",
|
||||
stringify!(V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
stringify!(PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
|
||||
);
|
||||
println!("{V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:?}");
|
||||
println!("{PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128:?}");
|
||||
}
|
||||
|
||||
@@ -7,26 +7,8 @@ use std::io::Write;
|
||||
use std::path::Path;
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::keycache::KEY_CACHE;
|
||||
use tfhe::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::{
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
use tfhe::shortint::parameters::current_params::*;
|
||||
use tfhe::shortint::parameters::*;
|
||||
use tfhe::shortint::{
|
||||
ClassicPBSParameters, ClientKey, CompactPrivateKey, CompressedCompactPublicKey,
|
||||
CompressedKeySwitchingKey, CompressedServerKey, PBSParameters,
|
||||
@@ -40,17 +22,17 @@ fn write_result(file: &mut File, name: &str, value: usize) {
|
||||
|
||||
fn client_server_key_sizes(results_file: &Path) {
|
||||
let shortint_params_vec: Vec<PBSParameters> = vec![
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V0_11_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into(),
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128.into(),
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128.into(),
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128.into(),
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
@@ -184,7 +166,7 @@ fn tuniform_key_set_sizes(results_file: &Path) {
|
||||
|
||||
println!("Measuring shortint key sizes:");
|
||||
|
||||
let param_fhe = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_fhe = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_fhe_name = param_fhe.name();
|
||||
let cks = ClientKey::new(param_fhe);
|
||||
let compressed_sks = CompressedServerKey::new(&cks);
|
||||
@@ -224,8 +206,8 @@ fn tuniform_key_set_sizes(results_file: &Path) {
|
||||
&mut file,
|
||||
);
|
||||
|
||||
let param_pke = V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_pke_name = stringify!(PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let param_pke = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_pke_name = stringify!(PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
let compact_private_key = CompactPrivateKey::new(param_pke);
|
||||
let compressed_pk = CompressedCompactPublicKey::new(&compact_private_key);
|
||||
let pk = compressed_pk.decompress();
|
||||
@@ -240,11 +222,11 @@ fn tuniform_key_set_sizes(results_file: &Path) {
|
||||
&mut file,
|
||||
);
|
||||
|
||||
let param_compression = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_compression_name = stringify!(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let param_compression = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_compression_name = stringify!(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
let params_tuple = (
|
||||
param_compression,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
);
|
||||
|
||||
let private_compression_key = cks.new_compression_private_key(param_compression);
|
||||
@@ -268,8 +250,8 @@ fn tuniform_key_set_sizes(results_file: &Path) {
|
||||
&mut file,
|
||||
);
|
||||
|
||||
let param_casting = V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_casting_name = stringify!(PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let param_casting = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_casting_name = stringify!(PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
let compressed_casting_key = CompressedKeySwitchingKey::new(
|
||||
(&compact_private_key, None),
|
||||
(&cks, &compressed_sks),
|
||||
|
||||
@@ -9,22 +9,7 @@ use std::fs::{File, OpenOptions};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use tfhe::keycache::NamedParam;
|
||||
use tfhe::shortint::keycache::{
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_NAME,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64_NAME,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64_NAME,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64_NAME,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64_NAME,
|
||||
};
|
||||
use tfhe::shortint::parameters::classic::compact_pk::{
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
};
|
||||
use tfhe::shortint::parameters::classic::tuniform::p_fail_2_minus_64::ks_pbs::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use tfhe::shortint::parameters::{
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
use tfhe::shortint::keycache::get_shortint_parameter_set_from_name;
|
||||
use tfhe::shortint::{ClassicPBSParameters, PBSParameters};
|
||||
|
||||
const BENCHMARK_NAME_PREFIX: &str = "wasm::";
|
||||
@@ -36,23 +21,14 @@ struct Args {
|
||||
}
|
||||
|
||||
fn params_from_name(name: &str) -> ClassicPBSParameters {
|
||||
match name.to_uppercase().as_str() {
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64_NAME => {
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64
|
||||
match get_shortint_parameter_set_from_name(name.to_uppercase().as_str())
|
||||
.pbs_parameters()
|
||||
.unwrap()
|
||||
{
|
||||
PBSParameters::PBS(p) => p,
|
||||
PBSParameters::MultiBitPBS(_) => {
|
||||
panic!("Tried to get a MultiBitPBS, expected ClassicPBSParameters")
|
||||
}
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64_NAME => {
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64
|
||||
}
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64_NAME => {
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64
|
||||
}
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64_NAME => {
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64
|
||||
}
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_NAME => {
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
}
|
||||
_ => panic!("failed to get parameters for name '{name}'"),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ test("hlapi_compressed_public_client_int8_big", (t) => {
|
||||
|
||||
test("hlapi_public_key_encrypt_decrypt_int32_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -127,7 +127,7 @@ test("hlapi_public_key_encrypt_decrypt_int32_small", (t) => {
|
||||
|
||||
test("hlapi_decompress_public_key_then_encrypt_decrypt_int32_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -213,7 +213,7 @@ test("hlapi_client_key_encrypt_decrypt_int128_big", (t) => {
|
||||
|
||||
test("hlapi_client_key_encrypt_decrypt_int128_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -323,7 +323,7 @@ test("hlapi_client_key_encrypt_decrypt_int256_big", (t) => {
|
||||
|
||||
test("hlapi_client_key_encrypt_decrypt_int256_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -384,7 +384,7 @@ test("hlapi_client_key_encrypt_decrypt_int256_small", (t) => {
|
||||
|
||||
test("hlapi_decompress_public_key_then_encrypt_decrypt_int256_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -412,7 +412,7 @@ test("hlapi_decompress_public_key_then_encrypt_decrypt_int256_small", (t) => {
|
||||
|
||||
test("hlapi_public_key_encrypt_decrypt_int256_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -470,7 +470,7 @@ function hlapi_compact_public_key_encrypt_decrypt_int32_single(config) {
|
||||
|
||||
test("hlapi_compact_public_key_encrypt_decrypt_int32_big_single", (t) => {
|
||||
const block_params = new ShortintParameters(
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64,
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_128,
|
||||
);
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
@@ -481,7 +481,7 @@ test("hlapi_compact_public_key_encrypt_decrypt_int32_big_single", (t) => {
|
||||
|
||||
test("hlapi_compact_public_key_encrypt_decrypt_int32_small_single", (t) => {
|
||||
const block_params = new ShortintParameters(
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
);
|
||||
let config = TfheConfigBuilder.default()
|
||||
.use_custom_parameters(block_params)
|
||||
@@ -563,10 +563,10 @@ test("hlapi_compact_ciphertext_list", (t) => {
|
||||
|
||||
test("hlapi_compact_ciphertext_list_with_proof", (t) => {
|
||||
const block_params = new ShortintParameters(
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
);
|
||||
let publicKeyParams = new ShortintCompactPublicKeyEncryptionParameters(
|
||||
ShortintCompactPublicKeyEncryptionParametersName.SHORTINT_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
ShortintCompactPublicKeyEncryptionParametersName.PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
);
|
||||
|
||||
let config = TfheConfigBuilder.default()
|
||||
@@ -616,10 +616,10 @@ test("hlapi_compact_pk_conformance", (t) => {
|
||||
const limit = BigInt(1 << 20);
|
||||
|
||||
let blockParams = new ShortintParameters(
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
);
|
||||
let publicKeyParams = new ShortintCompactPublicKeyEncryptionParameters(
|
||||
ShortintCompactPublicKeyEncryptionParametersName.SHORTINT_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
ShortintCompactPublicKeyEncryptionParametersName.PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
);
|
||||
|
||||
let config = TfheConfigBuilder.default()
|
||||
|
||||
@@ -80,7 +80,7 @@ test("hlapi_key_gen_big", (t) => {
|
||||
|
||||
test("hlapi_key_gen_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -151,7 +151,7 @@ test("hlapi_compressed_public_client_uint8_big", (t) => {
|
||||
|
||||
test("hlapi_public_key_encrypt_decrypt_uint32_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -178,7 +178,7 @@ test("hlapi_public_key_encrypt_decrypt_uint32_small", (t) => {
|
||||
|
||||
test("hlapi_decompress_public_key_then_encrypt_decrypt_uint32_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -264,7 +264,7 @@ test("hlapi_client_key_encrypt_decrypt_uint128_big", (t) => {
|
||||
|
||||
test("hlapi_client_key_encrypt_decrypt_uint128_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -365,7 +365,7 @@ test("hlapi_client_key_encrypt_decrypt_uint256_big", (t) => {
|
||||
|
||||
test("hlapi_client_key_encrypt_decrypt_uint256_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -417,7 +417,7 @@ test("hlapi_client_key_encrypt_decrypt_uint256_small", (t) => {
|
||||
|
||||
test("hlapi_decompress_public_key_then_encrypt_decrypt_uint256_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
@@ -445,7 +445,7 @@ test("hlapi_decompress_public_key_then_encrypt_decrypt_uint256_small", (t) => {
|
||||
|
||||
test("hlapi_public_key_encrypt_decrypt_uint256_small", (t) => {
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let config = TfheConfigBuilder.with_custom_parameters(params_small).build();
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ test("boolean_deterministic_keygen", (t) => {
|
||||
// Shortint tests
|
||||
test("shortint_encrypt_decrypt", (t) => {
|
||||
let params_name =
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = new ShortintParameters(params_name);
|
||||
let cks = Shortint.new_client_key(params);
|
||||
let ct = Shortint.encrypt(cks, BigInt(3));
|
||||
@@ -128,7 +128,7 @@ test("shortint_encrypt_decrypt", (t) => {
|
||||
|
||||
// Encryption using small keys
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let cks_small = Shortint.new_client_key(params_small);
|
||||
|
||||
@@ -144,7 +144,7 @@ test("shortint_encrypt_decrypt", (t) => {
|
||||
|
||||
test("shortint_compressed_encrypt_decrypt", (t) => {
|
||||
let params_name =
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = new ShortintParameters(params_name);
|
||||
let cks = Shortint.new_client_key(params);
|
||||
let ct = Shortint.encrypt_compressed(cks, BigInt(3));
|
||||
@@ -164,7 +164,7 @@ test("shortint_compressed_encrypt_decrypt", (t) => {
|
||||
// Encryption using small keys
|
||||
// We don't have TUniform small params so use previous gaussian ones.
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let cks_small = Shortint.new_client_key(params_small);
|
||||
|
||||
@@ -184,7 +184,7 @@ test("shortint_compressed_encrypt_decrypt", (t) => {
|
||||
|
||||
test("shortint_public_encrypt_decrypt", (t) => {
|
||||
let params_name_2_0 =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M128;
|
||||
let params_2_0 = new ShortintParameters(params_name_2_0);
|
||||
let cks = Shortint.new_client_key(params_2_0);
|
||||
let pk = Shortint.new_public_key(cks);
|
||||
@@ -199,7 +199,7 @@ test("shortint_public_encrypt_decrypt", (t) => {
|
||||
|
||||
// Small
|
||||
let params_name_2_2_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_2_2_small = new ShortintParameters(params_name_2_2_small);
|
||||
let cks_small = Shortint.new_client_key(params_2_2_small);
|
||||
|
||||
@@ -238,7 +238,7 @@ test("shortint_compressed_public_encrypt_decrypt", (t) => {
|
||||
|
||||
// Small
|
||||
let params_name_small =
|
||||
ShortintParametersName.V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64;
|
||||
ShortintParametersName.V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128;
|
||||
let params_small = new ShortintParameters(params_name_small);
|
||||
let cks_small = Shortint.new_client_key(params_small);
|
||||
|
||||
@@ -268,7 +268,7 @@ test("shortint_deterministic_keygen", (t) => {
|
||||
let seed_low_bytes = genRandomBigIntWithBytes(8);
|
||||
|
||||
let params_name =
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
ShortintParametersName.PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let params = new ShortintParameters(params_name);
|
||||
let cks = Shortint.new_client_key_from_seed_and_parameters(
|
||||
seed_high_bytes,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
pub use crate::core_crypto::commons::dispersion::StandardDev;
|
||||
pub use crate::core_crypto::commons::parameters::{
|
||||
DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
|
||||
};
|
||||
use crate::core_crypto::commons::parameters::{NoiseEstimationMeasureBound, RSigmaFactor};
|
||||
use crate::core_crypto::prelude::{LweCiphertextCount, Variance};
|
||||
pub use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
pub use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::v0_11::classic::compact_pk::*;
|
||||
use crate::shortint::parameters::v0_11::classic::gaussian::*;
|
||||
use crate::shortint::parameters::v0_11::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::v0_11::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::v0_11::list_compression::V0_11_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::v1_0::*;
|
||||
use crate::shortint::parameters::ModulusSwitchNoiseReductionParams as RustModulusSwitchNoiseReductionParams;
|
||||
pub use crate::shortint::parameters::*;
|
||||
|
||||
@@ -432,15 +430,40 @@ impl ShortintCompactPublicKeyEncryptionParameters {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: use macros once we have more parameters using the same pattern as
|
||||
// expose_predefined_parameters
|
||||
#[no_mangle]
|
||||
pub static SHORTINT_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64:
|
||||
ShortintCompactPublicKeyEncryptionParameters =
|
||||
ShortintCompactPublicKeyEncryptionParameters::convert((
|
||||
macro_rules! expose_as_shortint_compact_public_key_parameters(
|
||||
(
|
||||
$(
|
||||
($param_pke_name:ident, $param_ks_name:ident)
|
||||
),*
|
||||
$(,)?
|
||||
) => {
|
||||
::paste::paste!{
|
||||
$(
|
||||
#[no_mangle]
|
||||
pub static [<SHORTINT_ $param_pke_name>]: ShortintCompactPublicKeyEncryptionParameters =
|
||||
ShortintCompactPublicKeyEncryptionParameters::convert((
|
||||
$param_pke_name,
|
||||
$param_ks_name,
|
||||
));
|
||||
)*
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
expose_as_shortint_compact_public_key_parameters!(
|
||||
(
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
),
|
||||
(
|
||||
V1_0_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
),
|
||||
(
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
));
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
),
|
||||
);
|
||||
|
||||
macro_rules! expose_as_shortint_pbs_parameters(
|
||||
(
|
||||
@@ -468,7 +491,7 @@ macro_rules! expose_as_shortint_pbs_parameters(
|
||||
$(
|
||||
// 1 scope for each parameters
|
||||
{
|
||||
let rust_params = crate::shortint::parameters::$param_name;
|
||||
let rust_params = $param_name;
|
||||
let c_params = ShortintPBSParameters::from(rust_params);
|
||||
let rust_params_from_c = crate::shortint::parameters::ClassicPBSParameters::try_from(c_params).unwrap();
|
||||
assert_eq!(rust_params, rust_params_from_c);
|
||||
@@ -479,6 +502,87 @@ macro_rules! expose_as_shortint_pbs_parameters(
|
||||
);
|
||||
|
||||
expose_as_shortint_pbs_parameters!(
|
||||
// TUniform
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
// v1.0
|
||||
// Gaussian
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_5_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_6_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_6_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_5_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_6_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_7_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_7_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_6_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_5_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_3_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_6_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_7_CARRY_1_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_8_CARRY_0_KS_PBS_GAUSSIAN_2M128,
|
||||
// Small params
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_PBS_KS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_PBS_KS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_PBS_KS_GAUSSIAN_2M128,
|
||||
// CPK
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_3_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_4_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_5_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_6_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_7_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_1_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_3_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_4_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_5_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_6_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_1_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_4_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_5_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_1_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_3_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_1_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_5_CARRY_3_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_6_CARRY_1_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_6_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_7_CARRY_1_COMPACT_PK_KS_PBS_GAUSSIAN_2M128,
|
||||
// CPK SMALL
|
||||
V1_0_PARAM_MESSAGE_1_CARRY_1_COMPACT_PK_PBS_KS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_3_CARRY_3_COMPACT_PK_PBS_KS_GAUSSIAN_2M128,
|
||||
V1_0_PARAM_MESSAGE_4_CARRY_4_COMPACT_PK_PBS_KS_GAUSSIAN_2M128,
|
||||
// v0.11
|
||||
// Gaussian
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_1_CARRY_1_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_0_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -554,15 +658,33 @@ expose_as_shortint_pbs_parameters!(
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_3_CARRY_3_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_MESSAGE_4_CARRY_4_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
// TUniform
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
);
|
||||
|
||||
pub struct CompressionParameters(
|
||||
pub(crate) crate::shortint::parameters::list_compression::CompressionParameters,
|
||||
);
|
||||
|
||||
#[no_mangle]
|
||||
pub static SHORTINT_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64: CompressionParameters = CompressionParameters(
|
||||
crate::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
macro_rules! expose_as_shortint_compression_parameters(
|
||||
(
|
||||
$(
|
||||
$param_name:ident
|
||||
),*
|
||||
$(,)?
|
||||
) => {
|
||||
::paste::paste!{
|
||||
$(
|
||||
#[no_mangle]
|
||||
pub static [<SHORTINT_ $param_name>]: CompressionParameters =
|
||||
CompressionParameters(
|
||||
$param_name,
|
||||
);
|
||||
)*
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
expose_as_shortint_compression_parameters!(
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V0_11_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
);
|
||||
|
||||
@@ -90,7 +90,7 @@ use tfhe_fft::c64;
|
||||
///
|
||||
/// let ct_plaintext = Plaintext(3 << 60);
|
||||
///
|
||||
/// let mut ct_plaintexts = PlaintextList::new(ct_plaintext.0, PlaintextCount(polynomial_size.0));
|
||||
/// let ct_plaintexts = PlaintextList::new(ct_plaintext.0, PlaintextCount(polynomial_size.0));
|
||||
/// let mut ct = GlweCiphertext::new(0u64, glwe_size_in, polynomial_size, ciphertext_modulus);
|
||||
///
|
||||
/// encrypt_glwe_ciphertext(
|
||||
|
||||
@@ -202,7 +202,7 @@ pub fn partial_extract_lwe_sample_from_glwe_ciphertext<Scalar, InputCont, Output
|
||||
/// // Create the plaintext
|
||||
/// let msg = 3u64;
|
||||
/// let encoded_msg = msg << 60;
|
||||
/// let mut plaintext = Plaintext(encoded_msg);
|
||||
/// let plaintext = Plaintext(encoded_msg);
|
||||
///
|
||||
/// // Create a new LweCiphertext
|
||||
/// let mut lwe = LweCiphertext::new(0u64, lwe_dimension.to_lwe_size(), ciphertext_modulus);
|
||||
|
||||
@@ -53,7 +53,7 @@ pub fn generate_partial_binary_glwe_secret_key<Scalar, KeyCont, Gen>(
|
||||
/// let seeder = seeder.as_mut();
|
||||
/// let mut secret_generator = SecretRandomGenerator::<DefaultRandomGenerator>::new(seeder.seed());
|
||||
///
|
||||
/// let mut glwe_secret_key: GlweSecretKeyOwned<u64> =
|
||||
/// let glwe_secret_key: GlweSecretKeyOwned<u64> =
|
||||
/// allocate_and_generate_new_partial_binary_glwe_secret_key(
|
||||
/// glwe_dimension,
|
||||
/// polynomial_size,
|
||||
|
||||
@@ -313,6 +313,7 @@ mod zk {
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::integer::ciphertext::IntegerProvenCompactCiphertextListConformanceParams;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::zk::CompactPkeCrs;
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
@@ -320,11 +321,11 @@ mod zk {
|
||||
fn conformance_zk_compact_ciphertext_list() {
|
||||
let mut rng = thread_rng();
|
||||
|
||||
let params = crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let cpk_params = crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let cpk_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let casting_params = crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let casting_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let config = crate::ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params));
|
||||
@@ -524,6 +525,7 @@ impl CompactCiphertextListBuilder {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::prelude::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::{set_server_key, FheBool, FheInt64, FheUint16, FheUint2, FheUint32};
|
||||
|
||||
#[test]
|
||||
@@ -581,16 +583,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_compact_list_with_casting() {
|
||||
use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
|
||||
let config = crate::ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.use_dedicated_compact_public_key_parameters((
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
))
|
||||
.build();
|
||||
|
||||
@@ -644,16 +642,12 @@ mod tests {
|
||||
#[cfg(feature = "zk-pok")]
|
||||
#[test]
|
||||
fn test_proven_compact_list() {
|
||||
use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
|
||||
let config = crate::ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.use_dedicated_compact_public_key_parameters((
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
))
|
||||
.build();
|
||||
|
||||
@@ -733,17 +727,14 @@ mod tests {
|
||||
#[cfg(feature = "strings")]
|
||||
#[test]
|
||||
fn test_compact_list_with_string_and_casting() {
|
||||
use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::FheAsciiString;
|
||||
|
||||
let config = crate::ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.use_dedicated_compact_public_key_parameters((
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
))
|
||||
.build();
|
||||
|
||||
|
||||
@@ -700,9 +700,17 @@ pub mod gpu {
|
||||
mod tests {
|
||||
use crate::prelude::*;
|
||||
use crate::safe_serialization::{safe_deserialize, safe_serialize};
|
||||
use crate::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::multi_bit::tuniform::p_fail_2_minus_64::ks_pbs::V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
// TODO GPU DRIFT UPDATE
|
||||
use crate::shortint::parameters::current_params::{
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
};
|
||||
use crate::shortint::parameters::{
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
};
|
||||
use crate::shortint::PBSParameters;
|
||||
use crate::{
|
||||
set_server_key, unset_server_key, ClientKey, CompressedCiphertextList,
|
||||
@@ -711,12 +719,28 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_compressed_ct_list_cpu_gpu() {
|
||||
for params in [
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
] {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
let (test_params, comp_params) = if cfg!(feature = "gpu") {
|
||||
(
|
||||
[
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
],
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
[
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into(),
|
||||
],
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
};
|
||||
|
||||
for params in test_params {
|
||||
let config = crate::ConfigBuilder::with_custom_parameters::<PBSParameters>(params)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.enable_compression(comp_params)
|
||||
.build();
|
||||
|
||||
let ck = crate::ClientKey::generate(config);
|
||||
@@ -865,9 +889,9 @@ mod tests {
|
||||
#[cfg(feature = "strings")]
|
||||
#[test]
|
||||
fn test_compressed_strings_cpu() {
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into();
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into();
|
||||
let config = crate::ConfigBuilder::with_custom_parameters::<PBSParameters>(params)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
|
||||
.build();
|
||||
|
||||
let ck = crate::ClientKey::generate(config);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use crate::integer::I256;
|
||||
use crate::prelude::*;
|
||||
use crate::safe_serialization::{DeserializationConfig, SerializationConfig};
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::{
|
||||
generate_keys, set_server_key, ClientKey, CompactCiphertextList, CompactPublicKey,
|
||||
CompressedFheInt16, CompressedFheInt32, Config, ConfigBuilder, FheInt16, FheInt256, FheInt32,
|
||||
@@ -25,10 +26,9 @@ fn test_signed_integer_compressed() {
|
||||
fn test_integer_compressed_small() {
|
||||
let mut rng = thread_rng();
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
crate::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
)
|
||||
.build();
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
let clear = rng.gen::<i16>();
|
||||
@@ -280,9 +280,7 @@ fn test_int64_rotate() {
|
||||
#[test]
|
||||
fn test_multi_bit_rotate() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
crate::shortint::parameters::V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
)
|
||||
.use_custom_parameters(V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
fhe_int64_rotate(config);
|
||||
}
|
||||
@@ -368,9 +366,7 @@ fn test_int32_div_rem() {
|
||||
#[test]
|
||||
fn test_multi_div_rem() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
crate::shortint::parameters::V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
)
|
||||
.use_custom_parameters(V1_0_PARAM_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
fhe_int32_div_rem(config);
|
||||
}
|
||||
@@ -532,10 +528,9 @@ fn test_trivial_fhe_int8() {
|
||||
|
||||
#[test]
|
||||
fn test_trivial_fhe_int256_small() {
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
crate::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
)
|
||||
.build();
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (client_key, sks) = generate_keys(config);
|
||||
|
||||
set_server_key(sks);
|
||||
@@ -548,9 +543,7 @@ fn test_trivial_fhe_int256_small() {
|
||||
#[test]
|
||||
fn test_compact_public_key_big() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
crate::shortint::parameters::classic::compact_pk::V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64,
|
||||
)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
@@ -568,9 +561,7 @@ fn test_compact_public_key_big() {
|
||||
#[test]
|
||||
fn test_compact_public_key_small() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(
|
||||
crate::shortint::parameters::classic::compact_pk::V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64,
|
||||
)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
@@ -646,7 +637,7 @@ fn test_leading_trailing_zeros_ones() {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_fhe_int32() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let (client_key, server_key) =
|
||||
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
@@ -671,7 +662,7 @@ fn test_safe_deserialize_conformant_fhe_int32() {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_compressed_fhe_int32() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let (client_key, server_key) =
|
||||
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
|
||||
@@ -189,7 +189,7 @@ where
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::core_crypto::prelude::UnsignedInteger;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
use crate::shortint::{CiphertextModulus, CompressedCiphertext};
|
||||
use crate::{generate_keys, set_server_key, CompressedFheUint8, ConfigBuilder};
|
||||
use rand::{thread_rng, Rng};
|
||||
@@ -241,7 +241,7 @@ mod test {
|
||||
let ct = CompressedFheUint8::try_encrypt(0_u64, &client_key).unwrap();
|
||||
|
||||
assert!(ct.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
)));
|
||||
|
||||
let breaker_lists = [
|
||||
@@ -265,7 +265,7 @@ mod test {
|
||||
breaker(i, &mut ct_clone);
|
||||
|
||||
assert!(!ct_clone.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -296,7 +296,7 @@ mod test {
|
||||
breaker(i, &mut ct_clone);
|
||||
|
||||
assert!(!ct_clone.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -313,7 +313,7 @@ mod test {
|
||||
let ct = CompressedFheUint8::try_encrypt(0_u64, &client_key).unwrap();
|
||||
|
||||
assert!(ct.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
)));
|
||||
|
||||
let mut rng = thread_rng();
|
||||
@@ -333,7 +333,7 @@ mod test {
|
||||
.0 = rng.gen::<u128>();
|
||||
}
|
||||
assert!(ct_clone.is_conformant(&FheUintConformanceParams::from(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
)));
|
||||
|
||||
let mut ct_clone_decompressed = ct_clone.decompress();
|
||||
|
||||
@@ -4,9 +4,7 @@ use crate::high_level_api::tests::{setup_cpu, setup_default_cpu};
|
||||
use crate::high_level_api::{generate_keys, set_server_key, ConfigBuilder, FheUint8};
|
||||
use crate::integer::U256;
|
||||
use crate::safe_serialization::{DeserializationConfig, SerializationConfig};
|
||||
use crate::shortint::parameters::classic::compact_pk::*;
|
||||
use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::{
|
||||
ClientKey, CompactCiphertextList, CompactCiphertextListConformanceParams, CompactPublicKey,
|
||||
@@ -46,10 +44,9 @@ fn test_integer_compressed() {
|
||||
|
||||
#[test]
|
||||
fn test_integer_compressed_small() {
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
crate::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
)
|
||||
.build();
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
let clear = 12_837u16;
|
||||
@@ -137,10 +134,9 @@ fn test_multi_div_rem() {
|
||||
|
||||
#[test]
|
||||
fn test_small_uint128() {
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
crate::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M64,
|
||||
)
|
||||
.build();
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_PBS_KS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
|
||||
let (cks, sks) = generate_keys(config);
|
||||
|
||||
@@ -187,7 +183,7 @@ fn test_decompressed_public_key_encrypt() {
|
||||
#[test]
|
||||
fn test_compact_public_key_big() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
@@ -205,7 +201,7 @@ fn test_compact_public_key_big() {
|
||||
#[test]
|
||||
fn test_compact_public_key_small() {
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64)
|
||||
.use_custom_parameters(V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_PBS_KS_GAUSSIAN_2M64)
|
||||
.build();
|
||||
let (client_key, _) = generate_keys(config);
|
||||
|
||||
@@ -402,7 +398,7 @@ fn test_sum() {
|
||||
|
||||
#[test]
|
||||
fn test_safe_deserialize_conformant_fhe_uint32() {
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let (client_key, server_key) =
|
||||
generate_keys(ConfigBuilder::with_custom_parameters(block_params));
|
||||
set_server_key(server_key.clone());
|
||||
@@ -486,9 +482,9 @@ fn test_safe_deserialize_conformant_compact_fhe_uint32() {
|
||||
|
||||
#[test]
|
||||
fn test_cpk_encrypt_cast_compute_hl() {
|
||||
let param_pke_only = V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_fhe = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_ksk = V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_pke_only = V1_0_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_fhe = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_ksk = V1_0_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let num_block = 4usize;
|
||||
|
||||
@@ -535,9 +531,9 @@ fn test_cpk_encrypt_cast_compute_hl() {
|
||||
|
||||
#[test]
|
||||
fn test_compressed_cpk_encrypt_cast_compute_hl() {
|
||||
let param_pke_only = V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_fhe = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_ksk = V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let param_pke_only = V1_0_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_fhe = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let param_ksk = V1_0_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let num_block = 4usize;
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ impl Default for IntegerConfig {
|
||||
fn default() -> Self {
|
||||
#[cfg(not(feature = "gpu"))]
|
||||
let params =
|
||||
crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into();
|
||||
crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into();
|
||||
#[cfg(feature = "gpu")]
|
||||
let params =
|
||||
crate::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
|
||||
@@ -274,17 +274,15 @@ impl ParameterSetConformant for CompressedCompactPublicKey {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::conformance::ParameterSetConformant;
|
||||
use crate::shortint::parameters::{
|
||||
CompactPublicKeyEncryptionParameters,
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64,
|
||||
};
|
||||
use crate::shortint::parameters::current_params::V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::{
|
||||
generate_keys, ClientKey, CompactPublicKey, CompressedCompactPublicKey, ConfigBuilder,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn conformance_compact_public_key() {
|
||||
let params = V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64;
|
||||
let params = V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128;
|
||||
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params)
|
||||
@@ -302,11 +300,11 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn conformance_compact_public_key_casting() {
|
||||
let params = crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let cpk_params = crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let cpk_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let casting_params = crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let casting_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params));
|
||||
@@ -320,7 +318,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn conformance_compressed_compact_public_key() {
|
||||
let params = V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64;
|
||||
let params = V1_0_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M128;
|
||||
|
||||
let config = ConfigBuilder::default()
|
||||
.use_custom_parameters(params)
|
||||
@@ -338,11 +336,13 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn conformance_compressed_compact_public_key_casting() {
|
||||
let params = crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let cpk_params = crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let cpk_params =
|
||||
crate::shortint::parameters::PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let casting_params = crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let casting_params =
|
||||
crate::shortint::parameters::PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params));
|
||||
|
||||
@@ -430,23 +430,27 @@ impl ParameterSetConformant for CompressedServerKey {
|
||||
mod test {
|
||||
use crate::high_level_api::keys::inner::IntegerServerKeyConformanceParams;
|
||||
use crate::prelude::ParameterSetConformant;
|
||||
use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs;
|
||||
use crate::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::{
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::shortint::{ClassicPBSParameters, PBSParameters};
|
||||
use crate::{ClientKey, CompressedServerKey, ConfigBuilder, ServerKey};
|
||||
|
||||
#[test]
|
||||
fn conformance_hl_key() {
|
||||
{
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.build();
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.build();
|
||||
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = ServerKey::new(&ck);
|
||||
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
|
||||
let conformance_params = IntegerServerKeyConformanceParams {
|
||||
sk_param,
|
||||
@@ -457,30 +461,31 @@ mod test {
|
||||
assert!(sk.is_conformant(&conformance_params));
|
||||
}
|
||||
{
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.build();
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
|
||||
.build();
|
||||
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = ServerKey::new(&ck);
|
||||
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
|
||||
let conformance_params = IntegerServerKeyConformanceParams {
|
||||
sk_param,
|
||||
cpk_param: None,
|
||||
compression_param: Some(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64),
|
||||
compression_param: Some(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128),
|
||||
};
|
||||
|
||||
assert!(sk.is_conformant(&conformance_params));
|
||||
}
|
||||
{
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let cpk_params = ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let cpk_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let casting_params = crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let casting_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params));
|
||||
@@ -488,7 +493,7 @@ mod test {
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = ServerKey::new(&ck);
|
||||
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
|
||||
let conformance_params = IntegerServerKeyConformanceParams {
|
||||
sk_param,
|
||||
@@ -503,9 +508,10 @@ mod test {
|
||||
#[test]
|
||||
fn broken_conformance_hl_key() {
|
||||
{
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.build();
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.build();
|
||||
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = ServerKey::new(&ck);
|
||||
@@ -518,7 +524,7 @@ mod test {
|
||||
sk_param.polynomial_size.0 += 1;
|
||||
},
|
||||
] {
|
||||
let mut sk_param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let mut sk_param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
modifier(&mut sk_param);
|
||||
|
||||
@@ -534,11 +540,11 @@ mod test {
|
||||
}
|
||||
}
|
||||
{
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let mut cpk_params = ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let mut cpk_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let casting_params = crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let casting_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params));
|
||||
@@ -546,7 +552,7 @@ mod test {
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = ServerKey::new(&ck);
|
||||
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
|
||||
cpk_params.encryption_lwe_dimension.0 += 1;
|
||||
|
||||
@@ -563,14 +569,15 @@ mod test {
|
||||
#[test]
|
||||
fn conformance_compressed_hl_key() {
|
||||
{
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.build();
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.build();
|
||||
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = CompressedServerKey::new(&ck);
|
||||
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
|
||||
let conformance_params = IntegerServerKeyConformanceParams {
|
||||
sk_param,
|
||||
@@ -582,30 +589,30 @@ mod test {
|
||||
}
|
||||
{
|
||||
let config = crate::ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.enable_compression(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
|
||||
.build();
|
||||
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = CompressedServerKey::new(&ck);
|
||||
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
|
||||
let conformance_params = IntegerServerKeyConformanceParams {
|
||||
sk_param,
|
||||
cpk_param: None,
|
||||
compression_param: Some(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64),
|
||||
compression_param: Some(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128),
|
||||
};
|
||||
|
||||
assert!(sk.is_conformant(&conformance_params));
|
||||
}
|
||||
{
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let cpk_params = ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let cpk_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let casting_params = crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let casting_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params));
|
||||
@@ -613,7 +620,7 @@ mod test {
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = CompressedServerKey::new(&ck);
|
||||
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
|
||||
let conformance_params = IntegerServerKeyConformanceParams {
|
||||
sk_param,
|
||||
@@ -628,9 +635,10 @@ mod test {
|
||||
#[test]
|
||||
fn broken_conformance_compressed_hl_key() {
|
||||
{
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
.build();
|
||||
let config = ConfigBuilder::with_custom_parameters(
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)
|
||||
.build();
|
||||
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = CompressedServerKey::new(&ck);
|
||||
@@ -643,7 +651,7 @@ mod test {
|
||||
sk_param.polynomial_size.0 += 1;
|
||||
},
|
||||
] {
|
||||
let mut sk_param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let mut sk_param = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
modifier(&mut sk_param);
|
||||
|
||||
@@ -659,11 +667,11 @@ mod test {
|
||||
}
|
||||
}
|
||||
{
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let mut cpk_params = ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let mut cpk_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let casting_params = crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let casting_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let config = ConfigBuilder::with_custom_parameters(params)
|
||||
.use_dedicated_compact_public_key_parameters((cpk_params, casting_params));
|
||||
@@ -671,7 +679,7 @@ mod test {
|
||||
let ck = ClientKey::generate(config);
|
||||
let sk = CompressedServerKey::new(&ck);
|
||||
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let sk_param = PBSParameters::PBS(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128);
|
||||
|
||||
cpk_params.encryption_lwe_dimension.0 += 1;
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ fn test_serialize_deserialize_are_implemented() {
|
||||
|
||||
#[test]
|
||||
fn test_try_from_single_lwe_encryption_key() {
|
||||
let parameters = crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let parameters = crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let lwe_sk = crate::shortint::engine::ShortintEngine::with_thread_local_mut(|engine| {
|
||||
crate::core_crypto::algorithms::allocate_and_generate_new_binary_lwe_secret_key(
|
||||
parameters
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
use crate::prelude::*;
|
||||
use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::*;
|
||||
use crate::shortint::ClassicPBSParameters;
|
||||
use crate::shortint::parameters::{
|
||||
ClassicPBSParameters, CompactPublicKeyEncryptionParameters, CompressionParameters,
|
||||
ShortintKeySwitchingParameters, COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
#[cfg(feature = "gpu")]
|
||||
use crate::shortint::parameters::{
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64, PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
};
|
||||
use crate::{
|
||||
set_server_key, ClientKey, CompactCiphertextList, CompactCiphertextListExpander,
|
||||
CompactPublicKey, CompressedCiphertextList, CompressedCiphertextListBuilder, CompressedFheBool,
|
||||
@@ -16,15 +23,15 @@ use rand::random;
|
||||
fn test_tag_propagation_cpu() {
|
||||
test_tag_propagation(
|
||||
Device::Cpu,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
Some((
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)),
|
||||
Some(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64),
|
||||
Some(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128),
|
||||
Some((
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)),
|
||||
)
|
||||
}
|
||||
@@ -32,14 +39,14 @@ fn test_tag_propagation_cpu() {
|
||||
#[test]
|
||||
#[cfg(feature = "zk-pok")]
|
||||
fn test_tag_propagation_zk_pok() {
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
use crate::ProvenCompactCiphertextList;
|
||||
|
||||
let config =
|
||||
ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64)
|
||||
ConfigBuilder::with_custom_parameters(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128)
|
||||
.use_dedicated_compact_public_key_parameters((
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
))
|
||||
.build();
|
||||
let crs = crate::zk::CompactPkeCrs::from_config(config, (2 * 32) + (2 * 64) + 2).unwrap();
|
||||
@@ -145,12 +152,13 @@ fn test_tag_propagation_zk_pok() {
|
||||
fn test_tag_propagation_gpu() {
|
||||
test_tag_propagation(
|
||||
Device::CudaGpu,
|
||||
// TODO GPU DRIFT_UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
None,
|
||||
Some(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64),
|
||||
Some((
|
||||
V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ impl RadixCiphertext {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // 8 bits
|
||||
/// let (cks, sks) = gen_keys_radix(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64, 4);
|
||||
/// let (cks, sks) = gen_keys_radix(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, 4);
|
||||
///
|
||||
/// let msg = 124u8;
|
||||
/// let msg2 = 17u8;
|
||||
@@ -170,10 +170,10 @@ impl SignedRadixCiphertext {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::{gen_keys_radix, SignedRadixCiphertext};
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // 8 bits
|
||||
/// let (cks, sks) = gen_keys_radix(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64, 4);
|
||||
/// let (cks, sks) = gen_keys_radix(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, 4);
|
||||
///
|
||||
/// let msg = -35i8;
|
||||
/// let msg2 = 17i8;
|
||||
|
||||
@@ -24,11 +24,11 @@ use tfhe_versionable::Versionize;
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64, size);
|
||||
/// let (cks, sks) = gen_keys_radix(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, size);
|
||||
///
|
||||
/// let a = 128u8;
|
||||
/// let b = 55u8;
|
||||
@@ -83,11 +83,11 @@ impl BooleanBlock {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::{gen_keys_radix, BooleanBlock};
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64, size);
|
||||
/// let (cks, sks) = gen_keys_radix(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, size);
|
||||
///
|
||||
/// let a = 128u8;
|
||||
/// let ct_a = cks.encrypt(a);
|
||||
@@ -142,10 +142,10 @@ impl BooleanBlock {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // 8 bits
|
||||
/// let (cks, sks) = gen_keys_radix(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64, 4);
|
||||
/// let (cks, sks) = gen_keys_radix(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, 4);
|
||||
///
|
||||
/// let msg = false;
|
||||
/// let msg2 = true;
|
||||
|
||||
@@ -828,9 +828,9 @@ impl CompactCiphertextList {
|
||||
/// RadixCiphertext, SignedRadixCiphertext,
|
||||
/// };
|
||||
/// use tfhe::integer::{ClientKey, CompactPublicKey};
|
||||
/// use tfhe::shortint::parameters::classic::compact_pk::V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let fhe_params = V0_11_PARAM_MESSAGE_2_CARRY_2_COMPACT_PK_KS_PBS_GAUSSIAN_2M64;
|
||||
/// let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let num_blocks = 4usize;
|
||||
///
|
||||
@@ -1152,23 +1152,27 @@ mod tests {
|
||||
use crate::integer::{
|
||||
BooleanBlock, ClientKey, CompactPrivateKey, CompactPublicKey, RadixCiphertext, ServerKey,
|
||||
};
|
||||
use crate::shortint::parameters::classic::tuniform::p_fail_2_minus_64::ks_pbs::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::compact_public_key_only::p_fail_2_minus_64::ks_pbs::{
|
||||
V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1,
|
||||
};
|
||||
use crate::shortint::parameters::key_switching::p_fail_2_minus_64::ks_pbs::{
|
||||
V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V0_11_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1,
|
||||
use crate::shortint::parameters::{
|
||||
PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
};
|
||||
use crate::zk::{CompactPkeCrs, ZkComputeLoad};
|
||||
use crate::shortint::parameters::current_params::compact_public_key_only::p_fail_2_minus_128::ks_pbs::{
|
||||
V1_0_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1,
|
||||
};
|
||||
use crate::shortint::parameters::current_params::key_switching::p_fail_2_minus_128::ks_pbs::{
|
||||
V1_0_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
V1_0_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1,
|
||||
};
|
||||
use rand::random;
|
||||
|
||||
#[test]
|
||||
fn test_zk_compact_ciphertext_list_encryption_ci_run_filter() {
|
||||
let pke_params = V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let ksk_params = V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let pke_params = PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
@@ -1229,11 +1233,11 @@ mod tests {
|
||||
/// Test a compact list encryption proven with the v1 zk scheme
|
||||
#[test]
|
||||
fn test_zkv1_compact_ciphertext_list_encryption_ci_run_filter() {
|
||||
let pke_params = V0_11_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1;
|
||||
let pke_params = V1_0_PARAM_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1;
|
||||
let ksk_params =
|
||||
V0_11_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64_ZKV1;
|
||||
V1_0_PARAM_KEYSWITCH_PKE_TO_BIG_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128_ZKV1;
|
||||
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
@@ -1293,9 +1297,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_several_proven_lists() {
|
||||
let pke_params = V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let ksk_params = V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let pke_params = V1_0_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = V1_0_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
@@ -1356,9 +1360,9 @@ mod tests {
|
||||
fn test_malicious_boolean_proven_lists() {
|
||||
use super::DataKind;
|
||||
|
||||
let pke_params = V0_11_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let ksk_params = V0_11_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let pke_params = V1_0_PARAM_PKE_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let ksk_params = V1_0_PARAM_KEYSWITCH_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
let fhe_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
|
||||
let metadata = [b'i', b'n', b't', b'e', b'g', b'e', b'r'];
|
||||
|
||||
|
||||
@@ -156,17 +156,17 @@ impl CompressedCiphertextList {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::integer::{gen_keys, IntegerKeyKind};
|
||||
use crate::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::multi_bit::tuniform::p_fail_2_minus_64::ks_pbs::V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::ShortintParameterSet;
|
||||
use crate::shortint::parameters::current_params::classic::tuniform::p_fail_2_minus_128::ks_pbs::V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
use crate::shortint::parameters::current_params::list_compression::p_fail_2_minus_128::V1_0_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128;
|
||||
use crate::shortint::parameters::current_params::multi_bit::tuniform::p_fail_2_minus_64::ks_pbs::V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use itertools::Itertools;
|
||||
use rand::Rng;
|
||||
|
||||
const NB_TESTS: usize = 10;
|
||||
const NB_OPERATOR_TESTS: usize = 10;
|
||||
const NUM_BLOCKS: usize = 32;
|
||||
const MAX_NB_MESSAGES: usize = 2 * COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
const MAX_NB_MESSAGES: usize = 2 * V1_0_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128
|
||||
.lwe_per_glwe
|
||||
.0
|
||||
/ NUM_BLOCKS;
|
||||
@@ -174,13 +174,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_ciphertext_compression() {
|
||||
for params in [
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
V1_0_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128.into(),
|
||||
V1_0_PARAM_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
] {
|
||||
let (cks, sks) = gen_keys::<ShortintParameterSet>(params, IntegerKeyKind::Radix);
|
||||
|
||||
let private_compression_key =
|
||||
cks.new_compression_private_key(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
let private_compression_key = cks.new_compression_private_key(
|
||||
V1_0_COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M128,
|
||||
);
|
||||
|
||||
let (compression_key, decompression_key) =
|
||||
cks.new_compression_decompression_keys(&private_compression_key);
|
||||
|
||||
@@ -17,15 +17,13 @@ use crate::shortint::parameters::Degree;
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
/// use tfhe::shortint::PBSParameters;
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix::<PBSParameters>(
|
||||
/// V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
/// size,
|
||||
/// );
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix::<PBSParameters>(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128.into(), size);
|
||||
///
|
||||
/// let clear = 3u8;
|
||||
///
|
||||
@@ -62,15 +60,13 @@ impl ParameterSetConformant for CompressedModulusSwitchedRadixCiphertext {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
/// use tfhe::shortint::PBSParameters;
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix::<PBSParameters>(
|
||||
/// V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64.into(),
|
||||
/// size,
|
||||
/// );
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys_radix::<PBSParameters>(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128.into(), size);
|
||||
///
|
||||
/// let clear = -3i8;
|
||||
///
|
||||
|
||||
@@ -13,10 +13,10 @@ use tfhe_versionable::Versionize;
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::CrtClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let basis = vec![2, 3, 5];
|
||||
/// let cks = CrtClientKey::new(V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64, basis);
|
||||
/// let cks = CrtClientKey::new(PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128, basis);
|
||||
///
|
||||
/// let msg = 13_u64;
|
||||
///
|
||||
|
||||
@@ -132,12 +132,12 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // Generate the client key, that can encrypt in
|
||||
/// // radix and crt decomposition, where each block of the decomposition
|
||||
/// // have over 2 bits of message modulus.
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
/// ```
|
||||
pub fn new<P>(parameter_set: P) -> Self
|
||||
where
|
||||
@@ -155,12 +155,12 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // Generate the client key, that can encrypt in
|
||||
/// // radix and crt decomposition, where each block of the decomposition
|
||||
/// // have over 2 bits of message modulus.
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
///
|
||||
/// let key = cks.into_raw_parts();
|
||||
/// ```
|
||||
@@ -174,12 +174,12 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // Generate the client key, that can encrypt in
|
||||
/// // radix and crt decomposition, where each block of the decomposition
|
||||
/// // have over 2 bits of message modulus.
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
///
|
||||
/// let key = cks.into_raw_parts();
|
||||
///
|
||||
@@ -213,9 +213,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
/// let num_block = 4;
|
||||
///
|
||||
/// let msg = 167_u64;
|
||||
@@ -239,9 +239,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
/// let num_block = 4;
|
||||
///
|
||||
/// let msg = 167_u64;
|
||||
@@ -314,9 +314,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
/// let num_block = 4;
|
||||
///
|
||||
/// let msg = 191_u64;
|
||||
@@ -342,9 +342,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
/// let num_block = 4;
|
||||
///
|
||||
/// let msg = 191_u64;
|
||||
@@ -489,9 +489,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
///
|
||||
/// let msg = 2_u64;
|
||||
///
|
||||
@@ -510,11 +510,11 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64, size);
|
||||
/// let (cks, sks) = gen_keys_radix(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, size);
|
||||
///
|
||||
/// let a = cks.encrypt_bool(false);
|
||||
/// let dec = cks.decrypt_bool(&a);
|
||||
@@ -545,9 +545,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::{BooleanBlock, ClientKey};
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
///
|
||||
/// let a = cks.encrypt_one_block(1u64);
|
||||
/// let wrapped = BooleanBlock::new_unchecked(a);
|
||||
@@ -564,9 +564,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
///
|
||||
/// let msg = 13_u64;
|
||||
///
|
||||
@@ -604,10 +604,10 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128);
|
||||
///
|
||||
/// let msg = 27_u64;
|
||||
/// let basis: Vec<u64> = vec![2, 3, 5];
|
||||
@@ -642,9 +642,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128);
|
||||
///
|
||||
/// let msg = 13_u64;
|
||||
///
|
||||
@@ -683,9 +683,9 @@ impl ClientKey {
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// let cks = ClientKey::new(V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let cks = ClientKey::new(PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M128);
|
||||
///
|
||||
/// let msg = 27_u64;
|
||||
/// let basis: Vec<u64> = vec![2, 3, 5];
|
||||
|
||||
@@ -22,14 +22,11 @@ use tfhe_versionable::Versionize;
|
||||
///
|
||||
/// ```rust
|
||||
/// use tfhe::integer::RadixClientKey;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128;
|
||||
///
|
||||
/// // 2 * 4 = 8 bits of message
|
||||
/// let num_block = 4;
|
||||
/// let cks = RadixClientKey::new(
|
||||
/// V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
/// num_block,
|
||||
/// );
|
||||
/// let cks = RadixClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M128, num_block);
|
||||
///
|
||||
/// let msg = 167_u64;
|
||||
///
|
||||
|
||||
@@ -110,25 +110,27 @@ impl CudaBooleanBlock {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::BooleanBlock;
|
||||
/// use tfhe::shortint::parameters::V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut stream = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let stream = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 1;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(
|
||||
/// V0_11_PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
/// num_blocks,
|
||||
/// &mut stream,
|
||||
/// &stream,
|
||||
/// );
|
||||
///
|
||||
/// let msg1 = true;
|
||||
/// let ct1 = cks.encrypt_bool(msg1);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let d_ct1 = CudaBooleanBlock::from_boolean_block(&ct1, &mut stream);
|
||||
/// let ct2 = d_ct1.to_boolean_block(&mut stream);
|
||||
/// let d_ct1 = CudaBooleanBlock::from_boolean_block(&ct1, &stream);
|
||||
/// let ct2 = d_ct1.to_boolean_block(&stream);
|
||||
/// let res = cks.decrypt_bool(&ct2);
|
||||
///
|
||||
/// assert_eq!(msg1, res);
|
||||
|
||||
@@ -141,26 +141,32 @@ impl CudaCompressedCiphertextList {
|
||||
/// use tfhe::integer::gpu::ciphertext::compressed_ciphertext_list::CudaCompressedCiphertextListBuilder;
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaSignedRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// use tfhe::shortint::parameters::{
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
/// };
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// let compression_params = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// let num_blocks = 32;
|
||||
/// let streams = CudaStreams::new_multi_gpu();
|
||||
///
|
||||
/// let (radix_cks, _) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// let (radix_cks, _) = gen_keys_radix_gpu(block_params,
|
||||
/// num_blocks,
|
||||
/// &streams,
|
||||
/// );
|
||||
/// let cks = radix_cks.as_ref();
|
||||
///
|
||||
/// let private_compression_key =
|
||||
/// cks.new_compression_private_key(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
/// cks.new_compression_private_key(compression_params);
|
||||
///
|
||||
/// let (cuda_compression_key, cuda_decompression_key) =
|
||||
/// radix_cks.new_cuda_compression_decompression_keys(&private_compression_key, &streams);
|
||||
///
|
||||
/// let private_compression_key =
|
||||
/// cks.new_compression_private_key(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
/// cks.new_compression_private_key(compression_params);
|
||||
///
|
||||
/// let (compressed_compression_key, compressed_decompression_key) =
|
||||
/// radix_cks.new_compressed_compression_decompression_keys(&private_compression_key);
|
||||
@@ -174,7 +180,7 @@ impl CudaCompressedCiphertextList {
|
||||
/// let ct2 = radix_cks.encrypt_signed(-2);
|
||||
/// let ct3 = radix_cks.encrypt_bool(true);
|
||||
///
|
||||
/// /// Copy to GPU
|
||||
/// // Copy to GPU
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct2, &streams);
|
||||
/// let d_ct3 = CudaBooleanBlock::from_boolean_block(&ct3, &streams);
|
||||
@@ -258,24 +264,26 @@ impl CompressedCiphertextList {
|
||||
///```rust
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::ciphertext::CompressedCiphertextListBuilder;
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaSignedRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::ciphertext::boolean_value::CudaBooleanBlock;
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaSignedRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// use tfhe::shortint::parameters::{
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// };
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let block_params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// let compression_params = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// let num_blocks = 32;
|
||||
/// let streams = CudaStreams::new_multi_gpu();
|
||||
///
|
||||
/// let (radix_cks, _) = gen_keys_radix_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// num_blocks,
|
||||
/// &streams,
|
||||
/// );
|
||||
/// let (radix_cks, _) = gen_keys_radix_gpu(block_params, num_blocks, &streams);
|
||||
/// let cks = radix_cks.as_ref();
|
||||
///
|
||||
/// let private_compression_key =
|
||||
/// cks.new_compression_private_key(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
/// let private_compression_key = cks.new_compression_private_key(compression_params);
|
||||
///
|
||||
/// let (compressed_compression_key, compressed_decompression_key) =
|
||||
/// radix_cks.new_compressed_compression_decompression_keys(&private_compression_key);
|
||||
@@ -286,7 +294,7 @@ impl CompressedCiphertextList {
|
||||
/// radix_cks.parameters().message_modulus(),
|
||||
/// radix_cks.parameters().carry_modulus(),
|
||||
/// radix_cks.parameters().ciphertext_modulus(),
|
||||
/// &streams
|
||||
/// &streams,
|
||||
/// );
|
||||
///
|
||||
/// let compression_key = compressed_compression_key.decompress();
|
||||
@@ -306,20 +314,26 @@ impl CompressedCiphertextList {
|
||||
///
|
||||
/// assert_eq!(recovered_cuda_compressed, compressed);
|
||||
///
|
||||
/// let d_decompressed1: CudaUnsignedRadixCiphertext =
|
||||
/// cuda_compressed.get(0, &cuda_decompression_key, &streams).unwrap().unwrap();
|
||||
/// let d_decompressed1: CudaUnsignedRadixCiphertext = cuda_compressed
|
||||
/// .get(0, &cuda_decompression_key, &streams)
|
||||
/// .unwrap()
|
||||
/// .unwrap();
|
||||
/// let decompressed1 = d_decompressed1.to_radix_ciphertext(&streams);
|
||||
/// let decrypted: u32 = radix_cks.decrypt(&decompressed1);
|
||||
/// assert_eq!(decrypted, 3_u32);
|
||||
///
|
||||
/// let d_decompressed2: CudaSignedRadixCiphertext =
|
||||
/// cuda_compressed.get(1, &cuda_decompression_key, &streams).unwrap().unwrap();
|
||||
/// let d_decompressed2: CudaSignedRadixCiphertext = cuda_compressed
|
||||
/// .get(1, &cuda_decompression_key, &streams)
|
||||
/// .unwrap()
|
||||
/// .unwrap();
|
||||
/// let decompressed2 = d_decompressed2.to_signed_radix_ciphertext(&streams);
|
||||
/// let decrypted: i32 = radix_cks.decrypt_signed(&decompressed2);
|
||||
/// assert_eq!(decrypted, -2);
|
||||
///
|
||||
/// let d_decompressed3: CudaBooleanBlock =
|
||||
/// cuda_compressed.get(2, &cuda_decompression_key, &streams).unwrap().unwrap();
|
||||
/// let d_decompressed3: CudaBooleanBlock = cuda_compressed
|
||||
/// .get(2, &cuda_decompression_key, &streams)
|
||||
/// .unwrap()
|
||||
/// .unwrap();
|
||||
/// let decompressed3 = d_decompressed3.to_boolean_block(&streams);
|
||||
/// let decrypted = radix_cks.decrypt_bool(&decompressed3);
|
||||
/// assert!(decrypted);
|
||||
@@ -520,10 +534,11 @@ mod tests {
|
||||
use crate::integer::ciphertext::CompressedCiphertextListBuilder;
|
||||
use crate::integer::gpu::gen_keys_radix_gpu;
|
||||
use crate::integer::{ClientKey, RadixCiphertext, RadixClientKey};
|
||||
use crate::shortint::parameters::list_compression::COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use crate::shortint::parameters::{
|
||||
// TODO GPU DRIFT UPDATE
|
||||
COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
};
|
||||
use crate::shortint::ShortintParameterSet;
|
||||
use rand::Rng;
|
||||
@@ -536,6 +551,7 @@ mod tests {
|
||||
const NUM_BLOCKS: usize = 32;
|
||||
let streams = CudaStreams::new_multi_gpu();
|
||||
|
||||
// TODO GPU DRIFT UPDATE
|
||||
let params = PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
let comp_params = COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
|
||||
@@ -560,6 +576,7 @@ mod tests {
|
||||
|
||||
// How many uints of NUM_BLOCKS we have to push in the list to ensure it
|
||||
// internally has more than one packed GLWE
|
||||
// TODO GPU DRIFT UPDATE
|
||||
const MAX_NB_MESSAGES: usize = 1 + 2 * COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
.lwe_per_glwe
|
||||
.0
|
||||
@@ -685,19 +702,22 @@ mod tests {
|
||||
let streams = CudaStreams::new_multi_gpu();
|
||||
|
||||
for params in [
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64.into(),
|
||||
] {
|
||||
let (radix_cks, sks) =
|
||||
gen_keys_radix_gpu::<ShortintParameterSet>(params, NUM_BLOCKS, &streams);
|
||||
let cks = radix_cks.as_ref();
|
||||
|
||||
// TODO GPU DRIFT UPDATE
|
||||
let private_compression_key =
|
||||
cks.new_compression_private_key(COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
|
||||
let (cuda_compression_key, cuda_decompression_key) = radix_cks
|
||||
.new_cuda_compression_decompression_keys(&private_compression_key, &streams);
|
||||
|
||||
// TODO GPU DRIFT UPDATE
|
||||
const MAX_NB_MESSAGES: usize = 2 * COMP_PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
.lwe_per_glwe
|
||||
.0
|
||||
|
||||
@@ -188,17 +188,19 @@ impl CudaUnsignedRadixCiphertext {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// let size = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// size,
|
||||
/// &mut streams,
|
||||
/// &streams,
|
||||
/// );
|
||||
///
|
||||
/// let clear: u64 = 255;
|
||||
@@ -206,8 +208,8 @@ impl CudaUnsignedRadixCiphertext {
|
||||
/// // Encrypt two messages
|
||||
/// let ctxt = cks.encrypt(clear);
|
||||
///
|
||||
/// let mut d_ctxt = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt, &mut streams);
|
||||
/// let mut h_ctxt = d_ctxt.to_radix_ciphertext(&mut streams);
|
||||
/// let d_ctxt = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt, &streams);
|
||||
/// let h_ctxt = d_ctxt.to_radix_ciphertext(&streams);
|
||||
///
|
||||
/// assert_eq!(h_ctxt, ctxt);
|
||||
/// ```
|
||||
@@ -253,25 +255,27 @@ impl CudaUnsignedRadixCiphertext {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// num_blocks,
|
||||
/// &mut streams,
|
||||
/// &streams,
|
||||
/// );
|
||||
///
|
||||
/// let msg1 = 10u32;
|
||||
/// let ct1 = cks.encrypt(msg1);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &mut streams);
|
||||
/// let ct2 = d_ct1.to_radix_ciphertext(&mut streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let ct2 = d_ct1.to_radix_ciphertext(&streams);
|
||||
/// let msg2 = cks.decrypt(&ct2);
|
||||
///
|
||||
/// assert_eq!(msg1, msg2);
|
||||
@@ -296,17 +300,19 @@ impl CudaSignedRadixCiphertext {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// let size = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// size,
|
||||
/// &mut streams,
|
||||
/// &streams,
|
||||
/// );
|
||||
///
|
||||
/// let clear: i64 = 255;
|
||||
@@ -314,8 +320,8 @@ impl CudaSignedRadixCiphertext {
|
||||
/// // Encrypt two messages
|
||||
/// let ctxt = cks.encrypt_signed(clear);
|
||||
///
|
||||
/// let mut d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &mut streams);
|
||||
/// let mut h_ctxt = d_ctxt.to_signed_radix_ciphertext(&mut streams);
|
||||
/// let d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
/// let h_ctxt = d_ctxt.to_signed_radix_ciphertext(&streams);
|
||||
///
|
||||
/// assert_eq!(h_ctxt, ctxt);
|
||||
/// ```
|
||||
@@ -368,25 +374,27 @@ impl CudaSignedRadixCiphertext {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// num_blocks,
|
||||
/// &mut streams,
|
||||
/// &streams,
|
||||
/// );
|
||||
///
|
||||
/// let msg1 = 10i32;
|
||||
/// let ct1 = cks.encrypt_signed(msg1);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let d_ct1 = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct1, &mut streams);
|
||||
/// let ct2 = d_ct1.to_signed_radix_ciphertext(&mut streams);
|
||||
/// let d_ct1 = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct1, &streams);
|
||||
/// let ct2 = d_ct1.to_signed_radix_ciphertext(&streams);
|
||||
/// let msg2 = cks.decrypt_signed(&ct2);
|
||||
///
|
||||
/// assert_eq!(msg1, msg2);
|
||||
@@ -405,27 +413,29 @@ impl CudaRadixCiphertext {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaIntegerRadixCiphertext, CudaSignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// num_blocks,
|
||||
/// &mut streams,
|
||||
/// &streams,
|
||||
/// );
|
||||
///
|
||||
/// let msg = 10i32;
|
||||
/// let ct = cks.encrypt_signed(msg);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let d_ct = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct, &mut streams);
|
||||
/// let d_ct_copied = d_ct.duplicate(&mut streams);
|
||||
/// let d_ct = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct_copied = d_ct.duplicate(&streams);
|
||||
///
|
||||
/// let ct_copied = d_ct_copied.to_signed_radix_ciphertext(&mut streams);
|
||||
/// let ct_copied = d_ct_copied.to_signed_radix_ciphertext(&streams);
|
||||
/// let msg_copied = cks.decrypt_signed(&ct_copied);
|
||||
///
|
||||
/// assert_eq!(msg, msg_copied);
|
||||
|
||||
@@ -200,13 +200,15 @@ where
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// // generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &mut streams);
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
/// ```
|
||||
pub fn gen_keys_radix_gpu<P>(
|
||||
parameters_set: P,
|
||||
|
||||
@@ -49,16 +49,18 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::CudaServerKey;
|
||||
/// use tfhe::integer::ClientKey;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key:
|
||||
/// let cks = ClientKey::new(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
///
|
||||
/// // Generate the server key:
|
||||
/// let sks = CudaServerKey::new(&cks, &mut streams);
|
||||
/// let sks = CudaServerKey::new(&cks, &streams);
|
||||
/// ```
|
||||
pub fn new<C>(cks: C, streams: &CudaStreams) -> Self
|
||||
where
|
||||
@@ -168,11 +170,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::CudaServerKey;
|
||||
/// use tfhe::integer::{ClientKey, CompressedServerKey, ServerKey};
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let size = 4;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let cks = ClientKey::new(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
/// let compressed_sks = CompressedServerKey::new_radix_compressed_server_key(&cks);
|
||||
/// let cuda_sks = CudaServerKey::decompress_from_cpu(&compressed_sks, &streams);
|
||||
|
||||
@@ -101,11 +101,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
|
||||
@@ -36,6 +36,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
@@ -43,6 +44,7 @@ impl CudaServerKey {
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let msg1 = 14;
|
||||
@@ -136,11 +138,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
@@ -418,11 +422,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
@@ -594,11 +600,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaSignedRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
|
||||
@@ -28,11 +28,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -121,11 +123,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -137,7 +141,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a bitwise and:
|
||||
@@ -268,11 +272,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -284,7 +290,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a bitwise and:
|
||||
@@ -335,11 +341,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -351,7 +359,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a bitwise and:
|
||||
@@ -402,11 +410,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -418,7 +428,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a bitwise and:
|
||||
@@ -508,11 +518,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -524,7 +536,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a bitwise and:
|
||||
@@ -613,11 +625,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -629,7 +643,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a bitwise and:
|
||||
@@ -719,11 +733,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
|
||||
@@ -146,11 +146,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -162,7 +164,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_eq(&d_ct1, &d_ct2, &streams);
|
||||
@@ -220,11 +222,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -236,7 +240,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_ne(&d_ct1, &d_ct2, &streams);
|
||||
@@ -319,11 +323,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -335,7 +341,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.eq(&d_ct1, &d_ct2, &streams);
|
||||
@@ -413,11 +419,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -429,7 +437,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.ne(&d_ct1, &d_ct2, &streams);
|
||||
@@ -477,11 +485,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -493,7 +503,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_gt(&d_ct1, &d_ct2, &streams);
|
||||
@@ -601,11 +611,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -617,7 +629,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_ge(&d_ct1, &d_ct2, &streams);
|
||||
@@ -725,11 +737,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -741,7 +755,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_lt(&d_ct1, &d_ct2, &streams);
|
||||
@@ -849,11 +863,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -865,7 +881,7 @@ impl CudaServerKey {
|
||||
/// let ct2 = cks.encrypt(msg2);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct2, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_le(&d_ct1, &d_ct2, &streams);
|
||||
|
||||
@@ -511,13 +511,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let number_of_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -526,10 +528,10 @@ impl CudaServerKey {
|
||||
/// // Encrypt two messages
|
||||
/// let ctxt = cks.encrypt_signed_radix(msg, number_of_blocks);
|
||||
///
|
||||
/// let mut d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
/// let d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
///
|
||||
/// // Compute homomorphically trailing zeros
|
||||
/// let mut d_ct_res = sks.trailing_zeros(&d_ctxt, &streams);
|
||||
/// let d_ct_res = sks.trailing_zeros(&d_ctxt, &streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
@@ -584,13 +586,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let number_of_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -599,10 +603,10 @@ impl CudaServerKey {
|
||||
/// // Encrypt two messages
|
||||
/// let ctxt = cks.encrypt_signed_radix(msg, number_of_blocks);
|
||||
///
|
||||
/// let mut d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
/// let d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
///
|
||||
/// // Compute homomorphically trailing ones
|
||||
/// let mut d_ct_res = sks.trailing_ones(&d_ctxt, &streams);
|
||||
/// let d_ct_res = sks.trailing_ones(&d_ctxt, &streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
@@ -657,13 +661,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let number_of_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -672,10 +678,10 @@ impl CudaServerKey {
|
||||
/// // Encrypt two messages
|
||||
/// let ctxt = cks.encrypt_signed_radix(msg, number_of_blocks);
|
||||
///
|
||||
/// let mut d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
/// let d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
///
|
||||
/// // Compute homomorphically leading zeros
|
||||
/// let mut d_ct_res = sks.leading_zeros(&d_ctxt, &streams);
|
||||
/// let d_ct_res = sks.leading_zeros(&d_ctxt, &streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
@@ -730,13 +736,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let number_of_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -745,10 +753,10 @@ impl CudaServerKey {
|
||||
/// // Encrypt two messages
|
||||
/// let ctxt = cks.encrypt_signed_radix(msg, number_of_blocks);
|
||||
///
|
||||
/// let mut d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
/// let d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
///
|
||||
/// // Compute homomorphically leading ones
|
||||
/// let mut d_ct_res = sks.leading_ones(&d_ctxt, &streams);
|
||||
/// let d_ct_res = sks.leading_ones(&d_ctxt, &streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
@@ -796,13 +804,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let number_of_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -811,10 +821,10 @@ impl CudaServerKey {
|
||||
/// // Encrypt two messages
|
||||
/// let ctxt = cks.encrypt_signed_radix(msg, number_of_blocks);
|
||||
///
|
||||
/// let mut d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
/// let d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a log2
|
||||
/// let mut d_ct_res = sks.ilog2(&d_ctxt, &streams);
|
||||
/// let d_ct_res = sks.ilog2(&d_ctxt, &streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
@@ -866,13 +876,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let number_of_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -881,9 +893,9 @@ impl CudaServerKey {
|
||||
/// // Encrypt two messages
|
||||
/// let ctxt = cks.encrypt_signed_radix(msg, number_of_blocks);
|
||||
///
|
||||
/// let mut d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
/// let d_ctxt = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ctxt, &streams);
|
||||
/// // Compute homomorphically a log2 and a check if input is valid
|
||||
/// let (mut d_ct_res, mut d_is_oks) = sks.checked_ilog2(&d_ctxt, &streams);
|
||||
/// let (d_ct_res, d_is_oks) = sks.checked_ilog2(&d_ctxt, &streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
|
||||
@@ -72,14 +72,16 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let d_ctxt: CudaUnsignedRadixCiphertext =
|
||||
@@ -122,14 +124,16 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let d_ctxt: CudaUnsignedRadixCiphertext =
|
||||
@@ -441,17 +445,19 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let mut d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// let d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(7u64, num_blocks, &streams);
|
||||
/// let ct1 = d_ct1.to_radix_ciphertext(&streams);
|
||||
/// assert_eq!(ct1.blocks().len(), 4);
|
||||
@@ -462,6 +468,7 @@ impl CudaServerKey {
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
/// assert_eq!(ct_res.blocks().len(), 6);
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Decrypt
|
||||
/// let res: u64 = cks.decrypt(&ct_res);
|
||||
/// assert_eq!(
|
||||
@@ -534,17 +541,19 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let mut d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// let d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(7u64, num_blocks, &streams);
|
||||
/// let ct1 = d_ct1.to_radix_ciphertext(&streams);
|
||||
/// assert_eq!(ct1.blocks().len(), 4);
|
||||
@@ -616,17 +625,19 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let mut d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// let d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(119u64, num_blocks, &streams);
|
||||
/// let ct1 = d_ct1.to_radix_ciphertext(&streams);
|
||||
/// assert_eq!(ct1.blocks().len(), 4);
|
||||
@@ -698,17 +709,19 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let mut d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// let d_ct1: CudaUnsignedRadixCiphertext =
|
||||
/// sks.create_trivial_radix(119u64, num_blocks, &streams);
|
||||
/// let ct1 = d_ct1.to_radix_ciphertext(&streams);
|
||||
/// assert_eq!(ct1.blocks().len(), 4);
|
||||
@@ -1109,15 +1122,17 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// use tfhe::shortint::gen_keys;
|
||||
/// use tfhe::shortint::parameters::{
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64,
|
||||
/// PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
/// };
|
||||
/// {
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) =
|
||||
/// gen_keys(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64);
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(
|
||||
/// PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
@@ -1134,7 +1149,7 @@ impl CudaServerKey {
|
||||
/// let f2 = |x: u64| x.count_ones() as u64 % 4;
|
||||
/// // Easy to use for generation
|
||||
/// let luts = sks.generate_many_lookup_table(&[&f1, &f2]);
|
||||
/// let vec_res = unsafe { sks.apply_many_lookup_table_async(&d_ct.as_ref(), &luts, &streams) };
|
||||
/// let vec_res = unsafe { sks.apply_many_lookup_table_async(d_ct.as_ref(), &luts, &streams) };
|
||||
/// streams.synchronize();
|
||||
/// // Need to manually help Rust to iterate over them easily
|
||||
/// let functions: &[&dyn Fn(u64) -> u64] = &[&f1, &f2];
|
||||
@@ -1149,12 +1164,13 @@ impl CudaServerKey {
|
||||
/// }
|
||||
/// }
|
||||
/// {
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys(V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let (cks, sks) = gen_keys(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64);
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(V0_11_PARAM_MESSAGE_3_CARRY_3_KS_PBS_GAUSSIAN_2M64, &streams);
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64, &streams);
|
||||
/// let num_blocks = 2;
|
||||
/// let msg = 3;
|
||||
/// let ct = cks.encrypt_radix(msg, num_blocks);
|
||||
@@ -1166,7 +1182,7 @@ impl CudaServerKey {
|
||||
/// let f2 = |x: u64| x.count_ones() as u64 % 8;
|
||||
/// // Easy to use for generation
|
||||
/// let luts = sks.generate_many_lookup_table(&[&f1, &f2]);
|
||||
/// let vec_res = unsafe { sks.apply_many_lookup_table_async(&d_ct.as_ref(), &luts, &streams) };
|
||||
/// let vec_res = unsafe { sks.apply_many_lookup_table_async(d_ct.as_ref(), &luts, &streams) };
|
||||
/// streams.synchronize();
|
||||
/// // Need to manually help Rust to iterate over them easily
|
||||
/// let functions: &[&dyn Fn(u64) -> u64] = &[&f1, &f2];
|
||||
@@ -1547,18 +1563,20 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::IntegerCiphertext;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let num_blocks = 4;
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let msg = -2i8;
|
||||
///
|
||||
/// let mut ct1 = cks.encrypt_signed(msg);
|
||||
/// let ct1 = cks.encrypt_signed(msg);
|
||||
/// assert_eq!(ct1.blocks().len(), 4);
|
||||
/// let d_ct1 = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct1, &streams);
|
||||
///
|
||||
@@ -1653,18 +1671,20 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, IntegerCiphertext};
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let num_blocks = 8;
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// // Generate the client key and the server key:
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
/// let msg = u16::MAX;
|
||||
///
|
||||
/// let mut ct1 = cks.encrypt(msg);
|
||||
/// let ct1 = cks.encrypt(msg);
|
||||
/// assert_eq!(ct1.blocks().len(), num_blocks);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
///
|
||||
|
||||
@@ -18,20 +18,22 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let number_of_blocks = 2;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
/// let modulus = PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
/// .message_modulus
|
||||
/// .0
|
||||
/// .pow(number_of_blocks as u32) as u64;
|
||||
/// .pow(number_of_blocks as u32);
|
||||
/// let clear_1: u64 = 13 % modulus;
|
||||
/// let clear_2: u64 = 4 % modulus;
|
||||
///
|
||||
@@ -39,11 +41,11 @@ impl CudaServerKey {
|
||||
/// let ctxt_1 = cks.encrypt_radix(clear_1, number_of_blocks);
|
||||
/// let ctxt_2 = cks.encrypt_radix(clear_2, number_of_blocks);
|
||||
///
|
||||
/// let mut d_ctxt_1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt_1, &streams);
|
||||
/// let d_ctxt_1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt_1, &streams);
|
||||
/// let d_ctxt_2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt_2, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a multiplication
|
||||
/// let mut d_ct_res = sks.unchecked_mul(&mut d_ctxt_1, &d_ctxt_2, &streams);
|
||||
/// let d_ct_res = sks.unchecked_mul(&d_ctxt_1, &d_ctxt_2, &streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
@@ -152,20 +154,22 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let number_of_blocks = 2;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
/// let modulus = PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
/// .message_modulus
|
||||
/// .0
|
||||
/// .pow(number_of_blocks as u32) as u64;
|
||||
/// .pow(number_of_blocks as u32);
|
||||
/// let clear_1: u64 = 13 % modulus;
|
||||
/// let clear_2: u64 = 4 % modulus;
|
||||
///
|
||||
@@ -173,11 +177,11 @@ impl CudaServerKey {
|
||||
/// let ctxt_1 = cks.encrypt_radix(clear_1, number_of_blocks);
|
||||
/// let ctxt_2 = cks.encrypt_radix(clear_2, number_of_blocks);
|
||||
///
|
||||
/// let mut d_ctxt_1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt_1, &streams);
|
||||
/// let d_ctxt_1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt_1, &streams);
|
||||
/// let d_ctxt_2 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt_2, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a multiplication
|
||||
/// let mut d_ct_res = sks.mul(&mut d_ctxt_1, &d_ctxt_2, &streams);
|
||||
/// let d_ct_res = sks.mul(&d_ctxt_1, &d_ctxt_2, &streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
/// let ct_res = d_ct_res.to_radix_ciphertext(&streams);
|
||||
|
||||
@@ -20,11 +20,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let modulus = 1 << 8;
|
||||
@@ -33,11 +35,11 @@ impl CudaServerKey {
|
||||
/// let msg = 159u64;
|
||||
///
|
||||
/// // Encrypt a message
|
||||
/// let mut ctxt = cks.encrypt(msg);
|
||||
/// let mut d_ctxt = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt, &streams);
|
||||
/// let ctxt = cks.encrypt(msg);
|
||||
/// let d_ctxt = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a negation
|
||||
/// let d_res = sks.unchecked_neg(&mut d_ctxt, &streams);
|
||||
/// let d_res = sks.unchecked_neg(&d_ctxt, &streams);
|
||||
/// let res = d_res.to_radix_ciphertext(&streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
@@ -93,11 +95,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let modulus = 1 << 8;
|
||||
@@ -106,11 +110,11 @@ impl CudaServerKey {
|
||||
/// let msg = 159u64;
|
||||
///
|
||||
/// // Encrypt a message
|
||||
/// let mut ctxt = cks.encrypt(msg);
|
||||
/// let mut d_ctxt = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt, &streams);
|
||||
/// let ctxt = cks.encrypt(msg);
|
||||
/// let d_ctxt = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ctxt, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a negation
|
||||
/// let d_res = sks.neg(&mut d_ctxt, &streams);
|
||||
/// let d_res = sks.neg(&d_ctxt, &streams);
|
||||
/// let res = d_res.to_radix_ciphertext(&streams);
|
||||
///
|
||||
/// // Decrypt
|
||||
|
||||
@@ -35,6 +35,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// use tfhe::Seed;
|
||||
///
|
||||
@@ -42,6 +43,7 @@ impl CudaServerKey {
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -125,6 +127,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// use tfhe::Seed;
|
||||
///
|
||||
@@ -132,6 +135,7 @@ impl CudaServerKey {
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let size = 4;
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -226,6 +230,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// use tfhe::Seed;
|
||||
///
|
||||
@@ -233,6 +238,7 @@ impl CudaServerKey {
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let size = 4;
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -287,6 +293,7 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::CudaStreams;
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::gen_keys_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
/// use tfhe::Seed;
|
||||
///
|
||||
@@ -294,6 +301,7 @@ impl CudaServerKey {
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let size = 4;
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, &streams);
|
||||
///
|
||||
@@ -569,6 +577,7 @@ pub(crate) mod test {
|
||||
use crate::integer::gpu::{gen_keys_gpu, CudaServerKey};
|
||||
use crate::integer::{ClientKey, RadixCiphertext};
|
||||
use crate::shortint::oprf::create_random_from_seed_modulus_switched;
|
||||
// TODO GPU DRIFT UPDATE
|
||||
use crate::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
use rayon::prelude::*;
|
||||
use statrs::distribution::ContinuousCDF;
|
||||
@@ -583,6 +592,7 @@ pub(crate) mod test {
|
||||
fn oprf_compare_plain_ci_run_filter() {
|
||||
let gpu_index = 0;
|
||||
let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
// TODO GPU DRIFT UPDATE
|
||||
let (ck, gpu_sk) = gen_keys_gpu(
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
&streams,
|
||||
@@ -673,6 +683,7 @@ pub(crate) mod test {
|
||||
let p_value_limit: f64 = 0.000_01;
|
||||
let gpu_index = 0;
|
||||
let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
// TODO GPU DRIFT UPDATE
|
||||
let (ck, gpu_sk) = gen_keys_gpu(
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
&streams,
|
||||
|
||||
@@ -346,11 +346,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -361,8 +363,8 @@ impl CudaServerKey {
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let rotate_ct = cks.encrypt(rotate);
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let mut d_rotate_ct =
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_rotate_ct =
|
||||
/// CudaUnsignedRadixCiphertext::from_radix_ciphertext(&rotate_ct, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.rotate_right(&d_ct, &d_rotate_ct, &streams);
|
||||
@@ -500,11 +502,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -515,8 +519,8 @@ impl CudaServerKey {
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let rotate_ct = cks.encrypt(rotate);
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let mut d_rotate_ct =
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_rotate_ct =
|
||||
/// CudaUnsignedRadixCiphertext::from_radix_ciphertext(&rotate_ct, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.rotate_left(&d_ct, &d_rotate_ct, &streams);
|
||||
|
||||
@@ -27,11 +27,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -40,7 +42,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 40;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically an addition:
|
||||
/// let d_ct_res = sks.unchecked_scalar_add(&d_ct, scalar, &streams);
|
||||
@@ -134,11 +136,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -147,7 +151,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 40;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically an addition:
|
||||
/// let d_ct_res = sks.scalar_add(&d_ct, scalar, &streams);
|
||||
@@ -284,11 +288,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaSignedRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
|
||||
@@ -627,13 +627,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// let size = 4;
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
///
|
||||
@@ -643,7 +645,7 @@ impl CudaServerKey {
|
||||
/// let ct1 = cks.encrypt(msg1);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.scalar_eq(&d_ct1, msg2, &streams);
|
||||
///
|
||||
@@ -709,13 +711,15 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// use tfhe::integer::{gen_keys_radix, RadixCiphertext};
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// let size = 4;
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
///
|
||||
@@ -725,7 +729,7 @@ impl CudaServerKey {
|
||||
/// let ct1 = cks.encrypt(msg1);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.scalar_ne(&d_ct1, msg2, &streams);
|
||||
///
|
||||
|
||||
@@ -74,20 +74,26 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(
|
||||
/// PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
/// size,
|
||||
/// &streams,
|
||||
/// );
|
||||
///
|
||||
/// let msg = 30;
|
||||
/// let scalar = 3;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar division:
|
||||
/// let d_ct_res = sks.unchecked_scalar_div(&d_ct, scalar, &streams);
|
||||
@@ -242,11 +248,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -255,7 +263,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 3;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar multiplication:
|
||||
/// let d_ct_res = sks.scalar_div(&d_ct, scalar, &streams);
|
||||
@@ -368,11 +376,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -381,7 +391,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 3;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar multiplication:
|
||||
/// let (d_ct_q, d_ct_r) = sks.scalar_div_rem(&d_ct, scalar, &streams);
|
||||
@@ -482,11 +492,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -495,7 +507,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 3;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar multiplication:
|
||||
/// let d_ct_res = sks.scalar_rem(&d_ct, scalar, &streams);
|
||||
@@ -720,11 +732,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -733,7 +747,7 @@ impl CudaServerKey {
|
||||
/// let scalar = -3;
|
||||
///
|
||||
/// let ct = cks.encrypt_signed(msg);
|
||||
/// let mut d_ct = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar division:
|
||||
/// let d_ct_res = sks.signed_scalar_div(&d_ct, scalar, &streams);
|
||||
@@ -835,11 +849,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -848,7 +864,7 @@ impl CudaServerKey {
|
||||
/// let scalar = -3;
|
||||
///
|
||||
/// let ct = cks.encrypt_signed(msg);
|
||||
/// let mut d_ct = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar division:
|
||||
/// let (d_ct_q, d_ct_r) = sks.signed_scalar_div_rem(&d_ct, scalar, &streams);
|
||||
@@ -950,11 +966,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaSignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -963,7 +981,7 @@ impl CudaServerKey {
|
||||
/// let scalar = -3;
|
||||
///
|
||||
/// let ct = cks.encrypt_signed(msg);
|
||||
/// let mut d_ct = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaSignedRadixCiphertext::from_signed_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar multiplication:
|
||||
/// let d_ct_res = sks.signed_scalar_rem(&d_ct, scalar, &streams);
|
||||
|
||||
@@ -24,11 +24,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -37,7 +39,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 3;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar multiplication:
|
||||
/// let d_ct_res = sks.unchecked_scalar_mul(&d_ct, scalar, &streams);
|
||||
@@ -196,11 +198,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -209,7 +213,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 3;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically a scalar multiplication:
|
||||
/// let d_ct_res = sks.scalar_mul(&d_ct, scalar, &streams);
|
||||
|
||||
@@ -112,11 +112,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -126,7 +128,7 @@ impl CudaServerKey {
|
||||
///
|
||||
/// let ct1 = cks.encrypt(msg);
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_scalar_left_shift(&d_ct1, shift, &streams);
|
||||
///
|
||||
@@ -311,11 +313,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -325,7 +329,7 @@ impl CudaServerKey {
|
||||
///
|
||||
/// let ct1 = cks.encrypt(msg);
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_scalar_right_shift(&d_ct1, shift, &streams);
|
||||
///
|
||||
@@ -404,11 +408,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -418,7 +424,7 @@ impl CudaServerKey {
|
||||
///
|
||||
/// let ct1 = cks.encrypt(msg);
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.scalar_right_shift(&d_ct1, shift, &streams);
|
||||
///
|
||||
@@ -492,11 +498,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -506,7 +514,7 @@ impl CudaServerKey {
|
||||
///
|
||||
/// let ct1 = cks.encrypt(msg);
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
/// let d_ct1 = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct1, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.scalar_left_shift(&d_ct1, shift, &streams);
|
||||
///
|
||||
|
||||
@@ -23,11 +23,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
@@ -36,7 +38,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 3;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically an addition:
|
||||
/// let d_ct_res = sks.unchecked_scalar_sub(&d_ct, scalar, &streams);
|
||||
@@ -108,11 +110,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
@@ -121,7 +125,7 @@ impl CudaServerKey {
|
||||
/// let scalar = 3;
|
||||
///
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
///
|
||||
/// // Compute homomorphically an addition:
|
||||
/// let d_ct_res = sks.scalar_sub(&d_ct, scalar, &streams);
|
||||
@@ -178,11 +182,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaSignedRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
|
||||
@@ -342,11 +342,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -357,8 +359,8 @@ impl CudaServerKey {
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let shift_ct = cks.encrypt(shift as u64);
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let mut d_shift_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&shift_ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_shift_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&shift_ct, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.unchecked_right_shift(&d_ct, &d_shift_ct, &streams);
|
||||
///
|
||||
@@ -495,11 +497,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let mut streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let size = 4;
|
||||
/// // Generate the client key and the server key:
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -510,8 +514,8 @@ impl CudaServerKey {
|
||||
/// let ct = cks.encrypt(msg);
|
||||
/// let shift_ct = cks.encrypt(shift as u64);
|
||||
/// // Copy to GPU
|
||||
/// let mut d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let mut d_shift_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&shift_ct, &streams);
|
||||
/// let d_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&ct, &streams);
|
||||
/// let d_shift_ct = CudaUnsignedRadixCiphertext::from_radix_ciphertext(&shift_ct, &streams);
|
||||
///
|
||||
/// let d_ct_res = sks.left_shift(&d_ct, &d_shift_ct, &streams);
|
||||
///
|
||||
|
||||
@@ -28,11 +28,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
///
|
||||
@@ -111,11 +113,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::integer::gen_keys_radix;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
@@ -170,11 +174,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::CudaUnsignedRadixCiphertext;
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // We have 4 * 2 = 8 bits of message
|
||||
/// let size = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, size, &streams);
|
||||
@@ -183,7 +189,7 @@ impl CudaServerKey {
|
||||
/// let msg_2 = 181u8;
|
||||
///
|
||||
/// // Encrypt two messages:
|
||||
/// let mut ct1 = cks.encrypt(msg_1 as u64);
|
||||
/// let ct1 = cks.encrypt(msg_1 as u64);
|
||||
/// let ct2 = cks.encrypt(msg_2 as u64);
|
||||
///
|
||||
/// // Copy to GPU
|
||||
@@ -434,11 +440,13 @@ impl CudaServerKey {
|
||||
/// use tfhe::core_crypto::gpu::vec::GpuIndex;
|
||||
/// use tfhe::integer::gpu::ciphertext::{CudaSignedRadixCiphertext, CudaUnsignedRadixCiphertext};
|
||||
/// use tfhe::integer::gpu::gen_keys_radix_gpu;
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// use tfhe::shortint::parameters::PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64;
|
||||
///
|
||||
/// let gpu_index = 0;
|
||||
/// let streams = CudaStreams::new_single_gpu(GpuIndex::new(gpu_index));
|
||||
///
|
||||
/// # // TODO GPU DRIFT UPDATE
|
||||
/// // Generate the client key and the server key:
|
||||
/// let num_blocks = 4;
|
||||
/// let (cks, sks) = gen_keys_radix_gpu(PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64, num_blocks, &streams);
|
||||
|
||||
@@ -7,12 +7,15 @@ use crate::integer::server_key::radix_parallel::tests_long_run::test_erc20::{
|
||||
use crate::shortint::parameters::*;
|
||||
|
||||
create_gpu_parameterized_test!(safe_erc20 {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
});
|
||||
create_gpu_parameterized_test!(whitepaper_erc20 {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
});
|
||||
create_gpu_parameterized_test!(no_cmux_erc20 {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ use crate::shortint::parameters::*;
|
||||
use std::cmp::{max, min};
|
||||
|
||||
create_gpu_parameterized_test!(random_op_sequence {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
});
|
||||
fn random_op_sequence<P>(param: P)
|
||||
|
||||
@@ -7,9 +7,11 @@ use crate::integer::server_key::radix_parallel::tests_long_run::test_signed_erc2
|
||||
use crate::shortint::parameters::*;
|
||||
|
||||
create_gpu_parameterized_test!(signed_whitepaper_erc20 {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
});
|
||||
create_gpu_parameterized_test!(signed_no_cmux_erc20 {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
});
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ use crate::shortint::parameters::*;
|
||||
use std::cmp::{max, min};
|
||||
|
||||
create_gpu_parameterized_test!(signed_random_op_sequence {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64
|
||||
});
|
||||
fn signed_random_op_sequence<P>(param: P)
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::integer::gpu::CudaServerKey;
|
||||
use crate::integer::server_key::radix_parallel::tests_signed::test_abs::{
|
||||
signed_default_absolute_value_test, signed_unchecked_absolute_value_test,
|
||||
};
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
|
||||
create_gpu_parameterized_test!(integer_signed_unchecked_abs);
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::integer::gpu::CudaServerKey;
|
||||
use crate::integer::server_key::radix_parallel::tests_signed::test_add::{
|
||||
signed_default_add_test, signed_unchecked_add_test, signed_unchecked_overflowing_add_test,
|
||||
};
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
|
||||
create_gpu_parameterized_test!(integer_unchecked_add);
|
||||
|
||||
@@ -7,6 +7,7 @@ use crate::integer::server_key::radix_parallel::tests_signed::test_bitwise_op::{
|
||||
signed_default_bitxor_test, signed_unchecked_bitand_test, signed_unchecked_bitor_test,
|
||||
signed_unchecked_bitxor_test,
|
||||
};
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
|
||||
create_gpu_parameterized_test!(integer_signed_unchecked_bitand);
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::integer::gpu::CudaServerKey;
|
||||
use crate::integer::server_key::radix_parallel::tests_signed::test_cmux::{
|
||||
signed_default_if_then_else_test, signed_unchecked_if_then_else_test,
|
||||
};
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
|
||||
create_gpu_parameterized_test!(integer_unchecked_if_then_else);
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::integer::server_key::radix_parallel::tests_signed::test_comparison::{
|
||||
test_signed_default_function, test_signed_default_minmax, test_signed_unchecked_function,
|
||||
test_signed_unchecked_minmax,
|
||||
};
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
|
||||
/// This macro generates the tests for a given comparison fn
|
||||
@@ -44,11 +45,13 @@ macro_rules! define_gpu_signed_comparison_test_functions {
|
||||
|
||||
// Then call our create_gpu_parameterized_test macro onto or specialized fns
|
||||
create_gpu_parameterized_test!([<integer_signed_unchecked_ $comparison_name _ $clear_type>]{
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
});
|
||||
create_gpu_parameterized_test!([<integer_signed_default_ $comparison_name _ $clear_type>]{
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
@@ -90,21 +93,25 @@ where
|
||||
}
|
||||
|
||||
create_gpu_parameterized_test!(integer_signed_unchecked_max_128_bits {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
});
|
||||
create_gpu_parameterized_test!(integer_signed_unchecked_min_128_bits {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
});
|
||||
create_gpu_parameterized_test!(integer_signed_max_128_bits {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
});
|
||||
create_gpu_parameterized_test!(integer_signed_min_128_bits {
|
||||
// TODO GPU DRIFT UPDATE
|
||||
PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
PARAM_GPU_MULTI_BIT_GROUP_3_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64,
|
||||
V1_0_PARAM_GPU_MULTI_BIT_GROUP_2_MESSAGE_2_CARRY_2_KS_PBS_GAUSSIAN_2M64,
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::integer::gpu::server_key::radix::tests_unsigned::{
|
||||
};
|
||||
use crate::integer::gpu::CudaServerKey;
|
||||
use crate::integer::server_key::radix_parallel::tests_signed::test_div_rem::signed_unchecked_div_rem_test;
|
||||
use crate::shortint::parameters::current_params::*;
|
||||
use crate::shortint::parameters::*;
|
||||
|
||||
create_gpu_parameterized_test!(integer_signed_unchecked_div_rem);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user