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

chore: avoid nonnative dereferences #861

Merged
merged 5 commits into from Oct 19, 2023

Conversation

ivokub
Copy link
Collaborator

@ivokub ivokub commented Oct 13, 2023

Description

With the upcoming pr #749 it is necessary that we do not change the limb values of emulated.Element values. Mostly the API is designed in a way that this doesn't happen (we pass in and out pointers and do not perform in-place modifications), but there are a few cases in nonnative algebra where the API is overridden. This is mostly due to that for structs containing nonnative elements we need to use the value instead of pointer to count the number of field elements to allocate and have initialized values.

For example, if we have definition like:

type G1Affine struct {
    X, Y emulated.Element[emparams.BN254Fp]
}

and we compute

var P G1Affine
P = curve.Add(c.G, c.Q)
P.X = *emulated.Add(&p.X, other)

then we modify the value P.X. Now, as the multiplication checks are deferred for amortizing some computations, we get a failed check.

This PR changes such occurrences, making #749 more streamlined. Similar changes are already incorporated in #846.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

How has this been benchmarked?

Not benchmarked, circuit stats are the same are the same.

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I did not modify files generated from templates
  • golangci-lint does not output errors locally
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@ivokub ivokub added the consolidate strengthen an existing feature label Oct 13, 2023
@ivokub ivokub requested a review from gbotrel October 13, 2023 08:12
@ivokub ivokub self-assigned this Oct 13, 2023
@ivokub ivokub changed the title choe: avoid nonnative dereferences chore: avoid nonnative dereferences Oct 13, 2023
@ivokub
Copy link
Collaborator Author

ivokub commented Oct 17, 2023

@gbotrel - pinging. This PR is a pre-requisite for #749.

@gbotrel gbotrel merged commit 3f137c7 into master Oct 19, 2023
5 checks passed
@ivokub ivokub deleted the chore/avoid-nonnative-dereferences branch October 19, 2023 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consolidate strengthen an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants