diff --git a/tfhe/src/strings/mod.rs b/tfhe/src/strings/mod.rs index 9e63d3f7cb..9a1079d499 100644 --- a/tfhe/src/strings/mod.rs +++ b/tfhe/src/strings/mod.rs @@ -9,3 +9,6 @@ mod test_functions; // Used as the const argument for StaticUnsignedBigInt, specifying the max chars length of a // ClearString const N: usize = 32; + +pub use client_key::ClientKey; +pub use server_key::ServerKey; diff --git a/tfhe/src/strings/server_key/comp.rs b/tfhe/src/strings/server_key/comp.rs index 16342ac0d1..0b6ea4720d 100644 --- a/tfhe/src/strings/server_key/comp.rs +++ b/tfhe/src/strings/server_key/comp.rs @@ -57,13 +57,15 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s1, s2) = ("hello", "hello"); /// /// let enc_s1 = FheString::new(&ck, s1, None); /// let enc_s2 = GenericPattern::Enc(FheString::new(&ck, s2, None)); /// /// let result = sk.string_eq(&enc_s1, enc_s2.as_ref()); - /// let are_equal = ck.decrypt_bool(&result); + /// let are_equal = ck.inner().decrypt_bool(&result); /// /// assert!(are_equal); /// ``` @@ -115,13 +117,15 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s1, s2) = ("hello", "world"); /// /// let enc_s1 = FheString::new(&ck, s1, None); /// let enc_s2 = GenericPattern::Enc(FheString::new(&ck, s2, None)); /// /// let result = sk.string_ne(&enc_s1, enc_s2.as_ref()); - /// let are_not_equal = ck.decrypt_bool(&result); + /// let are_not_equal = ck.inner().decrypt_bool(&result); /// /// assert!(are_not_equal); /// ``` @@ -146,13 +150,15 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s1, s2) = ("apple", "banana"); /// /// let enc_s1 = FheString::new(&ck, s1, None); /// let enc_s2 = GenericPattern::Enc(FheString::new(&ck, s2, None)); /// /// let result = sk.string_lt(&enc_s1, enc_s2.as_ref()); - /// let is_lt = ck.decrypt_bool(&result); + /// let is_lt = ck.inner().decrypt_bool(&result); /// /// assert!(is_lt); // "apple" is less than "banana" /// ``` @@ -184,13 +190,15 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s1, s2) = ("banana", "apple"); /// /// let enc_s1 = FheString::new(&ck, s1, None); /// let enc_s2 = GenericPattern::Enc(FheString::new(&ck, s2, None)); /// /// let result = sk.string_gt(&enc_s1, enc_s2.as_ref()); - /// let is_gt = ck.decrypt_bool(&result); + /// let is_gt = ck.inner().decrypt_bool(&result); /// /// assert!(is_gt); // "banana" is greater than "apple" /// ``` @@ -222,13 +230,15 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s1, s2) = ("apple", "banana"); /// /// let enc_s1 = FheString::new(&ck, s1, None); /// let enc_s2 = GenericPattern::Enc(FheString::new(&ck, s2, None)); /// /// let result = sk.string_le(&enc_s1, enc_s2.as_ref()); - /// let is_le = ck.decrypt_bool(&result); + /// let is_le = ck.inner().decrypt_bool(&result); /// /// assert!(is_le); // "apple" is less than or equal to "banana" /// ``` @@ -259,13 +269,15 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s1, s2) = ("banana", "apple"); /// /// let enc_s1 = FheString::new(&ck, s1, None); /// let enc_s2 = GenericPattern::Enc(FheString::new(&ck, s2, None)); /// /// let result = sk.string_ge(&enc_s1, enc_s2.as_ref()); - /// let is_ge = ck.decrypt_bool(&result); + /// let is_ge = ck.inner().decrypt_bool(&result); /// /// assert!(is_ge); // "banana" is greater than or equal to "apple" /// ``` diff --git a/tfhe/src/strings/server_key/no_patterns.rs b/tfhe/src/strings/server_key/no_patterns.rs index b2fb814e34..82630f750a 100644 --- a/tfhe/src/strings/server_key/no_patterns.rs +++ b/tfhe/src/strings/server_key/no_patterns.rs @@ -22,6 +22,8 @@ impl + Sync> ServerKey { /// use tfhe::strings::server_key::FheStringLen; /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let s = "hello"; /// let number_of_nulls = 3; /// @@ -40,7 +42,7 @@ impl + Sync> ServerKey { /// FheStringLen::NoPadding(_) => panic!("Unexpected no padding"), /// FheStringLen::Padding(ciphertext) => { /// // Homomorphically computed length, requires decryption for actual length - /// let length = ck.decrypt_radix::(&ciphertext); + /// let length = ck.inner().decrypt_radix::(&ciphertext); /// assert_eq!(length, 5) /// } /// } @@ -85,6 +87,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let s = ""; /// let number_of_nulls = 2; /// @@ -103,7 +107,7 @@ impl + Sync> ServerKey { /// FheStringIsEmpty::NoPadding(_) => panic!("Unexpected no padding"), /// FheStringIsEmpty::Padding(ciphertext) => { /// // Homomorphically computed emptiness, requires decryption for actual value - /// let is_empty = ck.decrypt_bool(&ciphertext); + /// let is_empty = ck.inner().decrypt_bool(&ciphertext); /// assert!(is_empty) /// } /// } @@ -136,6 +140,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let s = "Hello World"; /// /// let enc_s = FheString::new(&ck, s, None); @@ -191,6 +197,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let s = "Hello World"; /// /// let enc_s = FheString::new(&ck, s, None); @@ -252,13 +260,15 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s1, s2) = ("Hello", "hello"); /// /// let enc_s1 = FheString::new(&ck, s1, None); /// let enc_s2 = GenericPattern::Enc(FheString::new(&ck, s2, None)); /// /// let result = sk.eq_ignore_case(&enc_s1, enc_s2.as_ref()); - /// let are_equal = ck.decrypt_bool(&result); + /// let are_equal = ck.inner().decrypt_bool(&result); /// /// assert!(are_equal); /// ``` @@ -289,6 +299,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (lhs, rhs) = ("Hello, ", "world!"); /// /// let enc_lhs = FheString::new(&ck, lhs, None); @@ -344,6 +356,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let s = "hi"; /// /// let enc_s = FheString::new(&ck, s, None); diff --git a/tfhe/src/strings/server_key/pattern/contains.rs b/tfhe/src/strings/server_key/pattern/contains.rs index 7b795249f6..4ec7a9afdf 100644 --- a/tfhe/src/strings/server_key/pattern/contains.rs +++ b/tfhe/src/strings/server_key/pattern/contains.rs @@ -93,6 +93,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (bananas, nana, apples) = ("bananas", "nana", "apples"); /// /// let enc_bananas = FheString::new(&ck, bananas, None); @@ -102,8 +104,8 @@ impl + Sync> ServerKey { /// let result1 = sk.contains(&enc_bananas, enc_nana.as_ref()); /// let result2 = sk.contains(&enc_bananas, clear_apples.as_ref()); /// - /// let should_be_true = ck.decrypt_bool(&result1); - /// let should_be_false = ck.decrypt_bool(&result2); + /// let should_be_true = ck.inner().decrypt_bool(&result1); + /// let should_be_false = ck.inner().decrypt_bool(&result2); /// /// assert!(should_be_true); /// assert!(!should_be_false); @@ -156,6 +158,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (bananas, ba, nan) = ("bananas", "ba", "nan"); /// /// let enc_bananas = FheString::new(&ck, bananas, None); @@ -165,8 +169,8 @@ impl + Sync> ServerKey { /// let result1 = sk.starts_with(&enc_bananas, enc_ba.as_ref()); /// let result2 = sk.starts_with(&enc_bananas, clear_nan.as_ref()); /// - /// let should_be_true = ck.decrypt_bool(&result1); - /// let should_be_false = ck.decrypt_bool(&result2); + /// let should_be_true = ck.inner().decrypt_bool(&result1); + /// let should_be_false = ck.inner().decrypt_bool(&result2); /// /// assert!(should_be_true); /// assert!(!should_be_false); @@ -236,6 +240,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (bananas, anas, nana) = ("bananas", "anas", "nana"); /// /// let enc_bananas = FheString::new(&ck, bananas, None); @@ -245,8 +251,8 @@ impl + Sync> ServerKey { /// let result1 = sk.ends_with(&enc_bananas, enc_anas.as_ref()); /// let result2 = sk.ends_with(&enc_bananas, clear_nana.as_ref()); /// - /// let should_be_true = ck.decrypt_bool(&result1); - /// let should_be_false = ck.decrypt_bool(&result2); + /// let should_be_true = ck.inner().decrypt_bool(&result1); + /// let should_be_false = ck.inner().decrypt_bool(&result2); /// /// assert!(should_be_true); /// assert!(!should_be_false); diff --git a/tfhe/src/strings/server_key/pattern/find.rs b/tfhe/src/strings/server_key/pattern/find.rs index 7ebf2c075e..f874169d3a 100644 --- a/tfhe/src/strings/server_key/pattern/find.rs +++ b/tfhe/src/strings/server_key/pattern/find.rs @@ -109,6 +109,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (haystack, needle) = ("hello world", "world"); /// /// let enc_haystack = FheString::new(&ck, haystack, None); @@ -116,8 +118,8 @@ impl + Sync> ServerKey { /// /// let (index, found) = sk.find(&enc_haystack, enc_needle.as_ref()); /// - /// let index = ck.decrypt_radix::(&index); - /// let found = ck.decrypt_bool(&found); + /// let index = ck.inner().decrypt_radix::(&index); + /// let found = ck.inner().decrypt_bool(&found); /// /// assert!(found); /// assert_eq!(index, 6); // "world" starts at index 6 in "hello world" @@ -185,6 +187,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (haystack, needle) = ("hello world world", "world"); /// /// let enc_haystack = FheString::new(&ck, haystack, None); @@ -192,8 +196,8 @@ impl + Sync> ServerKey { /// /// let (index, found) = sk.rfind(&enc_haystack, enc_needle.as_ref()); /// - /// let index = ck.decrypt_radix::(&index); - /// let found = ck.decrypt_bool(&found); + /// let index = ck.inner().decrypt_radix::(&index); + /// let found = ck.inner().decrypt_bool(&found); /// /// assert!(found); /// assert_eq!(index, 12); // The last "world" starts at index 12 in "hello world world" diff --git a/tfhe/src/strings/server_key/pattern/replace.rs b/tfhe/src/strings/server_key/pattern/replace.rs index 5bfd4db036..8a79ddd28a 100644 --- a/tfhe/src/strings/server_key/pattern/replace.rs +++ b/tfhe/src/strings/server_key/pattern/replace.rs @@ -219,6 +219,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, from, to) = ("hello", "l", "r"); /// /// let enc_s = FheString::new(&ck, s, None); @@ -348,6 +350,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, from, to) = ("hi", "i", "o"); /// /// let enc_s = FheString::new(&ck, s, None); diff --git a/tfhe/src/strings/server_key/pattern/split/mod.rs b/tfhe/src/strings/server_key/pattern/split/mod.rs index 45888d20a4..25192f4d34 100644 --- a/tfhe/src/strings/server_key/pattern/split/mod.rs +++ b/tfhe/src/strings/server_key/pattern/split/mod.rs @@ -82,6 +82,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = (" hello world", " "); /// let enc_s = FheString::new(&ck, s, None); /// let enc_pat = GenericPattern::Enc(FheString::new(&ck, pat, None)); @@ -90,7 +92,7 @@ impl + Sync> ServerKey { /// /// let lhs_decrypted = ck.decrypt_ascii(&lhs); /// let rhs_decrypted = ck.decrypt_ascii(&rhs); - /// let split_occurred = ck.decrypt_bool(&split_occurred); + /// let split_occurred = ck.inner().decrypt_bool(&split_occurred); /// /// assert_eq!(lhs_decrypted, " hello"); /// assert_eq!(rhs_decrypted, "world"); @@ -156,6 +158,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = (" hello world", " "); /// let enc_s = FheString::new(&ck, s, None); /// let enc_pat = GenericPattern::Enc(FheString::new(&ck, pat, None)); @@ -164,7 +168,7 @@ impl + Sync> ServerKey { /// /// let lhs_decrypted = ck.decrypt_ascii(&lhs); /// let rhs_decrypted = ck.decrypt_ascii(&rhs); - /// let split_occurred = ck.decrypt_bool(&split_occurred); + /// let split_occurred = ck.inner().decrypt_bool(&split_occurred); /// /// assert_eq!(lhs_decrypted, ""); /// assert_eq!(rhs_decrypted, "hello world"); diff --git a/tfhe/src/strings/server_key/pattern/split/split_iters.rs b/tfhe/src/strings/server_key/pattern/split/split_iters.rs index cbe67492b9..c995a89491 100644 --- a/tfhe/src/strings/server_key/pattern/split/split_iters.rs +++ b/tfhe/src/strings/server_key/pattern/split/split_iters.rs @@ -55,6 +55,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = ("hello ", " "); /// /// let enc_s = FheString::new(&ck, s, None); @@ -66,10 +68,10 @@ impl + Sync> ServerKey { /// let (_, no_more_items) = split_iter.next(&sk); // Attempting to get a third item /// /// let first_decrypted = ck.decrypt_ascii(&first_item); - /// let first_is_some = ck.decrypt_bool(&first_is_some); + /// let first_is_some = ck.inner().decrypt_bool(&first_is_some); /// let second_decrypted = ck.decrypt_ascii(&second_item); - /// let second_is_some = ck.decrypt_bool(&second_is_some); - /// let no_more_items = ck.decrypt_bool(&no_more_items); + /// let second_is_some = ck.inner().decrypt_bool(&second_is_some); + /// let no_more_items = ck.inner().decrypt_bool(&no_more_items); /// /// assert_eq!(first_decrypted, "hello"); /// assert!(first_is_some); // There is a first item @@ -103,6 +105,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = ("hello ", " "); /// /// let enc_s = FheString::new(&ck, s, None); @@ -114,10 +118,10 @@ impl + Sync> ServerKey { /// let (_, no_more_items) = rsplit_iter.next(&sk); // Attempting to get a third item /// /// let last_decrypted = ck.decrypt_ascii(&last_item); - /// let last_is_some = ck.decrypt_bool(&last_is_some); + /// let last_is_some = ck.inner().decrypt_bool(&last_is_some); /// let second_last_decrypted = ck.decrypt_ascii(&second_last_item); - /// let second_last_is_some = ck.decrypt_bool(&second_last_is_some); - /// let no_more_items = ck.decrypt_bool(&no_more_items); + /// let second_last_is_some = ck.inner().decrypt_bool(&second_last_is_some); + /// let no_more_items = ck.inner().decrypt_bool(&no_more_items); /// /// assert_eq!(last_decrypted, ""); /// assert!(last_is_some); // The last item is empty @@ -152,6 +156,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = ("hello world", " "); /// /// let enc_s = FheString::new(&ck, s, None); @@ -164,8 +170,8 @@ impl + Sync> ServerKey { /// let (_, no_more_items) = splitn_iter.next(&sk); // Attempting to get a second item /// /// let first_decrypted = ck.decrypt_ascii(&first_item); - /// let first_is_some = ck.decrypt_bool(&first_is_some); - /// let no_more_items = ck.decrypt_bool(&no_more_items); + /// let first_is_some = ck.inner().decrypt_bool(&first_is_some); + /// let no_more_items = ck.inner().decrypt_bool(&no_more_items); /// /// // We get the whole str as n is 1 /// assert_eq!(first_decrypted, "hello world"); @@ -207,6 +213,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = ("hello world", " "); /// /// let enc_s = FheString::new(&ck, s, None); @@ -219,8 +227,8 @@ impl + Sync> ServerKey { /// let (_, no_more_items) = rsplitn_iter.next(&sk); // Attempting to get a second item /// /// let last_decrypted = ck.decrypt_ascii(&last_item); - /// let last_is_some = ck.decrypt_bool(&last_is_some); - /// let no_more_items = ck.decrypt_bool(&no_more_items); + /// let last_is_some = ck.inner().decrypt_bool(&last_is_some); + /// let no_more_items = ck.inner().decrypt_bool(&no_more_items); /// /// // We get the whole str as n is 1 /// assert_eq!(last_decrypted, "hello world"); @@ -260,6 +268,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = ("hello world ", " "); /// /// let enc_s = FheString::new(&ck, s, None); @@ -271,10 +281,10 @@ impl + Sync> ServerKey { /// let (_, no_more_items) = split_terminator_iter.next(&sk); // Attempting to get a third item /// /// let first_decrypted = ck.decrypt_ascii(&first_item); - /// let first_is_some = ck.decrypt_bool(&first_is_some); + /// let first_is_some = ck.inner().decrypt_bool(&first_is_some); /// let second_decrypted = ck.decrypt_ascii(&second_item); - /// let second_is_some = ck.decrypt_bool(&second_is_some); - /// let no_more_items = ck.decrypt_bool(&no_more_items); + /// let second_is_some = ck.inner().decrypt_bool(&second_is_some); + /// let no_more_items = ck.inner().decrypt_bool(&no_more_items); /// /// assert_eq!(first_decrypted, "hello"); /// assert!(first_is_some); // There is a first item @@ -311,6 +321,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = ("hello world ", " "); /// /// let enc_s = FheString::new(&ck, s, None); @@ -322,10 +334,10 @@ impl + Sync> ServerKey { /// let (_, no_more_items) = rsplit_terminator_iter.next(&sk); // Attempting to get a third item /// /// let last_decrypted = ck.decrypt_ascii(&last_item); - /// let last_is_some = ck.decrypt_bool(&last_is_some); + /// let last_is_some = ck.inner().decrypt_bool(&last_is_some); /// let second_last_decrypted = ck.decrypt_ascii(&second_last_item); - /// let second_last_is_some = ck.decrypt_bool(&second_last_is_some); - /// let no_more_items = ck.decrypt_bool(&no_more_items); + /// let second_last_is_some = ck.inner().decrypt_bool(&second_last_is_some); + /// let no_more_items = ck.inner().decrypt_bool(&no_more_items); /// /// assert_eq!(last_decrypted, "world"); /// assert!(last_is_some); // The last item is "world" instead of "" @@ -365,6 +377,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, pat) = ("hello world ", " "); /// /// let enc_s = FheString::new(&ck, s, None); @@ -376,10 +390,10 @@ impl + Sync> ServerKey { /// let (_, no_more_items) = split_inclusive_iter.next(&sk); // Attempting to get a third item /// /// let first_decrypted = ck.decrypt_ascii(&first_item); - /// let first_is_some = ck.decrypt_bool(&first_is_some); + /// let first_is_some = ck.inner().decrypt_bool(&first_is_some); /// let second_decrypted = ck.decrypt_ascii(&second_item); - /// let second_is_some = ck.decrypt_bool(&second_is_some); - /// let no_more_items = ck.decrypt_bool(&no_more_items); + /// let second_is_some = ck.inner().decrypt_bool(&second_is_some); + /// let no_more_items = ck.inner().decrypt_bool(&no_more_items); /// /// assert_eq!(first_decrypted, "hello "); /// assert!(first_is_some); // The first item includes the delimiter diff --git a/tfhe/src/strings/server_key/pattern/strip.rs b/tfhe/src/strings/server_key/pattern/strip.rs index f65d5a69ea..80bb7646fe 100644 --- a/tfhe/src/strings/server_key/pattern/strip.rs +++ b/tfhe/src/strings/server_key/pattern/strip.rs @@ -116,6 +116,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, prefix, not_prefix) = ("hello world", "hello", "world"); /// /// let enc_s = FheString::new(&ck, s, None); @@ -124,11 +126,11 @@ impl + Sync> ServerKey { /// /// let (result, found) = sk.strip_prefix(&enc_s, enc_prefix.as_ref()); /// let stripped = ck.decrypt_ascii(&result); - /// let found = ck.decrypt_bool(&found); + /// let found = ck.inner().decrypt_bool(&found); /// /// let (result_no_match, not_found) = sk.strip_prefix(&enc_s, clear_not_prefix.as_ref()); /// let not_stripped = ck.decrypt_ascii(&result_no_match); - /// let not_found = ck.decrypt_bool(¬_found); + /// let not_found = ck.inner().decrypt_bool(¬_found); /// /// assert!(found); /// assert_eq!(stripped, " world"); // "hello" is stripped from "hello world" @@ -207,6 +209,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let (s, suffix, not_suffix) = ("hello world", "world", "hello"); /// /// let enc_s = FheString::new(&ck, s, None); @@ -215,11 +219,11 @@ impl + Sync> ServerKey { /// /// let (result, found) = sk.strip_suffix(&enc_s, enc_suffix.as_ref()); /// let stripped = ck.decrypt_ascii(&result); - /// let found = ck.decrypt_bool(&found); + /// let found = ck.inner().decrypt_bool(&found); /// /// let (result_no_match, not_found) = sk.strip_suffix(&enc_s, clear_not_suffix.as_ref()); /// let not_stripped = ck.decrypt_ascii(&result_no_match); - /// let not_found = ck.decrypt_bool(¬_found); + /// let not_found = ck.inner().decrypt_bool(¬_found); /// /// assert!(found); /// assert_eq!(stripped, "hello "); // "world" is stripped from "hello world" diff --git a/tfhe/src/strings/server_key/trim.rs b/tfhe/src/strings/server_key/trim.rs index 3163d218c4..8f68db1c23 100644 --- a/tfhe/src/strings/server_key/trim.rs +++ b/tfhe/src/strings/server_key/trim.rs @@ -203,6 +203,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let s = " hello world"; /// /// let enc_s = FheString::new(&ck, s, None); @@ -261,6 +263,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let s = "hello world "; /// /// let enc_s = FheString::new(&ck, s, None); @@ -303,6 +307,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); + /// let ck = tfhe::strings::ClientKey::new(ck); + /// let sk = tfhe::strings::ServerKey::new(sk); /// let s = " hello world "; /// /// let enc_s = FheString::new(&ck, s, None); @@ -341,6 +347,8 @@ impl + Sync> ServerKey { /// /// let ck = ClientKey::new(PARAM_MESSAGE_2_CARRY_2_KS_PBS_TUNIFORM_2M64); /// let sk = ServerKey::new_radix_server_key(&ck); +/// let ck = tfhe::strings::ClientKey::new(ck); +/// let sk = tfhe::strings::ServerKey::new(sk); /// let s = "hello \t\nworld "; /// /// let enc_s = FheString::new(&ck, s, None); @@ -351,11 +359,11 @@ impl + Sync> ServerKey { /// let (empty, no_more_items) = whitespace_iter.next(&sk); // Attempting to get a third item /// /// let first_decrypted = ck.decrypt_ascii(&first_item); -/// let first_is_some = ck.decrypt_bool(&first_is_some); +/// let first_is_some = ck.inner().decrypt_bool(&first_is_some); /// let second_decrypted = ck.decrypt_ascii(&second_item); -/// let second_is_some = ck.decrypt_bool(&second_is_some); +/// let second_is_some = ck.inner().decrypt_bool(&second_is_some); /// let empty = ck.decrypt_ascii(&empty); -/// let no_more_items = ck.decrypt_bool(&no_more_items); +/// let no_more_items = ck.inner().decrypt_bool(&no_more_items); /// /// assert_eq!(first_decrypted, "hello"); /// assert!(first_is_some);