Skip to content

Add file to construct fields in Sage#128

Merged
matteo-frigo merged 2 commits intogoogle:mainfrom
divergentdave:david/sage-field
Apr 8, 2026
Merged

Add file to construct fields in Sage#128
matteo-frigo merged 2 commits intogoogle:mainfrom
divergentdave:david/sage-field

Conversation

@divergentdave
Copy link
Copy Markdown
Contributor

This adds a Python file that handles constructing Sage finite field objects, for use throughout the rest of the reference implementation. This is similar to the code from #32 (comment), but with ^ and .<x> desugared, and using Python ints instead of sage.rings.integer.Integer. This module doesn't provide generators as exported module variables, to avoid confusion between variable names. Generators are instead only created inside function scopes. Other code that needs to access a generator element can call the field's gens() method later.

@divergentdave
Copy link
Copy Markdown
Contributor Author

I changed my mind on the name, I want to call this module fields to allow for arguments named field without shadowing variable names.

Comment thread docs/specs/code/fields.py
Comment on lines +20 to +21
Fp384 = GF(2 ** 384 - 2 ** 128 - 2 ** 96 + 2 ** 32 - 1)
Fp521 = GF(2 ** 521 - 1)
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.

I think we discussed elsewhere that P384 and P521 aren't used in any circuits, and so maybe we should omit them from the spec. Same goes for P128, if we re-work test vectors to use P256 and GF(2^128). But then again since these field definitions are so lightweight, we can keep them for now and revisit the discussion of which fields to put in the spec later.

@matteo-frigo matteo-frigo merged commit 7fe28b2 into google:main Apr 8, 2026
1 check passed
@divergentdave divergentdave deleted the david/sage-field branch April 8, 2026 23:19
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.

3 participants