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

Is there an implementation of modulo operation for field? #712

Closed
wenti-123 opened this issue Dec 11, 2023 · 4 comments
Closed

Is there an implementation of modulo operation for field? #712

wenti-123 opened this issue Dec 11, 2023 · 4 comments

Comments

@wenti-123
Copy link

Hi, I am currently working on a project involving the arkworks library and have a question regarding modulo operation on field elements.

Specifically, I am interested in calculating the result of taking a field element modulo an arbitrary number. I've searched through the documentation but couldn't find a direct implementation or information regarding this operation.

Could you kindly provide guidance on whether arkworks supports modulo operation on field elements, and if so, how I can perform such operations?

Thank you in advance for your time and assistance. I appreciate your efforts in developing and maintaining the arkworks library.

@burdges
Copy link
Contributor

burdges commented Dec 11, 2023

All elements are invertable in a field, so the remainer is always zero (or divide by zero error).

"Reduce" means the remainder in integer division. It lives in https://github.com/arkworks-rs/algebra/blob/master/ff/src/fields/models/fp/montgomery_backend.rs. ark-poly has polynomial division.

@mmaker
Copy link
Member

mmaker commented Dec 22, 2023

Agree with @burdges: for fields this doesn't make sense, but for BigInt it could be useful! in which case though it's a duplicate of #717 -- I think we can close it?

@Pratyush
Copy link
Member

Agreed that an element of a field only coincidentally happens to be an integer (and that only for prime fields). The recommended way to do what you're looking for is via #717

@hdvanegasm
Copy link
Contributor

Agree with @burdges: for fields this doesn't make sense, but for BigInt it could be useful! in which case though it's a duplicate of #717 -- I think we can close it?

I'm currently implementing this functionality to close #717.

@mmagician mmagician changed the title Is there an implementation of modulo operation for filed? Is there an implementation of modulo operation for field? Jan 11, 2024
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

5 participants