fix: low entropy calc when using Mnemonic XOR#745
fix: low entropy calc when using Mnemonic XOR#745qlrd wants to merge 3 commits intoselfcustody:developfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #745 +/- ##
===========================================
+ Coverage 97.38% 97.40% +0.01%
===========================================
Files 83 83
Lines 10548 10586 +38
===========================================
+ Hits 10272 10311 +39
+ Misses 276 275 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b7fd7c4 to
14e048f
Compare
|
Shannon of derivatives (variation), instead of raw data, was used in dice rolls to detect arithmetic progression patterns, but to have Shannon measurement you shouldn't derive the data. |
bc3c7fb to
f0e2f25
Compare
37c45b3 to
c1fc6cd
Compare
d4c10d9 to
a6d7b50
Compare
a6d7b50 to
0e8c0e5
Compare
|
There's another mnemonic that have low entropy (2.29 IDK which unit) on tests and not documented AFAIK. |
0e8c0e5 to
abe2204
Compare
abe2204 to
fd225d3
Compare
|
I liked the mnemonic entropy measurement. |
|
IMHO we should not offer a settings for this, especially a default that "value was a random choice". Instead we need to ensure a "secure" value, as we already do with dice rolls and camera. |
|
Yes
Yes, this needs to be well discussed. The safest approach is to set hard-coded value that cover obvious problematic entropy, and don't overwhelm user with settings in this case. |
|
It would be nice to somehow show the distribution, if possible - similar to how we do with dice - or at least display the entropy in bits instead of an error with |
I thought in a |
f1c308e to
474167a
Compare
|
Didn't tested on simulator and in device with new changes about warning entropy measure in both simulator and device. In Simulator, IDK, this is happening: ❯ poetry run poe simulator
Poe => python simulator/simulator.py --device maixpy_amigo
pygame 2.6.1 (SDL 2.32.10, Python 3.14.0)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/Users/qlrd/github/krux/simulator/simulator.py", line 49, in <module>
parser.add_argument(
~~~~~~~~~~~~~~~~~~~^
"--printer",
^^^^^^^^^^^^
...<3 lines>...
action=argparse.BooleanOptionalAction,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/opt/homebrew/Cellar/python@3.14/3.14.0_1/Frameworks/Python.framework/Versions/3.14/lib/python3.14/argparse.py", line 1538, in add_argument
action = action_class(**kwargs)
TypeError: BooleanOptionalAction.__init__() got an unexpected keyword argument 'type'Didn't re-build in device because wasn't able to simulate. |
|
Did you merge with develop? |
474167a to
836db0b
Compare
|
Maybe use py3.14 could be the issue? |
Fixed and rebased. |
836db0b to
97d9160
Compare
This commit add a fix for shannon entropy validation. Before this commit we checked for only two specific cases (zero/all-ff entropy). We can, instead, use a factor that measures the ammount of information have this entropy and we can avoid what could be called "dangerous entropies for the current context": entropies that have less information than the current mnemonic entropy. This can be tunned by a constant called `MIN_BITS_PER_WORD11` that is a float value measuring the amount of entropy of the involved mnemonics.
97d9160 to
eb52af1
Compare
What is this PR for?
This commit add a fix for shannon entropy calculation of a choosen entroypy bytes before operate the XOR between input and current mnemonic.
Changes made to:
Did you build the code and tested on device?
What is the purpose of this pull request?