klaytn / caver-js

Official caver-js repository
GNU Lesser General Public License v3.0
114 stars 75 forks source link

caver.klay.accounts.decrypt function doesn't work as expected #404

Closed devhyunjae closed 3 years ago

devhyunjae commented 3 years ago

DEMO

https://codesandbox.io/s/serene-pare-05puk?file=/src/App.js

Describe the bug A clear and concise description of what the bug is.

caver.klay.accounts.decrypt throws unexpected error when executed multiple times. Invalid keystore V3 format: 'crypto' is not defined.

It should only throw this error Key derivation failed - possibly wrong password

How to reproduce Steps to reproduce the behavior:

  1. Click the demo app above
  2. Check out the given json file
  3. Press the DECRPYT! button
  4. Check out the keyjson again. It has been manipulated. crypoto field has been changed to keyring field
  5. Press the DECRPYT! button
  6. Now it will show a different error

Expected behavior A clear and concise description of what you expected to happen. It should only throw this error Key derivation failed - possibly wrong password

Attachments If applicable, add data, logs or screenshots to help explain your problem.

Screen Shot 2020-12-15 at 11 12 38 AM Screen Shot 2020-12-15 at 11 13 04 AM Screen Shot 2020-12-15 at 11 13 38 AM

Environment (please complete the following information)

Additional context Add any other context about the problem here.

jimni1222 commented 3 years ago

Hi, thank you for reporting the bug. :)

This is a bug caused by modifying the original data right away when decrypting. Modifications are included in the PR below, and when the PR is merged, the rc version is released and can be used. https://github.com/klaytn/caver-js/pull/405

I will let you know when the rc version is released. Thank you so much :)

jimni1222 commented 3 years ago

This issue has been resolved in caver-js v1.5.6-rc.6, so i will close this issue. If there is an unresolved issue, please feel free to open it again. :)