Skip to content

Vendor primitives from ctutils - #1377

Merged
tarcieri merged 1 commit into
masterfrom
vendor-primitives-from-ctutils
Oct 26, 2026
Merged

tarcieri merged 1 commit into
masterfrom
vendor-primitives-from-ctutils

Conversation

@tarcieri

Copy link
Copy Markdown
Member

It seems I made a mistake extracting these into ctutils. I thought that might be a nice place to handle modeling borrows/overflows as Choice but in the course of both trying to fix the constant-time issues in crypto-bigint and then try to restore some of the previous performance I discovered the actual requirements of the function changed because I accidentally shipped a function signature with a performance bottleneck, and then in the course of subsequent refactoring I found I wasn't even able to salvage overflowing_add_*.

So I am declaring the entire ctutils::primitives module a mistake, but it's already published, so the best I can do is remove crypto-bigint's dependence on it and then deprecate it.

This moves the exact primitives that crypto-bigint needs back to the crypto_bigint::primitives module, which uses intrinsics we know work when available with a software fallback.

It also adds cargo checkct tests for these primitives.

It seems I made a mistake extracting these into `ctutils`. I thought
that might be a nice place to handle modeling borrows/overflows as
`Choice` but in the course of both trying to fix the constant-time
issues in `crypto-bigint` and then try to restore some of the previous
performance I discovered the actual requirements of the function changed
because I accidentally shipped a function signature with a performance
bottleneck, and then in the course of subsequent refactoring I found I
wasn't even able to salvage `overflowing_add_*`.

So I am declaring the entire `ctutils::primitives` module a mistake,
but it's already published, so the best I can do is remove
`crypto-bigint`'s dependence on it and then deprecate it.

This moves the exact primitives that `crypto-bigint` needs back to the
`crypto_bigint::primitives` module, which uses intrinsics we know work
when available with a software fallback.

It also adds `cargo checkct` tests for these primitives.
@tarcieri
tarcieri force-pushed the vendor-primitives-from-ctutils branch from 31c6e8f to f87f8cb Compare October 26, 2026 02:41
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.29412% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.37%. Comparing base (ec04d14) to head (f87f8cb).

Files with missing lines Patch % Lines
src/primitives.rs 84.37% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1377      +/-   ##
==========================================
- Coverage   91.39%   91.37%   -0.02%     
==========================================
  Files         190      190              
  Lines       23128    23192      +64     
==========================================
+ Hits        21138    21192      +54     
- Misses       1990     2000      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tarcieri
tarcieri merged commit 041414f into master Oct 26, 2026
63 of 64 checks passed
@tarcieri
tarcieri deleted the vendor-primitives-from-ctutils branch October 26, 2026 03:36
@tarcieri tarcieri mentioned this pull request Oct 26, 2026
tarcieri added a commit that referenced this pull request Oct 26, 2026
## Fixed
- Optimize Montgomery multiplication carry propagation (#1376)
- Replace `ctutils` primitives with faster internal primitives (#1377)
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