Exemplo n.º 1
0
        private void TestParams()
        {
            RLWEParameters mpar = RLWEParamSets.RLWEN256Q7681;

            byte[] enc = mpar.ToBytes();

            using (RLWEParameters mpar2 = RLWEParameters.From(enc))
            {
                if (!mpar.Equals(mpar2))
                {
                    throw new Exception("EncryptionKey: public key comparison test failed!");
                }
            }
            OnProgress(new TestEventArgs("Passed parameters byte serialization"));

            MemoryStream mstr = mpar.ToStream();

            using (RLWEParameters mpar2 = RLWEParameters.From(mstr))
            {
                if (!mpar.Equals(mpar2))
                {
                    throw new Exception("EncryptionKey: public key comparison test failed!");
                }
            }
            OnProgress(new TestEventArgs("Passed parameters stream serialization"));
        }
Exemplo n.º 2
0
        private void TestParams()
        {
            RLWEParameters mpar = (RLWEParameters)RLWEParamSets.RLWEN256Q7681.DeepCopy();

            byte[] enc = mpar.ToBytes();

            using (RLWEParameters mpar2 = RLWEParameters.From(enc))
            {
                if (!mpar.Equals(mpar2))
                {
                    throw new Exception("Parameters: public key comparison test failed!");
                }
                if (mpar.GetHashCode() != mpar2.GetHashCode())
                {
                    throw new Exception("Parameters: parameters hash test failed!");
                }
            }
            OnProgress(new TestEventArgs("Passed parameters byte serialization"));

            MemoryStream mstr = mpar.ToStream();

            using (RLWEParameters mpar2 = RLWEParameters.From(mstr))
            {
                if (!mpar.Equals(mpar2))
                {
                    throw new Exception("Parameters: public key comparison test failed!");
                }
            }
            OnProgress(new TestEventArgs("Passed parameters stream serialization"));
        }