Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

fixed accounts.sign invalid length because of missing leading zero - #6411

Merged
luu-alex merged 2 commits into
web3:4.xfrom
emn178:feature/fixed_accounts_sign_bug
Sep 11, 2023
Merged

fixed accounts.sign invalid length because of missing leading zero#6411
luu-alex merged 2 commits into
web3:4.xfrom
emn178:feature/fixed_accounts_sign_bug

Conversation

@emn178

@emn178 emn178 commented Sep 9, 2023

Copy link
Copy Markdown
Contributor

Description

Sometimes r and s should have leading zero, but current version has bug and return invalid length, for example:

{
  message: '0xc1af4b94166cd32fc49b7b926cbb91ee421de2d04450e8ae57857b9b56ac7e53',
  messageHash: '0x69a1658d9d5e169959e0e2acec0eb76ec15549ebc0680f45cfc25c4a3ca952e6',
  v: '0x1c',
  r: '0x3105c6f9bcc43236f5ef5e78038506c2551fc11d65701097295094c06c9d4f3',
  s: '0x29ec14347d37d8115cebcf915dc8f6f74c011698d9b7aea15c184f2277197a',
  signature: '0x03105c6f9bcc43236f5ef5e78038506c2551fc11d65701097295094c06c9d4f30029ec14347d37d8115cebcf915dc8f6f74c011698d9b7aea15c184f2277197a1c'
}

It should be

{
  message: '0xc1af4b94166cd32fc49b7b926cbb91ee421de2d04450e8ae57857b9b56ac7e53',
  messageHash: '0x69a1658d9d5e169959e0e2acec0eb76ec15549ebc0680f45cfc25c4a3ca952e6',
  v: '0x1c',
  r: '0x03105c6f9bcc43236f5ef5e78038506c2551fc11d65701097295094c06c9d4f3',
  s: '0x0029ec14347d37d8115cebcf915dc8f6f74c011698d9b7aea15c184f2277197a',
  signature: '0x03105c6f9bcc43236f5ef5e78038506c2551fc11d65701097295094c06c9d4f30029ec14347d37d8115cebcf915dc8f6f74c011698d9b7aea15c184f2277197a1c'
}

In old version, e.g. 1.x it returns correct result like above.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run lint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I ran npm run test:coverage and my test cases cover all the lines and branches of the added code.
  • I ran npm run build and tested dist/web3.min.js in a browser.
  • I have tested my code on the live network.
  • I have checked the Deploy Preview and it looks correct.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have linked Issue(s) with this PR in "Linked Issues" menu.

@luu-alex

luu-alex commented Sep 9, 2023

Copy link
Copy Markdown
Contributor

Thanks for the PR! can you update the changelog as well

@codecov

codecov Bot commented Sep 9, 2023

Copy link
Copy Markdown

Codecov Report

Merging #6411 (9879a8e) into 4.x (3a9f7d7) will not change coverage.
Report is 1 commits behind head on 4.x.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##              4.x    #6411   +/-   ##
=======================================
  Coverage   89.11%   89.11%           
=======================================
  Files         199      199           
  Lines        7723     7723           
  Branches     2128     2128           
=======================================
  Hits         6882     6882           
  Misses        841      841           
Flag Coverage Δ
UnitTests 89.11% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
web3 ∅ <ø> (∅)
web3-core ∅ <ø> (∅)
web3-errors ∅ <ø> (∅)
web3-eth ∅ <ø> (∅)
web3-eth-abi ∅ <ø> (∅)
web3-eth-accounts ∅ <ø> (∅)
web3-eth-contract ∅ <ø> (∅)
web3-eth-ens ∅ <ø> (∅)
web3-eth-iban ∅ <ø> (∅)
web3-eth-personal ∅ <ø> (∅)
web3-net ∅ <ø> (∅)
web3-providers-http ∅ <ø> (∅)
web3-providers-ipc ∅ <ø> (∅)
web3-providers-ws ∅ <ø> (∅)
web3-rpc-methods ∅ <ø> (∅)
web3-utils ∅ <ø> (∅)
web3-validator ∅ <ø> (∅)

@jdevcs jdevcs added the 4.x 4.0 related label Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

4.x 4.0 related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants