Skip to content

Commit aafad56

Browse files
committed
Refactoring
1 parent 92c99a5 commit aafad56

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

crypto/src/math/ec/multiplier/WNafUtilities.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22

3+
using Org.BouncyCastle.Utilities;
4+
35
namespace Org.BouncyCastle.Math.EC.Multiplier
46
{
57
public abstract class WNafUtilities
@@ -8,16 +10,14 @@ public abstract class WNafUtilities
810

911
private static readonly int[] DEFAULT_WINDOW_SIZE_CUTOFFS = new int[]{ 13, 41, 121, 337, 897, 2305 };
1012

11-
private static readonly byte[] EMPTY_BYTES = new byte[0];
12-
private static readonly int[] EMPTY_INTS = new int[0];
1313
private static readonly ECPoint[] EMPTY_POINTS = new ECPoint[0];
1414

1515
public static int[] GenerateCompactNaf(BigInteger k)
1616
{
1717
if ((k.BitLength >> 16) != 0)
1818
throw new ArgumentException("must have bitlength < 2^16", "k");
1919
if (k.SignValue == 0)
20-
return EMPTY_INTS;
20+
return Arrays.EmptyInts;
2121

2222
BigInteger _3k = k.ShiftLeft(1).Add(k);
2323

@@ -63,7 +63,7 @@ public static int[] GenerateCompactWindowNaf(int width, BigInteger k)
6363
if ((k.BitLength >> 16) != 0)
6464
throw new ArgumentException("must have bitlength < 2^16", "k");
6565
if (k.SignValue == 0)
66-
return EMPTY_INTS;
66+
return Arrays.EmptyInts;
6767

6868
int[] wnaf = new int[k.BitLength / width + 1];
6969

@@ -176,7 +176,7 @@ public static byte[] GenerateJsf(BigInteger g, BigInteger h)
176176
public static byte[] GenerateNaf(BigInteger k)
177177
{
178178
if (k.SignValue == 0)
179-
return EMPTY_BYTES;
179+
return Arrays.EmptyBytes;
180180

181181
BigInteger _3k = k.ShiftLeft(1).Add(k);
182182

@@ -221,7 +221,7 @@ public static byte[] GenerateWindowNaf(int width, BigInteger k)
221221
if (width < 2 || width > 8)
222222
throw new ArgumentException("must be in the range [2, 8]", "width");
223223
if (k.SignValue == 0)
224-
return EMPTY_BYTES;
224+
return Arrays.EmptyBytes;
225225

226226
byte[] wnaf = new byte[k.BitLength + 1];
227227

crypto/src/util/Arrays.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace Org.BouncyCastle.Utilities
88
/// <summary> General array utilities.</summary>
99
public abstract class Arrays
1010
{
11+
public static readonly byte[] EmptyBytes = new byte[0];
12+
public static readonly int[] EmptyInts = new int[0];
13+
1114
public static bool AreEqual(
1215
bool[] a,
1316
bool[] b)

0 commit comments

Comments
 (0)