/**
         * Tests if the key pair is valid.
         * @return <code>true</code> if the key pair is valid, <code>false</code> otherwise
         */
        public bool isValid()
        {
            if (priv.N != pub.h.Coeffs.Length)
            {
                return(false);
            }
            if (priv.q != pub.q)
            {
                return(false);
            }

            int B = priv.getNumBases() - 1;

            for (int i = 0; i <= B; i++)
            {
                Basis basis = priv.getBasis(i);
                if (!basis.isValid(i == 0 ? pub.h : basis.h))
                {
                    return(false);
                }
            }

            return(true);
        }
 /**
  * Adds a basis to the key.
  * @param b a NtruSign basis
  */
 public void add(Basis b)
 {
     bases.Add(b);
 }
Exemple #3
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            if (obj == null)
            {
                return(false);
            }
            if (!(obj.GetType().IsAssignableFrom(typeof(Basis))))
            {
                return(false);
            }
            Basis other = (Basis)obj;

            if (N != other.N)
            {
                return(false);
            }
            if (basisType != other.basisType)
            {
                return(false);
            }
            if (f == null)
            {
                if (other.f != null)
                {
                    return(false);
                }
            }
            else if (!f.Equals(other.f))
            {
                return(false);
            }
            if (fPrime == null)
            {
                if (other.fPrime != null)
                {
                    return(false);
                }
            }
            else if (!fPrime.Equals(other.fPrime))
            {
                return(false);
            }
            if (h == null)
            {
                if (other.h != null)
                {
                    return(false);
                }
            }
            else if (!h.Equals(other.h))
            {
                return(false);
            }
            if (BitConverter.DoubleToInt64Bits(keyNormBoundSq) != BitConverter.DoubleToInt64Bits(other.keyNormBoundSq))
            {
                return(false);
            }
            if (polyType != other.polyType)
            {
                return(false);
            }
            if (q != other.q)
            {
                return(false);
            }
            return(true);
        }
 /**
  * Adds a basis to the key.
  * @param b a NtruSign basis
  */
 public void add(Basis b)
 {
     bases.Add(b);
 }