-
Notifications
You must be signed in to change notification settings - Fork 431
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
sr25519
signature verification
#1757
Conversation
message: &[u8], | ||
pub_key: &[u8; 32], | ||
) -> Result<()> { | ||
let context = signing_context(b"substrate"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For further use, i think there should be an option to verify signature from any context. Right now there is such limitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create a SIGNING_CTX
constant like in the substrate and add a comment with the link to the code on the substrate side(that substrate uses the same context)?
Hey, was just testing out your changes here which solve my sr25519 signing issue in the ink smart contracts - many thanks for your changes. Just a quick fyi that if the public key is invalid the error is not caught and causes a panic (in the smart contract call, not sure where the panic originates). I found this from one of my unit tests (https://github.com/prosopo/protocol/blob/81c90b2edde0b71072b1f56b5b3af65a5589e9dc/contracts/lib.rs#L2292) which deliberately uses an incorrect public key. Produces the following error:
Happily, incorrect signatures / payload data result in verify returning false. The valid verification test also passes. |
any update on this? @cmichi @kziemianek :) |
I'm a bit busy recently. I doubt I'll have a time to look at it in the near future. |
@cmichi Would it be possible to merge this given that the review suggestions have been completed? Obviously, after master is merged in. Thx |
Can you please address the unhandled error resulting in the call panic which was addressed by @goastler ? |
Hey @kziemianek did you have a change at the review comments? |
Yes, they all are resolved. |
I have fixed the unhandled errors I was having with this PR, added tests, added docs and fixed the merge conflicts in my PR (#1840) that builds upon this one |
message: &[u8], | ||
pub_key: &[u8; 32], | ||
) -> Result<()> { | ||
let context = signing_context(b"substrate"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you create a SIGNING_CTX
constant like in the substrate and add a comment with the link to the code on the substrate side(that substrate uses the same context)?
@@ -63,7 +63,7 @@ impl TryFrom<ast::AttributeArgs> for E2EConfig { | |||
return Err(format_err_spanned!( | |||
arg, | |||
"expected a string literal for `additional_contracts` ink! E2E test configuration argument", | |||
)) | |||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you exclude this file from the PR, please?=)
@@ -263,7 +263,7 @@ impl ItemMod { | |||
.into_combine(format_err!( | |||
overlap.span(), | |||
"first ink! message with overlapping wildcard selector here", | |||
))) | |||
))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you exclude this file from the PR, please?=)
@@ -384,7 +384,7 @@ impl InkItemTrait { | |||
).into_combine(format_err_spanned!( | |||
duplicate_selector, | |||
"first ink! trait constructor or message with same selector found here", | |||
))) | |||
))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you exclude this file from the PR, please?=)
@@ -880,6 +880,16 @@ where | |||
.map_err(|_| Error::EcdsaRecoveryFailed) | |||
} | |||
|
|||
pub fn sr25519_verify( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment here as well, please?=)
Closed in favor of #1840 |
Add ability to call contract's
sr25519_verify
function.sr25519_verify
is still unstable so it's required to run node withtype UnsafeUnstableInterface = ConstBool<true>;
in pallet-contracts config.This is related to paritytech/substrate#13703.