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();
}
int[] aCoefficients = this.coefficients;
int aLength = aCoefficients.Length;
int[] bCoefficients = other.coefficients;
int bLength = bCoefficients.Length;
int[] product = new int[aLength + bLength - 1];
for (int i = 0; i < aLength; i++) {
int aCoeff = aCoefficients[i];
for (int j = 0; j < bLength; j++) {
product[i + j] = GF256.AddOrSubtract(product[i + j],
field.Multiply(aCoeff, bCoefficients[j]));
}
}
return new GF256Poly(field, product);
}