using KyberDotnet.Shake;
using System.Security.Cryptography;

namespace KyberDotnet
{
	public static class Hashes
	{
		static Shake128 Shake128 = new(1024);
		static Shake256 Shake256 = new(256);
		static SHA256 SHA256 = SHA256.Create();
		static SHA512 SHA512 = SHA512.Create();

		public static byte[] XOF(byte[] a, byte i, byte j)
		{
			var src = new byte[a.Length + 2];
			a.CopyTo(src, 0);
			src[a.Length] = i;
			src[a.Length + 1] = j;
			return Shake128.ComputeHash(src);
		}

		public static byte[] H(byte[] a)
		{
			return SHA256.ComputeHash(a);
		}

		public static byte[] G(byte[] a)
		{
			return SHA512.ComputeHash(a);
		}

		public static byte[] PRF(byte[] s, byte b)
		{
			var src = new byte[s.Length + 1];
			s.CopyTo(src, 0);
			src[s.Length] = b;
			return Shake256.ComputeHash(src);
		}

		public static byte[] KDF(byte[] a)
		{
			return Shake256.ComputeHash(a);
		}
	}
}
