-
Notifications
You must be signed in to change notification settings - Fork 250
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
feat(acir_field): Add little-endian byte serialization for FieldElement #7258
Conversation
Thank you for your contribution to the Noir language. Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch. Thanks for your understanding. |
@aakoshh Corrected |
@aakoshh Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for adding this @VolodymyrBg 🙏
It looks good to me, but I'd like to defer to @TomAFrench about it, in case he remembers more context about this TODO.
FWIW I see one location where we're reversing after to_be_bytes, although I'm confused by the comment whether it should be big or little endian.
This doesn't compile. |
@VolodymyrBg can you run |
Oh wait, it looks like fbfc367 truncated most of |
Really, corrected |
Thanks. I'd like to ask though that you revert this branch to 445ac75 , apply the formatting fix there, then force push. That's because if you look at the blame then it looks like you authored the whole thing, because it all comes from the commit that restored the lost lines. Compared that to what it looked like before a lot of the history is now buried. |
@aakoshh Done |
@TomAFrench this seems ready apart from the circuit size report. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* master: fix(performance): Remove redundant slice access check from brillig (#7434) chore(docs): updating tutorials and other nits to beta.2 (#7405) feat: LSP hover for integer literals (#7368) feat(experimental): Compile match expressions (#7312) feat(acir_field): Add little-endian byte serialization for FieldElement (#7258) feat: allow unquoting TraitConstraint in trait impl position (#7395) feat(brillig): Hoist shared constants across functions to the global space (#7216) feat(LSP): auto-import via visible reexport (#7409) fix(brillig): Brillig entry point analysis and function specialization through duplication (#7277) chore: redo typo PR by maximevtush (#7425) fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (#7396) feat!: remove bigint from stdlib (#7411)
…m brillig (noir-lang/noir#7434) chore(docs): updating tutorials and other nits to beta.2 (noir-lang/noir#7405) feat: LSP hover for integer literals (noir-lang/noir#7368) feat(experimental): Compile match expressions (noir-lang/noir#7312) feat(acir_field): Add little-endian byte serialization for FieldElement (noir-lang/noir#7258) feat: allow unquoting TraitConstraint in trait impl position (noir-lang/noir#7395) feat(brillig): Hoist shared constants across functions to the global space (noir-lang/noir#7216) feat(LSP): auto-import via visible reexport (noir-lang/noir#7409) fix(brillig): Brillig entry point analysis and function specialization through duplication (noir-lang/noir#7277) chore: redo typo PR by maximevtush (noir-lang/noir#7425) fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (noir-lang/noir#7396) feat!: remove bigint from stdlib (noir-lang/noir#7411) chore: bump aztec-packages commit (noir-lang/noir#7415) chore: deprecate `merkle` module of stdlib (noir-lang/noir#7413) chore(ci): lock aztec-packages commit in CI (noir-lang/noir#7414) feat: while statement (noir-lang/noir#7280)
…oir-lang/noir#7434) chore(docs): updating tutorials and other nits to beta.2 (noir-lang/noir#7405) feat: LSP hover for integer literals (noir-lang/noir#7368) feat(experimental): Compile match expressions (noir-lang/noir#7312) feat(acir_field): Add little-endian byte serialization for FieldElement (noir-lang/noir#7258) feat: allow unquoting TraitConstraint in trait impl position (noir-lang/noir#7395) feat(brillig): Hoist shared constants across functions to the global space (noir-lang/noir#7216) feat(LSP): auto-import via visible reexport (noir-lang/noir#7409) fix(brillig): Brillig entry point analysis and function specialization through duplication (noir-lang/noir#7277) chore: redo typo PR by maximevtush (noir-lang/noir#7425) fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (noir-lang/noir#7396) feat!: remove bigint from stdlib (noir-lang/noir#7411) chore: bump aztec-packages commit (noir-lang/noir#7415) chore: deprecate `merkle` module of stdlib (noir-lang/noir#7413) chore(ci): lock aztec-packages commit in CI (noir-lang/noir#7414) feat: while statement (noir-lang/noir#7280)
Automated pull of development from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix(performance): Remove redundant slice access check from brillig (noir-lang/noir#7434) chore(docs): updating tutorials and other nits to beta.2 (noir-lang/noir#7405) feat: LSP hover for integer literals (noir-lang/noir#7368) feat(experimental): Compile match expressions (noir-lang/noir#7312) feat(acir_field): Add little-endian byte serialization for FieldElement (noir-lang/noir#7258) feat: allow unquoting TraitConstraint in trait impl position (noir-lang/noir#7395) feat(brillig): Hoist shared constants across functions to the global space (noir-lang/noir#7216) feat(LSP): auto-import via visible reexport (noir-lang/noir#7409) fix(brillig): Brillig entry point analysis and function specialization through duplication (noir-lang/noir#7277) chore: redo typo PR by maximevtush (noir-lang/noir#7425) fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (noir-lang/noir#7396) feat!: remove bigint from stdlib (noir-lang/noir#7411) chore: bump aztec-packages commit (noir-lang/noir#7415) chore: deprecate `merkle` module of stdlib (noir-lang/noir#7413) chore(ci): lock aztec-packages commit in CI (noir-lang/noir#7414) feat: while statement (noir-lang/noir#7280) END_COMMIT_OVERRIDE --------- Co-authored-by: Tom French <tom@tomfren.ch>
Description
Added a new to_le_bytes() method to FieldElement that provides native little-endian byte serialization. This complements the existing to_be_bytes() method and allows callers to choose their preferred endianness without manual byte reversal.
Changes:
Problem
Resolves #TODO
Summary
Added little-endian byte serialization support for FieldElement to provide more flexibility in byte order handling. Previously, the to_be_bytes() method was using little-endian serialization internally and then reversing the bytes. This PR adds a dedicated to_le_bytes() method to make the endianness handling more explicit and efficient.
Additional Context
The implementation:
Adds new to_le_bytes() method that returns bytes in little-endian order
Removes redundant comments from to_be_bytes()
Includes comprehensive test coverage for both endianness formats
Maintains backward compatibility with existing code
Documentation
[x] No documentation needed.
PR Checklist
[x] I have tested the changes locally.
Added new test case test_endianness() that verifies correct byte ordering
Verified existing tests pass
[x] I have formatted the changes with Prettier and/or cargo fmt on default settings.
Code follows Rust formatting guidelines
All new code is properly documented with comments