RustCrypto / RustCrypto/crypto-bigint

Determine and document `BoxedUint` widening arithmetic semantics

Open
#312 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Arithmetic with BoxedUint needs to deal with values whose number of limbs don't match. This is true of Uint as well, but there everything is nicely type safe.

So far the internal BoxedUint::chain operation (which addition and subtraction are implemented in terms of) handles widening to the widest of the two inputs.

The wrapping_* and checked_* functions use the self/left-hand side argument as the overflow width.

The mul_wide operation widens to as many limbs as are in the sum of the number of limbs in the operands (though should perhaps be renamed to just BoxedUint::mul for consistency with Uint::mul, which is also a widening multiply.

This seems like a reasonable enough approach, but whatever one we take should be thoroughly documented, both as an overall policy and on the individual functions.

We should also ensure it's consistent with how Uint performs widening, where applicable.

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 comparing BoxedUint and Uint widening behavior, then inspect the existing chain, wrapping_, checked_, and mul_wide operations. Document the chosen overall policy and individual function semantics, including consistency with Uint where applicable, and resolve whether mul_wide should be renamed.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.