X-Git-Url: https://git.novaco.in/?p=NovacoinLibrary.git;a=blobdiff_plain;f=Novacoin%2Fuint256.cs;h=0c451ef496fcc9fbdc7be27ab69a4ecec8ee2bd2;hp=09e1a2c7572be9d8aa2769fe6e007e7919145f10;hb=0beeb4bd4e68e4f0d81832370f2f0388d0d76c65;hpb=3d161970699fd79a954f36ff10cf0a3f09986a80 diff --git a/Novacoin/uint256.cs b/Novacoin/uint256.cs index 09e1a2c..0c451ef 100644 --- a/Novacoin/uint256.cs +++ b/Novacoin/uint256.cs @@ -10,36 +10,31 @@ namespace Novacoin { public class uint256 : base_uint { - new public readonly int nWidth = 8; + new protected int nWidth { + get { return base.nWidth; } + private set { base.nWidth = value; } + } + new protected uint[] pn { + get { return base.pn; } + private set { base.pn = value; } + } public uint256() { - base.nWidth = nWidth; + nWidth = 8; pn = new uint[nWidth]; - - for (int i = 0; i < nWidth; i++) - { - pn[i] = 0; - } } - public uint256(uint256 b) + public uint256(uint256 b) : this() { - base.nWidth = nWidth; - pn = new uint[nWidth]; - for (int i = 0; i < nWidth; i++) { pn[i] = b.pn[i]; } } - - public uint256(ulong n) + public uint256(ulong n) : this() { - base.nWidth = nWidth; - pn = new uint[nWidth]; - pn[0] = (uint)n; pn[1] = (uint)(n >> 32); for (int i = 2; i < nWidth; i++) @@ -48,19 +43,17 @@ namespace Novacoin } } - public uint256(byte[] bytes) + public uint256(byte[] bytes) : this() { Contract.Requires(bytes.Length == 32, "Incorrect array length"); - base.nWidth = nWidth; pn = Interop.ToUInt32Array(bytes); } - public uint256(string hex) + public uint256(string hex) : this() { Contract.Requires(hex.Length == 64, "Incorrect string"); - base.nWidth = nWidth; var bytes = Interop.ReverseBytes(Interop.HexToArray(hex)); pn = Interop.ToUInt32Array(bytes); }