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).
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,
sourceimpl<P> GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
pub fn lt(&self, other: &Self) -> Self
pub fn le(&self, other: &Self) -> Self
pub fn gt(&self, other: &Self) -> Self
pub fn ge(&self, other: &Self) -> Self
pub fn eq(&self, other: &Self) -> Self
pub fn bivariate_pbs<F>(&self, other: &Self, func: F) -> Self where
F: Fn(u8, u8) -> u8,
Trait Implementations
sourceimpl<P> Add<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Add<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the +
operator.
sourcefn add(self, rhs: &GenericShortInt<P>) -> Self::Output
fn add(self, rhs: &GenericShortInt<P>) -> Self::Output
Performs the +
operation. Read more
sourceimpl<P> Add<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Add<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the +
operator.
sourcefn add(self, rhs: GenericShortInt<P>) -> Self::Output
fn add(self, rhs: GenericShortInt<P>) -> Self::Output
Performs the +
operation. Read more
sourceimpl<P, I> Add<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<GenericShortInt<P>>,
impl<P, I> Add<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> Add<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Add<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Add<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Add<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P, I> AddAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> AddAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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)
Performs the +=
operation. Read more
sourceimpl<P> AddAssign<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> AddAssign<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourcefn add_assign(&mut self, rhs: u8)
fn add_assign(&mut self, rhs: u8)
Performs the +=
operation. Read more
sourceimpl<P, I> BitAnd<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<GenericShortInt<P>>,
impl<P, I> BitAnd<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> BitAnd<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> BitAndAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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)
Performs the &=
operation. Read more
sourceimpl<P, I> BitOr<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<GenericShortInt<P>>,
impl<P, I> BitOr<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> BitOr<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> BitOrAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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)
Performs the |=
operation. Read more
sourceimpl<P, I> BitXor<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<GenericShortInt<P>>,
impl<P, I> BitXor<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> BitXor<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> BitXorAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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)
Performs the ^=
operation. Read more
sourceimpl<P: Clone + ShortIntegerParameter> Clone for GenericShortInt<P>
impl<P: Clone + ShortIntegerParameter> Clone for GenericShortInt<P>
sourcefn clone(&self) -> GenericShortInt<P>
fn clone(&self) -> GenericShortInt<P>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'de, P: ShortIntegerParameter> Deserialize<'de> for GenericShortInt<P>
impl<'de, P: ShortIntegerParameter> Deserialize<'de> for GenericShortInt<P>
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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<P> Div<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Div<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the /
operator.
sourcefn div(self, rhs: &GenericShortInt<P>) -> Self::Output
fn div(self, rhs: &GenericShortInt<P>) -> Self::Output
Performs the /
operation. Read more
sourceimpl<P> Div<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Div<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the /
operator.
sourcefn div(self, rhs: GenericShortInt<P>) -> Self::Output
fn div(self, rhs: GenericShortInt<P>) -> Self::Output
Performs the /
operation. Read more
sourceimpl<P, I> Div<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<GenericShortInt<P>>,
impl<P, I> Div<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> Div<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Div<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Div<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Div<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P, I> DivAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> DivAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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)
Performs the /=
operation. Read more
sourceimpl<P> FheBootstrap for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> FheBootstrap for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> FheDecrypt<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerClientKey<P>: RefKeyFromKeyChain,
impl<P> FheDecrypt<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerClientKey<P>: RefKeyFromKeyChain,
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, T> FheTryEncrypt<T> for GenericShortInt<P> where
T: TryInto<u8>,
P: ShortIntegerParameter,
ShortIntegerClientKey<P>: RefKeyFromKeyChain,
impl<P, T> FheTryEncrypt<T> for GenericShortInt<P> where
T: TryInto<u8>,
P: ShortIntegerParameter,
ShortIntegerClientKey<P>: RefKeyFromKeyChain,
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<P: ShortIntegerParameter> From<Ciphertext> for GenericShortInt<P>
impl<P: ShortIntegerParameter> From<Ciphertext> for GenericShortInt<P>
sourcefn from(ciphertext: Ciphertext) -> Self
fn from(ciphertext: Ciphertext) -> Self
Converts to this type from the input type.
sourceimpl<P> Mul<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Mul<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: &GenericShortInt<P>) -> Self::Output
fn mul(self, rhs: &GenericShortInt<P>) -> Self::Output
Performs the *
operation. Read more
sourceimpl<P> Mul<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Mul<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the *
operator.
sourcefn mul(self, rhs: GenericShortInt<P>) -> Self::Output
fn mul(self, rhs: GenericShortInt<P>) -> Self::Output
Performs the *
operation. Read more
sourceimpl<P, I> Mul<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<GenericShortInt<P>>,
impl<P, I> Mul<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> Mul<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Mul<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Mul<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Mul<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P, I> MulAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> MulAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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)
Performs the *=
operation. Read more
sourceimpl<P> MulAssign<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> MulAssign<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourcefn mul_assign(&mut self, rhs: u8)
fn mul_assign(&mut self, rhs: u8)
Performs the *=
operation. Read more
sourceimpl<P> Neg for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Neg for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Neg for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Neg for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Rem<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Rem<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the %
operator.
sourcefn rem(self, rhs: &GenericShortInt<P>) -> Self::Output
fn rem(self, rhs: &GenericShortInt<P>) -> Self::Output
Performs the %
operation. Read more
sourceimpl<P> Rem<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Rem<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the %
operator.
sourcefn rem(self, rhs: GenericShortInt<P>) -> Self::Output
fn rem(self, rhs: GenericShortInt<P>) -> Self::Output
Performs the %
operation. Read more
sourceimpl<P> Rem<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Rem<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Rem<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Rem<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P: ShortIntegerParameter> Serialize for GenericShortInt<P>
impl<P: ShortIntegerParameter> Serialize for GenericShortInt<P>
sourceimpl<P> Shl<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Shl<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the <<
operator.
sourcefn shl(self, rhs: &GenericShortInt<P>) -> Self::Output
fn shl(self, rhs: &GenericShortInt<P>) -> Self::Output
Performs the <<
operation. Read more
sourceimpl<P> Shl<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Shl<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the <<
operator.
sourcefn shl(self, rhs: GenericShortInt<P>) -> Self::Output
fn shl(self, rhs: GenericShortInt<P>) -> Self::Output
Performs the <<
operation. Read more
sourceimpl<P> Shl<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Shl<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Shl<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Shl<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Shr<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Shr<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the >>
operator.
sourcefn shr(self, rhs: &GenericShortInt<P>) -> Self::Output
fn shr(self, rhs: &GenericShortInt<P>) -> Self::Output
Performs the >>
operation. Read more
sourceimpl<P> Shr<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Shr<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the >>
operator.
sourcefn shr(self, rhs: GenericShortInt<P>) -> Self::Output
fn shr(self, rhs: GenericShortInt<P>) -> Self::Output
Performs the >>
operation. Read more
sourceimpl<P> Shr<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Shr<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Shr<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Shr<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Sub<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Sub<&GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: &GenericShortInt<P>) -> Self::Output
fn sub(self, rhs: &GenericShortInt<P>) -> Self::Output
Performs the -
operation. Read more
sourceimpl<P> Sub<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Sub<GenericShortInt<P>> for u8 where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
type Output = GenericShortInt<P>
type Output = GenericShortInt<P>
The resulting type after applying the -
operator.
sourcefn sub(self, rhs: GenericShortInt<P>) -> Self::Output
fn sub(self, rhs: GenericShortInt<P>) -> Self::Output
Performs the -
operation. Read more
sourceimpl<P, I> Sub<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<GenericShortInt<P>>,
impl<P, I> Sub<I> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> Sub<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Sub<u8> for &GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P> Sub<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> Sub<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourceimpl<P, I> SubAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
I: Borrow<Self>,
impl<P, I> SubAssign<I> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
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)
Performs the -=
operation. Read more
sourceimpl<P> SubAssign<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
impl<P> SubAssign<u8> for GenericShortInt<P> where
P: ShortIntegerParameter,
ShortIntegerServerKey<P>: WithGlobalKey,
sourcefn sub_assign(&mut self, rhs: u8)
fn sub_assign(&mut self, rhs: u8)
Performs the -=
operation. Read more
Auto Trait Implementations
impl<P> !RefUnwindSafe for GenericShortInt<P>
impl<P> Send for GenericShortInt<P> where
P: Send,
impl<P> !Sync for GenericShortInt<P>
impl<P> Unpin for GenericShortInt<P> where
P: Unpin,
impl<P> UnwindSafe for GenericShortInt<P> where
P: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more