public static IntPoly from_arr(byte[] arr, ushort n, ushort q) { IntPoly p = IntPoly.Default(); IntPtr poly_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(p)); Marshal.StructureToPtr(p, poly_ptr, false); IntPtr arr_ptr = Marshal.AllocHGlobal(arr.Length); Marshal.Copy(arr, 0, arr_ptr, arr.Length); ffi.ntru_from_arr(arr_ptr, n, q, poly_ptr); p = (IntPoly)Marshal.PtrToStructure(poly_ptr, typeof(IntPoly)); Marshal.FreeHGlobal(poly_ptr); Marshal.FreeHGlobal(arr_ptr); return(p); }
public static PublicKey Default() { return(new PublicKey(0, IntPoly.Default())); }