Beispiel #1
0
        public void InfinityWorks()
        {
            var a = GroupElement.Infinity;
            var b = new GroupElement(GE.Infinity);
            var c = new GroupElement(new GE(FE.Zero, FE.Zero, infinity: true));
            var d = new GroupElement(new GE(new FE(1), new FE(1), infinity: true));
            var e = new GroupElement(new GE(EC.G.x, EC.G.y, infinity: true));

            Assert.True(a.IsInfinity);
            Assert.True(b.IsInfinity);
            Assert.True(c.IsInfinity);
            Assert.True(d.IsInfinity);
            Assert.True(e.IsInfinity);

            Assert.Equal(a, b);
            Assert.Equal(a, c);
            Assert.Equal(a, d);
            Assert.Equal(a, e);

            Assert.Equal(a.GetHashCode(), b.GetHashCode());
            Assert.Equal(a.GetHashCode(), c.GetHashCode());
            Assert.Equal(a.GetHashCode(), d.GetHashCode());
            Assert.Equal(a.GetHashCode(), e.GetHashCode());

            var singleSet = new HashSet <GroupElement> {
                a, b, c, d, e
            };

            Assert.Single(singleSet);
        }
Beispiel #2
0
        public void InfinityWorks()
        {
            var a = GroupElement.Infinity;
            var b = new GroupElement(GE.Infinity);
            var c = new GroupElement(new GE(FE.Zero, FE.Zero, infinity: true));
            var d = new GroupElement(new GE(new FE(1), new FE(1), infinity: true));
            var e = new GroupElement(GEJ.Infinity);
            var f = new GroupElement(new GEJ(FE.Zero, FE.Zero, FE.Zero, infinity: true));
            var g = new GroupElement(new GEJ(new FE(1), new FE(1), new FE(1), infinity: true));
            var h = new GroupElement(new GE(EC.G.x, EC.G.y, infinity: true));
            var i = new GroupElement(EC.G * Scalar.Zero);

            Assert.True(a.IsInfinity);
            Assert.True(b.IsInfinity);
            Assert.True(c.IsInfinity);
            Assert.True(d.IsInfinity);
            Assert.True(e.IsInfinity);
            Assert.True(f.IsInfinity);
            Assert.True(g.IsInfinity);
            Assert.True(h.IsInfinity);
            Assert.True(i.IsInfinity);

            Assert.Equal(a, b);
            Assert.Equal(a, c);
            Assert.Equal(a, d);
            Assert.Equal(a, e);
            Assert.Equal(a, f);
            Assert.Equal(a, g);
            Assert.Equal(a, h);
            Assert.Equal(a, i);

            Assert.Equal(a.GetHashCode(), b.GetHashCode());
            Assert.Equal(a.GetHashCode(), c.GetHashCode());
            Assert.Equal(a.GetHashCode(), d.GetHashCode());
            Assert.Equal(a.GetHashCode(), e.GetHashCode());
            Assert.Equal(a.GetHashCode(), f.GetHashCode());
            Assert.Equal(a.GetHashCode(), g.GetHashCode());
            Assert.Equal(a.GetHashCode(), h.GetHashCode());
            Assert.Equal(a.GetHashCode(), i.GetHashCode());

            var singleSet = new HashSet <GroupElement> {
                a, b, c, d, e, f, g, h, i
            };

            Assert.Single(singleSet);
        }