Skip to content

Conversation

HusseinAdeiza
Copy link

Summary

This PR addresses and corrects Noir compatibility, code safety, and style issues in uint_note.nr.
Improvements include safer randomness usage, robust array concatenation, updated constant declarations, and clarified assertions. These changes ensure the contract logic remains secure, maintainable, and compatible with current Noir standards.

Problem

  • The previous code used potentially unsafe randomness and array concatenation that may not be fully supported in Noir.
  • Constants were declared using outdated syntax.
  • Assertion statements included custom messages, which may not be supported in all Noir versions.
  • The code and tests mixed styles that could cause confusion or errors for future maintainers.

Solution

  • Replaced unsafe randomness with Noir’s recommended random() usage.
  • Refactored array concatenation and padding logic to use idiomatic Noir patterns.
  • Updated constants to use const for clarity and compatibility.
  • Simplified assertion statements to avoid unsupported custom messages.
  • Improved comments and test code for readability and maintainability.

How to Test

  1. Run all contract tests:
    noir test -b uint-note
  2. Ensure all tests pass and compilation succeeds.
  3. Verify the contract logic, especially note creation, partial note handling, and packing/unpacking, works as intended.

Additional Context

These changes align the code with best practices for Noir development and should reduce future technical debt.
If you have questions or suggestions, please let's discuss here

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