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

Make signature verification customizable in the host module #2955

Merged
merged 9 commits into from
Nov 1, 2022

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Oct 31, 2022

cc @xlc
After looking at #2952, I thought that the approach in this PR is a better idea.

As shown in the changes to runtime_host.rs and read_only_runtime_host.rs, you now have a new variant called SignatureVerification that allows you to overwrite the verification if you so desire.

As I was implemented this PR, I noticed that the implementation of ext_crypto_ecdsa_verify loads the message from the first parameter, which is actually the signature. Oops. This is fixed at the same time.

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

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

Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2022

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────
      -46751 ┊ smoldot::executor::host::ReadyToRun::run_once::hf7ef020065c87327
      +43446 ┊ smoldot::executor::host::ReadyToRun::run_once::hb561411be6b6648f
       +6498 ┊ smoldot::executor::runtime_host::Inner::run::h00dbc1e8c496721a
       -6425 ┊ smoldot::executor::runtime_host::Inner::run::h9ce8afad44bbbc9e
       +3317 ┊ smoldot::chain::chain_information::build::ChainInformationBuild::from_call_in_progress::h78f133b288650e47
       -3279 ┊ smoldot::chain::chain_information::build::ChainInformationBuild::from_call_in_progress::hc1307e305a6a59b1
       -2433 ┊ smoldot::executor::runtime_host::PrefixKeys::inject_keys_ordered::h03ca3001a3b4e38c
       +2433 ┊ smoldot::executor::runtime_host::PrefixKeys::inject_keys_ordered::h6ae2f62989d2df62
       +2081 ┊ smoldot::executor::host::SignatureVerification::is_valid::h1841d24f16569000
       +1659 ┊ smoldot::executor::read_only_runtime_host::Inner::run::ha0ee4cf62bf56c74
       -1586 ┊ smoldot::executor::read_only_runtime_host::Inner::run::h024988323bc43ea8
       +1202 ┊ smoldot::transactions::validate::Query::from_step1::hc0cf20082d0389d4
       -1177 ┊ smoldot::transactions::validate::Query::from_step1::h343ecc865befbad8
       -1117 ┊ <smoldot::executor::host::Error as core::fmt::Debug>::fmt::h314eed3af6e93936
       +1117 ┊ <smoldot::executor::host::Error as core::fmt::Debug>::fmt::h7499c8a10287db1b
       +1045 ┊ smoldot::executor::runtime_host::StorageGet::inject_value::h13e5f5b9f7f9032d
       -1045 ┊ smoldot::executor::runtime_host::StorageGet::inject_value::ha90296e5300e1ef6
       +1038 ┊ smoldot::transactions::validate::Query::from_step2::h40737ba20899a5e1
       -1007 ┊ smoldot::transactions::validate::Query::from_step2::hb486cd8add5380b8
        -853 ┊ smoldot::executor::host::ExternalStorageGet::resume_vectored::h931bd0a461f3506e
       +3533 ┊ ... and 165 more.
       +2524 ┊ Σ [185 Total Rows]

@tomaka
Copy link
Contributor Author

tomaka commented Oct 31, 2022

I also did ext_crypto_ecdsa_verify_prehashed_version_1, which I had forgotten about.

@xlc
Copy link
Contributor

xlc commented Oct 31, 2022

This is indeed better. Will try integrate this.

@xlc
Copy link
Contributor

xlc commented Oct 31, 2022

Because I am using RuntimeHostVm, so I will need a variant for it to be able to override the verification handling logic

pub enum RuntimeHostVm {

@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge pull request as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants