Skip to content

Commit

Permalink
feat(integer): improve {overflowing_}scalar_add/sub
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontaigu committed Aug 9, 2024
1 parent 5340859 commit b9b5d6f
Show file tree
Hide file tree
Showing 10 changed files with 1,258 additions and 648 deletions.
16 changes: 11 additions & 5 deletions tfhe/src/high_level_api/integers/signed/overflowing_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ where
impl<Id, Clear> OverflowingAdd<Clear> for &FheInt<Id>
where
Id: FheIntId,
Clear: SignedNumeric + DecomposableInto<u64>,
Clear: SignedNumeric + DecomposableInto<u64> + DecomposableInto<u8>,
{
type Output = FheInt<Id>;

Expand Down Expand Up @@ -155,7 +155,7 @@ where
impl<Id, Clear> OverflowingAdd<Clear> for FheInt<Id>
where
Id: FheIntId,
Clear: SignedNumeric + DecomposableInto<u64>,
Clear: SignedNumeric + DecomposableInto<u64> + DecomposableInto<u8>,
{
type Output = Self;

Expand Down Expand Up @@ -192,7 +192,7 @@ where
impl<Id, Clear> OverflowingAdd<&FheInt<Id>> for Clear
where
Id: FheIntId,
Clear: SignedNumeric + DecomposableInto<u64>,
Clear: SignedNumeric + DecomposableInto<u64> + DecomposableInto<u8>,
{
type Output = FheInt<Id>;

Expand Down Expand Up @@ -318,7 +318,10 @@ where
impl<Id, Clear> OverflowingSub<Clear> for &FheInt<Id>
where
Id: FheIntId,
Clear: SignedNumeric + DecomposableInto<u64>,
Clear: SignedNumeric
+ DecomposableInto<u8>
+ std::ops::Not<Output = Clear>
+ DecomposableInto<u64>,
{
type Output = FheInt<Id>;

Expand Down Expand Up @@ -369,7 +372,10 @@ where
impl<Id, Clear> OverflowingSub<Clear> for FheInt<Id>
where
Id: FheIntId,
Clear: SignedNumeric + DecomposableInto<u64>,
Clear: SignedNumeric
+ DecomposableInto<u8>
+ std::ops::Not<Output = Clear>
+ DecomposableInto<u64>,
{
type Output = Self;

Expand Down
4 changes: 2 additions & 2 deletions tfhe/src/high_level_api/integers/unsigned/overflowing_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ where
impl<Id, Clear> OverflowingSub<Clear> for &FheUint<Id>
where
Id: FheUintId,
Clear: UnsignedNumeric + DecomposableInto<u8>,
Clear: UnsignedNumeric + DecomposableInto<u8> + std::ops::Not<Output = Clear>,
{
type Output = FheUint<Id>;

Expand Down Expand Up @@ -371,7 +371,7 @@ where
impl<Id, Clear> OverflowingSub<Clear> for FheUint<Id>
where
Id: FheUintId,
Clear: UnsignedNumeric + DecomposableInto<u8>,
Clear: UnsignedNumeric + DecomposableInto<u8> + std::ops::Not<Output = Clear>,
{
type Output = Self;

Expand Down
Loading

0 comments on commit b9b5d6f

Please sign in to comment.