summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2018-09-20 23:47:43 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2018-09-20 23:47:43 +0700
commitaafad562a09077d87e5fc1de630b26a937618086 (patch)
tree0089d469f200c8195922622fb456c97bb565038b
parentCode cleanup (from Java build) (diff)
downloadBouncyCastle.NET-ed25519-aafad562a09077d87e5fc1de630b26a937618086.tar.xz
Refactoring
-rw-r--r--crypto/src/math/ec/multiplier/WNafUtilities.cs12
-rw-r--r--crypto/src/util/Arrays.cs3
2 files changed, 9 insertions, 6 deletions
diff --git a/crypto/src/math/ec/multiplier/WNafUtilities.cs b/crypto/src/math/ec/multiplier/WNafUtilities.cs
index e893abd49..24646deb2 100644
--- a/crypto/src/math/ec/multiplier/WNafUtilities.cs
+++ b/crypto/src/math/ec/multiplier/WNafUtilities.cs
@@ -1,5 +1,7 @@
 using System;
 
+using Org.BouncyCastle.Utilities;
+
 namespace Org.BouncyCastle.Math.EC.Multiplier
 {
     public abstract class WNafUtilities
@@ -8,8 +10,6 @@ namespace Org.BouncyCastle.Math.EC.Multiplier
 
         private static readonly int[] DEFAULT_WINDOW_SIZE_CUTOFFS = new int[]{ 13, 41, 121, 337, 897, 2305 };
 
-        private static readonly byte[] EMPTY_BYTES = new byte[0];
-        private static readonly int[] EMPTY_INTS = new int[0];
         private static readonly ECPoint[] EMPTY_POINTS = new ECPoint[0];
 
         public static int[] GenerateCompactNaf(BigInteger k)
@@ -17,7 +17,7 @@ namespace Org.BouncyCastle.Math.EC.Multiplier
             if ((k.BitLength >> 16) != 0)
                 throw new ArgumentException("must have bitlength < 2^16", "k");
             if (k.SignValue == 0)
-                return EMPTY_INTS;
+                return Arrays.EmptyInts;
 
             BigInteger _3k = k.ShiftLeft(1).Add(k);
 
@@ -63,7 +63,7 @@ namespace Org.BouncyCastle.Math.EC.Multiplier
             if ((k.BitLength >> 16) != 0)
                 throw new ArgumentException("must have bitlength < 2^16", "k");
             if (k.SignValue == 0)
-                return EMPTY_INTS;
+                return Arrays.EmptyInts;
 
             int[] wnaf = new int[k.BitLength / width + 1];
 
@@ -176,7 +176,7 @@ namespace Org.BouncyCastle.Math.EC.Multiplier
         public static byte[] GenerateNaf(BigInteger k)
         {
             if (k.SignValue == 0)
-                return EMPTY_BYTES;
+                return Arrays.EmptyBytes;
 
             BigInteger _3k = k.ShiftLeft(1).Add(k);
 
@@ -221,7 +221,7 @@ namespace Org.BouncyCastle.Math.EC.Multiplier
             if (width < 2 || width > 8)
                 throw new ArgumentException("must be in the range [2, 8]", "width");
             if (k.SignValue == 0)
-                return EMPTY_BYTES;
+                return Arrays.EmptyBytes;
 
             byte[] wnaf = new byte[k.BitLength + 1];
 
diff --git a/crypto/src/util/Arrays.cs b/crypto/src/util/Arrays.cs
index df9b4e7ee..3df908240 100644
--- a/crypto/src/util/Arrays.cs
+++ b/crypto/src/util/Arrays.cs
@@ -8,6 +8,9 @@ namespace Org.BouncyCastle.Utilities
     /// <summary> General array utilities.</summary>
     public abstract class Arrays
     {
+        public static readonly byte[] EmptyBytes = new byte[0];
+        public static readonly int[] EmptyInts = new int[0];
+
         public static bool AreEqual(
             bool[]  a,
             bool[]  b)