This repository was archived by the owner on May 26, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
crypto.scryptSync is undefined on frontend framework
Affected version:
2.2.0
Affected symptoms: cannot decrypt keystore files using scrypt algorithm
There was a change of
scrypt
usage fromscrypt.js
to using NodeJS'scrypto.scryptSync
. Commit: fa9b561. This change was to resolve some building logging errors reported byscrypt.js
and to take advantage of the new NodeJscrypto
packages.https://github.com/Zilliqa/Zilliqa-JavaScript-Library/blob/dev/packages/zilliqa-js-crypto/src/keystore.ts#L63
However, the
crypto
package does not seem to be accessible by frontend frameworks and also our webpack bundle (zilliqa.min.js
). Whenever users tried to executezilliqa.wallet.addByKeyStore
orzilliqa.wallet.export("address", "password", 'scrypt');
, they encountered acrypto.scryptSync
not a function error.Unit tests are not able to catch this error, as the
crypto
package is working fine in the standard nodeJS manner, e.g. as follows:Solution
This PR replaces the builti-in NodeJS
crypto.scryptSync
with a different javascript implementation;scrypt-js
. https://github.com/ricmoo/scrypt-js.How to test
The error only affects for keystore files that are created using the scrypt algorithm. The webpack examples,
examples/webpack/html/load-keystore-demo.js
is a demonstration that adds an account by keystore and export it.