示例#1
0
        public GGHModel(int dim, int l, VectorND errorVector)
        {
            this.dim = dim;
            this.l   = l;
            k        = (int)Math.Round(l * Math.Sqrt(dim));

            do
            {
                GeneratePrivateKey();
                GeneratePublicKey();
            } while (privateKeyR.Det() == 0 || publicKeyB.Det() == 0);

            privateKeyR1 = privateKeyR.Invert();
            publicKeyB1  = publicKeyB.Invert();

            GenerateLattice();

            if (errorVector == null || errorVector.dim != dim)
            {
                GenerateErrorVector();
            }
            else
            {
                this.errorVector  = errorVector;
                errorVectorIntern = new MatrixND(dim, 1);
                for (int i = 0; i < dim; i++)
                {
                    errorVectorIntern[i, 0] = (double)errorVector.values[i];
                }
            }
        }
示例#2
0
 public bool DoTheKeysFit()
 {
     try
     {
         transU = (publicKeyB * privateKeyR1);
         return(Math.Abs(Math.Round(transU.Det(), 5)) == 1.00000);
     }
     catch (Exception)
     {
         return(false);
     }
 }