internal GF256Poly Multiply(GF256Poly other)
{
if (!field.Equals(other.field))
{
throw new ArgumentException("GF256Polys do not have same GF256 field");
}
if (IsZero() || other.IsZero())
{
return(field.GetZero());
}
var aCoefficients = coefficients;
var aLength = aCoefficients.Length;
var bCoefficients = other.coefficients;
var bLength = bCoefficients.Length;
var product = new int[aLength + bLength - 1];
for (var i = 0; i < aLength; i++)
{
var aCoeff = aCoefficients[i];
for (var j = 0; j < bLength; j++)
{
product[i + j] = GF256.AddOrSubtract(product[i + j],
field.Multiply(aCoeff, bCoefficients[j]));
}
}
return(new GF256Poly(field, product));
}