/// <summary> /// Decrypt a cipher text /// </summary> /// /// <param name="Input">The cipher text</param> /// /// <returns>The plain text</returns> /// /// <exception cref="RLWEException">Thrown if cipher has not been initialized</exception> public byte[] Decrypt(byte[] Input) { if (!_isInitialized) { throw new RLWEException("RLWEEncrypt:Decrypt", "The cipher has not been initialized!", new InvalidOperationException()); } int plen = _N >> 3; if (_N == 512) { NTT512 ntt = new NTT512(_rndEngine); return(ntt.Decrypt((RLWEPrivateKey)_keyPair.PrivateKey, Input).SubArray(_mFp, plen - _mFp)); } else { NTT256 ntt = new NTT256(_rndEngine); return(ntt.Decrypt((RLWEPrivateKey)_keyPair.PrivateKey, Input).SubArray(_mFp, plen - _mFp)); } }
/// <summary> /// Decrypt a cipher text /// </summary> /// /// <param name="Input">The cipher text</param> /// /// <returns>The plain text</returns> /// /// <exception cref="CryptoAsymmetricException">Thrown if cipher has not been initialized</exception> public byte[] Decrypt(byte[] Input) { if (!_isInitialized) { throw new CryptoAsymmetricException("RLWEEncrypt:Decrypt", "The cipher has not been initialized!", new InvalidOperationException()); } if (_isEncryption) { throw new CryptoAsymmetricSignException("RLWEEncrypt:Decrypt", "The cipher is not initialized for decryption!", new ArgumentException()); } int plen = _N >> 3; if (_N == 512) { NTT512 ntt = new NTT512(_rndEngine); return(ntt.Decrypt((RLWEPrivateKey)_asmKey, Input).SubArray(_mFp, plen - _mFp)); } else { NTT256 ntt = new NTT256(_rndEngine); return(ntt.Decrypt((RLWEPrivateKey)_asmKey, Input).SubArray(_mFp, plen - _mFp)); } }