public static byte[] Decrypt(ModuloRing @private, byte[] C) { byte[] M = new byte[C.Length / 4]; fixed(byte *pc = C) { int *ptr = (int *)pc; Parallel.For(0, M.Length, i => M[i] = Decrypt(@private, ptr[i])); } return(M); }
public static byte[] Encrypt(ModuloRing @public, byte[] M) { byte[] C = new byte[M.Length * 4]; fixed(byte *pc = C) { int *ptr = (int *)pc; Parallel.For(0, M.Length, i => ptr[i] = Encrypt(@public, M[i])); } return(C); }
public override int NextInt() => (_x = _x.Power(2)).GetHashCode();
private static byte Decrypt(ModuloRing @private, int C) => (byte)(bint.ModPow(C, @private.Value, @private.Modulus) - 2);
private static int Encrypt(ModuloRing @public, byte M) => (int)bint.ModPow(M + 2, @public.Value, @public.Modulus);