Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

galois.GF(2^128) problem #531

Closed
suchuankai opened this issue Dec 30, 2023 · 2 comments
Closed

galois.GF(2^128) problem #531

suchuankai opened this issue Dec 30, 2023 · 2 comments

Comments

@suchuankai
Copy link

Hello,

I am relatively new to coding and want to express my gratitude for your library, which helps me a lot!

Currently, I am encountering an issue while working with calculations in GF(2^128). When attempting to create a class for GF(2^128), I encountered a LookupError. When using "galois.irreducible_poly," I identified an irreducible polynomial: "x^128 + x^7 + x^2 + x + 1."

I am seeking guidance on how to make GF(2^128) compatible with this specific irreducible polynomial. Any assistance would be greatly appreciated!

Thank you very much for your time and support!

@mhostetter
Copy link
Owner

I'm glad you're enjoying the library. The keyword argument you're looking for is irreducible_poly, see here https://mhostetter.github.io/galois/latest/api/galois.GF/#p-irreducible_poly. You can specify a PolyLike object, see here https://mhostetter.github.io/galois/latest/api/galois.typing.PolyLike/.

So, for you, you can create the field like this

In [1]: import galois

In [2]: GF = galois.GF(2**128, irreducible_poly="x^128 + x^7 + x^2 + x + 1")

In [3]: GF
Out[3]: <class 'galois.GF(2^128)'>

In [4]: print(GF.properties)
Galois Field:
  name: GF(2^128)
  characteristic: 2
  degree: 128
  order: 340282366920938463463374607431768211456
  irreducible_poly: x^128 + x^7 + x^2 + x + 1
  is_primitive_poly: True
  primitive_element: x

@suchuankai
Copy link
Author

Thanks for the solution you provided!
It worked perfectly and solved my issue.
I really appreciate your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants