Skip to content

crypto: Rewrite modexp_even to use variadic-length numbers#1443

Merged
chfast merged 1 commit intomasterfrom
crypto/modexp_even
Feb 7, 2026
Merged

crypto: Rewrite modexp_even to use variadic-length numbers#1443
chfast merged 1 commit intomasterfrom
crypto/modexp_even

Conversation

@chfast
Copy link
Member

@chfast chfast commented Feb 6, 2026

Extends the variadic-length span approach to modexp_even, replacing fixed-width UIntT operations with span-based arithmetic over only the ⌈k/64⌉ words needed.
New add and sub helpers are introduced. The mul function is relaxed to auto-swap operands instead of requiring x.size() >= y.size().

Copilot AI review requested due to automatic review settings February 6, 2026 20:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the even-modulus modular exponentiation path to operate on variadic-length word spans (⌈k/64⌉ words) instead of fixed-width UIntT arithmetic, aligning it with the existing span-based approach used elsewhere in modexp.cpp.

Changes:

  • Added small span-based add() and sub() helpers for multi-word arithmetic.
  • Updated mul() to auto-swap operands so it no longer requires x.size() >= y.size().
  • Rewrote modexp_even() to compute intermediate values using only the words required by k and temporary span buffers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.53%. Comparing base (d6b2f2a) to head (a3a9a8e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1443   +/-   ##
=======================================
  Coverage   96.52%   96.53%           
=======================================
  Files         152      152           
  Lines       13845    13862   +17     
  Branches     3227     3230    +3     
=======================================
+ Hits        13364    13381   +17     
  Misses        342      342           
  Partials      139      139           
Flag Coverage Δ
eest-develop 92.15% <100.00%> (+0.02%) ⬆️
eest-develop-gmp 29.33% <100.00%> (+0.08%) ⬆️
eest-legacy 15.29% <0.00%> (-0.02%) ⬇️
eest-legacy-silkpre 24.84% <100.00%> (+0.09%) ⬆️
evmone-unittests 91.28% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 94.94% <100.00%> (+0.01%) ⬆️
tooling 85.28% <ø> (ø)
tests 99.77% <ø> (ø)
Files with missing lines Coverage Δ
lib/evmone_precompiles/modexp.cpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Extends the variadic-length span approach to modexp_even, replacing
fixed-width UIntT operations with span-based arithmetic over only
the ⌈k/64⌉ words needed.
New add and sub helpers are introduced. The mul function is relaxed to
auto-swap operands instead of requiring x.size() >= y.size().
@chfast chfast force-pushed the crypto/modexp_even branch from 1c414d7 to a3a9a8e Compare February 7, 2026 08:02
@chfast chfast merged commit 5acfc2b into master Feb 7, 2026
23 checks passed
@chfast chfast deleted the crypto/modexp_even branch February 7, 2026 08:31
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