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

feat(acir_field): Add little-endian byte serialization for FieldElement #7258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VolodymyrBg
Copy link

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:

  • Added to_le_bytes() method that returns bytes in little-endian order
  • Cleaned up documentation around byte ordering
  • Added test case to verify correct endianness handling

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

Copy link
Contributor

github-actions bot commented Feb 1, 2025

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.

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.

1 participant