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

pkg/crypto: cover account/prefixed data sig verification and fix case sensitivity #139

Merged
merged 2 commits into from
Aug 10, 2023

Conversation

jchappelow
Copy link
Contributor

@jchappelow jchappelow commented Jul 25, 2023

Came across a minor inconsistency while initially reviewing the code. This is not very consequential, but the change is relatively trivial, adds test coverage, and simplifies the two signature verification methods. The only observable change is that signatures from clients like a frontend producing signatures from metamask will verify successfully if there are inconsequential string case deviations in the address. This matches the verification from clients like pkg/client/kwil-cli.

The first commit adds test coverage for the verification code in checkSignatureAccountSECP256k1Uncompressed, which is the verification used for signatures made by clients such as Kuneiform with MetaMask as the signer (crypto.ACCOUNT_SECP256K1_UNCOMPRESSED).

The second commit introduces a minor refactor to reuse common code between the two signature verification helpers, and it fixes a bug that causes the last test introduced in the first commit to fail if there is any string case or prefix deviation from the canonical (EIP 55) formatting. The verification for PK_SECP256K1_UNCOMPRESSED-type signatures was already fine.

@jchappelow jchappelow marked this pull request as ready for review July 26, 2023 23:00
@jchappelow jchappelow force-pushed the sig-verif branch 3 times, most recently from c21cfff to 13da5f5 Compare August 5, 2023 01:58
Copy link
Contributor

@brennanjl brennanjl left a comment

Choose a reason for hiding this comment

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

Looks good. I force pushed a rebase on main, but it did not change anything.

@sonarcloud
Copy link

sonarcloud bot commented Aug 10, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@brennanjl brennanjl merged commit f2be488 into main Aug 10, 2023
1 of 3 checks passed
@brennanjl brennanjl deleted the sig-verif branch August 10, 2023 14:11
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
… sensitivity (#139)

* test for non-canonical eth address encodings

* use SigToPub in regular sig verification

---------

Co-authored-by: Jonathan Chappelow <jonathan.chappelow@gmail.com>
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
… sensitivity (#139)

* test for non-canonical eth address encodings

* use SigToPub in regular sig verification

---------

Co-authored-by: Jonathan Chappelow <jonathan.chappelow@gmail.com>
jchappelow added a commit that referenced this pull request Feb 26, 2024
… sensitivity (#139)

* test for non-canonical eth address encodings

* use SigToPub in regular sig verification

---------

Co-authored-by: Jonathan Chappelow <jonathan.chappelow@gmail.com>
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
… sensitivity (#139)

* test for non-canonical eth address encodings

* use SigToPub in regular sig verification

---------

Co-authored-by: Jonathan Chappelow <jonathan.chappelow@gmail.com>
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
… sensitivity (#139)

* test for non-canonical eth address encodings

* use SigToPub in regular sig verification

---------

Co-authored-by: Jonathan Chappelow <jonathan.chappelow@gmail.com>
brennanjl pushed a commit that referenced this pull request Feb 26, 2024
… sensitivity (#139)

* test for non-canonical eth address encodings

* use SigToPub in regular sig verification

---------

Co-authored-by: Jonathan Chappelow <jonathan.chappelow@gmail.com>
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.

None yet

3 participants