RustCrypto / RustCrypto/crypto-bigint

Square root trait and implementation cleanups

Open
#1,082 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
309
Forks
96
Avg merge
1d 14h
Merged PRs (30d)
3

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing square-root traits and the Uint::sqrt/sqrt_vartime and OddUint APIs, then compare the proposed trait names and return types with the issue's remaining tasks. Done would require an agreed design and implementation for OddUint square roots, plus a decision on whether nth roots belong in a separate trait and how algorithm 1.14 applies.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.