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

refactor: Compile(ecc.ID) -> Compile(field *big.Int) #328

Merged
merged 20 commits into from Jun 7, 2022

Conversation

gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented Jun 6, 2022

This PR makes frontend.Compile hints witness and cs packages dependent on a field instead of being dependent on a curveID.

This PR adds a tinyfield package (modulus == 47), for test purposes.

I believe the only algorithmic change is witness Serialization; instead of using curve.Encoder it directly uses fr.Element [Set]Bytes() methods.

  • build: update to latest gnark-crypto
  • refactor: frontend.Compile(ecc.ID) -> frontend.Compile(field.Field)
  • refactor: field.Field -> *big.Int
  • build: update to latest gnark-crypto
  • feat: added internal/tinyfield
  • refactor: NewWitness(ecc.ID) -> NewWitness(field big.Int)
  • feat: build R1CS with tinyfield
  • test: ignore range circuit for tinyfield r1cs serialization
  • refactor: hint now takes *big.Int scalar field instead of curveID

@gbotrel gbotrel requested a review from ivokub June 6, 2022 17:35
Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that in general the changes make sense. I'm just thinking that maybe it would be better to name the modulus variable as primeFieldModulus etc? If it is field, then may be ambiguous?

internal/utils/field_to_curve.go Show resolved Hide resolved
backend/witness/witness.go Outdated Show resolved Hide resolved
frontend/compiled/cs.go Outdated Show resolved Hide resolved
frontend/compiled/cs.go Outdated Show resolved Hide resolved
frontend/cs/r1cs/builder.go Show resolved Hide resolved
std/algebra/fields_bls12377/e12_test.go Show resolved Hide resolved
std/fiat-shamir/transcript_test.go Outdated Show resolved Hide resolved
std/fiat-shamir/transcript_test.go Outdated Show resolved Hide resolved
std/math/bits/conversion_binary.go Outdated Show resolved Hide resolved
std/math/bits/conversion_ternary.go Outdated Show resolved Hide resolved
@gbotrel gbotrel merged commit 9266fff into develop Jun 7, 2022
@gbotrel gbotrel deleted the test/fuzz_small_field branch June 7, 2022 20:06
@drakstik
Copy link

Hey, I know this is a closed issue, but it was not updated in your Go package documentations https://pkg.go.dev/github.com/consensys/gnark#section-readme. Specifically, the first example given of a cubic equation. Would save time for beginners to just add the ecc.BN254.ScalarField() to the example! I had to look around the GitHub for this, which is good practice, but I'd rather save other's time just a little.

Thanks for all the hard work!

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 this pull request may close these issues.

None yet

3 participants