Skip to content

Commit 5e4ffd7

Browse files
committed
Fixed loop count for BigInteger conversion
- remove length-specific variants of FromBigInteger
1 parent 8614e49 commit 5e4ffd7

20 files changed

+27
-182
lines changed

crypto/src/math/ec/custom/djb/Curve25519Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void AddOne(uint[] x, uint[] z)
4747

4848
public static uint[] FromBigInteger(BigInteger x)
4949
{
50-
uint[] z = Nat256.FromBigInteger(x);
50+
uint[] z = Nat.FromBigInteger(256, x);
5151
while (Nat256.Gte(z, P))
5252
{
5353
Nat256.SubFrom(P, z);

crypto/src/math/ec/custom/gm/SM2P256V1Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void AddOne(uint[] x, uint[] z)
4747

4848
public static uint[] FromBigInteger(BigInteger x)
4949
{
50-
uint[] z = Nat256.FromBigInteger(x);
50+
uint[] z = Nat.FromBigInteger(256, x);
5151
if (z[7] >= P7 && Nat256.Gte(z, P))
5252
{
5353
Nat256.SubFrom(P, z);

crypto/src/math/ec/custom/sec/SecP128R1Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static void AddOne(uint[] x, uint[] z)
4747

4848
public static uint[] FromBigInteger(BigInteger x)
4949
{
50-
uint[] z = Nat128.FromBigInteger(x);
50+
uint[] z = Nat.FromBigInteger(128, x);
5151
if (z[3] >= P3 && Nat128.Gte(z, P))
5252
{
5353
Nat128.SubFrom(P, z);

crypto/src/math/ec/custom/sec/SecP160R1Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static void AddOne(uint[] x, uint[] z)
5151

5252
public static uint[] FromBigInteger(BigInteger x)
5353
{
54-
uint[] z = Nat160.FromBigInteger(x);
54+
uint[] z = Nat.FromBigInteger(160, x);
5555
if (z[4] == P4 && Nat160.Gte(z, P))
5656
{
5757
Nat160.SubFrom(P, z);

crypto/src/math/ec/custom/sec/SecP160R2Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static void AddOne(uint[] x, uint[] z)
5151

5252
public static uint[] FromBigInteger(BigInteger x)
5353
{
54-
uint[] z = Nat160.FromBigInteger(x);
54+
uint[] z = Nat.FromBigInteger(160, x);
5555
if (z[4] == P4 && Nat160.Gte(z, P))
5656
{
5757
Nat160.SubFrom(P, z);

crypto/src/math/ec/custom/sec/SecP192K1Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void AddOne(uint[] x, uint[] z)
5252

5353
public static uint[] FromBigInteger(BigInteger x)
5454
{
55-
uint[] z = Nat192.FromBigInteger(x);
55+
uint[] z = Nat.FromBigInteger(192, x);
5656
if (z[5] == P5 && Nat192.Gte(z, P))
5757
{
5858
Nat192.SubFrom(P, z);

crypto/src/math/ec/custom/sec/SecP192R1Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static void AddOne(uint[] x, uint[] z)
5151

5252
public static uint[] FromBigInteger(BigInteger x)
5353
{
54-
uint[] z = Nat192.FromBigInteger(x);
54+
uint[] z = Nat.FromBigInteger(192, x);
5555
if (z[5] == P5 && Nat192.Gte(z, P))
5656
{
5757
Nat192.SubFrom(P, z);

crypto/src/math/ec/custom/sec/SecP224K1Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void AddOne(uint[] x, uint[] z)
5353

5454
public static uint[] FromBigInteger(BigInteger x)
5555
{
56-
uint[] z = Nat224.FromBigInteger(x);
56+
uint[] z = Nat.FromBigInteger(224, x);
5757
if (z[6] == P6 && Nat224.Gte(z, P))
5858
{
5959
Nat224.SubFrom(P, z);

crypto/src/math/ec/custom/sec/SecP224R1Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void AddOne(uint[] x, uint[] z)
5252

5353
public static uint[] FromBigInteger(BigInteger x)
5454
{
55-
uint[] z = Nat224.FromBigInteger(x);
55+
uint[] z = Nat.FromBigInteger(224, x);
5656
if (z[6] == P6 && Nat224.Gte(z, P))
5757
{
5858
Nat224.SubFrom(P, z);

crypto/src/math/ec/custom/sec/SecP256K1Field.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static void AddOne(uint[] x, uint[] z)
5353

5454
public static uint[] FromBigInteger(BigInteger x)
5555
{
56-
uint[] z = Nat256.FromBigInteger(x);
56+
uint[] z = Nat.FromBigInteger(256, x);
5757
if (z[7] == P7 && Nat256.Gte(z, P))
5858
{
5959
Nat256.SubFrom(P, z);

0 commit comments

Comments
 (0)