Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monero hackathon results #2219

Merged
merged 10 commits into from May 16, 2022
Merged

Monero hackathon results #2219

merged 10 commits into from May 16, 2022

Conversation

matejcik
Copy link
Contributor

This is a significant cleanup of Monero code and a good step on the way to #642.

  • remove support for HF12 and below
  • remove MLSAG support
  • clean up monero cryptography naming
  • get rid of "optional first argument" pattern, in favor of mandatory argument that is allowed to be None
    (and fix several bugs related to this feature)

One protobuf-level change is worth noting: the integer field network_type was replaced by an enum. This does not change the on-the-wire format.

@andrewkozlik or @onvej-sl please leave us a note whether it's ok to remove range_proof from the crypto library like this.

@onvej-sl you reviewed the Monero code previously so you might want to take a look; however, there are basically no functional changes here except for the removal of some steps, and the automated tests against Monero blob pass.

@trezor-ci trezor-ci added this to To be reviewed in Pull Requests via automation Apr 13, 2022
@matejcik
Copy link
Contributor Author

@ph4r05 @mmilata @grdddj please have a look over this, whether this is what you expect to see

@matejcik matejcik requested review from mmilata and grdddj and removed request for prusnak and onvej-sl April 13, 2022 13:51
@matejcik matejcik force-pushed the monero-hackathon-results branch 3 times, most recently from a91830f to ac0e1a2 Compare April 13, 2022 13:54
Pull Requests automation moved this from To be reviewed to Finalizing Apr 16, 2022
Copy link
Member

@mmilata mmilata left a comment

Choose a reason for hiding this comment

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

Nice job with the typing and with the extmod. I scanned the changes and haven't spotted any issue.

ci/shell.nix Outdated
@@ -20,7 +20,7 @@ let
}) { };
moneroTests = nixpkgs.fetchurl {
url = "https://github.com/ph4r05/monero/releases/download/v0.17.3.0-dev-tests/trezor_tests";
sha256 = "sha256-tTQTe/Yk6oURq7GDOEotJ7Y2UpCgyuU5odjEHNTMrmE=";
sha256 = "b534137bf624ea8511abb183384a2d27b6365290a0cae539a1d8c41cd4ccae61";
Copy link
Member

Choose a reason for hiding this comment

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

This is fine

$ nix hash to-sri --type sha256 b534137bf624ea8511abb183384a2d27b6365290a0cae539a1d8c41cd4ccae61
sha256-tTQTe/Yk6oURq7GDOEotJ7Y2UpCgyuU5odjEHNTMrmE=

Copy link
Member

@prusnak prusnak Apr 16, 2022

Choose a reason for hiding this comment

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

But we can still keep the switch to hex notation as part of this PR. Honestly, I hate the base64-notation for files and I guess hex is easier for ph4r05 to provide.


# @classmethod
# def f_specs(cls) -> XmrFspec:
# return ()
Copy link
Member

Choose a reason for hiding this comment

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

Wanna delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in rebase

@grdddj
Copy link
Contributor

grdddj commented Apr 19, 2022

Currently, the unused_monero.py snippet is not working as expected, because of file-system issues and the removal of the alias core/src/apps/monero/xmr/crypto/__init__.py file. I am looking at how to make it work again.

@grdddj
Copy link
Contributor

grdddj commented Apr 19, 2022

Currently, the unused_monero.py snippet is not working as expected, because of file-system issues and the removal of the alias core/src/apps/monero/xmr/crypto/__init__.py file. I am looking at how to make it work again.

Fixed in a0ac673 (on grdddj/monero_hackathon_snippet_fix) branch)

Current results say:

3 unused functions:
ge25519_mul8 {'mapping': ['ge25519_mul8'], 'is_used': False}
xmr_add_keys2 {'mapping': ['xmr_add_keys2'], 'is_used': False}
xmr_add_keys3 {'mapping': ['xmr_add_keys3'], 'is_used': False}

It really looks like these three functions from core/mocks/generated/trezorcrypto/monero.pyi are unused and could be deleted

@ph4r05
Copy link
Contributor

ph4r05 commented Apr 19, 2022

Did you pls check also usage in tests? I recall mul8 might be used there

@grdddj
Copy link
Contributor

grdddj commented Apr 19, 2022

Did you pls check also usage in tests? I recall mul8 might be used there

Right, that is really used in tests - I will need to modify the script to also look there. Those two others look safe to delete, I will do it in my own branch and run CI on it

@andrewkozlik
Copy link
Contributor

@andrewkozlik or @onvej-sl please leave us a note whether it's ok to remove range_proof from the crypto library like this.

If I understand correctly, this is dead code in Trezor. In that case I am for removing it, because we won't be maintaining it. So if somebody happens to be using this function, they should fork the code and take over the maintenance.

@grdddj
Copy link
Contributor

grdddj commented Apr 19, 2022

Those two others look safe to delete, I will do it in my own branch and run CI on it

CI is green on grdddj/monero_hackathon_snippet_fix where I removed xmr_add_keys2 and xmr_add_keys3, so we could hopefully safely merge it into this PR branch

@ph4r05
Copy link
Contributor

ph4r05 commented Apr 21, 2022

For completeness, I got notified that a new hardfork is being prepared, part of which is new Bulletproof+ protocol. I am currently studying changes required to support this protocol on Trezor.

Fallback would be to generate it on the client-side completely, but we will need new to release a new Trezor firmware anyway to support transaction signatures on a new HF (I need to check whether it will be mandatory to use BP+ on new HF or whether we can still use old versions).

Other related info:

@sethforprivacy
Copy link

I need to check whether it will be mandatory to use BP+ on new HF or whether we can still use old versions

BP+ will be mandatory after the hard-fork for all transactions, just to clarify and save you some searching :)

@ph4r05
Copy link
Contributor

ph4r05 commented Apr 26, 2022

Note: I've implemented BP+ verifier and prover in my new branch. I also cleaned up some existing BP code. Should we add changes to this PR @matejcik ?

@matejcik
Copy link
Contributor Author

@ph4r05 please make a separate PR going to the monero-hackathon-results branch. I'll change base once this is merged.

@grdddj please push your changes into this branch.

@grdddj
Copy link
Contributor

grdddj commented Apr 26, 2022

@grdddj please push your changes into this branch.

Done, there are four new fixups - I did not want to force-push, so they will need to be squashed

@matejcik matejcik moved this from Finalizing to In progress in Pull Requests Apr 28, 2022
@matejcik matejcik force-pushed the monero-hackathon-results branch 2 times, most recently from 13f60c6 to 437bef8 Compare May 11, 2022 12:54
* remove support for HF12 and below
* remove MLSAG support
* clean up monero cryptography naming
* get rid of "optional first argument" pattern, in favor of mandatory argument that is allowed to be None
  (and fix several bugs related to this feature)

Co-authored-by: grdddj <jiri.musil06@seznam.cz>
Co-authored-by: Martin Milata <martin@martinmilata.cz>
Co-authored-by: matejcik <ja@matejcik.cz>
matejcik and others added 9 commits May 16, 2022 10:46
__slots__ are unsupported in micropython

[no changelog]
[no changelog]

Co-authored-by: Martin Milata <martin@martinmilata.cz>
- implement BulletProof plus verifier and prover
- use bulletproof exception to signalize proof generation failed and should be tried again. More robust, fixes bug that was not triggered yet (return tuple did not work properly in all situations)
- precomputed 2**i vector is removed as it can be easily computed
- BP code cleanup, minor optimizations, comments
- old BP GI, HI constants are shortened to reduce firmware size
@matejcik matejcik merged commit 5e6582a into master May 16, 2022
Pull Requests automation moved this from In progress to Merged May 16, 2022
@matejcik matejcik deleted the monero-hackathon-results branch May 16, 2022 10:37
@ph4r05
Copy link
Contributor

ph4r05 commented May 31, 2022

hi @matejcik , there was a change in the Monero (monero-project/monero#8277) we might need to address by a new PR. Is there pls any codefreeze date for a new firmware release so all XMR-related PRs are merged by the next release? Thanks!

@matejcik
Copy link
Contributor Author

matejcik commented Jun 1, 2022

no timeframe currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants