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

Fields are Groups #507

Closed
2 of 4 tasks
mmaker opened this issue Nov 1, 2022 · 12 comments · Fixed by #577
Closed
2 of 4 tasks

Fields are Groups #507

mmaker opened this issue Nov 1, 2022 · 12 comments · Fixed by #577

Comments

@mmaker
Copy link
Member

mmaker commented Nov 1, 2022

A lot of cryptographic schemes (some IBEs, ABEs, hash proof systems,  and sumcheck arguments [BCS]) use the abstraction of "modules". Arkworks currently has a nice abstraction, Group, that essentially implements the operations that we would expect from a module: this is already satisfied in pairing-friendly curves by G1, G2, and PairingOutput.

It'd be really nice if also field implemented this abstraction, so to make possible the realizations of such schemes without having wrappers around the structures. To avoid confusion and lock-out of features of the multiplicative group, perhaps consider renaming Group into AdditiveGroup?. Here's a possible sketch of the steps to achieve this:

  • state clearly in the documentation that Groups are additive
  • make all Field a Group: this can be first perhaps done in ark-ec with a blanket implementation, to avoid moving code around (hoping this does not break anything)
  • move the Group definition into ark-ff for the small operations, and re-assing group-specific methods
  • rename Group into AdditiveGroup?
@Pratyush
Copy link
Member

Pratyush commented Nov 1, 2022

We can move Group to ark-ff without breaking changes, as long as we publicly re-export it from ark-ec anyway. I suggest that we go all the way and just directly make an ark-group crate that is imported by both ark-ff and ark-ec.

mmaker added a commit to mmaker/arkworks-algebra that referenced this issue Dec 24, 2022
@mmaker
Copy link
Member Author

mmaker commented Dec 24, 2022

@Pratyush @mmagician what do you think of the above?

  1. I created AdditiveGroup in ark_ff which encapsulates all group operations.
  2. Made Field: AdditiveGroup
  3. Renamed ark_ec::Group into ark_ec::PrimeGroup
  4. Made PrimeGroup: AdditiveGroup

One example where this is useful is this generic sumcheck argument; https://github.com/arkworks-rs/gemini/blob/main/src/herring/
That can avoid all this useless code: https://github.com/arkworks-rs/gemini/blob/main/src/herring/module.rs

@mmagician
Copy link
Member

I'll look at the actual code later, the idea seems reasonable though 👍🏼

@Pratyush
Copy link
Member

Pratyush commented Dec 25, 2022

What's the difference between PrimeGroup and AdditiveGroup?

EDIT: That is, do we ever instantiate AdditiveGroups that are not of prime order?

@mmaker
Copy link
Member Author

mmaker commented Dec 25, 2022

Hey, thanks for taking a look! Yes, all field extensions are not of prime order, so making them PrimeGroup wouldn't be possible. The main difference between AdditiveGroup and PrimeGroup is that ScalarField: Field in the former and ScalarField: PrimeField in the latter. Plus, there's all these methods dealing with bit- and byte-representation that are not really fit for non-cyclic groups of composite order

mmaker added a commit to mmaker/arkworks-algebra that referenced this issue Dec 25, 2022
@mmaker
Copy link
Member Author

mmaker commented Dec 25, 2022

removed some code not useful at this stage (implementation of PrimeGroup for PrimeField)

@Pratyush
Copy link
Member

That's a good point, makes sense. In that case it might make sense to remove ScalarField from AdditiveGroup, as we might have groups with composite order that is not a prime-power. For example, elliptic curve groups.

@mmaker
Copy link
Member Author

mmaker commented Dec 28, 2022

mmh ScalarField is needed for any abstract operation you do on them, and we do not have the notion of a Ring.. should I call it FieldModule, VectorSpace or something else?
Plus, all constructions that i know of need a field structure, like sumcheck arguments, hash proof systems, or ABE.

@Pratyush
Copy link
Member

Why do you need a scalar field for operations? Group operations only require Add, Sub, Neg, Zero, One, etc, no?

Do sumcheck arguments require composite-order groups?

@mmaker
Copy link
Member Author

mmaker commented Dec 29, 2022

yes we need scalar field operations -- and sumcheck arguments require modules (over rings, not necessarily over fields). See e.g. def. 4.1.
Screenshot 2022-12-29 at 08 11 43

@mmaker
Copy link
Member Author

mmaker commented Jan 6, 2023

bump! @Pratyush @mmagician

@Pratyush
Copy link
Member

Hm my main worry is just that we don't have a way to define a Scalar*Field* for composite order groups. We would need to introduce a Ring abstraction (which I am fine with). However that would make the scope of this PR larger (which I am also fine with)

mmaker added a commit to mmaker/arkworks-algebra that referenced this issue Jan 19, 2023
mmaker added a commit to mmaker/arkworks-algebra that referenced this issue Jan 19, 2023
mmaker added a commit to mmaker/arkworks-algebra that referenced this issue Jan 19, 2023
mmaker added a commit to mmaker/arkworks-algebra that referenced this issue Jan 19, 2023
mmaker added a commit that referenced this issue May 10, 2023
* Add AdditiveGroup trait + Field: AdditiveGroup. This trait now integrates ZERO, double, double_in_place, and negate. Fix doctests accordingly (#507)
* Fix disambiguation of what is a ScalarField in bench-templates. Remove `ScalarField` from `CurveGroup`

---------

Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
aleasims pushed a commit to NilFoundation/arkworks-algebra that referenced this issue Oct 18, 2023
* Add AdditiveGroup trait + Field: AdditiveGroup. This trait now integrates ZERO, double, double_in_place, and negate. Fix doctests accordingly (arkworks-rs#507)
* Fix disambiguation of what is a ScalarField in bench-templates. Remove `ScalarField` from `CurveGroup`

---------

Co-authored-by: Pratyush Mishra <pratyushmishra@berkeley.edu>
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

Successfully merging a pull request may close this issue.

3 participants