Skip to content

General refact, and removing dead calls - #930

Open
joaozinhom wants to merge 5 commits into
selfcustody:developfrom
joaozinhom:cleanup/dependencies_and_dead_code
Open

joaozinhom wants to merge 5 commits into
selfcustody:developfrom
joaozinhom:cleanup/dependencies_and_dead_code

Conversation

@joaozinhom

Copy link
Copy Markdown
Member

What is this PR for?

This Pr intention is to solve a lot of minor nits that i notice reading the krux codebase.

Changes made to:

  • Code
  • Tests
  • Docs
  • CHANGELOG

Did you build the code and tested on device?

  • Yes, build and tested on macbook air m4

What is the purpose of this pull request?

  • Bug fix
  • New feature
  • Docs update
  • Other

@joaozinhom
joaozinhom marked this pull request as draft August 13, 2026 14:49
@codecov

codecov Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.42085% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.61%. Comparing base (2937a29) to head (ffcdb7a).

Files with missing lines Patch % Lines
src/krux/pages/settings_page.py 89.47% 2 Missing ⚠️
src/krux/pages/tools.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #930   +/-   ##
========================================
  Coverage    97.60%   97.61%           
========================================
  Files           84       85    +1     
  Lines        10994    11007   +13     
========================================
+ Hits         10731    10744   +13     
  Misses         263      263           

☔ 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.

@qlrd qlrd left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

I think it's a reasonable PR and i share some thouhgts on that like the imports and naming the try function on kef (so @jdlcdl eyes). It need some check on codecov report too since some untouched missing lines -- IDK if it's related.

Since this touches a important module i will just share some thoughts on docsstrings nits for now an a doubt about the sha256d name (althought the code explains by itself IMO).:

Comment thread src/krux/pages/encryption_ui.py Resolved
Comment thread src/krux/hashes.py Resolved
Comment thread src/krux/hashes.py Resolved
@odudex

odudex commented Aug 13, 2026

Copy link
Copy Markdown
Member

Something I don't think is worth changing in a refactor: 985f059 silently moves several hashes from software to K210 hardware SHA

This is labeled chore: refact, but it is a real on-device behavior change, not a no-op. bip39.entropy_checksum, key.py:349, capture_entropy.capture, dice_rolls, sign_message_ui, and encryption.MnemonicStorage._deprecated_decrypt previously used MaixPy's software hashlib (a full implementation, port/src/uhashlib/hashlib.c); they now route through uhashlib_hw, the hardware accelerator.

@joaozinhom

Copy link
Copy Markdown
Member Author

Something I don't think is worth changing in a refactor: 985f059 silently moves several hashes from software to K210 hardware SHA

This is labeled chore: refact, but it is a real on-device behavior change, not a no-op. bip39.entropy_checksum, key.py:349, capture_entropy.capture, dice_rolls, sign_message_ui, and encryption.MnemonicStorage._deprecated_decrypt previously used MaixPy's software hashlib (a full implementation, port/src/uhashlib/hashlib.c); they now route through uhashlib_hw, the hardware accelerator.

Good catch! I'll fix hashes.py to explicitly import and wrap hashlib (software backend), just with no silent backend swap. I'll push the fix squashed into the original commit shortly to keep the review clean.

@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch from e93c922 to 0d37eba Compare August 18, 2026 18:56
@joaozinhom
joaozinhom requested a review from qlrd August 20, 2026 12:38

@qlrd qlrd left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM on a 2nd round of manual lecture. I will do a strict review with that and LYN

@joaozinhom
joaozinhom marked this pull request as ready for review August 25, 2026 13:31
@joaozinhom
joaozinhom requested review from jdlcdl and qlrd August 25, 2026 16:34

@qlrd qlrd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

3rd round :)

Wen running without rebase, all went well:

gh pr checkout 930
git submodule update --recursive
uv sync --frozen --reinstall-package=uUR
uv run poe pre-commit

But due to recent updates, also did:

git reset --hard cleanup/dependencies_and_dead_code
git rebase origin/develop

And got some conflicts locally but easy to resolve (i think).

@joaozinhom

Copy link
Copy Markdown
Member Author

3rd round :)

Wen running without rebase, all went well:

gh pr checkout 930
git submodule update --recursive
uv sync --frozen --reinstall-package=uUR
uv run poe pre-commit

But due to recent updates, also did:

git reset --hard cleanup/dependencies_and_dead_code
git rebase origin/develop

And got some conflicts locally but easy to resolve (i think).

i will take a look

@joaozinhom

joaozinhom commented Aug 27, 2026 •

Copy link
Copy Markdown
Member Author

@qlrd you thinki should rebase to develop and change the base here on PR? iv already made it in other branch and everithing looks fine joaozinhom#6

@qlrd

qlrd commented Aug 28, 2026

Copy link
Copy Markdown
Member

@qlrd you thinki should rebase to develop and change the base here on PR? iv already made it in other branch and everithing looks fine joaozinhom#6

i think would be good. I noted now that is pointed to main

@joaozinhom
joaozinhom marked this pull request as draft August 28, 2026 21:31
@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch from 0d37eba to 3177fd7 Compare August 31, 2026 13:42
@joaozinhom
joaozinhom changed the base branch from main to develop August 31, 2026 13:42
@joaozinhom
joaozinhom requested a review from qlrd August 31, 2026 14:10

@qlrd qlrd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

some nit, i think this will reduce diff while keep functionality, wdyt?

@joaozinhom
joaozinhom marked this pull request as ready for review September 4, 2026 18:31
@qlrd qlrd mentioned this pull request Sep 6, 2026
8 of 9 tasks
@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch from 3177fd7 to e407917 Compare October 6, 2026 18:24
Comment thread firmware/MaixPy Resolved
@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch 2 times, most recently from 601ae94 to 38f7fb6 Compare October 12, 2026 21:26
@joaozinhom
joaozinhom requested review from notTanveer and qlrd October 13, 2026 14:01

@notTanveer notTanveer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i can still see changes in firmware/MaixPy and vendor/embit. this branch is not properly rebased. can you do a proper rebase on develop.

also there's a new file disclaimer.py which needs to be updated.

@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch from 38f7fb6 to b091561 Compare October 13, 2026 20:22
Comment thread mkdocs.yml Resolved
Comment thread src/krux/hashes.py Resolved
@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch from b091561 to f1026b8 Compare October 14, 2026 16:02
Comment thread mkdocs.yml Resolved
@joaozinhom
joaozinhom requested a review from notTanveer October 15, 2026 20:55

@notTanveer notTanveer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i can still see the old relative imports here:

  • src/krux/camera.py:88 from .display import display, SPLASH
  • tests/pages/test_disclaimer.py:2,53,77,99 from . import create_ctx / from ..shared_mocks
  • tests/pages/test_mnemonic_loader.py:3 from . import create_ctx

@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch from f1026b8 to 489b1b6 Compare October 18, 2026 15:58
@joaozinhom
joaozinhom marked this pull request as draft October 21, 2026 17:03

@qlrd qlrd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

some nits, idk yet if blockable or not:

Comment thread tests/test_hashes.py Resolved
Comment thread tests/test_hashes.py Resolved
Comment thread src/krux/hashes.py Resolved
@joaozinhom
joaozinhom marked this pull request as ready for review November 3, 2026 13:11
@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch from 489b1b6 to 479ccaa Compare November 4, 2026 20:00
@joaozinhom
joaozinhom requested a review from qlrd November 4, 2026 20:05

@notTanveer notTanveer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK 479ccaa

@qlrd qlrd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall good! just a doubt now that need better understanding of mine:

Comment thread tests/test_hashes.py Resolved
@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch 3 times, most recently from 8fda859 to 94dc14c Compare November 7, 2026 14:53
@joaozinhom
joaozinhom requested a review from qlrd November 7, 2026 14:55

@qlrd qlrd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, almost look good! just a last nit:

Comment thread tests/test_hashes.py Resolved
@joaozinhom
joaozinhom force-pushed the cleanup/dependencies_and_dead_code branch from 94dc14c to ffcdb7a Compare November 10, 2026 20:27
@joaozinhom
joaozinhom requested a review from qlrd November 10, 2026 20:27

@qlrd qlrd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tACK ffcdb7a

@HarshPopat23

Copy link
Copy Markdown

Host-side Tested ACK on ffcdb7a, compared with 2937a29.

Full suites: base 1,194 passed / 1 xfailed; PR 1,199 passed / 1 xfailed.

Native SegWit, Taproot and Taproot Miniscript fixtures produced identical recipient/amount/change/fee review messages and exported signed PSBTs. Message signing, cancellation/retry and legacy ECB/CBC decryption also matched.

Checked hash vectors and backend routing. The new tests caught four injected routing/truncation faults. No blocking findings.

Tested on CPython 3.12.14 with native secp256k1 and uUR. Hardware hashing was mocked; no firmware build, physical K210/ktool boot test or live regtest run.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this PR needs a rebase. because we now pin 3.11.17 and 3.12.15

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@notTanveer good catch, but the pinning is not in develop yet, it only landed on main (e1961d0, merged via #967). I think we forgot to sync develop with main.

@jdlcdl I think the correct fix is to merge main into develop first (as done before in 0cf754d), which brings the python pinning and the CCA keys leak release lock, and then I re-rebase this PR on the updated develop. On my side I will drop or rewrite the "bump python minimals" commit, since it relaxed the pins to 3.11/3.12 and main now pins exact 3.11.17/3.12.15, so it will conflict and is likely superseded by main's CI changes.

wdyt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Quick check before I clean things up: is the diff in kkdao#4 (suggestions with translations) still useful for this PR? If it's not relevant anymore, I'll close the sub-PR.

ACK

@jdlcdl jdlcdl Nov 15, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm just seeing this now, merging main into develop creates conflicts.

will look at pr967, already in main, to see how best to get it's changes into develop.

I've created a "develop_two" branch in my fork of Krux, can see the changes that would go to "develop" before I actually push it. develop...jdlcdl:develop_two
pr977, submitted Nov 15th are the 2 commits already merged into main from pr967.

This branch has not been deployed

No deployments
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.

6 participants