public void BasicTests()
        {
            // Make sure byte array comparision works within hashset and that the underlying API won't pull the floor out.
            var byteArray          = new byte[] { 1, 2, 3 };
            var sameByteArray      = new byte[] { 1, 2, 3 };
            var differentByteArray = new byte[] { 4, 5, 6 };
            var twoSet             = new HashSet <byte[]>(new ByteArrayEqualityComparer())
            {
                byteArray,
                sameByteArray,
                differentByteArray
            };

            Assert.True(ByteHelpers.CompareFastUnsafe(byteArray, sameByteArray));
            Assert.False(ByteHelpers.CompareFastUnsafe(byteArray, differentByteArray));
            Assert.Equal(2, twoSet.Count);

            // It's probabilistically ensured that it never produces the same scalar, so unit test should pass always.
            var           pseudoSet      = new HashSet <byte[]>();
            var           secureSet      = new HashSet <byte[]>();
            var           count          = 100;
            IWasabiRandom unsecureRandom = new UnsecureRandom();

            using var secureRandomToDispose = new SecureRandom();
            IWasabiRandom secureRandom = secureRandomToDispose;

            for (int i = 0; i < count; i++)
            {
                pseudoSet.Add(unsecureRandom.GetBytes(10));
                secureSet.Add(secureRandom.GetBytes(10));
            }
            Assert.Equal(count, pseudoSet.Count);
            Assert.Equal(count, secureSet.Count);
        }
        public void ScalarInternalTests()
        {
            var           mockRandom    = new MockRandom();
            IWasabiRandom iWasabiRandom = mockRandom;

            // The random should not overfow.
            mockRandom.GetBytesResults.Add(EC.N.ToBytes());

            // The random should not overfow.
            mockRandom.GetBytesResults.Add(new Scalar(uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue, uint.MaxValue).ToBytes());

            mockRandom.GetBytesResults.Add(Scalar.Zero.ToBytes());
            var one = new Scalar(1);

            mockRandom.GetBytesResults.Add(one.ToBytes());
            var two = new Scalar(2);

            mockRandom.GetBytesResults.Add(two.ToBytes());
            var big = new Scalar(int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue, int.MaxValue);

            mockRandom.GetBytesResults.Add(big.ToBytes());
            var biggest = EC.N + one.Negate();

            mockRandom.GetBytesResults.Add(biggest.ToBytes());

            var randomScalar = iWasabiRandom.GetScalar();

            Assert.Equal(Scalar.Zero, randomScalar);
            randomScalar = iWasabiRandom.GetScalar();
            Assert.Equal(one, randomScalar);
            randomScalar = iWasabiRandom.GetScalar();
            Assert.Equal(two, randomScalar);
            randomScalar = iWasabiRandom.GetScalar();
            Assert.Equal(big, randomScalar);
            randomScalar = iWasabiRandom.GetScalar();
            Assert.Equal(biggest, randomScalar);
        }