Skip to content

Commit

Permalink
Add BIsZero_Static37
Browse files Browse the repository at this point in the history
  • Loading branch information
tuokri committed Aug 10, 2024
1 parent 036d4ba commit 9faebd8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
16 changes: 13 additions & 3 deletions Classes/FCryptoBigInt.uc
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,7 @@ static final function ToMonty(
* This function is called "BIsZero" because
* "IsZero" would clash with Object::IsZero.
*/
static final function int BIsZero(
const out array<int> X
)
static final function int BIsZero(const out array<int> X)
{
local int Z;
local int U;
Expand All @@ -1271,6 +1269,18 @@ static final function int BIsZero(
return ~(Z | -Z) >>> 31;
}

static final function int BIsZero_Static37(const out int X[37])
{
local int Z;
local int U;

Z = 0;
for (U = (X[0] + 15) >>> 4; U > 0; --U)
{
Z = Z | X[U];
}
return ~(Z | -Z) >>> 31;
}

/*
* Negate big integer conditionally. The value consists of 'len' words,
Expand Down
3 changes: 1 addition & 2 deletions Classes/FCryptoEC_Prime.uc
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ static final function int RunCode(
case 4:
break;
default:
// TODO: need static variant for this too.
// R = R & (class'FCryptoBigInt'.static.BIsZero(T[D]));
R = R & class'FCryptoBigInt'.static.BIsZero_Static37(T[D].X);
break;
}
}
Expand Down

0 comments on commit 9faebd8

Please sign in to comment.