Skip to content

Square root trait and implementation cleanups #1082

@andrewwhitehead

Description

@andrewwhitehead

Some potential cleanups for the traits and implementation:

  • Add a CheckedSquareRoot trait which could be implemented by Int (returning none for negative inputs). This could be a supertrait of SquareRoot.
  • Rename the SquareRoot trait for clarity, perhaps UintSquareRoot or FloorSquareRoot.
  • [ ] Implement the square root trait(s) for Montgomery forms (this makes FloorSquareRoot a less desirable name).
  • Rename Uint::sqrt/sqrt_vartime to isqrt or sqrt_unchecked to reflect the inexact nature of the result (and corresponding trait updates to match).
  • Implement square root traits and methods for OddUint for consistency. This would require changing the return type, but it seems reasonable to add an Output type to the trait(s).
  • Support nth roots based on algorithm 1.14 from the same source (Brent & Zimmermann, Modern Computer Arithmetic, v0.5.9). Should this be a separate trait?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions