public void testFromToBinary()
        {
            SecureRandom            random      = new SecureRandom();
            SparseTernaryPolynomial poly1       = SparseTernaryPolynomial.GenerateRandom(1000, 100, 101, random);
            MemoryStream            poly1Stream = new MemoryStream(poly1.ToBinary());
            SparseTernaryPolynomial poly2       = SparseTernaryPolynomial.FromBinary(poly1Stream, 1000, 100, 101);

            Assert.AreEqual(poly1.GetOnes(), poly2.GetOnes());
            Assert.AreEqual(poly1.GetNegOnes(), poly2.GetNegOnes());
            Assert.AreEqual(poly1.ToIntegerPolynomial().coeffs, poly2.ToIntegerPolynomial().coeffs);
        }
        private void FromToBinary()
        {
            CSPRng rng = new CSPRng();
            int    N   = 1000;
            SparseTernaryPolynomial poly1       = SparseTernaryPolynomial.GenerateRandom(N, 100, 101, rng);
            MemoryStream            poly1Stream = new MemoryStream(poly1.ToBinary());
            SparseTernaryPolynomial poly2       = SparseTernaryPolynomial.FromBinary(poly1Stream, N);

            if (!Compare.Equals(poly1, poly2))
            {
                throw new Exception("SparseTernaryPolynomial FromToBinary test failed!");
            }
        }