Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
W95Psp committed Feb 12, 2024
1 parent bb5b411 commit ef91c46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
18 changes: 12 additions & 6 deletions lib/src/machine_integers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ macro_rules! implement_public_signed_mi {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn signed_modulo(self, n: Self) -> Self {
let mut ret = self.modulo(n);
while ret.less_than(Self::ZERO()) {
while ret.less_than(<Self as Integer>::ZERO()) {
ret = ret + n;
}
ret
Expand Down Expand Up @@ -147,15 +147,18 @@ macro_rules! implement_public_mi {
#[inline]
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn get_bit(self, i: usize) -> Self {
(self >> i) & Self::ONE()
(self >> i) & <Self as Integer>::ONE()
}

/// Set bit `i` of this integer to `b` and return the result.
/// Bit `b` has to be `0` or `1`.
#[inline]
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn set_bit(self, b: Self, i: usize) -> Self {
debug_assert!(b.clone().equal(Self::ONE()) || b.clone().equal(Self::ZERO()));
debug_assert!(
b.clone().equal(<Self as Integer>::ONE())
|| b.clone().equal(<Self as Integer>::ZERO())
);
let tmp1 = Self::from_literal(!(1 << i));
let tmp2 = b << i;
(self & tmp1) | tmp2
Expand Down Expand Up @@ -397,7 +400,7 @@ macro_rules! implement_secret_signed_mi {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn signed_modulo(self, n: Self) -> Self {
let mut ret = self.modulo(n);
while ret.less_than(Self::ZERO()) {
while ret.less_than(<Self as Integer>::ZERO()) {
ret = ret + n;
}
ret
Expand Down Expand Up @@ -451,15 +454,18 @@ macro_rules! implement_secret_mi {
#[inline]
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn get_bit(self, i: usize) -> Self {
(self >> i) & Self::ONE()
(self >> i) & <Self as Integer>::ONE()
}

/// Set bit `i` of this integer to `b` and return the result.
/// Bit `b` has to be `0` or `1`.
#[inline]
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn set_bit(self, b: Self, i: usize) -> Self {
debug_assert!(b.clone().equal(Self::ONE()) || b.clone().equal(Self::ZERO()));
debug_assert!(
b.clone().equal(<Self as Integer>::ONE())
|| b.clone().equal(<Self as Integer>::ZERO())
);
let tmp1 = Self::from_literal(!(1 << i));
let tmp2 = b << i;
(self & tmp1) | tmp2
Expand Down
3 changes: 0 additions & 3 deletions rust-toolchain

This file was deleted.

0 comments on commit ef91c46

Please sign in to comment.