public void Compare_UncompressedTest()
        {
            var comp = new PrvToAddrBothComparer();

            Assert.True(comp.Init(KeyHelper.Pub1UnCompAddr));
            byte[] key = KeyHelper.Prv1.ToBytes();
            key[0]++;

            bool b = comp.Compare(key);

            Assert.False(b);

            key[0]--;
            b = comp.Compare(key);
            Assert.True(b);
        }
        public unsafe void Compare_Sha512Hpt_Test(PrvToAddrBothComparer comp, byte[] key, bool expected)
        {
            ulong *hPt = stackalloc ulong[8];

            Helper.WriteToHpt32(key, hPt);
            bool actual = comp.Compare(hPt);

            Assert.Equal(expected, actual);
        }
        public void Compare_EdgeTest()
        {
            var comp = new PrvToAddrBothComparer();

            Assert.True(comp.Init(KeyHelper.Pub1CompAddr));
            byte[] key = new byte[32];
            bool   b   = comp.Compare(key);

            Assert.False(b);

            ((Span <byte>)key).Fill(255);
            b = comp.Compare(key);
            Assert.False(b);

            key = new SecP256k1().N.ToByteArray(true, true);
            b   = comp.Compare(key);
            Assert.False(b);
        }
        public unsafe void Compare_PointJ_Test(PrvToAddrBothComparer comp, byte[] key, bool expected)
        {
            Scalar sc = new(key, out int overflow);

            if (overflow == 0 && !sc.IsZero)
            {
                PointJacobian point  = Helper.Calc.MultiplyByG(sc);
                bool          actual = comp.Compare(point);
                Assert.Equal(expected, actual);
            }
        }
        public void CloneTest()
        {
            var original = new PrvToAddrBothComparer();

            Assert.True(original.Init(KeyHelper.Pub1CompAddr)); // Make sure it is successfully initialized
            var cloned = original.Clone();

            // Change original field value to make sure it is cloned not a reference copy
            Assert.True(original.Init(KeyHelper.Pub2CompAddr));

            byte[] key = KeyHelper.Prv1.ToBytes();

            // Since the original was changed it should fail when comparing
            Assert.False(original.Compare(key));
            Assert.True(cloned.Compare(key));
        }