Beispiel #1
0
        /// <summary>
        /// Creates an instance of SEALContext, and performs several pre-computations
        /// on the given EncryptionParameters.
        /// </summary>
        /// <param name="parms">The encryption parameters.</param>
        /// <param name="expandModChain">Determines whether the modulus switching chain
        /// should be created</param>
        /// <exception cref="ArgumentNullException">if parms is null</exception>
        public static SEALContext Create(EncryptionParameters parms, bool expandModChain = true)
        {
            if (null == parms)
            {
                throw new ArgumentNullException(nameof(parms));
            }

            NativeMethods.SEALContext_Create(parms.NativePtr, expandModChain, out IntPtr contextPtr);
            SEALContext context = new SEALContext(contextPtr);

            return(context);
        }
Beispiel #2
0
        /// <summary>
        /// Creates an instance of SEALContext and performs several pre-computations
        /// on the given EncryptionParameters.
        /// </summary>
        /// <param name="parms">The encryption parameters.</param>
        /// <param name="expandModChain">Determines whether the modulus switching chain
        /// should be created</param>
        /// <param name="secLevel">Determines whether a specific security level should be
        /// enforced according to HomomorphicEncryption.org security standard</param>
        /// <exception cref="ArgumentNullException">if parms is null</exception>
        public SEALContext(EncryptionParameters parms,
                           bool expandModChain = true, SecLevelType secLevel = SecLevelType.TC128)
        {
            if (null == parms)
            {
                throw new ArgumentNullException(nameof(parms));
            }

            NativeMethods.SEALContext_Create(parms.NativePtr,
                                             expandModChain, (int)secLevel, out IntPtr context);
            NativePtr = context;
        }