Struct concrete::GenericShortInt
source · [−]pub struct GenericShortInt<P: ShortIntegerParameter> { /* private fields */ }
shortints
only.Expand description
A Generic short FHE unsigned integer
Short means less than 7 bits.
It is generic over some parameters, as its the parameters that controls how many bit they represent.
Its the type that overloads the operators (+
, -
, *
).
Since the GenericShortInt
type is not Copy
the operators are also overloaded
to work with references.
You will need to use one of this type specialization (e.g., FheUint2, FheUint3, FheUint4).
To be able to use this type, the cargo feature shortints
must be enabled,
and your config should also enable the type with either default parameters or custom ones.
Example
To use FheUint2
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
// Enable the FheUint2 type in the config
let config = ConfigBuilder::all_disabled().enable_default_uint2().build();
// With the FheUint2 type enabled in the config, the needed keys and details
// can be taken care of.
let (client_key, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(0, &client_key)?;
let b = FheUint2::try_encrypt(1, &client_key)?;
// Do not forget to set the server key before doing any computation
set_server_key(server_key);
// Since FHE types are bigger than native rust type they are not `Copy`,
// meaning that to reuse the same value in a computation and avoid the cost
// of calling `clone`, you'll have to use references:
let c = a + &b;
// `a` was moved but not `b`, so `a` cannot be reused, but `b` can
let d = &c + b;
// `b` was moved but not `c`, so `b` cannot be reused, but `c` can
let fhe_result = d + c;
// both `d` and `c` were moved.
let expected: u8 = {
let a = 0;
let b = 1;
let c = a + b;
let d = c + b;
d + c
};
let clear_result = fhe_result.decrypt(&client_key);
assert_eq!(expected, 3);
assert_eq!(clear_result, expected);
Implementations
sourceimpl<P> GenericShortInt<P>where
P: ShortIntegerParameter,
impl<P> GenericShortInt<P>where
P: ShortIntegerParameter,
pub fn message_max(&self) -> u64
pub fn message_modulus(&self) -> u64
sourceimpl<P> GenericShortInt<P>where
P: StaticShortIntegerParameter,
impl<P> GenericShortInt<P>where
P: StaticShortIntegerParameter,
sourceimpl<P> GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
Trait Implementations
sourceimpl<P> Add<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Add<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
+
operator.sourcefn add(self, rhs: &GenericShortInt<P>) -> Self::Output
fn add(self, rhs: &GenericShortInt<P>) -> Self::Output
+
operation. Read moresourceimpl<P> Add<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Add<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
+
operator.sourcefn add(self, rhs: GenericShortInt<P>) -> Self::Output
fn add(self, rhs: GenericShortInt<P>) -> Self::Output
+
operation. Read moresourceimpl<P, I> Add<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
impl<P, I> Add<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
Allows using the +
operator between a
&GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a + b;
let decrypted = c.decrypt(&keys);
let expected = 2 + 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a + &b;
let decrypted = c.decrypt(&keys);
let expected = 2 + 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> Add<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> Add<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the +
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a + b;
let decrypted = c.decrypt(&keys);
let expected = 2 + 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a + &b;
let decrypted = c.decrypt(&keys);
let expected = 2 + 1;
assert_eq!(decrypted, expected);
sourceimpl<P> Add<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Add<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Add<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Add<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P, I> AddAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> AddAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the +=
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a += b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected += 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a += &b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected += 1;
assert_eq!(decrypted, expected);
sourcefn add_assign(&mut self, rhs: I)
fn add_assign(&mut self, rhs: I)
+=
operation. Read moresourceimpl<P> AddAssign<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> AddAssign<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourcefn add_assign(&mut self, rhs: u8)
fn add_assign(&mut self, rhs: u8)
+=
operation. Read moresourceimpl<P, I> BitAnd<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
impl<P, I> BitAnd<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
Allows using the &
operator between a
&GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a & b;
let decrypted = c.decrypt(&keys);
let expected = 2 & 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a & &b;
let decrypted = c.decrypt(&keys);
let expected = 2 & 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> BitAnd<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> BitAnd<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the &
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a & b;
let decrypted = c.decrypt(&keys);
let expected = 2 & 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a & &b;
let decrypted = c.decrypt(&keys);
let expected = 2 & 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> BitAndAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> BitAndAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the &=
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a &= b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected &= 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a &= &b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected &= 1;
assert_eq!(decrypted, expected);
sourcefn bitand_assign(&mut self, rhs: I)
fn bitand_assign(&mut self, rhs: I)
&=
operation. Read moresourceimpl<P, I> BitOr<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
impl<P, I> BitOr<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
Allows using the |
operator between a
&GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a | b;
let decrypted = c.decrypt(&keys);
let expected = 2 | 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a | &b;
let decrypted = c.decrypt(&keys);
let expected = 2 | 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> BitOr<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> BitOr<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the |
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a | b;
let decrypted = c.decrypt(&keys);
let expected = 2 | 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a | &b;
let decrypted = c.decrypt(&keys);
let expected = 2 | 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> BitOrAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> BitOrAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the |=
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a |= b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected |= 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a |= &b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected |= 1;
assert_eq!(decrypted, expected);
sourcefn bitor_assign(&mut self, rhs: I)
fn bitor_assign(&mut self, rhs: I)
|=
operation. Read moresourceimpl<P, I> BitXor<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
impl<P, I> BitXor<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
Allows using the ^
operator between a
&GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a ^ b;
let decrypted = c.decrypt(&keys);
let expected = 2 ^ 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a ^ &b;
let decrypted = c.decrypt(&keys);
let expected = 2 ^ 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> BitXor<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> BitXor<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the ^
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a ^ b;
let decrypted = c.decrypt(&keys);
let expected = 2 ^ 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a ^ &b;
let decrypted = c.decrypt(&keys);
let expected = 2 ^ 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> BitXorAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> BitXorAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the ^=
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a ^= b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected ^= 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a ^= &b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected ^= 1;
assert_eq!(decrypted, expected);
sourcefn bitxor_assign(&mut self, rhs: I)
fn bitxor_assign(&mut self, rhs: I)
^=
operation. Read moresourceimpl<P: Clone + ShortIntegerParameter> Clone for GenericShortInt<P>where
P::Id: Clone,
impl<P: Clone + ShortIntegerParameter> Clone for GenericShortInt<P>where
P::Id: Clone,
sourcefn clone(&self) -> GenericShortInt<P>
fn clone(&self) -> GenericShortInt<P>
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl<'de, P: ShortIntegerParameter> Deserialize<'de> for GenericShortInt<P>where
P::Id: Deserialize<'de>,
impl<'de, P: ShortIntegerParameter> Deserialize<'de> for GenericShortInt<P>where
P::Id: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
sourceimpl<P> Div<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Div<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
/
operator.sourcefn div(self, rhs: &GenericShortInt<P>) -> Self::Output
fn div(self, rhs: &GenericShortInt<P>) -> Self::Output
/
operation. Read moresourceimpl<P> Div<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Div<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
/
operator.sourcefn div(self, rhs: GenericShortInt<P>) -> Self::Output
fn div(self, rhs: GenericShortInt<P>) -> Self::Output
/
operation. Read moresourceimpl<P, I> Div<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
impl<P, I> Div<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
Allows using the /
operator between a
&GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a / b;
let decrypted = c.decrypt(&keys);
let expected = 2 / 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a / &b;
let decrypted = c.decrypt(&keys);
let expected = 2 / 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> Div<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> Div<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the /
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a / b;
let decrypted = c.decrypt(&keys);
let expected = 2 / 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a / &b;
let decrypted = c.decrypt(&keys);
let expected = 2 / 1;
assert_eq!(decrypted, expected);
sourceimpl<P> Div<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Div<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Div<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Div<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P, I> DivAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> DivAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the /=
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a /= b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected /= 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a /= &b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected /= 1;
assert_eq!(decrypted, expected);
sourcefn div_assign(&mut self, rhs: I)
fn div_assign(&mut self, rhs: I)
/=
operation. Read moresourceimpl<P> FheBootstrap for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> FheBootstrap for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> FheDecrypt<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: RefKeyFromKeyChain<Key = ShortIntegerClientKey<P>>,
impl<P> FheDecrypt<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: RefKeyFromKeyChain<Key = ShortIntegerClientKey<P>>,
sourcefn decrypt(&self, key: &ClientKey) -> u8
fn decrypt(&self, key: &ClientKey) -> u8
Decrypt the encrypted value to a u8
Example
use concrete::OutOfRangeError;
use concrete::prelude::*;
let a = FheUint2::try_encrypt(2, &client_key)?;
let a_clear = a.decrypt(&client_key);
assert_eq!(a_clear, 2);
let a = FheUint3::try_encrypt(7, &client_key)?;
let a_clear = a.decrypt(&client_key);
assert_eq!(a_clear, 7);
sourceimpl<P, B> FheEq<B> for GenericShortInt<P>where
B: Borrow<Self>,
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P, B> FheEq<B> for GenericShortInt<P>where
B: Borrow<Self>,
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
fn eq(&self, other: B) -> Self
sourceimpl<P> FheEq<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> FheEq<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P, B> FheOrd<B> for GenericShortInt<P>where
B: Borrow<Self>,
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P, B> FheOrd<B> for GenericShortInt<P>where
B: Borrow<Self>,
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> FheOrd<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> FheOrd<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<T, P> FheTryEncrypt<T> for GenericShortInt<P>where
T: TryInto<u8>,
P: StaticShortIntegerParameter,
P::Id: Default + RefKeyFromKeyChain<Key = ShortIntegerClientKey<P>>,
impl<T, P> FheTryEncrypt<T> for GenericShortInt<P>where
T: TryInto<u8>,
P: StaticShortIntegerParameter,
P::Id: Default + RefKeyFromKeyChain<Key = ShortIntegerClientKey<P>>,
sourcefn try_encrypt(value: T, key: &ClientKey) -> Result<Self, Self::Error>
fn try_encrypt(value: T, key: &ClientKey) -> Result<Self, Self::Error>
Try to create a new value.
As Shortints exposed by this crate have between 2 and 7 bits,
creating a value from a rust u8
may not be possible.
Example
use concrete::prelude::*;
use concrete::OutOfRangeError;
// The maximum value that can be represented with 3 bits is 7.
let a = FheUint3::try_encrypt(8, &client_key);
assert_eq!(a.is_err(), true);
let a = FheUint3::try_encrypt(7, &client_key);
assert_eq!(a.is_ok(), true);
type Error = OutOfRangeError
sourceimpl<Clear, P> FheTryTrivialEncrypt<Clear> for GenericShortInt<P>where
Clear: TryInto<u8>,
P: StaticShortIntegerParameter,
P::Id: Default + WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<Clear, P> FheTryTrivialEncrypt<Clear> for GenericShortInt<P>where
Clear: TryInto<u8>,
P: StaticShortIntegerParameter,
P::Id: Default + WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Error = OutOfRangeError
fn try_encrypt_trivial(value: Clear) -> Result<Self, Self::Error>
sourceimpl<P> Mul<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Mul<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
*
operator.sourcefn mul(self, rhs: &GenericShortInt<P>) -> Self::Output
fn mul(self, rhs: &GenericShortInt<P>) -> Self::Output
*
operation. Read moresourceimpl<P> Mul<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Mul<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
*
operator.sourcefn mul(self, rhs: GenericShortInt<P>) -> Self::Output
fn mul(self, rhs: GenericShortInt<P>) -> Self::Output
*
operation. Read moresourceimpl<P, I> Mul<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
impl<P, I> Mul<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
Allows using the *
operator between a
&GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a * b;
let decrypted = c.decrypt(&keys);
let expected = 2 * 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a * &b;
let decrypted = c.decrypt(&keys);
let expected = 2 * 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> Mul<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> Mul<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the *
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a * b;
let decrypted = c.decrypt(&keys);
let expected = 2 * 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a * &b;
let decrypted = c.decrypt(&keys);
let expected = 2 * 1;
assert_eq!(decrypted, expected);
sourceimpl<P> Mul<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Mul<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Mul<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Mul<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P, I> MulAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> MulAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the *=
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a *= b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected *= 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a *= &b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected *= 1;
assert_eq!(decrypted, expected);
sourcefn mul_assign(&mut self, rhs: I)
fn mul_assign(&mut self, rhs: I)
*=
operation. Read moresourceimpl<P> MulAssign<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> MulAssign<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourcefn mul_assign(&mut self, rhs: u8)
fn mul_assign(&mut self, rhs: u8)
*=
operation. Read moresourceimpl<P> Neg for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Neg for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Neg for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Neg for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P, B> Product<B> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
Self: FheTryTrivialEncrypt<u8> + MulAssign<B>,
impl<P, B> Product<B> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
Self: FheTryTrivialEncrypt<u8> + MulAssign<B>,
sourceimpl<P> Rem<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Rem<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
%
operator.sourcefn rem(self, rhs: &GenericShortInt<P>) -> Self::Output
fn rem(self, rhs: &GenericShortInt<P>) -> Self::Output
%
operation. Read moresourceimpl<P> Rem<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Rem<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
%
operator.sourcefn rem(self, rhs: GenericShortInt<P>) -> Self::Output
fn rem(self, rhs: GenericShortInt<P>) -> Self::Output
%
operation. Read moresourceimpl<P> Rem<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Rem<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Rem<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Rem<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P: ShortIntegerParameter> Serialize for GenericShortInt<P>where
P::Id: Serialize,
impl<P: ShortIntegerParameter> Serialize for GenericShortInt<P>where
P::Id: Serialize,
sourceimpl<P> Shl<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Shl<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
<<
operator.sourcefn shl(self, rhs: &GenericShortInt<P>) -> Self::Output
fn shl(self, rhs: &GenericShortInt<P>) -> Self::Output
<<
operation. Read moresourceimpl<P> Shl<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Shl<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
<<
operator.sourcefn shl(self, rhs: GenericShortInt<P>) -> Self::Output
fn shl(self, rhs: GenericShortInt<P>) -> Self::Output
<<
operation. Read moresourceimpl<P> Shl<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Shl<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Shl<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Shl<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Shr<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Shr<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
>>
operator.sourcefn shr(self, rhs: &GenericShortInt<P>) -> Self::Output
fn shr(self, rhs: &GenericShortInt<P>) -> Self::Output
>>
operation. Read moresourceimpl<P> Shr<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Shr<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
>>
operator.sourcefn shr(self, rhs: GenericShortInt<P>) -> Self::Output
fn shr(self, rhs: GenericShortInt<P>) -> Self::Output
>>
operation. Read moresourceimpl<P> Shr<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Shr<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Shr<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Shr<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Sub<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Sub<&GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
-
operator.sourcefn sub(self, rhs: &GenericShortInt<P>) -> Self::Output
fn sub(self, rhs: &GenericShortInt<P>) -> Self::Output
-
operation. Read moresourceimpl<P> Sub<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Sub<GenericShortInt<P>> for u8where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
-
operator.sourcefn sub(self, rhs: GenericShortInt<P>) -> Self::Output
fn sub(self, rhs: GenericShortInt<P>) -> Self::Output
-
operation. Read moresourceimpl<P, I> Sub<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
impl<P, I> Sub<I> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<GenericShortInt<P>>,
Allows using the -
operator between a
&GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a - b;
let decrypted = c.decrypt(&keys);
let expected = 2 - 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = &a - &b;
let decrypted = c.decrypt(&keys);
let expected = 2 - 1;
assert_eq!(decrypted, expected);
sourceimpl<P, I> Sub<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> Sub<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the -
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a - b;
let decrypted = c.decrypt(&keys);
let expected = 2 - 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
let c = a - &b;
let decrypted = c.decrypt(&keys);
let expected = 2 - 1;
assert_eq!(decrypted, expected);
sourceimpl<P> Sub<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Sub<u8> for &GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P> Sub<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> Sub<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourceimpl<P, I> SubAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
impl<P, I> SubAssign<I> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
I: Borrow<Self>,
Allows using the -=
operator between a
GenericFheUint
and a GenericFheUint
or a &GenericFheUint
Examples
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a -= b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected -= 1;
assert_eq!(decrypted, expected);
use concrete::prelude::*;
use concrete::{generate_keys, set_server_key, ConfigBuilder, FheUint2};
let config = ConfigBuilder::all_disabled()
.enable_default_uint2()
.build();
let (keys, server_key) = generate_keys(config);
let mut a = FheUint2::try_encrypt(2, &keys)?;
let b = FheUint2::try_encrypt(1, &keys)?;
set_server_key(server_key);
a -= &b;
let decrypted = a.decrypt(&keys);
let mut expected = 2;
expected -= 1;
assert_eq!(decrypted, expected);
sourcefn sub_assign(&mut self, rhs: I)
fn sub_assign(&mut self, rhs: I)
-=
operation. Read moresourceimpl<P> SubAssign<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
impl<P> SubAssign<u8> for GenericShortInt<P>where
P: ShortIntegerParameter,
P::Id: WithGlobalKey<Key = ShortIntegerServerKey<P>>,
sourcefn sub_assign(&mut self, rhs: u8)
fn sub_assign(&mut self, rhs: u8)
-=
operation. Read more