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 Verify(SparseTernaryPolynomial poly)
        {
            // make sure ones and negative ones don't share indices
            int[] ones  = poly.GetOnes();
            int[] nones = poly.GetNegOnes();

            for (int i = 0; i < ones.Length; i++)
            {
                for (int j = 0; j < nones.Length; j++)
                {
                    if (ones[i] == nones[j])
                    {
                        throw new Exception("SparseTernaryPolynomial GenerateRandom test failed!");
                    }
                }
            }
        }