/// <summary> /// Creates a IntegerEncoder object. The constructor takes as input a pointer to /// a SEALContext object which contains the plaintext modulus. /// </summary> /// <param name="context">The SEALContext</param> /// <exception cref="ArgumentNullException">if context is null</exception> /// <exception cref="ArgumentException">if the context is not set</exception> /// <exception cref="ArgumentException">if the PlainModulus set in context is not /// at least 2</exception> public IntegerEncoder(SEALContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } if (!context.ParametersSet) { throw new ArgumentException("Encryption parameters are not set correctly"); } SEALContext.ContextData contextData = context.FirstContextData; if (contextData.Parms.Scheme != SchemeType.BFV) { throw new ArgumentException("Unsupported scheme"); } NativeMethods.IntegerEncoder_Create(context.NativePtr, out IntPtr encoderPtr); NativePtr = encoderPtr; }
/// <summary> /// Creates a BatchEncoder. It is necessary that the encryption parameters /// given through the SEALContext object support batching. /// </summary> /// <param name="context">The SEALContext</param> /// @param[in] context /// <exception cref="ArgumentNullException">if context is null.</exception> /// <exception cref="ArgumentException">if the context is not set or encryption /// parameters are not valid for batching</exception> /// <exception cref="ArgumentException">if scheme is not SchemeType.BFV</exception> public BatchEncoder(SEALContext context) { if (null == context) { throw new ArgumentNullException(nameof(context)); } if (!context.ParametersSet) { throw new ArgumentException("Encryption parameters are not set correctly"); } SEALContext.ContextData contextData = context.FirstContextData; if (contextData.Parms.Scheme != SchemeType.BFV) { throw new ArgumentException("Unsupported scheme"); } if (!contextData.Qualifiers.UsingBatching) { throw new ArgumentException("Encryption parameters are not valid for batching"); } NativeMethods.BatchEncoder_Create(context.NativePtr, out IntPtr ptr); NativePtr = ptr; }