Skip to content

feat: field/goldilocks (more efficient 1-limb modulus arith)#177

Merged
gbotrel merged 20 commits intodevelopfrom
feat/goldilocks
May 10, 2022
Merged

feat: field/goldilocks (more efficient 1-limb modulus arith)#177
gbotrel merged 20 commits intodevelopfrom
feat/goldilocks

Conversation

@gbotrel
Copy link
Copy Markdown
Collaborator

@gbotrel gbotrel commented Apr 29, 2022

This PR adds field/goldilocks (q = 0xffffffff00000001) .

Mostly tunes the code generation for field arithmetic to produce more efficient code when len(modulus) == 1 limb; no assembly is generated (it would be counter productive) and no "goldilocks" specific tricks are used.

plonky2 paper mentions some "arithmetic tricks" that makes modular reduction efficient. In practice, perf is in the same range than the CIOS Montgomery reduction for 1-liimb.

closes #174

@gbotrel gbotrel requested a review from Tabaie April 29, 2022 18:18
{{- end}}

{{ template "reduce" .}}
{{ template "reduce" .}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should reduce be in an else clause? There's no situation where we would need two reductions. Does it matter?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't understand the two reductions part / does it matter --> both code path must exist at the template level, when all bits are set and you have a carry to the last addition, then you need to reduce, but if not, you still need to check that z < q.

@gbotrel gbotrel linked an issue May 4, 2022 that may be closed by this pull request
@gbotrel gbotrel merged commit 7cf9daf into develop May 10, 2022
@gbotrel gbotrel deleted the feat/goldilocks branch May 10, 2022 00:44
@gbotrel gbotrel mentioned this pull request Aug 3, 2022
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.

field arithmetic should handle 1-limb modulus

2 participants