GenericPolynomialExtensionField.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. using System;
  3. using Org.BouncyCastle.Utilities;
  4. namespace Org.BouncyCastle.Math.Field
  5. {
  6. internal class GenericPolynomialExtensionField
  7. : IPolynomialExtensionField
  8. {
  9. protected readonly IFiniteField subfield;
  10. protected readonly IPolynomial minimalPolynomial;
  11. internal GenericPolynomialExtensionField(IFiniteField subfield, IPolynomial polynomial)
  12. {
  13. this.subfield = subfield;
  14. this.minimalPolynomial = polynomial;
  15. }
  16. public virtual BigInteger Characteristic
  17. {
  18. get { return subfield.Characteristic; }
  19. }
  20. public virtual int Dimension
  21. {
  22. get { return subfield.Dimension * minimalPolynomial.Degree; }
  23. }
  24. public virtual IFiniteField Subfield
  25. {
  26. get { return subfield; }
  27. }
  28. public virtual int Degree
  29. {
  30. get { return minimalPolynomial.Degree; }
  31. }
  32. public virtual IPolynomial MinimalPolynomial
  33. {
  34. get { return minimalPolynomial; }
  35. }
  36. public override bool Equals(object obj)
  37. {
  38. if (this == obj)
  39. {
  40. return true;
  41. }
  42. GenericPolynomialExtensionField other = obj as GenericPolynomialExtensionField;
  43. if (null == other)
  44. {
  45. return false;
  46. }
  47. return subfield.Equals(other.subfield) && minimalPolynomial.Equals(other.minimalPolynomial);
  48. }
  49. public override int GetHashCode()
  50. {
  51. return subfield.GetHashCode() ^ Integers.RotateLeft(minimalPolynomial.GetHashCode(), 16);
  52. }
  53. }
  54. }
  55. #endif