public void CSBadSerializeGroupElementArrayTest()
        {
            GroupElement[] input = StaticHelperClass.GenerateRandomBases(10, paramIndex);

            StaticHelperClass.TryBodyDelegate negativeLength =
                new StaticHelperClass.TryBodyDelegate(
                    () => {
                string[] serialized = CryptoSerializer.SerializeGroupElementArray(input, 3, -1, "blah");
            });
            StaticHelperClass.AssertThrowsException(negativeLength, typeof(Exception), "negative output length");

            // zero output length
            string[] output = CryptoSerializer.SerializeGroupElementArray(input, 3, 0, "blah");
            Assert.AreEqual(0, output.Length, "output.Length.");

            // output length too long
            StaticHelperClass.TryBodyDelegate outputLengthTooLarge =
                new StaticHelperClass.TryBodyDelegate(
                    () =>
            {
                string[] serialized = CryptoSerializer.SerializeGroupElementArray(input, 3, 9, "blah");
            });
            StaticHelperClass.AssertThrowsException(outputLengthTooLarge, typeof(Exception), "Output length too large");

            // copy index negative
            StaticHelperClass.TryBodyDelegate startIndexNegative =
                new StaticHelperClass.TryBodyDelegate(
                    () =>
            {
                string[] serialized = CryptoSerializer.SerializeGroupElementArray(input, -1, 4, "blah");
            });
            StaticHelperClass.AssertThrowsException(startIndexNegative, typeof(Exception), "Start index is negative.");
        }
        public void CSBadDeserializeFieldZqElementArrayTest()
        {
            FieldZqElement[] input      = StaticHelperClass.GenerateRandomExponents(10, paramIndex);
            string[]         serialized = CryptoSerializer.SerializeFieldZqElementArray(input, 3, 4, "blah");
            Assert.AreEqual(4, serialized.Length, "serialized array length");

            StaticHelperClass.TryBodyDelegate negativeStartIndex =
                new StaticHelperClass.TryBodyDelegate(
                    () =>
            {
                FieldZqElement[] output = CryptoSerializer.DeserializeFieldZqElementArray(serialized, -1, 10, "blah", crypto.Group);
            });
            StaticHelperClass.AssertThrowsException(negativeStartIndex, typeof(Exception), "negative start index");


            StaticHelperClass.TryBodyDelegate startIndexTooLarge =
                new StaticHelperClass.TryBodyDelegate(
                    () =>
            {
                FieldZqElement[] output = CryptoSerializer.DeserializeFieldZqElementArray(serialized, 8, 10, "blah", crypto.Group);
            });
            StaticHelperClass.AssertThrowsException(startIndexTooLarge, typeof(Exception), "start index too large");

            StaticHelperClass.TryBodyDelegate startIndexWaytooLarge =
                new StaticHelperClass.TryBodyDelegate(
                    () =>
            {
                FieldZqElement[] output = CryptoSerializer.DeserializeFieldZqElementArray(serialized, 11, 10, "blah", crypto.Group);
            });
            StaticHelperClass.AssertThrowsException(startIndexWaytooLarge, typeof(Exception), "start index greater than output length ");
        }
        public void CSBadSerializeFieldZqElementArrayTest()
        {
            FieldZqElement[] input = StaticHelperClass.GenerateRandomExponents(10, paramIndex);

            StaticHelperClass.TryBodyDelegate negativeLength =
                new StaticHelperClass.TryBodyDelegate(
                    () =>
            {
                string[] serialized = CryptoSerializer.SerializeFieldZqElementArray(input, 3, -1, "blah");
            });
            StaticHelperClass.AssertThrowsException(negativeLength, typeof(Exception), "negative output length");

            // zero output length
            string[] output = CryptoSerializer.SerializeFieldZqElementArray(input, 3, 0, "blah");
            Assert.AreEqual(0, output.Length, "output.Length.");

            // output length too long
            StaticHelperClass.TryBodyDelegate outputLengthTooLarge =
                new StaticHelperClass.TryBodyDelegate(
                    () =>
            {
                string[] serialized = CryptoSerializer.SerializeFieldZqElementArray(input, 3, 9, "blah");
            });
            StaticHelperClass.AssertThrowsException(outputLengthTooLarge, typeof(Exception), "Output length too large");

            // copy index negative
            StaticHelperClass.TryBodyDelegate startIndexNegative =
                new StaticHelperClass.TryBodyDelegate(
                    () =>
            {
                string[] serialized = CryptoSerializer.SerializeFieldZqElementArray(input, -1, 4, "blah");
            });
            StaticHelperClass.AssertThrowsException(startIndexNegative, typeof(Exception), "Start index is negative.");

            string[] jsonStrings = new string[32];
            StaticHelperClass.AssertThrowsException(
                () => { CryptoSerializer.DeserializeFieldZqElementArray(jsonStrings, 0, 0, "field", null); },
                typeof(SerializationException),
                "Group is null.");
        }