Exemplo n.º 1
0
 public void Decrypt()
 {
     Utils.ProcessInEnv(env =>
     {
         var dec = enc1.Decrypt(env);
         Compare(vec1, dec);
     }, Factory);
 }
Exemplo n.º 2
0
        public static void Show(IVector v, IFactory factory, string name = "", bool showAll = false)
        {
            Vector <double> dec = null;

            Utils.ProcessInEnv((env) => { dec = v.Decrypt(env); }, factory);
            Console.Write("{0} size {1}", name, dec.Count);
            int last = dec.Count;

            if (!showAll && 3 < last)
            {
                last = 3;
            }
            for (int i = 0; i < last; i++)
            {
                Console.Write("\t{0:F4}", dec[i]);
            }
            Console.WriteLine("\t||\t{0:F4}\t{1:F4}", dec.Min(), dec.Max());
        }
Exemplo n.º 3
0
        public void SaveLoadKeys()
        {
            if (Factory is EncryptedSealBfvFactory factory)
            {
                var now = DateTime.Now;
                factory.Save("keys.keys");
                factory.Save("keys2.keys", true);
                Console.WriteLine("Saved in {0}", (DateTime.Now - now).TotalSeconds);
                var v = Vector <Double> .Build.Dense(new double[] { 1, 2, 3 });

                IVector         vEnc     = factory.GetEncryptedVector(v, EVectorFormat.dense, 1);
                var             factory2 = new EncryptedSealBfvFactory("keys2.keys");
                Vector <double> w        = null;
                Utils.ProcessInEnv(env =>
                {
                    w = vEnc.Decrypt(env);
                }, factory2);
                Compare(v, w);
            }
        }