/// <summary> /// Retrieve a parameter set by its identity code /// </summary> /// /// <param name="OId">The 4 byte parameter set identity code</param> /// /// <returns>A populated parameter set</returns> /// /// <exception cref="CryptoAsymmetricException">Thrown if an invalid or unknown OId is used.</exception> public static RLWEParameters FromId(byte[] OId) { if (OId == null) { throw new CryptoAsymmetricException("RLWEParamSets:FromId", "OId can not be null!", new ArgumentNullException()); } if (OId.Length != 4) { throw new CryptoAsymmetricException("RLWEParamSets:FromId", "OId must be 4 bytes in length!", new ArgumentOutOfRangeException()); } if (OId[0] != 3) { throw new CryptoAsymmetricException("RLWEParamSets:FromId", "OId is not a valid RLWE parameter id!", new ArgumentException()); } if (OId[3] == 1) { return((RLWEParameters)RLWEN256Q7681.DeepCopy()); } else if (OId[3] == 2) { return((RLWEParameters)RLWEN512Q12289.DeepCopy()); } throw new CryptoAsymmetricException("RLWEParamSets:FromId", "OId does not identify a valid param set!", new ArgumentOutOfRangeException()); }
/// <summary> /// Retrieve a parameter set by its enumeration name /// </summary> /// /// <param name="Name">The enumeration name</param> /// /// <returns>A populated parameter set</returns> /// /// <exception cref="CryptoAsymmetricException">Thrown if an invalid or unknown parameter name is used.</exception> public static RLWEParameters FromName(RLWEParamNames Name) { switch (Name) { case RLWEParamNames.N256Q7681: return((RLWEParameters)RLWEN256Q7681.DeepCopy()); case RLWEParamNames.N512Q12289: return((RLWEParameters)RLWEN512Q12289.DeepCopy()); default: throw new CryptoAsymmetricException("RLWEParamSets:FromName", "The enumeration name is unknown!", new ArgumentException()); } }